netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@vyatta.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org
Subject: [PATCH 7/9] sky2: lock less transmit completion
Date: Fri, 14 Aug 2009 08:15:18 -0700	[thread overview]
Message-ID: <20090814151608.441363342@vyatta.com> (raw)
In-Reply-To: 20090814151511.992669598@vyatta.com

[-- Attachment #1: sky2-tx4b.patch --]
[-- Type: text/plain, Size: 2290 bytes --]

Transmit completion can safely run lockless against transmit start.
In the normal case, completion is done from NAPI and only looks
at elements that are at the tail of the ring.  When doing shutdown
or reset, the transmiter should be completely block by NAPI disable
and blocking of transmit queue. 

Based on earlier work by Mike McCormack.

Signed-off-by: Stephen Hemminger <shemminger@vyatta.com>

---
 drivers/net/sky2.c |  120 +++++++++++++++++++++++++----------------------------
 1 file changed, 57 insertions(+), 63 deletions(-)

--- a/drivers/net/sky2.c	2009-08-14 07:58:48.448220547 -0700
+++ b/drivers/net/sky2.c	2009-08-14 07:58:49.410251274 -0700
@@ -1734,8 +1734,12 @@ mapping_error:
 /*
  * Free ring elements from starting at tx_cons until "done"
  *
- * NB: the hardware will tell us about partial completion of multi-part
+ * NB:
+ *  1. The hardware will tell us about partial completion of multi-part
  *     buffers so make sure not to free skb to early.
+ *  2. This may run in parallel start_xmit because the it only
+ *     looks at the tail of the queue of FIFO (tx_cons), not
+ *     the head (tx_prod)
  */
 static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
 {
@@ -1793,16 +1797,6 @@ static void sky2_tx_complete(struct sky2
 		netif_wake_queue(dev);
 }
 
-/* Cleanup all untransmitted buffers, assume transmitter not running */
-static void sky2_tx_clean(struct net_device *dev)
-{
-	struct sky2_port *sky2 = netdev_priv(dev);
-
-	netif_tx_lock_bh(dev);
-	sky2_tx_complete(sky2, sky2->tx_prod);
-	netif_tx_unlock_bh(dev);
-}
-
 static void sky2_tx_reset(struct sky2_hw *hw, unsigned port)
 {
 	/* Disable Force Sync bit and Enable Alloc bit */
@@ -1890,7 +1884,9 @@ static int sky2_down(struct net_device *
 
 	sky2_tx_reset(hw, port);
 
-	sky2_tx_clean(dev);
+	/* Free any pending frames stuck in HW queue */
+	sky2_tx_complete(sky2, sky2->tx_prod);
+
 	sky2_rx_clean(sky2);
 
 	pci_free_consistent(hw->pdev, RX_LE_BYTES,
@@ -2367,11 +2363,8 @@ static inline void sky2_tx_done(struct n
 {
 	struct sky2_port *sky2 = netdev_priv(dev);
 
-	if (netif_running(dev)) {
-		netif_tx_lock(dev);
+	if (netif_running(dev))
 		sky2_tx_complete(sky2, last);
-		netif_tx_unlock(dev);
-	}
 }
 
 static inline void sky2_skb_rx(const struct sky2_port *sky2,

-- 


  parent reply	other threads:[~2009-08-14 15:19 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-14 15:15 [PATCH 0/9] sky2: version 1.24 Stephen Hemminger
2009-08-14 15:15 ` [PATCH 1/9] sky2: Avoid rewinding sky2->tx_prod Stephen Hemminger
2009-08-14 15:15 ` [PATCH 2/9] sky2: Move tx reset functionality to sky2_tx_reset() Stephen Hemminger
2009-08-14 15:15 ` [PATCH 3/9] sky2: Reset tx train after interrupts disabled Stephen Hemminger
2009-08-14 15:15 ` [PATCH 4/9] sky2: hold spinlock around phy_power_down Stephen Hemminger
2009-08-14 15:15 ` [PATCH 5/9] sky2: hold RTNL when doing suspend/shutdown operations Stephen Hemminger
2009-08-14 15:15 ` [PATCH 6/9] sky2: cleanup restart operations Stephen Hemminger
2009-08-14 15:15 ` Stephen Hemminger [this message]
2009-08-14 15:15 ` [PATCH 8/9] sky2: fix pause negotiation Stephen Hemminger
2009-08-14 15:15 ` [PATCH 9/9] sky2: version 1.24 Stephen Hemminger
2009-08-14 22:41 ` [PATCH 0/9] " David Miller
2009-08-14 23:33   ` [PATCH] sky2: remove restarting workaround flag Stephen Hemminger
2009-08-14 23:38     ` 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=20090814151608.441363342@vyatta.com \
    --to=shemminger@vyatta.com \
    --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).