linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: macb: Change interrupt and napi enable order in open
@ 2019-05-07 14:29 Harini Katakam
  2019-05-07 15:32 ` Nicolas.Ferre
  2019-05-07 19:28 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Harini Katakam @ 2019-05-07 14:29 UTC (permalink / raw)
  To: nicolas.ferre, davem, rafalo
  Cc: netdev, linux-kernel, michal.simek, harinikatakamlinux, harini.katakam

Current order in open:
-> Enable interrupts (macb_init_hw)
-> Enable NAPI
-> Start PHY

Sequence of RX handling:
-> RX interrupt occurs
-> Interrupt is cleared and interrupt bits disabled in handler
-> NAPI is scheduled
-> In NAPI, RX budget is processed and RX interrupts are re-enabled

With the above, on QEMU or fixed link setups (where PHY state doesn't
matter), there's a chance macb RX interrupt occurs before NAPI is
enabled. This will result in NAPI being scheduled before it is enabled.
Fix this macb open by changing the order.

Fixes: ae1f2a56d273 ("net: macb: Added support for many RX queues")
Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>
---
 drivers/net/ethernet/cadence/macb_main.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index 5d5c9d7..c049410 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -2427,12 +2427,12 @@ static int macb_open(struct net_device *dev)
 		goto pm_exit;
 	}
 
-	bp->macbgem_ops.mog_init_rings(bp);
-	macb_init_hw(bp);
-
 	for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
 		napi_enable(&queue->napi);
 
+	bp->macbgem_ops.mog_init_rings(bp);
+	macb_init_hw(bp);
+
 	/* schedule a link state check */
 	phy_start(dev->phydev);
 
-- 
2.7.4


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

* Re: [PATCH] net: macb: Change interrupt and napi enable order in open
  2019-05-07 14:29 [PATCH] net: macb: Change interrupt and napi enable order in open Harini Katakam
@ 2019-05-07 15:32 ` Nicolas.Ferre
  2019-05-07 19:28 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Nicolas.Ferre @ 2019-05-07 15:32 UTC (permalink / raw)
  To: harini.katakam, davem, rafalo
  Cc: netdev, linux-kernel, michal.simek, harinikatakamlinux

On 07/05/2019 at 16:29, Harini Katakam wrote:
> External E-Mail
> 
> 
> Current order in open:
> -> Enable interrupts (macb_init_hw)
> -> Enable NAPI
> -> Start PHY
> 
> Sequence of RX handling:
> -> RX interrupt occurs
> -> Interrupt is cleared and interrupt bits disabled in handler
> -> NAPI is scheduled
> -> In NAPI, RX budget is processed and RX interrupts are re-enabled
> 
> With the above, on QEMU or fixed link setups (where PHY state doesn't
> matter), there's a chance macb RX interrupt occurs before NAPI is
> enabled. This will result in NAPI being scheduled before it is enabled.
> Fix this macb open by changing the order.
> 
> Fixes: ae1f2a56d273 ("net: macb: Added support for many RX queues")
> Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>

it looks okay to me:
Acked-by: Nicolas Ferre <nicolas.ferre@microchip.com>

> ---
>   drivers/net/ethernet/cadence/macb_main.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index 5d5c9d7..c049410 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -2427,12 +2427,12 @@ static int macb_open(struct net_device *dev)
>   		goto pm_exit;
>   	}
>   
> -	bp->macbgem_ops.mog_init_rings(bp);
> -	macb_init_hw(bp);
> -
>   	for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
>   		napi_enable(&queue->napi);
>   
> +	bp->macbgem_ops.mog_init_rings(bp);
> +	macb_init_hw(bp);
> +
>   	/* schedule a link state check */
>   	phy_start(dev->phydev);
>   
> 


-- 
Nicolas Ferre

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

* Re: [PATCH] net: macb: Change interrupt and napi enable order in open
  2019-05-07 14:29 [PATCH] net: macb: Change interrupt and napi enable order in open Harini Katakam
  2019-05-07 15:32 ` Nicolas.Ferre
@ 2019-05-07 19:28 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-05-07 19:28 UTC (permalink / raw)
  To: harini.katakam
  Cc: nicolas.ferre, rafalo, netdev, linux-kernel, michal.simek,
	harinikatakamlinux

From: Harini Katakam <harini.katakam@xilinx.com>
Date: Tue, 7 May 2019 19:59:10 +0530

> Current order in open:
> -> Enable interrupts (macb_init_hw)
> -> Enable NAPI
> -> Start PHY
> 
> Sequence of RX handling:
> -> RX interrupt occurs
> -> Interrupt is cleared and interrupt bits disabled in handler
> -> NAPI is scheduled
> -> In NAPI, RX budget is processed and RX interrupts are re-enabled
> 
> With the above, on QEMU or fixed link setups (where PHY state doesn't
> matter), there's a chance macb RX interrupt occurs before NAPI is
> enabled. This will result in NAPI being scheduled before it is enabled.
> Fix this macb open by changing the order.
> 
> Fixes: ae1f2a56d273 ("net: macb: Added support for many RX queues")
> Signed-off-by: Harini Katakam <harini.katakam@xilinx.com>

Applied and queued up for -stable.

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

end of thread, other threads:[~2019-05-07 19:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-07 14:29 [PATCH] net: macb: Change interrupt and napi enable order in open Harini Katakam
2019-05-07 15:32 ` Nicolas.Ferre
2019-05-07 19:28 ` David Miller

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