netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: phy: ti: take into account all possible interrupt sources
@ 2021-02-26 15:30 Ioana Ciornei
  2021-02-28 20:00 ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Ioana Ciornei @ 2021-02-26 15:30 UTC (permalink / raw)
  To: davem, kuba, netdev
  Cc: andrew, hkallweit1, linux, Ioana Ciornei, Sven Schuchmann

From: Ioana Ciornei <ioana.ciornei@nxp.com>

The previous implementation of .handle_interrupt() did not take into
account the fact that all the interrupt status registers should be
acknowledged since multiple interrupt sources could be asserted.

Fix this by reading all the status registers before exiting with
IRQ_NONE or triggering the PHY state machine.

Fixes: 1d1ae3c6ca3f ("net: phy: ti: implement generic .handle_interrupt() callback")
Reported-by: Sven Schuchmann <schuchmann@schleissheimer.de>
Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com>
---
 drivers/net/phy/dp83822.c   |  9 +++++----
 drivers/net/phy/dp83tc811.c | 11 ++++++-----
 2 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
index be1224b4447b..f7a2ec150e54 100644
--- a/drivers/net/phy/dp83822.c
+++ b/drivers/net/phy/dp83822.c
@@ -290,6 +290,7 @@ static int dp83822_config_intr(struct phy_device *phydev)
 
 static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
 {
+	bool trigger_machine = false;
 	int irq_status;
 
 	/* The MISR1 and MISR2 registers are holding the interrupt status in
@@ -305,7 +306,7 @@ static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
 		return IRQ_NONE;
 	}
 	if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
-		goto trigger_machine;
+		trigger_machine = true;
 
 	irq_status = phy_read(phydev, MII_DP83822_MISR2);
 	if (irq_status < 0) {
@@ -313,11 +314,11 @@ static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
 		return IRQ_NONE;
 	}
 	if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
-		goto trigger_machine;
+		trigger_machine = true;
 
-	return IRQ_NONE;
+	if (!trigger_machine)
+		return IRQ_NONE;
 
-trigger_machine:
 	phy_trigger_machine(phydev);
 
 	return IRQ_HANDLED;
diff --git a/drivers/net/phy/dp83tc811.c b/drivers/net/phy/dp83tc811.c
index 688fadffb249..7ea32fb77190 100644
--- a/drivers/net/phy/dp83tc811.c
+++ b/drivers/net/phy/dp83tc811.c
@@ -264,6 +264,7 @@ static int dp83811_config_intr(struct phy_device *phydev)
 
 static irqreturn_t dp83811_handle_interrupt(struct phy_device *phydev)
 {
+	bool trigger_machine = false;
 	int irq_status;
 
 	/* The INT_STAT registers 1, 2 and 3 are holding the interrupt status
@@ -279,7 +280,7 @@ static irqreturn_t dp83811_handle_interrupt(struct phy_device *phydev)
 		return IRQ_NONE;
 	}
 	if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
-		goto trigger_machine;
+		trigger_machine = true;
 
 	irq_status = phy_read(phydev, MII_DP83811_INT_STAT2);
 	if (irq_status < 0) {
@@ -287,7 +288,7 @@ static irqreturn_t dp83811_handle_interrupt(struct phy_device *phydev)
 		return IRQ_NONE;
 	}
 	if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
-		goto trigger_machine;
+		trigger_machine = true;
 
 	irq_status = phy_read(phydev, MII_DP83811_INT_STAT3);
 	if (irq_status < 0) {
@@ -295,11 +296,11 @@ static irqreturn_t dp83811_handle_interrupt(struct phy_device *phydev)
 		return IRQ_NONE;
 	}
 	if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
-		goto trigger_machine;
+		trigger_machine = true;
 
-	return IRQ_NONE;
+	if (!trigger_machine)
+		return IRQ_NONE;
 
-trigger_machine:
 	phy_trigger_machine(phydev);
 
 	return IRQ_HANDLED;
-- 
2.30.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: phy: ti: take into account all possible interrupt sources
  2021-02-26 15:30 [PATCH net] net: phy: ti: take into account all possible interrupt sources Ioana Ciornei
@ 2021-02-28 20:00 ` Jakub Kicinski
  2021-03-01  8:21   ` Ioana Ciornei
  0 siblings, 1 reply; 4+ messages in thread
From: Jakub Kicinski @ 2021-02-28 20:00 UTC (permalink / raw)
  To: Ioana Ciornei
  Cc: davem, netdev, andrew, hkallweit1, linux, Ioana Ciornei, Sven Schuchmann

On Fri, 26 Feb 2021 17:30:20 +0200 Ioana Ciornei wrote:
> diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
> index be1224b4447b..f7a2ec150e54 100644
> --- a/drivers/net/phy/dp83822.c
> +++ b/drivers/net/phy/dp83822.c
> @@ -290,6 +290,7 @@ static int dp83822_config_intr(struct phy_device *phydev)
>  
>  static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
>  {
> +	bool trigger_machine = false;
>  	int irq_status;
>  
>  	/* The MISR1 and MISR2 registers are holding the interrupt status in
> @@ -305,7 +306,7 @@ static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
>  		return IRQ_NONE;
>  	}
>  	if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
> -		goto trigger_machine;
> +		trigger_machine = true;
>  
>  	irq_status = phy_read(phydev, MII_DP83822_MISR2);
>  	if (irq_status < 0) {
> @@ -313,11 +314,11 @@ static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
>  		return IRQ_NONE;
>  	}
>  	if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
> -		goto trigger_machine;
> +		trigger_machine = true;
>  
> -	return IRQ_NONE;
> +	if (!trigger_machine)
> +		return IRQ_NONE;
>  
> -trigger_machine:
>  	phy_trigger_machine(phydev);
>  
>  	return IRQ_HANDLED;

Would it be better to code it up as:

	irqreturn_t ret = IRQ_NONE;

	if (irq_status & ...)
		ret = IRQ_HANDLED;

	/* .. */

	if (ret != IRQ_NONE)
		phy_trigger_machine(phydev);

	return ret;

That reads a tiny bit better to me, but it's probably majorly
subjective so I'm happy with existing patch if you prefer it.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: phy: ti: take into account all possible interrupt sources
  2021-02-28 20:00 ` Jakub Kicinski
@ 2021-03-01  8:21   ` Ioana Ciornei
  2021-03-01 19:48     ` Jakub Kicinski
  0 siblings, 1 reply; 4+ messages in thread
From: Ioana Ciornei @ 2021-03-01  8:21 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Ioana Ciornei, davem, netdev, andrew, hkallweit1, linux,
	Ioana Ciornei, Sven Schuchmann

On Sun, Feb 28, 2021 at 12:00:27PM -0800, Jakub Kicinski wrote:
> On Fri, 26 Feb 2021 17:30:20 +0200 Ioana Ciornei wrote:
> > diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
> > index be1224b4447b..f7a2ec150e54 100644
> > --- a/drivers/net/phy/dp83822.c
> > +++ b/drivers/net/phy/dp83822.c
> > @@ -290,6 +290,7 @@ static int dp83822_config_intr(struct phy_device *phydev)
> >  
> >  static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
> >  {
> > +	bool trigger_machine = false;
> >  	int irq_status;
> >  
> >  	/* The MISR1 and MISR2 registers are holding the interrupt status in
> > @@ -305,7 +306,7 @@ static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
> >  		return IRQ_NONE;
> >  	}
> >  	if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
> > -		goto trigger_machine;
> > +		trigger_machine = true;
> >  
> >  	irq_status = phy_read(phydev, MII_DP83822_MISR2);
> >  	if (irq_status < 0) {
> > @@ -313,11 +314,11 @@ static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
> >  		return IRQ_NONE;
> >  	}
> >  	if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
> > -		goto trigger_machine;
> > +		trigger_machine = true;
> >  
> > -	return IRQ_NONE;
> > +	if (!trigger_machine)
> > +		return IRQ_NONE;
> >  
> > -trigger_machine:
> >  	phy_trigger_machine(phydev);
> >  
> >  	return IRQ_HANDLED;
> 
> Would it be better to code it up as:
> 
> 	irqreturn_t ret = IRQ_NONE;
> 
> 	if (irq_status & ...)
> 		ret = IRQ_HANDLED;
> 
> 	/* .. */
> 
> 	if (ret != IRQ_NONE)
> 		phy_trigger_machine(phydev);
> 
> 	return ret;
> 
> That reads a tiny bit better to me, but it's probably majorly
> subjective so I'm happy with existing patch if you prefer it.

I think I prefer it as it is and this is because it would be in line
with all the other PHY drivers which do this:

	if (!(irq_status & int_enabled))
		return IRQ_NONE;

	phy_trigger_machine(phydev);

	return IRQ_HANDLED;

Ioana

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] net: phy: ti: take into account all possible interrupt sources
  2021-03-01  8:21   ` Ioana Ciornei
@ 2021-03-01 19:48     ` Jakub Kicinski
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2021-03-01 19:48 UTC (permalink / raw)
  To: Ioana Ciornei
  Cc: davem, netdev, andrew, hkallweit1, linux, Ioana Ciornei, Sven Schuchmann

On Mon, 1 Mar 2021 10:21:14 +0200 Ioana Ciornei wrote:
> On Sun, Feb 28, 2021 at 12:00:27PM -0800, Jakub Kicinski wrote:
> > On Fri, 26 Feb 2021 17:30:20 +0200 Ioana Ciornei wrote:  
> > > diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c
> > > index be1224b4447b..f7a2ec150e54 100644
> > > --- a/drivers/net/phy/dp83822.c
> > > +++ b/drivers/net/phy/dp83822.c
> > > @@ -290,6 +290,7 @@ static int dp83822_config_intr(struct phy_device *phydev)
> > >  
> > >  static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
> > >  {
> > > +	bool trigger_machine = false;
> > >  	int irq_status;
> > >  
> > >  	/* The MISR1 and MISR2 registers are holding the interrupt status in
> > > @@ -305,7 +306,7 @@ static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
> > >  		return IRQ_NONE;
> > >  	}
> > >  	if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
> > > -		goto trigger_machine;
> > > +		trigger_machine = true;
> > >  
> > >  	irq_status = phy_read(phydev, MII_DP83822_MISR2);
> > >  	if (irq_status < 0) {
> > > @@ -313,11 +314,11 @@ static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev)
> > >  		return IRQ_NONE;
> > >  	}
> > >  	if (irq_status & ((irq_status & GENMASK(7, 0)) << 8))
> > > -		goto trigger_machine;
> > > +		trigger_machine = true;
> > >  
> > > -	return IRQ_NONE;
> > > +	if (!trigger_machine)
> > > +		return IRQ_NONE;
> > >  
> > > -trigger_machine:
> > >  	phy_trigger_machine(phydev);
> > >  
> > >  	return IRQ_HANDLED;  
> > 
> > Would it be better to code it up as:
> > 
> > 	irqreturn_t ret = IRQ_NONE;
> > 
> > 	if (irq_status & ...)
> > 		ret = IRQ_HANDLED;
> > 
> > 	/* .. */
> > 
> > 	if (ret != IRQ_NONE)
> > 		phy_trigger_machine(phydev);
> > 
> > 	return ret;
> > 
> > That reads a tiny bit better to me, but it's probably majorly
> > subjective so I'm happy with existing patch if you prefer it.  
> 
> I think I prefer it as it is and this is because it would be in line
> with all the other PHY drivers which do this:
> 
> 	if (!(irq_status & int_enabled))
> 		return IRQ_NONE;
> 
> 	phy_trigger_machine(phydev);
> 

Okay, applied, thanks!

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-01 20:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-26 15:30 [PATCH net] net: phy: ti: take into account all possible interrupt sources Ioana Ciornei
2021-02-28 20:00 ` Jakub Kicinski
2021-03-01  8:21   ` Ioana Ciornei
2021-03-01 19:48     ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).