Re: [PATCH] sky2: Avoid race in sky2_change_mtu

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Stephen Hemminger
Date: Monday, May 3, 2010 - 4:26 pm

On Mon, 03 May 2010 23:18:56 +0900
Mike McCormack <mikem@ring3k.org> wrote:


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);
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] sky2: Avoid race in sky2_change_mtu, Mike McCormack, (Mon May 3, 7:18 am)
Re: [PATCH] sky2: Avoid race in sky2_change_mtu, David Miller, (Mon May 3, 3:37 pm)
Re: [PATCH] sky2: Avoid race in sky2_change_mtu, Stephen Hemminger, (Mon May 3, 4:26 pm)
Re: [PATCH] sky2: Avoid race in sky2_change_mtu, David Miller, (Mon May 3, 4:36 pm)