netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] bnx2: Fix netpoll crash.
@ 2010-03-23 23:13 Michael Chan
  2010-03-23 23:13 ` [PATCH 2/2] bnx2: Use proper handler during netpoll Michael Chan
  2010-03-24  6:20 ` [PATCH 1/2] bnx2: Fix netpoll crash David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Michael Chan @ 2010-03-23 23:13 UTC (permalink / raw)
  To: davem; +Cc: netdev

From: Benjamin Li <benli@broadcom.com>

The bnx2 driver calls netif_napi_add() for all the NAPI structs during
->probe() time but not all of them will be used if we're not in MSI-X
mode.  This creates a problem for netpoll since it will poll all the
NAPI structs in the dev_list whether or not they are scheduled, resulting
in a crash when we access structure fields not initialized for that vector.

We fix it by moving the netif_napi_add() call to ->open() after the number
of IRQ vectors has been determined.

Signed-off-by: Benjamin Li <benli@broadcom.com>
Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/bnx2.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 381887b..417de1c 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -246,6 +246,8 @@ static const struct flash_spec flash_5709 = {
 
 MODULE_DEVICE_TABLE(pci, bnx2_pci_tbl);
 
+static void bnx2_init_napi(struct bnx2 *bp);
+
 static inline u32 bnx2_tx_avail(struct bnx2 *bp, struct bnx2_tx_ring_info *txr)
 {
 	u32 diff;
@@ -6197,6 +6199,7 @@ bnx2_open(struct net_device *dev)
 	bnx2_disable_int(bp);
 
 	bnx2_setup_int_mode(bp, disable_msi);
+	bnx2_init_napi(bp);
 	bnx2_napi_enable(bp);
 	rc = bnx2_alloc_mem(bp);
 	if (rc)
@@ -8207,7 +8210,7 @@ bnx2_init_napi(struct bnx2 *bp)
 {
 	int i;
 
-	for (i = 0; i < BNX2_MAX_MSIX_VEC; i++) {
+	for (i = 0; i < bp->irq_nvecs; i++) {
 		struct bnx2_napi *bnapi = &bp->bnx2_napi[i];
 		int (*poll)(struct napi_struct *, int);
 
@@ -8276,7 +8279,6 @@ bnx2_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 	dev->ethtool_ops = &bnx2_ethtool_ops;
 
 	bp = netdev_priv(dev);
-	bnx2_init_napi(bp);
 
 	pci_set_drvdata(pdev, dev);
 
-- 
1.6.4.GIT



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] bnx2: Use proper handler during netpoll.
  2010-03-23 23:13 [PATCH 1/2] bnx2: Fix netpoll crash Michael Chan
@ 2010-03-23 23:13 ` Michael Chan
  2010-03-24  6:20   ` David Miller
  2010-03-24  6:20 ` [PATCH 1/2] bnx2: Fix netpoll crash David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Michael Chan @ 2010-03-23 23:13 UTC (permalink / raw)
  To: davem; +Cc: netdev

Netpoll needs to call the proper handler depending on the IRQ mode
and the vector.

Signed-off-by: Michael Chan <mchan@broadcom.com>
---
 drivers/net/bnx2.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/bnx2.c b/drivers/net/bnx2.c
index 417de1c..a257bab 100644
--- a/drivers/net/bnx2.c
+++ b/drivers/net/bnx2.c
@@ -7646,9 +7646,11 @@ poll_bnx2(struct net_device *dev)
 	int i;
 
 	for (i = 0; i < bp->irq_nvecs; i++) {
-		disable_irq(bp->irq_tbl[i].vector);
-		bnx2_interrupt(bp->irq_tbl[i].vector, &bp->bnx2_napi[i]);
-		enable_irq(bp->irq_tbl[i].vector);
+		struct bnx2_irq *irq = &bp->irq_tbl[i];
+
+		disable_irq(irq->vector);
+		irq->handler(irq->vector, &bp->bnx2_napi[i]);
+		enable_irq(irq->vector);
 	}
 }
 #endif
-- 
1.6.4.GIT



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] bnx2: Fix netpoll crash.
  2010-03-23 23:13 [PATCH 1/2] bnx2: Fix netpoll crash Michael Chan
  2010-03-23 23:13 ` [PATCH 2/2] bnx2: Use proper handler during netpoll Michael Chan
@ 2010-03-24  6:20 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2010-03-24  6:20 UTC (permalink / raw)
  To: mchan; +Cc: netdev

From: "Michael Chan" <mchan@broadcom.com>
Date: Tue, 23 Mar 2010 15:13:11 -0800

> From: Benjamin Li <benli@broadcom.com>
> 
> The bnx2 driver calls netif_napi_add() for all the NAPI structs during
> ->probe() time but not all of them will be used if we're not in MSI-X
> mode.  This creates a problem for netpoll since it will poll all the
> NAPI structs in the dev_list whether or not they are scheduled, resulting
> in a crash when we access structure fields not initialized for that vector.
> 
> We fix it by moving the netif_napi_add() call to ->open() after the number
> of IRQ vectors has been determined.
> 
> Signed-off-by: Benjamin Li <benli@broadcom.com>
> Signed-off-by: Michael Chan <mchan@broadcom.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] bnx2: Use proper handler during netpoll.
  2010-03-23 23:13 ` [PATCH 2/2] bnx2: Use proper handler during netpoll Michael Chan
@ 2010-03-24  6:20   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2010-03-24  6:20 UTC (permalink / raw)
  To: mchan; +Cc: netdev

From: "Michael Chan" <mchan@broadcom.com>
Date: Tue, 23 Mar 2010 15:13:12 -0800

> Netpoll needs to call the proper handler depending on the IRQ mode
> and the vector.
> 
> Signed-off-by: Michael Chan <mchan@broadcom.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-03-24  6:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-23 23:13 [PATCH 1/2] bnx2: Fix netpoll crash Michael Chan
2010-03-23 23:13 ` [PATCH 2/2] bnx2: Use proper handler during netpoll Michael Chan
2010-03-24  6:20   ` David Miller
2010-03-24  6:20 ` [PATCH 1/2] bnx2: Fix netpoll crash David Miller

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).