From: Stephen Hemminger <shemminger@linux-foundation.org>
To: "David S. Miller" <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] netpoll: tx lock deadlock fix
Date: Tue, 29 May 2007 17:32:21 -0700 [thread overview]
Message-ID: <20070529173221.5c2dd261@freepuppy> (raw)
If sky2 device poll routine is called from netpoll_send_skb, it
would deadlock. The netpoll_send_skb held the netif_tx_lock, and the
poll routine could acquire it to clean up skb's. Other drivers
might use same locking model.
The driver is correct, netpoll should not introduce more locking problems
than it causes already. So change the code to drop lock before calling
poll handler.
Signed-off-by: Stephen Hemminger <shemminger@linux.foundation.org>
--- a/net/core/netpoll.c 2007-05-08 14:19:32.000000000 -0700
+++ b/net/core/netpoll.c 2007-05-29 15:28:22.000000000 -0700
@@ -250,22 +250,23 @@ static void netpoll_send_skb(struct netp
unsigned long flags;
local_irq_save(flags);
- if (netif_tx_trylock(dev)) {
- /* try until next clock tick */
- for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
- tries > 0; --tries) {
+ /* try until next clock tick */
+ for (tries = jiffies_to_usecs(1)/USEC_PER_POLL;
+ tries > 0; --tries) {
+ if (netif_tx_trylock(dev)) {
if (!netif_queue_stopped(dev))
status = dev->hard_start_xmit(skb, dev);
+ netif_tx_unlock(dev);
if (status == NETDEV_TX_OK)
break;
- /* tickle device maybe there is some cleanup */
- netpoll_poll(np);
-
- udelay(USEC_PER_POLL);
}
- netif_tx_unlock(dev);
+
+ /* tickle device maybe there is some cleanup */
+ netpoll_poll(np);
+
+ udelay(USEC_PER_POLL);
}
local_irq_restore(flags);
}
next reply other threads:[~2007-05-30 0:43 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-30 0:32 Stephen Hemminger [this message]
2007-06-27 7:40 ` [PATCH] netpoll: tx lock deadlock fix 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=20070529173221.5c2dd261@freepuppy \
--to=shemminger@linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=davem@davemloft.net \
--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 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).