All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: Mike McCormack <mikem@ring3k.org>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] sky2: Avoid race in sky2_change_mtu
Date: Mon, 3 May 2010 16:26:34 -0700	[thread overview]
Message-ID: <20100503162634.1f004023@nehalam> (raw)
In-Reply-To: <4BDEDB50.7000707@ring3k.org>

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

  parent reply	other threads:[~2010-05-03 23:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2010-05-03 23:36   ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100503162634.1f004023@nehalam \
    --to=shemminger@vyatta.com \
    --cc=mikem@ring3k.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.