netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Hemminger <shemminger@osdl.org>
To: Jeff Garzik <jgarzik@pobox.com>
Cc: netdev@vger.kernel.org
Subject: [PATCH 10/10] chelesio: transmit locking (plus bug fix).
Date: Fri, 01 Dec 2006 16:36:22 -0800	[thread overview]
Message-ID: <20061202003707.873200000@osdl.org> (raw)
In-Reply-To: 20061202003612.573260000@osdl.org

[-- Attachment #1: chelsio-tx-lock.patch --]
[-- Type: text/plain, Size: 1946 bytes --]

If transmit lock is contended on, then push return code back
and retry at higher level.

Bugfix: If buffer is reallocated because of lack of headroom
and the send is blocked, then drop packet. This is necessary
because caller would end up requeuing a freed skb.

Signed-off-by: Stephen Hemminger <shemminger@osdl.org>

---
 drivers/net/chelsio/sge.c |   19 +++++++++++++++----
 1 file changed, 15 insertions(+), 4 deletions(-)

--- chelsio.orig/drivers/net/chelsio/sge.c
+++ chelsio/drivers/net/chelsio/sge.c
@@ -1778,7 +1778,9 @@ static int t1_sge_tx(struct sk_buff *skb
 	struct cmdQ *q = &sge->cmdQ[qid];
 	unsigned int credits, pidx, genbit, count, use_sched_skb = 0;
 
-	spin_lock(&q->lock);
+	if (!spin_trylock(&q->lock))
+		return NETDEV_TX_LOCKED;
+
 	reclaim_completed_tx(sge, q);
 
 	pidx = q->pidx;
@@ -1887,6 +1889,8 @@ int t1_start_xmit(struct sk_buff *skb, s
 	struct sge *sge = adapter->sge;
 	struct sge_port_stats *st = per_cpu_ptr(sge->port_stats[dev->if_port], smp_processor_id());
 	struct cpl_tx_pkt *cpl;
+	struct sk_buff *orig_skb = skb;
+	int ret;
 
 	if (skb->protocol == htons(ETH_P_CPL5))
 		goto send;
@@ -1930,8 +1934,6 @@ int t1_start_xmit(struct sk_buff *skb, s
 		 * Complain when this happens but try to fix things up.
 		 */
 		if (unlikely(skb_headroom(skb) < dev->hard_header_len - ETH_HLEN)) {
-			struct sk_buff *orig_skb = skb;
-
 			pr_debug("%s: headroom %d header_len %d\n", dev->name,
 				 skb_headroom(skb), dev->hard_header_len);
 
@@ -1991,7 +1993,16 @@ int t1_start_xmit(struct sk_buff *skb, s
 send:
 	st->tx_packets++;
 	dev->trans_start = jiffies;
-	return t1_sge_tx(skb, adapter, 0, dev);
+	ret = t1_sge_tx(skb, adapter, 0, dev);
+
+	/* If transmit busy, and we reallocated skb's due to headroom limit,
+	 * then silently discard to avoid leak.
+	 */
+	if (unlikely(ret != NETDEV_TX_OK && skb != orig_skb)) {
+ 		dev_kfree_skb_any(skb);
+		ret = NETDEV_TX_OK;
+ 	}
+	return ret;
 }
 
 /*

-- 


  parent reply	other threads:[~2006-12-02  0:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-02  0:36 [PATCH 00/10] chelsio: 10G driver Stephen Hemminger
2006-12-02  0:36 ` [PATCH 01/10] chelsio: whitespace fixes Stephen Hemminger
2006-12-02  0:36 ` [PATCH 02/10] chelsio: use kzalloc Stephen Hemminger
2006-12-02  0:36 ` [PATCH 03/10] chelsio: remove unused mutex Stephen Hemminger
2006-12-02  0:36 ` [PATCH 05/10] chelsio: add 1G swcixw aupport Stephen Hemminger
2006-12-02  0:36 ` [PATCH 06/10] chelsio: cleanup pm3393 code Stephen Hemminger
2006-12-02  0:36 ` [PATCH 07/10] chelsio: use standard CRC routines Stephen Hemminger
2006-12-02  0:36 ` [PATCH 08/10] chelsio: add MSI support Stephen Hemminger
2006-12-02  0:36 ` [PATCH 09/10] chelsio: statistics improvement Stephen Hemminger
2006-12-02  0:36 ` Stephen Hemminger [this message]
2006-12-03 10:45   ` [PATCH 10/10] chelesio: transmit locking (plus bug fix) Eric Lemoine
2006-12-04 17:58     ` Stephen Hemminger

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=20061202003707.873200000@osdl.org \
    --to=shemminger@osdl.org \
    --cc=jgarzik@pobox.com \
    --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).