Skip to contentSkip to conversation

mv643xx ethernet driver IRQ registration fix

PATCH Applied [email protected] 4 participants 7 messages Mar 6, 2007 – Mar 9, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 18/19 mv643xx ethernet driver IRQ registration fix

From: Giridhar Pemmasani <[email protected]>

During initialization, mv643xx driver registers IRQ before setting up tx/rx rings. This causes kernel oops because mv643xx_poll, which gets called right after registering IRQ, calls netif_rx_complete, which accesses the rx ring (I don't have the oops message anymore; I just remember this sequence of calls). Attached (tested) patch first initializes the rx/tx rings and then registers the IRQ.

---

 drivers/net/mv643xx_eth.c |   40 +++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 18 deletions(-)
drivers/net/mv643xx_eth.c renamed from drivers/net/mv643xx_eth.c~mv643xx-ethernet-driver-irq-registration-fix +22 -18
diff -puN drivers/net/mv643xx_eth.c~mv643xx-ethernet-driver-irq-registration-fix drivers/net/mv643xx_eth.c
@@ -787,14 +787,6 @@ static int mv643xx_eth_open(struct net_d
 	unsigned int size;
 	int err;
 
-	err = request_irq(dev->irq, mv643xx_eth_int_handler,
-			IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
-	if (err) {
-		printk(KERN_ERR "Can not assign IRQ number to MV643XX_eth%d\n",
-								port_num);
-		return -EAGAIN;
-	}
-
 	eth_port_init(mp);
 
 	memset(&mp->timeout, 0, sizeof(struct timer_list));
@@ -806,8 +798,7 @@ static int mv643xx_eth_open(struct net_d
 								GFP_KERNEL);
 	if (!mp->rx_skb) {
 		printk(KERN_ERR "%s: Cannot allocate Rx skb ring\n", dev->name);
-		err = -ENOMEM;
-		goto out_free_irq;
+		return -ENOMEM;
 	}
 	mp->tx_skb = kmalloc(sizeof(*mp->tx_skb) * mp->tx_ring_size,
 								GFP_KERNEL);
@@ -861,13 +852,8 @@ static int mv643xx_eth_open(struct net_d
 							dev->name, size);
 		printk(KERN_ERR "%s: Freeing previously allocated TX queues...",
 							dev->name);
-		if (mp->rx_sram_size)
-			iounmap(mp->p_tx_desc_area);
-		else
-			dma_free_coherent(NULL, mp->tx_desc_area_size,
-					mp->p_tx_desc_area, mp->tx_desc_dma);
 		err = -ENOMEM;
-		goto out_free_tx_skb;
+		goto out_free_tx_ring;
 	}
 	memset((void *)mp->p_rx_desc_area, 0, size);
 
@@ -875,6 +861,14 @@ static int mv643xx_eth_open(struct net_d
 
 	mv643xx_eth_rx_refill_descs(dev);	/* Fill RX ring with skb's */
 
+	err = request_irq(dev->irq, mv643xx_eth_int_handler,
+			IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
+	if (err) {
+		printk(KERN_ERR "Can not assign IRQ number to MV643XX_eth%d\n",
+			port_num);
+		goto out_free_rx_ring;
+	}
+
 	/* Clear any pending ethernet port interrupts */
 	mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
 	mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
@@ -900,12 +894,22 @@ static int mv643xx_eth_open(struct net_d
 
 	return 0;
 
+out_free_rx_ring:
+	if (mp->rx_sram_size)
+		iounmap(mp->p_rx_desc_area);
+	else
+		dma_free_coherent(NULL, mp->rx_desc_area_size,
+			mp->p_rx_desc_area, mp->rx_desc_dma);
+out_free_tx_ring:
+	if (mp->tx_sram_size)
+		iounmap(mp->p_tx_desc_area);
+	else
+		dma_free_coherent(NULL, mp->tx_desc_area_size,
+				mp->p_tx_desc_area, mp->tx_desc_dma);
 out_free_tx_skb:
 	kfree(mp->tx_skb);
 out_free_rx_skb:
 	kfree(mp->rx_skb);
-out_free_irq:
-	free_irq(dev->irq, dev);
 
 	return err;
 }

_

#1 lore raw
Quoted 9 lines · [email protected] wrote:

From: Giridhar Pemmasani <[email protected]>

During initialization, mv643xx driver registers IRQ before setting up tx/rx rings. This causes kernel oops because mv643xx_poll, which gets called right after registering IRQ, calls netif_rx_complete, which accesses the rx ring (I don't have the oops message anymore; I just remember this sequence of calls). Attached (tested) patch first initializes the rx/tx rings and then registers the IRQ.

Quoted 8 lines

---

 drivers/net/mv643xx_eth.c |   40 +++++++++++++++++++-----------------
 1 file changed, 22 insertions(+), 18 deletions(-)

seems sane enough to me, but I would like to get this via Dale, who has been a fairly active maintainer so far

#2 lore raw
In reply to [email protected]
Quoted 8 lines · On Tue, Mar 06, 2007 at 02:42:02AM -0800, [email protected] wrote:

From: Giridhar Pemmasani <[email protected]>

During initialization, mv643xx driver registers IRQ before setting up tx/rx rings. This causes kernel oops because mv643xx_poll, which gets called right after registering IRQ, calls netif_rx_complete, which accesses the rx ring (I don't have the oops message anymore; I just remember this sequence of calls). Attached (tested) patch first initializes the rx/tx rings and then registers the IRQ.

I believe a better fix is to disable any pending interrupt sources before calling request_irq(). I sent the patch below to Giri for confirmation, but haven't heard back. I should've copied Andrew.

Giri, have you had a chance to test this alternative patch?

Thanks,
-Dale

Quoted 13 lines

Date: Fri, 2 Mar 2007 17:03:53 -0700
To: Giridhar Pemmasani <[email protected]>
Message-ID: <[email protected]>
In-Reply-To: <[email protected]>

Quoted 7 lines · Giridhar Pemmasani

During initialization, mv643xx driver registers IRQ before setting up tx/rx rings. This causes kernel oops because mv643xx_poll, which gets called right after registering IRQ, calls netif_rx_complete, which accesses the rx ring (I don't have the oops message anymore; I just remember this sequence of calls). Attached (tested) patch first initializes the rx/tx rings and then registers the IRQ.

Quoted 8 lines
Quoted 3 lines

Giri

Giridhar, does the following patch fix your problem, in place of the patch you supplied?

-Dale

drivers/net/mv643xx_eth.c +6 -4
index 3e045a6..192b390 100644
@@ -787,6 +787,12 @@ static int mv643xx_eth_open(struct net_device *dev)
 	unsigned int size;
 	int err;
 
+	/* Clear any pending ethernet port interrupts */
+	mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
+	mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
+	/* wait for previous write to complete */
+	mv_read (MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num));
+
 	err = request_irq(dev->irq, mv643xx_eth_int_handler,
 			IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
 	if (err) {
@@ -875,10 +881,6 @@ static int mv643xx_eth_open(struct net_device *dev)
 
 	mv643xx_eth_rx_refill_descs(dev);	/* Fill RX ring with skb's */
 
-	/* Clear any pending ethernet port interrupts */
-	mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
-	mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
-
 	eth_port_start(dev);
 
 	/* Interrupt Coalescing */
#3 lore raw
Quoted 10 lines · --- Dale Farnsworth
Quoted 3 lines · On Tue, Mar 06, 2007 at 02:42:02AM -0800, [email protected] wrote:

From: Giridhar Pemmasani <[email protected]>

During initialization, mv643xx driver registers IRQ before setting up

tx/rx

Quoted 2 lines

rings. This causes kernel oops because mv643xx_poll, which gets called right after registering IRQ, calls netif_rx_complete, which accesses the

rx

Quoted 1 line

ring (I don't have the oops message anymore; I just remember this

sequence

Quoted 8 lines
Quoted 2 lines

of calls). Attached (tested) patch first initializes the rx/tx rings and then registers the IRQ.

I believe a better fix is to disable any pending interrupt sources before calling request_irq(). I sent the patch below to Giri for confirmation, but haven't heard back. I should've copied Andrew.

Giri, have you had a chance to test this alternative patch?

I will get my hands on the box this Friday. As soon as I can, I will test and give feedback.

FWIW, I had a patch earlier that was similar (not same) as you suggest. That patch was based on the changes from 2.6.15 to 2.6.16 when it broke. In 2.6.15, interrupts as well as rx/tx are disabled until rx/tx rings are setup. Anyway, I will test this and let you know.

Giri

____________________________________________________________________________________
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121

#4 lore raw
In reply to Dale Farnsworth
Quoted 10 lines · --- Dale Farnsworth
Quoted 3 lines · On Tue, Mar 06, 2007 at 02:42:02AM -0800, [email protected] wrote:

From: Giridhar Pemmasani <[email protected]>

During initialization, mv643xx driver registers IRQ before setting up

tx/rx

Quoted 2 lines

rings. This causes kernel oops because mv643xx_poll, which gets called right after registering IRQ, calls netif_rx_complete, which accesses the

rx

Quoted 1 line

ring (I don't have the oops message anymore; I just remember this

sequence

Quoted 8 lines
Quoted 2 lines

of calls). Attached (tested) patch first initializes the rx/tx rings and then registers the IRQ.

I believe a better fix is to disable any pending interrupt sources before calling request_irq(). I sent the patch below to Giri for confirmation, but haven't heard back. I should've copied Andrew.

Giri, have you had a chance to test this alternative patch?

I got a chance to test this patch today. I can confirm that this patch fixes the issue reported.

Thanks,
Giri

____________________________________________________________________________________
The fish are biting.
Get more visitors on your site using Yahoo! Search Marketing.
http://searchmarketing.yahoo.com/arp/sponsoredsearch_v2.php

#5 lore raw

PATCH 1/1 mv643xx: Clear pending interrupts before calling request_irq

From: Dale Farnsworth <[email protected]>

---

Giri, thank you very much for reporting the problem and confirming the fix.

Jeff, please apply.

Andrew, this patch supersedes the -mm patch:
mv643xx-ethernet-driver-irq-registration-fix.patch

 drivers/net/mv643xx_eth.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/mv643xx_eth.c +6 -4
index 3e045a6..192b390 100644
@@ -787,6 +787,12 @@ static int mv643xx_eth_open(struct net_device *dev)
 	unsigned int size;
 	int err;
 
+	/* Clear any pending ethernet port interrupts */
+	mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
+	mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
+	/* wait for previous write to complete */
+	mv_read (MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num));
+
 	err = request_irq(dev->irq, mv643xx_eth_int_handler,
 			IRQF_SHARED | IRQF_SAMPLE_RANDOM, dev->name, dev);
 	if (err) {
@@ -875,10 +881,6 @@ static int mv643xx_eth_open(struct net_device *dev)
 
 	mv643xx_eth_rx_refill_descs(dev);	/* Fill RX ring with skb's */
 
-	/* Clear any pending ethernet port interrupts */
-	mv_write(MV643XX_ETH_INTERRUPT_CAUSE_REG(port_num), 0);
-	mv_write(MV643XX_ETH_INTERRUPT_CAUSE_EXTEND_REG(port_num), 0);
-
 	eth_port_start(dev);
 
 	/* Interrupt Coalescing */
Applied
#6 lore raw

Re: [PATCH] mv643xx: Clear pending interrupts before calling request_irq

Quoted 10 lines · Dale Farnsworth

From: Dale Farnsworth <[email protected]>

---

Giri, thank you very much for reporting the problem and confirming the fix.

Quoted 7 lines

Jeff, please apply.

Andrew, this patch supersedes the -mm patch:
mv643xx-ethernet-driver-irq-registration-fix.patch

 drivers/net/mv643xx_eth.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

applied