netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] amd-xgbe: Enable IRQs only if napi_complete_done() is true
@ 2017-03-09 23:48 Tom Lendacky
  2017-03-10  2:31 ` David Miller
  2017-03-10 16:33 ` Jeremy Linton
  0 siblings, 2 replies; 5+ messages in thread
From: Tom Lendacky @ 2017-03-09 23:48 UTC (permalink / raw)
  To: netdev; +Cc: David Miller, Jeremy Linton

Depending on the hardware, the amd-xgbe driver may use disable_irq_nosync()
and enable_irq() when an interrupt is received to process Rx packets. If
the napi_complete_done() return value isn't checked an unbalanced enable
for the IRQ could result, generating a warning stack trace.

Update the driver to only enable interrupts if napi_complete_done() returns
true.

Reported-by: Jeremy Linton <jeremy.linton@arm.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/net/ethernet/amd/xgbe/xgbe-drv.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 248f60d..ffea985 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -2272,10 +2272,7 @@ static int xgbe_one_poll(struct napi_struct *napi, int budget)
 	processed = xgbe_rx_poll(channel, budget);
 
 	/* If we processed everything, we are done */
-	if (processed < budget) {
-		/* Turn off polling */
-		napi_complete_done(napi, processed);
-
+	if ((processed < budget) && napi_complete_done(napi, processed)) {
 		/* Enable Tx and Rx interrupts */
 		if (pdata->channel_irq_mode)
 			xgbe_enable_rx_tx_int(pdata, channel);
@@ -2317,10 +2314,7 @@ static int xgbe_all_poll(struct napi_struct *napi, int budget)
 	} while ((processed < budget) && (processed != last_processed));
 
 	/* If we processed everything, we are done */
-	if (processed < budget) {
-		/* Turn off polling */
-		napi_complete_done(napi, processed);
-
+	if ((processed < budget) && napi_complete_done(napi, processed)) {
 		/* Enable Tx and Rx interrupts */
 		xgbe_enable_rx_tx_ints(pdata);
 	}

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

* Re: [PATCH net] amd-xgbe: Enable IRQs only if napi_complete_done() is true
  2017-03-09 23:48 [PATCH net] amd-xgbe: Enable IRQs only if napi_complete_done() is true Tom Lendacky
@ 2017-03-10  2:31 ` David Miller
  2017-03-10 14:19   ` Tom Lendacky
  2017-03-10 16:33 ` Jeremy Linton
  1 sibling, 1 reply; 5+ messages in thread
From: David Miller @ 2017-03-10  2:31 UTC (permalink / raw)
  To: thomas.lendacky; +Cc: netdev, jeremy.linton

From: Tom Lendacky <thomas.lendacky@amd.com>
Date: Thu, 9 Mar 2017 17:48:23 -0600

> Depending on the hardware, the amd-xgbe driver may use disable_irq_nosync()
> and enable_irq() when an interrupt is received to process Rx packets. If
> the napi_complete_done() return value isn't checked an unbalanced enable
> for the IRQ could result, generating a warning stack trace.
> 
> Update the driver to only enable interrupts if napi_complete_done() returns
> true.
> 
> Reported-by: Jeremy Linton <jeremy.linton@arm.com>
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>

Applied, thanks.

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

* Re: [PATCH net] amd-xgbe: Enable IRQs only if napi_complete_done() is true
  2017-03-10  2:31 ` David Miller
@ 2017-03-10 14:19   ` Tom Lendacky
  2017-03-10 18:06     ` David Miller
  0 siblings, 1 reply; 5+ messages in thread
From: Tom Lendacky @ 2017-03-10 14:19 UTC (permalink / raw)
  To: David Miller; +Cc: netdev, jeremy.linton

On 3/9/2017 8:31 PM, David Miller wrote:
> From: Tom Lendacky <thomas.lendacky@amd.com>
> Date: Thu, 9 Mar 2017 17:48:23 -0600
>
>> Depending on the hardware, the amd-xgbe driver may use disable_irq_nosync()
>> and enable_irq() when an interrupt is received to process Rx packets. If
>> the napi_complete_done() return value isn't checked an unbalanced enable
>> for the IRQ could result, generating a warning stack trace.
>>
>> Update the driver to only enable interrupts if napi_complete_done() returns
>> true.
>>
>> Reported-by: Jeremy Linton <jeremy.linton@arm.com>
>> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
>
> Applied, thanks.

Thanks David!  The change to napi_complete_done() from void to bool
occurred in 4.10, can you queue this fix up against 4.10 stable?

Thanks,
Tom

>

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

* Re: [PATCH net] amd-xgbe: Enable IRQs only if napi_complete_done() is true
  2017-03-09 23:48 [PATCH net] amd-xgbe: Enable IRQs only if napi_complete_done() is true Tom Lendacky
  2017-03-10  2:31 ` David Miller
@ 2017-03-10 16:33 ` Jeremy Linton
  1 sibling, 0 replies; 5+ messages in thread
From: Jeremy Linton @ 2017-03-10 16:33 UTC (permalink / raw)
  To: Tom Lendacky, netdev; +Cc: David Miller

On 03/09/2017 05:48 PM, Tom Lendacky wrote:
> Depending on the hardware, the amd-xgbe driver may use disable_irq_nosync()
> and enable_irq() when an interrupt is received to process Rx packets. If
> the napi_complete_done() return value isn't checked an unbalanced enable
> for the IRQ could result, generating a warning stack trace.
>
> Update the driver to only enable interrupts if napi_complete_done() returns
> true.

I've been running this for a few hours now and haven't seen the warning. 
So it appears to be fixed. Thanks!

I guess Dave M picked it up already, but I will toss this in anyway.


Tested-by: Jeremy Linton <jeremy.linton@arm.com>

>
> Reported-by: Jeremy Linton <jeremy.linton@arm.com>
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  drivers/net/ethernet/amd/xgbe/xgbe-drv.c |   10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
> index 248f60d..ffea985 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
> @@ -2272,10 +2272,7 @@ static int xgbe_one_poll(struct napi_struct *napi, int budget)
>  	processed = xgbe_rx_poll(channel, budget);
>
>  	/* If we processed everything, we are done */
> -	if (processed < budget) {
> -		/* Turn off polling */
> -		napi_complete_done(napi, processed);
> -
> +	if ((processed < budget) && napi_complete_done(napi, processed)) {
>  		/* Enable Tx and Rx interrupts */
>  		if (pdata->channel_irq_mode)
>  			xgbe_enable_rx_tx_int(pdata, channel);
> @@ -2317,10 +2314,7 @@ static int xgbe_all_poll(struct napi_struct *napi, int budget)
>  	} while ((processed < budget) && (processed != last_processed));
>
>  	/* If we processed everything, we are done */
> -	if (processed < budget) {
> -		/* Turn off polling */
> -		napi_complete_done(napi, processed);
> -
> +	if ((processed < budget) && napi_complete_done(napi, processed)) {
>  		/* Enable Tx and Rx interrupts */
>  		xgbe_enable_rx_tx_ints(pdata);
>  	}
>

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

* Re: [PATCH net] amd-xgbe: Enable IRQs only if napi_complete_done() is true
  2017-03-10 14:19   ` Tom Lendacky
@ 2017-03-10 18:06     ` David Miller
  0 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2017-03-10 18:06 UTC (permalink / raw)
  To: thomas.lendacky; +Cc: netdev, jeremy.linton

From: Tom Lendacky <thomas.lendacky@amd.com>
Date: Fri, 10 Mar 2017 08:19:37 -0600

> On 3/9/2017 8:31 PM, David Miller wrote:
>> From: Tom Lendacky <thomas.lendacky@amd.com>
>> Date: Thu, 9 Mar 2017 17:48:23 -0600
>>
>>> Depending on the hardware, the amd-xgbe driver may use
>>> disable_irq_nosync()
>>> and enable_irq() when an interrupt is received to process Rx
>>> packets. If
>>> the napi_complete_done() return value isn't checked an unbalanced
>>> enable
>>> for the IRQ could result, generating a warning stack trace.
>>>
>>> Update the driver to only enable interrupts if napi_complete_done()
>>> returns
>>> true.
>>>
>>> Reported-by: Jeremy Linton <jeremy.linton@arm.com>
>>> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
>>
>> Applied, thanks.
> 
> Thanks David!  The change to napi_complete_done() from void to bool
> occurred in 4.10, can you queue this fix up against 4.10 stable?

Sure, done.

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

end of thread, other threads:[~2017-03-10 18:06 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-09 23:48 [PATCH net] amd-xgbe: Enable IRQs only if napi_complete_done() is true Tom Lendacky
2017-03-10  2:31 ` David Miller
2017-03-10 14:19   ` Tom Lendacky
2017-03-10 18:06     ` David Miller
2017-03-10 16:33 ` Jeremy Linton

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).