netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [proposed patch] via-rhine: prevent oops when requesting an IRQ
@ 2008-11-05  0:23 Chuck Ebbert
  2008-11-06  6:07 ` Jeff Garzik
  0 siblings, 1 reply; 4+ messages in thread
From: Chuck Ebbert @ 2008-11-05  0:23 UTC (permalink / raw)
  To: netdev

via-rhine: prevent oops when requesting an IRQ

via-rhine requests an IRQ before it's ready to handle an interrupt.
It oopses when CONFIG_DEBUG_SHIRQ is enabled.

https://bugzilla.redhat.com/show_bug.cgi?id=469303

---

NOTE: UNTESTED: Is it okay to init the hardware before requesting the
IRQ, or should that be done afterward?

Index: linux-2.6.27.noarch/drivers/net/via-rhine.c
===================================================================
--- linux-2.6.27.noarch.orig/drivers/net/via-rhine.c
+++ linux-2.6.27.noarch/drivers/net/via-rhine.c
@@ -1141,24 +1141,27 @@ static int rhine_open(struct net_device 
 	void __iomem *ioaddr = rp->base;
 	int rc;
 
-	rc = request_irq(rp->pdev->irq, &rhine_interrupt, IRQF_SHARED, dev->name,
-			dev);
+	rc = alloc_ring(dev);
 	if (rc)
 		return rc;
 
-	if (debug > 1)
-		printk(KERN_DEBUG "%s: rhine_open() irq %d.\n",
-		       dev->name, rp->pdev->irq);
-
-	rc = alloc_ring(dev);
-	if (rc) {
-		free_irq(rp->pdev->irq, dev);
-		return rc;
-	}
 	alloc_rbufs(dev);
 	alloc_tbufs(dev);
 	rhine_chip_reset(dev);
 	init_registers(dev);
+
+	rc = request_irq(rp->pdev->irq, &rhine_interrupt, IRQF_SHARED, dev->name,
+			dev);
+	if (rc) {
+		free_tbufs(dev);
+		free_rbufs(dev);
+		free_ring(dev);
+		return rc;
+	}
+
+	if (debug > 1)
+		printk(KERN_DEBUG "%s: rhine_open() irq %d.\n",
+		       dev->name, rp->pdev->irq);
 	if (debug > 2)
 		printk(KERN_DEBUG "%s: Done rhine_open(), status %4.4x "
 		       "MII status: %4.4x.\n",

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

* Re: [proposed patch] via-rhine: prevent oops when requesting an IRQ
  2008-11-05  0:23 [proposed patch] via-rhine: prevent oops when requesting an IRQ Chuck Ebbert
@ 2008-11-06  6:07 ` Jeff Garzik
  2008-11-10 22:28   ` Chuck Ebbert
  0 siblings, 1 reply; 4+ messages in thread
From: Jeff Garzik @ 2008-11-06  6:07 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: netdev

Chuck Ebbert wrote:
> via-rhine: prevent oops when requesting an IRQ
> 
> via-rhine requests an IRQ before it's ready to handle an interrupt.
> It oopses when CONFIG_DEBUG_SHIRQ is enabled.
> 
> https://bugzilla.redhat.com/show_bug.cgi?id=469303
> 
> ---
> 
> NOTE: UNTESTED: Is it okay to init the hardware before requesting the
> IRQ, or should that be done afterward?

First of all, _ideally_ your interrupt handler should be able to any 
state of software initialization, once registers are mapped.  So I would 
first concentrate on "hardening" the interrupt handler, if feasible.

It is certainly a common technique to disable interrupts somehow, during 
initialization of the hardware.  Note, though, that doing things before 
request_irq() is no real guarantee you are out of danger -- you might be 
on a shared PCI irq, and your init causes that interrupt to "scream" 
even though your driver has not registered the irq.

	Jeff





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

* Re: [proposed patch] via-rhine: prevent oops when requesting an IRQ
  2008-11-06  6:07 ` Jeff Garzik
@ 2008-11-10 22:28   ` Chuck Ebbert
  2008-11-10 22:35     ` Jeff Garzik
  0 siblings, 1 reply; 4+ messages in thread
From: Chuck Ebbert @ 2008-11-10 22:28 UTC (permalink / raw)
  To: Jeff Garzik; +Cc: netdev

On Thu, 06 Nov 2008 01:07:41 -0500
Jeff Garzik <jeff@garzik.org> wrote:

> Chuck Ebbert wrote:
> > via-rhine: prevent oops when requesting an IRQ
> > 
> > via-rhine requests an IRQ before it's ready to handle an interrupt.
> > It oopses when CONFIG_DEBUG_SHIRQ is enabled.
> > 
> > https://bugzilla.redhat.com/show_bug.cgi?id=469303
> > 
> > ---
> > 
> > NOTE: UNTESTED: Is it okay to init the hardware before requesting the
> > IRQ, or should that be done afterward?
> 
> First of all, _ideally_ your interrupt handler should be able to any 
> state of software initialization, once registers are mapped.  So I would 
> first concentrate on "hardening" the interrupt handler, if feasible.
> 
> It is certainly a common technique to disable interrupts somehow, during 
> initialization of the hardware.  Note, though, that doing things before 
> request_irq() is no real guarantee you are out of danger -- you might be 
> on a shared PCI irq, and your init causes that interrupt to "scream" 
> even though your driver has not registered the irq.
> 

The problem with this driver is that it doesn't call alloc_ring() before
request_irq() and then it oopses in the interrupt handler trying to access
the ring.

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

* Re: [proposed patch] via-rhine: prevent oops when requesting an IRQ
  2008-11-10 22:28   ` Chuck Ebbert
@ 2008-11-10 22:35     ` Jeff Garzik
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Garzik @ 2008-11-10 22:35 UTC (permalink / raw)
  To: Chuck Ebbert; +Cc: netdev

Chuck Ebbert wrote:
> On Thu, 06 Nov 2008 01:07:41 -0500
> Jeff Garzik <jeff@garzik.org> wrote:
> 
>> Chuck Ebbert wrote:
>>> via-rhine: prevent oops when requesting an IRQ
>>>
>>> via-rhine requests an IRQ before it's ready to handle an interrupt.
>>> It oopses when CONFIG_DEBUG_SHIRQ is enabled.
>>>
>>> https://bugzilla.redhat.com/show_bug.cgi?id=469303
>>>
>>> ---
>>>
>>> NOTE: UNTESTED: Is it okay to init the hardware before requesting the
>>> IRQ, or should that be done afterward?
>> First of all, _ideally_ your interrupt handler should be able to any 
>> state of software initialization, once registers are mapped.  So I would 
>> first concentrate on "hardening" the interrupt handler, if feasible.
>>
>> It is certainly a common technique to disable interrupts somehow, during 
>> initialization of the hardware.  Note, though, that doing things before 
>> request_irq() is no real guarantee you are out of danger -- you might be 
>> on a shared PCI irq, and your init causes that interrupt to "scream" 
>> even though your driver has not registered the irq.
>>
> 
> The problem with this driver is that it doesn't call alloc_ring() before
> request_irq() and then it oopses in the interrupt handler trying to access
> the ring.

Allocation should definitely occur prior to request_irq()

	Jeff



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

end of thread, other threads:[~2008-11-10 22:35 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-11-05  0:23 [proposed patch] via-rhine: prevent oops when requesting an IRQ Chuck Ebbert
2008-11-06  6:07 ` Jeff Garzik
2008-11-10 22:28   ` Chuck Ebbert
2008-11-10 22:35     ` Jeff Garzik

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