[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20061206233134.GC4649@austin.ibm.com>
Date: Wed, 6 Dec 2006 17:31:34 -0600
From: linas@...tin.ibm.com (Linas Vepstas)
To: Andrew Morton <akpm@...l.org>
Cc: jgarzik@...ox.com, netdev@...r.kernel.org, linuxppc-dev@...abs.org,
James K Lewis <jklewis@...ibm.com>,
Arnd Bergmann <arnd@...db.de>,
Geoff Levand <geoffrey.levand@...sony.com>
Subject: [PATCH 3/16] Spidernet RX Locking
The RX packet handling can be called from several
places, yet does not protect the rx ring structure.
This patch places the ring buffer pointers under a lock.
Signed-off-by: Linas Vepstas <linas@...tin.ibm.com>
Cc: James K Lewis <jklewis@...ibm.com>
Cc: Arnd Bergmann <arnd@...db.de>
----
drivers/net/spider_net.c | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
Index: linux-2.6.19-git7/drivers/net/spider_net.c
===================================================================
--- linux-2.6.19-git7.orig/drivers/net/spider_net.c 2006-12-06 15:58:27.000000000 -0600
+++ linux-2.6.19-git7/drivers/net/spider_net.c 2006-12-06 16:01:49.000000000 -0600
@@ -969,28 +969,33 @@ static int
spider_net_decode_one_descr(struct spider_net_card *card, int napi)
{
struct spider_net_descr_chain *chain = &card->rx_chain;
- struct spider_net_descr *descr = chain->tail;
+ struct spider_net_descr *descr;
int status;
int result;
+ unsigned long flags;
+
+ spin_lock_irqsave(&chain->lock, flags);
+ descr = chain->tail;
status = spider_net_get_descr_status(descr);
if (status == SPIDER_NET_DESCR_CARDOWNED) {
/* nothing in the descriptor yet */
- result=0;
- goto out;
+ spin_unlock_irqrestore(&chain->lock, flags);
+ return 0;
}
if (status == SPIDER_NET_DESCR_NOT_IN_USE) {
/* not initialized yet, the ring must be empty */
+ spin_unlock_irqrestore(&chain->lock, flags);
spider_net_refill_rx_chain(card);
spider_net_enable_rxdmac(card);
- result=0;
- goto out;
+ return 0;
}
/* descriptor definitively used -- move on tail */
chain->tail = descr->next;
+ spin_unlock_irqrestore(&chain->lock, flags);
result = 0;
if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) ||
@@ -1022,7 +1027,6 @@ refill:
/* change the descriptor state: */
if (!napi)
spider_net_refill_rx_chain(card);
-out:
return result;
}
-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists