* [PATCH] sky2: Avoid race in sky2_change_mtu
@ 2010-05-03 14:18 Mike McCormack
2010-05-03 22:37 ` David Miller
2010-05-03 23:26 ` Stephen Hemminger
0 siblings, 2 replies; 4+ messages in thread
From: Mike McCormack @ 2010-05-03 14:18 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
netif_stop_queue does not ensure all in-progress transmits are complete,
so use netif_tx_disable() instead.
Make sure NAPI polls are disabled, otherwise NAPI might trigger a TX
restart between when we stop the queue and NAPI is disabled.
Signed-off-by: Mike McCormack <mikem@ring3k.org>
---
drivers/net/sky2.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c
index 088c797..b839bae 100644
--- a/drivers/net/sky2.c
+++ b/drivers/net/sky2.c
@@ -2236,8 +2236,8 @@ static int sky2_change_mtu(struct net_device *dev, int new_mtu)
sky2_write32(hw, B0_IMSK, 0);
dev->trans_start = jiffies; /* prevent tx timeout */
- netif_stop_queue(dev);
napi_disable(&hw->napi);
+ netif_tx_disable(dev);
synchronize_irq(hw->pdev->irq);
--
1.5.6.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] sky2: Avoid race in sky2_change_mtu
2010-05-03 14:18 [PATCH] sky2: Avoid race in sky2_change_mtu Mike McCormack
@ 2010-05-03 22:37 ` David Miller
2010-05-03 23:26 ` Stephen Hemminger
1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2010-05-03 22:37 UTC (permalink / raw)
To: mikem; +Cc: shemminger, netdev
From: Mike McCormack <mikem@ring3k.org>
Date: Mon, 03 May 2010 23:18:56 +0900
> netif_stop_queue does not ensure all in-progress transmits are complete,
> so use netif_tx_disable() instead.
>
> Make sure NAPI polls are disabled, otherwise NAPI might trigger a TX
> restart between when we stop the queue and NAPI is disabled.
>
> Signed-off-by: Mike McCormack <mikem@ring3k.org>
This looks quite reasonable, Stephen please review.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sky2: Avoid race in sky2_change_mtu
2010-05-03 14:18 [PATCH] sky2: Avoid race in sky2_change_mtu Mike McCormack
2010-05-03 22:37 ` David Miller
@ 2010-05-03 23:26 ` Stephen Hemminger
2010-05-03 23:36 ` David Miller
1 sibling, 1 reply; 4+ messages in thread
From: Stephen Hemminger @ 2010-05-03 23:26 UTC (permalink / raw)
To: Mike McCormack; +Cc: netdev
On Mon, 03 May 2010 23:18:56 +0900
Mike McCormack <mikem@ring3k.org> wrote:
> netif_stop_queue does not ensure all in-progress transmits are complete,
> so use netif_tx_disable() instead.
>
> Make sure NAPI polls are disabled, otherwise NAPI might trigger a TX
> restart between when we stop the queue and NAPI is disabled.
How could NAPI trigger a TX restart? Restart is a timer, not controlled
by NAPI. There is a different race that your patch isn't covering.
If a large MTU send is in progress while mtu is changing, the changes
to the GMAC store and forward (sky2_set_tx_stfwd) are not synchronized
with hardware queued transmits.
So I think a there needs to be another spinloop.
--- a/drivers/net/sky2.c 2010-05-03 16:19:58.828106182 -0700
+++ b/drivers/net/sky2.c 2010-05-03 16:24:37.850232475 -0700
@@ -2274,8 +2274,12 @@ static int sky2_change_mtu(struct net_de
imask = sky2_read32(hw, B0_IMSK);
sky2_write32(hw, B0_IMSK, 0);
- dev->trans_start = jiffies; /* prevent tx timeout */
netif_stop_queue(dev);
+
+ /* Wait for ongoing Tx to complete */
+ while (sky2->tx_cons != sky2->tx_prod)
+ udelay(10);
+
napi_disable(&hw->napi);
synchronize_irq(hw->pdev->irq);
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] sky2: Avoid race in sky2_change_mtu
2010-05-03 23:26 ` Stephen Hemminger
@ 2010-05-03 23:36 ` David Miller
0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2010-05-03 23:36 UTC (permalink / raw)
To: shemminger; +Cc: mikem, netdev
From: Stephen Hemminger <shemminger@vyatta.com>
Date: Mon, 3 May 2010 16:26:34 -0700
> On Mon, 03 May 2010 23:18:56 +0900
> Mike McCormack <mikem@ring3k.org> wrote:
>
>> netif_stop_queue does not ensure all in-progress transmits are complete,
>> so use netif_tx_disable() instead.
>>
>> Make sure NAPI polls are disabled, otherwise NAPI might trigger a TX
>> restart between when we stop the queue and NAPI is disabled.
>
> How could NAPI trigger a TX restart? Restart is a timer, not controlled
> by NAPI. There is a different race that your patch isn't covering.
I think he meant to say that NAPI can trigger a TX queue wake, which
indeed it can, and it will if there is space in the TX queue and
we happen to see the TXIDLE status at this time.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2010-05-03 23:36 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-03 14:18 [PATCH] sky2: Avoid race in sky2_change_mtu Mike McCormack
2010-05-03 22:37 ` David Miller
2010-05-03 23:26 ` Stephen Hemminger
2010-05-03 23:36 ` 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).