* [PATCH 1/10] spidernet: node-aware skbuff allocation
2007-05-16 21:56 [PATCH 0/10] spidernet assorted fixes Linas Vepstas
@ 2007-05-16 21:58 ` Linas Vepstas
2007-05-18 0:46 ` Jeff Garzik
2007-05-16 22:00 ` [PATCH 2/10] spidernet: beautify error messages Linas Vepstas
` (8 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Linas Vepstas @ 2007-05-16 21:58 UTC (permalink / raw)
To: Jeff Garzik; +Cc: cbe-oss-dev, netdev, Christoph Hellwig
From: Christoph Hellwig <hch@lst.de>
Spidernet was the driver I original did all the node-aware netdevice
allocation for, but after a year it still hasn't hit mainline.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
----
drivers/net/spider_net.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c 2007-05-16 11:58:41.000000000 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c 2007-05-16 12:00:25.000000000 -0500
@@ -430,7 +430,8 @@ spider_net_prepare_rx_descr(struct spide
/* and we need to have it 128 byte aligned, therefore we allocate a
* bit more */
/* allocate an skb */
- descr->skb = dev_alloc_skb(bufsize + SPIDER_NET_RXBUF_ALIGN - 1);
+ descr->skb = netdev_alloc_skb(card->netdev,
+ bufsize + SPIDER_NET_RXBUF_ALIGN - 1);
if (!descr->skb) {
if (netif_msg_rx_err(card) && net_ratelimit())
pr_err("Not enough memory to allocate rx buffer\n");
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 2/10] spidernet: beautify error messages
2007-05-16 21:56 [PATCH 0/10] spidernet assorted fixes Linas Vepstas
2007-05-16 21:58 ` [PATCH 1/10] spidernet: node-aware skbuff allocation Linas Vepstas
@ 2007-05-16 22:00 ` Linas Vepstas
2007-05-16 23:28 ` [Cbe-oss-dev] " Michael Ellerman
2007-05-16 22:03 ` [PATCH 3/10] spidernet: move a block of code around Linas Vepstas
` (7 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Linas Vepstas @ 2007-05-16 22:00 UTC (permalink / raw)
To: Jeff Garzik; +Cc: cbe-oss-dev, netdev
Make error messages print which interface they apply to.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
----
drivers/net/spider_net.c | 10 ++++++----
drivers/net/spider_net.h | 2 +-
2 files changed, 7 insertions(+), 5 deletions(-)
Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c 2007-05-14 17:05:03.000000000 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c 2007-05-15 14:47:38.000000000 -0500
@@ -433,7 +433,8 @@ spider_net_prepare_rx_descr(struct spide
descr->skb = dev_alloc_skb(bufsize + SPIDER_NET_RXBUF_ALIGN - 1);
if (!descr->skb) {
if (netif_msg_rx_err(card) && net_ratelimit())
- pr_err("Not enough memory to allocate rx buffer\n");
+ pr_err("%s: Not enough memory to allocate rx buffer\n",
+ card->netdev->name);
card->spider_stats.alloc_rx_skb_error++;
return -ENOMEM;
}
@@ -454,7 +455,8 @@ spider_net_prepare_rx_descr(struct spide
dev_kfree_skb_any(descr->skb);
descr->skb = NULL;
if (netif_msg_rx_err(card) && net_ratelimit())
- pr_err("Could not iommu-map rx buffer\n");
+ pr_err("%s: Could not iommu-map rx buffer\n",
+ card->netdev->name);
card->spider_stats.rx_iommu_map_error++;
hwdescr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
} else {
@@ -1454,8 +1456,8 @@ spider_net_handle_error_irq(struct spide
case SPIDER_NET_GRFAFLLINT: /* fallthrough */
case SPIDER_NET_GRMFLLINT:
if (netif_msg_intr(card) && net_ratelimit())
- pr_err("Spider RX RAM full, incoming packets "
- "might be discarded!\n");
+ pr_err("%s: Spider RX RAM full, incoming packets "
+ "might be discarded!\n", card->netdev->name);
spider_net_rx_irq_off(card);
netif_rx_schedule(card->netdev);
show_error = 0;
Index: linux-2.6.22-rc1/drivers/net/spider_net.h
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.h 2007-05-15 14:47:33.000000000 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.h 2007-05-15 14:47:58.000000000 -0500
@@ -25,7 +25,7 @@
#ifndef _SPIDER_NET_H
#define _SPIDER_NET_H
-#define VERSION "2.0 A"
+#define VERSION "2.0 B"
#include "sungem_phy.h"
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [Cbe-oss-dev] [PATCH 2/10] spidernet: beautify error messages
2007-05-16 22:00 ` [PATCH 2/10] spidernet: beautify error messages Linas Vepstas
@ 2007-05-16 23:28 ` Michael Ellerman
2007-05-18 17:08 ` Linas Vepstas
0 siblings, 1 reply; 21+ messages in thread
From: Michael Ellerman @ 2007-05-16 23:28 UTC (permalink / raw)
To: Linas Vepstas; +Cc: Jeff Garzik, netdev, cbe-oss-dev
[-- Attachment #1: Type: text/plain, Size: 1294 bytes --]
On Wed, 2007-05-16 at 17:00 -0500, Linas Vepstas wrote:
> Make error messages print which interface they apply to.
>
> Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
>
> ----
> drivers/net/spider_net.c | 10 ++++++----
> drivers/net/spider_net.h | 2 +-
> 2 files changed, 7 insertions(+), 5 deletions(-)
>
> Index: linux-2.6.22-rc1/drivers/net/spider_net.c
> ===================================================================
> --- linux-2.6.22-rc1.orig/drivers/net/spider_net.c 2007-05-14 17:05:03.000000000 -0500
> +++ linux-2.6.22-rc1/drivers/net/spider_net.c 2007-05-15 14:47:38.000000000 -0500
> @@ -433,7 +433,8 @@ spider_net_prepare_rx_descr(struct spide
> descr->skb = dev_alloc_skb(bufsize + SPIDER_NET_RXBUF_ALIGN - 1);
> if (!descr->skb) {
> if (netif_msg_rx_err(card) && net_ratelimit())
> - pr_err("Not enough memory to allocate rx buffer\n");
> + pr_err("%s: Not enough memory to allocate rx buffer\n",
> + card->netdev->name);
Isn't that what dev_err() is for?
cheers
--
Michael Ellerman
OzLabs, IBM Australia Development Lab
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)
We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [Cbe-oss-dev] [PATCH 2/10] spidernet: beautify error messages
2007-05-16 23:28 ` [Cbe-oss-dev] " Michael Ellerman
@ 2007-05-18 17:08 ` Linas Vepstas
0 siblings, 0 replies; 21+ messages in thread
From: Linas Vepstas @ 2007-05-18 17:08 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Jeff Garzik, netdev, cbe-oss-dev
On Thu, May 17, 2007 at 09:28:53AM +1000, Michael Ellerman wrote:
> On Wed, 2007-05-16 at 17:00 -0500, Linas Vepstas wrote:
> > - pr_err("Not enough memory to allocate rx buffer\n");
> > + pr_err("%s: Not enough memory to allocate rx buffer\n",
> > + card->netdev->name);
>
> Isn't that what dev_err() is for?
Ahh, did not know that. These patches just got pushed upstream, I'll send
a separate round to clean this up.
--linas
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 3/10] spidernet: move a block of code around
2007-05-16 21:56 [PATCH 0/10] spidernet assorted fixes Linas Vepstas
2007-05-16 21:58 ` [PATCH 1/10] spidernet: node-aware skbuff allocation Linas Vepstas
2007-05-16 22:00 ` [PATCH 2/10] spidernet: beautify error messages Linas Vepstas
@ 2007-05-16 22:03 ` Linas Vepstas
2007-05-16 22:09 ` [PATCH 4/10] spidernet: zero out a pointer Linas Vepstas
` (6 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Linas Vepstas @ 2007-05-16 22:03 UTC (permalink / raw)
To: Jeff Garzik; +Cc: cbe-oss-dev, netdev
Put the enable and disable routines next to one-another,
as this makes verifying thier symmetry that much easier.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
----
drivers/net/spider_net.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c 2007-05-15 13:31:05.000000000 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c 2007-05-15 13:31:11.000000000 -0500
@@ -505,6 +505,20 @@ spider_net_enable_rxdmac(struct spider_n
}
/**
+ * spider_net_disable_rxdmac - disables the receive DMA controller
+ * @card: card structure
+ *
+ * spider_net_disable_rxdmac terminates processing on the DMA controller
+ * by turing off the DMA controller, with the force-end flag set.
+ */
+static inline void
+spider_net_disable_rxdmac(struct spider_net_card *card)
+{
+ spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR,
+ SPIDER_NET_DMA_RX_FEND_VALUE);
+}
+
+/**
* spider_net_refill_rx_chain - refills descriptors/skbs in the rx chains
* @card: card structure
*
@@ -656,20 +670,6 @@ write_hash:
}
/**
- * spider_net_disable_rxdmac - disables the receive DMA controller
- * @card: card structure
- *
- * spider_net_disable_rxdmac terminates processing on the DMA controller by
- * turing off DMA and issueing a force end
- */
-static void
-spider_net_disable_rxdmac(struct spider_net_card *card)
-{
- spider_net_write_reg(card, SPIDER_NET_GDADMACCNTR,
- SPIDER_NET_DMA_RX_FEND_VALUE);
-}
-
-/**
* spider_net_prepare_tx_descr - fill tx descriptor with skb data
* @card: card structure
* @descr: descriptor structure to fill out
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 4/10] spidernet: zero out a pointer.
2007-05-16 21:56 [PATCH 0/10] spidernet assorted fixes Linas Vepstas
` (2 preceding siblings ...)
2007-05-16 22:03 ` [PATCH 3/10] spidernet: move a block of code around Linas Vepstas
@ 2007-05-16 22:09 ` Linas Vepstas
2007-05-16 23:32 ` [Cbe-oss-dev] " Michael Ellerman
2007-05-16 22:12 ` [PATCH 5/10] spidernet: null out skb pointer after its been used Linas Vepstas
` (5 subsequent siblings)
9 siblings, 1 reply; 21+ messages in thread
From: Linas Vepstas @ 2007-05-16 22:09 UTC (permalink / raw)
To: Jeff Garzik; +Cc: cbe-oss-dev, netdev
Invalidate a pointer as its pci_unmap'ed; this is a bit of
paranoia to make sure hardware doesn't continue trying to
DMA to it.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
----
drivers/net/spider_net.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c 2007-05-15 13:31:11.000000000 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c 2007-05-15 13:31:16.000000000 -0500
@@ -1068,6 +1068,7 @@ spider_net_decode_one_descr(struct spide
struct spider_net_descr_chain *chain = &card->rx_chain;
struct spider_net_descr *descr = chain->tail;
struct spider_net_hw_descr *hwdescr = descr->hwdescr;
+ u32 hw_buf_addr;
int status;
status = spider_net_get_descr_status(hwdescr);
@@ -1081,7 +1082,9 @@ spider_net_decode_one_descr(struct spide
chain->tail = descr->next;
/* unmap descriptor */
- pci_unmap_single(card->pdev, hwdescr->buf_addr,
+ hw_buf_addr = hwdescr->buf_addr;
+ hwdescr->buf_addr = 0x0;
+ pci_unmap_single(card->pdev, hw_buf_addr,
SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
if ( (status == SPIDER_NET_DESCR_RESPONSE_ERROR) ||
@@ -1117,7 +1120,7 @@ spider_net_decode_one_descr(struct spide
pr_err("%s: bad status, cmd_status=x%08x\n",
card->netdev->name,
hwdescr->dmac_cmd_status);
- pr_err("buf_addr=x%08x\n", hwdescr->buf_addr);
+ pr_err("buf_addr=x%08x\n", hw_buf_addr);
pr_err("buf_size=x%08x\n", hwdescr->buf_size);
pr_err("next_descr_addr=x%08x\n", hwdescr->next_descr_addr);
pr_err("result_size=x%08x\n", hwdescr->result_size);
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [Cbe-oss-dev] [PATCH 4/10] spidernet: zero out a pointer.
2007-05-16 22:09 ` [PATCH 4/10] spidernet: zero out a pointer Linas Vepstas
@ 2007-05-16 23:32 ` Michael Ellerman
2007-05-22 23:35 ` Linas Vepstas
0 siblings, 1 reply; 21+ messages in thread
From: Michael Ellerman @ 2007-05-16 23:32 UTC (permalink / raw)
To: Linas Vepstas; +Cc: Jeff Garzik, netdev, cbe-oss-dev
[-- Attachment #1: Type: text/plain, Size: 1391 bytes --]
On Wed, 2007-05-16 at 17:09 -0500, Linas Vepstas wrote:
> Invalidate a pointer as its pci_unmap'ed; this is a bit of
> paranoia to make sure hardware doesn't continue trying to
> DMA to it.
>
> Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
>
> ----
> drivers/net/spider_net.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> Index: linux-2.6.22-rc1/drivers/net/spider_net.c
> ===================================================================
> --- linux-2.6.22-rc1.orig/drivers/net/spider_net.c 2007-05-15 13:31:11.000000000 -0500
> +++ linux-2.6.22-rc1/drivers/net/spider_net.c 2007-05-15 13:31:16.000000000 -0500
> @@ -1081,7 +1082,9 @@ spider_net_decode_one_descr(struct spide
> chain->tail = descr->next;
>
> /* unmap descriptor */
> - pci_unmap_single(card->pdev, hwdescr->buf_addr,
> + hw_buf_addr = hwdescr->buf_addr;
> + hwdescr->buf_addr = 0x0;
If you're going to be paranoid, shouldn't you do something here to make
sure the value's hit the device?
> + pci_unmap_single(card->pdev, hw_buf_addr,
> SPIDER_NET_MAX_FRAME, PCI_DMA_FROMDEVICE);
>
cheers
--
Michael Ellerman
OzLabs, IBM Australia Development Lab
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)
We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Cbe-oss-dev] [PATCH 4/10] spidernet: zero out a pointer.
2007-05-16 23:32 ` [Cbe-oss-dev] " Michael Ellerman
@ 2007-05-22 23:35 ` Linas Vepstas
2007-05-23 0:29 ` Segher Boessenkool
2007-05-23 3:23 ` Benjamin Herrenschmidt
0 siblings, 2 replies; 21+ messages in thread
From: Linas Vepstas @ 2007-05-22 23:35 UTC (permalink / raw)
To: Michael Ellerman; +Cc: Jeff Garzik, netdev, cbe-oss-dev
On Thu, May 17, 2007 at 09:32:56AM +1000, Michael Ellerman wrote:
> > + hwdescr->buf_addr = 0x0;
>
> If you're going to be paranoid, shouldn't you do something here to make
> sure the value's hit the device?
I thought the whole point of paranoia is that its inexplicable.
Here's a delusional reply: I didn't see any point to it.
1) a wmb would add overhead
2) the hardware is supposed to be looking at the status flag,
anyway, and not misbehaving.
3) there is a wmb when the descr is actually refilled in such
a way as to actually mean something to the hardware.
All that I really acomplished here is a minor trick to
aid in debug printing when looking for something bad.
--linas
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Cbe-oss-dev] [PATCH 4/10] spidernet: zero out a pointer.
2007-05-22 23:35 ` Linas Vepstas
@ 2007-05-23 0:29 ` Segher Boessenkool
2007-05-23 3:23 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 21+ messages in thread
From: Segher Boessenkool @ 2007-05-23 0:29 UTC (permalink / raw)
To: Linas Vepstas; +Cc: Jeff Garzik, cbe-oss-dev, Michael Ellerman, netdev
>> If you're going to be paranoid, shouldn't you do something here to
>> make
>> sure the value's hit the device?
>
> I thought the whole point of paranoia is that its inexplicable.
>
> Here's a delusional reply: I didn't see any point to it.
> 1) a wmb would add overhead
A wmb() doesn't guarantee the write has reached the device.
> 2) the hardware is supposed to be looking at the status flag,
> anyway, and not misbehaving.
But you're paranoid, right? Can't trust that device! :-)
Segher
^ permalink raw reply [flat|nested] 21+ messages in thread
* Re: [Cbe-oss-dev] [PATCH 4/10] spidernet: zero out a pointer.
2007-05-22 23:35 ` Linas Vepstas
2007-05-23 0:29 ` Segher Boessenkool
@ 2007-05-23 3:23 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 21+ messages in thread
From: Benjamin Herrenschmidt @ 2007-05-23 3:23 UTC (permalink / raw)
To: Linas Vepstas; +Cc: Michael Ellerman, netdev, Jeff Garzik, cbe-oss-dev
> Here's a delusional reply: I didn't see any point to it.
> 1) a wmb would add overhead
> 2) the hardware is supposed to be looking at the status flag,
> anyway, and not misbehaving.
> 3) there is a wmb when the descr is actually refilled in such
> a way as to actually mean something to the hardware.
>
> All that I really acomplished here is a minor trick to
> aid in debug printing when looking for something bad.
And the whole thing is moot because 0 is actually a perfectly valid DMA
address :-) I suspect spider will end up trying to hit some internal
register or it's PCIe or whatever it has mapped at 0 internally and will
blow up ... At least on spider, it's not RAM there....
Ben.
^ permalink raw reply [flat|nested] 21+ messages in thread
* [PATCH 5/10] spidernet: null out skb pointer after its been used.
2007-05-16 21:56 [PATCH 0/10] spidernet assorted fixes Linas Vepstas
` (3 preceding siblings ...)
2007-05-16 22:09 ` [PATCH 4/10] spidernet: zero out a pointer Linas Vepstas
@ 2007-05-16 22:12 ` Linas Vepstas
2007-05-16 22:15 ` [PATCH 6/10] spidernet: Don't terminate the RX ring Linas Vepstas
` (4 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Linas Vepstas @ 2007-05-16 22:12 UTC (permalink / raw)
To: Jeff Garzik; +Cc: cbe-oss-dev, netdev
If the ethernet interface is brought down while there is still
RX traffic in flight, the device shutdown routine can end up
trying to double-free an skb, leading to a crash in mm/slab.c
Avoid the double-free by nulling out the skb pointer.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
----
drivers/net/spider_net.c | 1 +
1 file changed, 1 insertion(+)
Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c 2007-05-15 14:36:13.000000000 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c 2007-05-15 14:39:18.000000000 -0500
@@ -1135,6 +1135,7 @@ spider_net_decode_one_descr(struct spide
/* Ok, we've got a packet in descr */
spider_net_pass_skb_up(descr, card);
+ descr->skb = NULL;
hwdescr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
return 1;
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 6/10] spidernet: Don't terminate the RX ring
2007-05-16 21:56 [PATCH 0/10] spidernet assorted fixes Linas Vepstas
` (4 preceding siblings ...)
2007-05-16 22:12 ` [PATCH 5/10] spidernet: null out skb pointer after its been used Linas Vepstas
@ 2007-05-16 22:15 ` Linas Vepstas
2007-05-16 22:17 ` [PATCH 7/10] spidernet: enhance the dump routine Linas Vepstas
` (3 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Linas Vepstas @ 2007-05-16 22:15 UTC (permalink / raw)
To: Jeff Garzik; +Cc: cbe-oss-dev, netdev
There is no real reason to terminate the RX ring; it
doesn't make the operation any smooother, and it does
require an extra sync. So don't do it.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
----
drivers/net/spider_net.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c 2007-05-15 13:31:16.000000000 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c 2007-05-15 13:51:39.000000000 -0500
@@ -461,13 +461,9 @@ spider_net_prepare_rx_descr(struct spide
hwdescr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
} else {
hwdescr->buf_addr = buf;
- hwdescr->next_descr_addr = 0;
wmb();
hwdescr->dmac_cmd_status = SPIDER_NET_DESCR_CARDOWNED |
SPIDER_NET_DMAC_NOINTR_COMPLETE;
-
- wmb();
- descr->prev->hwdescr->next_descr_addr = descr->bus_addr;
}
return 0;
@@ -556,12 +552,16 @@ spider_net_refill_rx_chain(struct spider
static int
spider_net_alloc_rx_skbs(struct spider_net_card *card)
{
- int result;
- struct spider_net_descr_chain *chain;
+ struct spider_net_descr_chain *chain = &card->rx_chain;
+ struct spider_net_descr *start= chain->tail;
+ struct spider_net_descr *descr = start;
- result = -ENOMEM;
+ /* Link up the hardware chain pointers */
+ do {
+ descr->prev->hwdescr->next_descr_addr = descr->bus_addr;
+ descr = descr->next;
+ } while (descr != start);
- chain = &card->rx_chain;
/* Put at least one buffer into the chain. if this fails,
* we've got a problem. If not, spider_net_refill_rx_chain
* will do the rest at the end of this function. */
@@ -578,7 +578,7 @@ spider_net_alloc_rx_skbs(struct spider_n
error:
spider_net_free_rx_chain_contents(card);
- return result;
+ return -ENOMEM;
}
/**
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 7/10] spidernet: enhance the dump routine
2007-05-16 21:56 [PATCH 0/10] spidernet assorted fixes Linas Vepstas
` (5 preceding siblings ...)
2007-05-16 22:15 ` [PATCH 6/10] spidernet: Don't terminate the RX ring Linas Vepstas
@ 2007-05-16 22:17 ` Linas Vepstas
2007-05-16 22:19 ` [PATCH 8/10] spidernet: reset the card when an rxramfull is seen Linas Vepstas
` (2 subsequent siblings)
9 siblings, 0 replies; 21+ messages in thread
From: Linas Vepstas @ 2007-05-16 22:17 UTC (permalink / raw)
To: Jeff Garzik; +Cc: cbe-oss-dev, netdev
Crazy device problems are hard to debug, when one does not have
good trace info. This patch makes a major enhancement to the
device dump routine.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
----
drivers/net/spider_net.c | 62 ++++++++++++++++++++++++++++++++++++++++-------
1 file changed, 54 insertions(+), 8 deletions(-)
Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c 2007-05-15 14:39:24.000000000 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c 2007-05-15 14:39:25.000000000 -0500
@@ -1023,34 +1023,78 @@ spider_net_pass_skb_up(struct spider_net
card->netdev_stats.rx_bytes += skb->len;
}
-#ifdef DEBUG
static void show_rx_chain(struct spider_net_card *card)
{
struct spider_net_descr_chain *chain = &card->rx_chain;
struct spider_net_descr *start= chain->tail;
struct spider_net_descr *descr= start;
+ struct spider_net_hw_descr *hwd = start->hwdescr;
+ char *iface = card->netdev->name;
+ u32 curr_desc, next_desc;
int status;
int cnt = 0;
- int cstat = spider_net_get_descr_status(descr);
- printk(KERN_INFO "RX chain tail at descr=%ld\n",
- (start - card->descr) - card->tx_chain.num_desc);
+ int off = 0;
+ int cstat = hwd->dmac_cmd_status;
+
+ printk(KERN_INFO "%s: Total number of descrs=%d\n",
+ iface, chain->num_desc);
+ printk(KERN_INFO "%s: Chain tail located at descr=%d\n",
+ iface, (int) (start - chain->ring));
+
+ curr_desc = spider_net_read_reg(card, SPIDER_NET_GDACTDPA);
+ next_desc = spider_net_read_reg(card, SPIDER_NET_GDACNEXTDA);
+
status = cstat;
do
{
- status = spider_net_get_descr_status(descr);
+ hwd = descr->hwdescr;
+ off = descr - chain->ring;
+ if (descr==chain->head)
+ printk(KERN_INFO "%s: chain head is at %d\n", iface, off);
+ if (curr_desc == descr->bus_addr)
+ printk(KERN_INFO "%s: hw curr desc is at %d\n", iface, off);
+ if (next_desc == descr->bus_addr)
+ printk(KERN_INFO "%s: hw next desc is at %d\n", iface, off);
+ if (hwd->next_descr_addr == 0)
+ printk(KERN_INFO "%s: chain is cut at %d\n", iface, off);
+ status = hwd->dmac_cmd_status;
if (cstat != status) {
- printk(KERN_INFO "Have %d descrs with stat=x%08x\n", cnt, cstat);
+ printk(KERN_INFO "%s: Have %d descrs with stat=x%08x\n",
+ iface, cnt, cstat);
cstat = status;
cnt = 0;
}
cnt ++;
descr = descr->next;
} while (descr != start);
- printk(KERN_INFO "Last %d descrs with stat=x%08x\n", cnt, cstat);
-}
+ printk(KERN_INFO "%s: Last %d descrs with stat=x%08x\n",
+ iface, cnt, cstat);
+
+#ifdef DEBUG
+ /* Now dump the whole ring */
+ descr = start;
+ do
+ {
+ struct spider_net_hw_descr *hwd = descr->hwdescr;
+ status = spider_net_get_descr_status(hwd);
+ cnt = descr - chain->ring;
+ printk(KERN_INFO "Descr %d stat=0x%08x skb=%p\n",
+ cnt, status, descr->skb);
+ printk(KERN_INFO "bus addr=%08x buf addr=%08x sz=%d\n",
+ descr->bus_addr, hwd->buf_addr, hwd->buf_size);
+ printk(KERN_INFO "next=%08x result sz=%d valid sz=%d\n",
+ hwd->next_descr_addr, hwd->result_size, hwd->valid_size);
+ printk(KERN_INFO "dmac=%08x data stat=%08x data err=%08x\n",
+ hwd->dmac_cmd_status, hwd->data_status, hwd->data_error);
+ printk(KERN_INFO "\n");
+
+ descr = descr->next;
+ } while (descr != start);
#endif
+}
+
/**
* spider_net_decode_one_descr - processes an RX descriptor
* @card: card structure
@@ -1140,6 +1184,8 @@ spider_net_decode_one_descr(struct spide
return 1;
bad_desc:
+ if (netif_msg_rx_err(card))
+ show_rx_chain(card);
dev_kfree_skb_irq(descr->skb);
descr->skb = NULL;
hwdescr->dmac_cmd_status = SPIDER_NET_DESCR_NOT_IN_USE;
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 8/10] spidernet: reset the card when an rxramfull is seen
2007-05-16 21:56 [PATCH 0/10] spidernet assorted fixes Linas Vepstas
` (6 preceding siblings ...)
2007-05-16 22:17 ` [PATCH 7/10] spidernet: enhance the dump routine Linas Vepstas
@ 2007-05-16 22:19 ` Linas Vepstas
2007-05-16 22:21 ` [PATCH 9/10] spidernet: service TX later Linas Vepstas
2007-05-16 22:23 ` [PATCH 10/10] spidernet: increase the NAPI weight Linas Vepstas
9 siblings, 0 replies; 21+ messages in thread
From: Linas Vepstas @ 2007-05-16 22:19 UTC (permalink / raw)
To: Jeff Garzik; +Cc: cbe-oss-dev, netdev
Some versions of the spider have a firmware bug, where the
RX ring sequencer goes crazy when the RX RAM on the device
fills up. Appearently the only viable wrkaround is a soft
reset of the card.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
----
drivers/net/spider_net.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c 2007-05-15 14:48:06.000000000 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c 2007-05-15 16:34:46.000000000 -0500
@@ -1505,11 +1505,17 @@ spider_net_handle_error_irq(struct spide
case SPIDER_NET_GRFBFLLINT: /* fallthrough */
case SPIDER_NET_GRFAFLLINT: /* fallthrough */
case SPIDER_NET_GRMFLLINT:
- if (netif_msg_intr(card) && net_ratelimit())
- pr_err("%s: Spider RX RAM full, incoming packets "
- "might be discarded!\n", card->netdev->name);
+ if (netif_msg_intr(card) && net_ratelimit()) {
+ pr_err("%s: Spider RX RAM full, reseting device.\n",
+ card->netdev->name);
+ show_rx_chain(card);
+ }
spider_net_rx_irq_off(card);
netif_rx_schedule(card->netdev);
+
+ /* If the card is spewing rxramfulls, then reset */
+ atomic_inc(&card->tx_timeout_task_counter);
+ schedule_work(&card->tx_timeout_task);
show_error = 0;
break;
@@ -2086,6 +2092,8 @@ spider_net_workaround_rxramfull(struct s
{
int i, sequencer = 0;
+ printk(KERN_INFO "%s: calling rxramfull workaround\n", card->netdev->name);
+
/* cancel reset */
spider_net_write_reg(card, SPIDER_NET_CKRCTRL,
SPIDER_NET_CKRCTRL_RUN_VALUE);
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 9/10] spidernet: service TX later.
2007-05-16 21:56 [PATCH 0/10] spidernet assorted fixes Linas Vepstas
` (7 preceding siblings ...)
2007-05-16 22:19 ` [PATCH 8/10] spidernet: reset the card when an rxramfull is seen Linas Vepstas
@ 2007-05-16 22:21 ` Linas Vepstas
2007-05-16 22:23 ` [PATCH 10/10] spidernet: increase the NAPI weight Linas Vepstas
9 siblings, 0 replies; 21+ messages in thread
From: Linas Vepstas @ 2007-05-16 22:21 UTC (permalink / raw)
To: Jeff Garzik; +Cc: cbe-oss-dev, netdev
When entering the netdev poll routine, empty out the RX
chain first, before cleaning up the TX chain. This should
help avoid RX buffer overflows.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
----
drivers/net/spider_net.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
Index: linux-2.6.22-rc1/drivers/net/spider_net.c
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.c 2007-05-16 17:20:36.000000000 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.c 2007-05-16 17:20:44.000000000 -0500
@@ -1212,7 +1212,6 @@ spider_net_poll(struct net_device *netde
int packets_to_do, packets_done = 0;
int no_more_packets = 0;
- spider_net_cleanup_tx_ring(card);
packets_to_do = min(*budget, netdev->quota);
while (packets_to_do) {
@@ -1231,6 +1230,8 @@ spider_net_poll(struct net_device *netde
spider_net_refill_rx_chain(card);
spider_net_enable_rxdmac(card);
+ spider_net_cleanup_tx_ring(card);
+
/* if all packets are in the stack, enable interrupts and return 0 */
/* if not, return 1 */
if (no_more_packets) {
^ permalink raw reply [flat|nested] 21+ messages in thread* [PATCH 10/10] spidernet: increase the NAPI weight
2007-05-16 21:56 [PATCH 0/10] spidernet assorted fixes Linas Vepstas
` (8 preceding siblings ...)
2007-05-16 22:21 ` [PATCH 9/10] spidernet: service TX later Linas Vepstas
@ 2007-05-16 22:23 ` Linas Vepstas
2007-05-16 23:34 ` [Cbe-oss-dev] " Michael Ellerman
9 siblings, 1 reply; 21+ messages in thread
From: Linas Vepstas @ 2007-05-16 22:23 UTC (permalink / raw)
To: Jeff Garzik; +Cc: cbe-oss-dev, netdev
Another way of minimizing the likelyhood of RX ram from overflowing
is to empty out the entire rx ring every chance we get. Change
the crazy watchdog timeout from 50 seconds to 3 seconds, while
we're here.
Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
----
drivers/net/spider_net.h | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
Index: linux-2.6.22-rc1/drivers/net/spider_net.h
===================================================================
--- linux-2.6.22-rc1.orig/drivers/net/spider_net.h 2007-05-16 12:00:35.000000000 -0500
+++ linux-2.6.22-rc1/drivers/net/spider_net.h 2007-05-16 12:00:35.000000000 -0500
@@ -56,8 +56,13 @@ extern char spider_net_driver_name[];
#define SPIDER_NET_RX_CSUM_DEFAULT 1
-#define SPIDER_NET_WATCHDOG_TIMEOUT 50*HZ
-#define SPIDER_NET_NAPI_WEIGHT 64
+#define SPIDER_NET_WATCHDOG_TIMEOUT 3*HZ
+
+/* We really really want to empty the ring buffer every time,
+ * so as to avoid the RX ram full bug. So set te napi wieght
+ * to the ring size
+ */
+#define SPIDER_NET_NAPI_WEIGHT SPIDER_NET_RX_DESCRIPTORS_DEFAULT
#define SPIDER_NET_FIRMWARE_SEQS 6
#define SPIDER_NET_FIRMWARE_SEQWORDS 1024
^ permalink raw reply [flat|nested] 21+ messages in thread* Re: [Cbe-oss-dev] [PATCH 10/10] spidernet: increase the NAPI weight
2007-05-16 22:23 ` [PATCH 10/10] spidernet: increase the NAPI weight Linas Vepstas
@ 2007-05-16 23:34 ` Michael Ellerman
0 siblings, 0 replies; 21+ messages in thread
From: Michael Ellerman @ 2007-05-16 23:34 UTC (permalink / raw)
To: Linas Vepstas; +Cc: Jeff Garzik, netdev, cbe-oss-dev
[-- Attachment #1: Type: text/plain, Size: 1455 bytes --]
On Wed, 2007-05-16 at 17:23 -0500, Linas Vepstas wrote:
> Another way of minimizing the likelyhood of RX ram from overflowing
> is to empty out the entire rx ring every chance we get. Change
> the crazy watchdog timeout from 50 seconds to 3 seconds, while
> we're here.
>
> Signed-off-by: Linas Vepstas <linas@austin.ibm.com>
>
> ----
> drivers/net/spider_net.h | 9 +++++++--
> 1 file changed, 7 insertions(+), 2 deletions(-)
>
> Index: linux-2.6.22-rc1/drivers/net/spider_net.h
> ===================================================================
> --- linux-2.6.22-rc1.orig/drivers/net/spider_net.h 2007-05-16 12:00:35.000000000 -0500
> +++ linux-2.6.22-rc1/drivers/net/spider_net.h 2007-05-16 12:00:35.000000000 -0500
> @@ -56,8 +56,13 @@ extern char spider_net_driver_name[];
>
> #define SPIDER_NET_RX_CSUM_DEFAULT 1
>
> -#define SPIDER_NET_WATCHDOG_TIMEOUT 50*HZ
> -#define SPIDER_NET_NAPI_WEIGHT 64
> +#define SPIDER_NET_WATCHDOG_TIMEOUT 3*HZ
> +
> +/* We really really want to empty the ring buffer every time,
> + * so as to avoid the RX ram full bug. So set te napi wieght
Speeeling ...................................... ^^ ^^^^ ^^^^^^
cheers
--
Michael Ellerman
OzLabs, IBM Australia Development Lab
wwweb: http://michael.ellerman.id.au
phone: +61 2 6212 1183 (tie line 70 21183)
We do not inherit the earth from our ancestors,
we borrow it from our children. - S.M.A.R.T Person
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
^ permalink raw reply [flat|nested] 21+ messages in thread