public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Register interrupt handler when net device is registered. Avoids missing
@ 2005-11-08  6:45 Pierre Ossman
  2005-11-13  2:52 ` Herbert Xu
  0 siblings, 1 reply; 3+ messages in thread
From: Pierre Ossman @ 2005-11-08  6:45 UTC (permalink / raw)
  To: akpm; +Cc: Pierre Ossman, linux-kernel

interrupts if the interrupt mask gets out of sync.

Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>

---

The reason this patch is needed for me is that the resume function is
broken. It enables interrupts unconditionally, but the interrupt handler
is only registered when the device is up.

I don't have enough knowledge about the driver to fix the resume
function so this patch will instead make sure that the interrupt handler
is registered at all times (which can be a nice safeguard even when the
resume function gets fixed).
---

 drivers/net/8139cp.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c
--- a/drivers/net/8139cp.c
+++ b/drivers/net/8139cp.c
@@ -1196,20 +1196,11 @@ static int cp_open (struct net_device *d
 
 	cp_init_hw(cp);
 
-	rc = request_irq(dev->irq, cp_interrupt, SA_SHIRQ, dev->name, dev);
-	if (rc)
-		goto err_out_hw;
-
 	netif_carrier_off(dev);
 	mii_check_media(&cp->mii_if, netif_msg_link(cp), TRUE);
 	netif_start_queue(dev);
 
 	return 0;
-
-err_out_hw:
-	cp_stop_hw(cp);
-	cp_free_rings(cp);
-	return rc;
 }
 
 static int cp_close (struct net_device *dev)
@@ -1230,7 +1221,6 @@ static int cp_close (struct net_device *
 	spin_unlock_irqrestore(&cp->lock, flags);
 
 	synchronize_irq(dev->irq);
-	free_irq(dev->irq, dev);
 
 	cp_free_rings(cp);
 	return 0;
@@ -1814,6 +1804,10 @@ static int cp_init_one (struct pci_dev *
 	if (rc)
 		goto err_out_iomap;
 
+	rc = request_irq(dev->irq, cp_interrupt, SA_SHIRQ, dev->name, dev);
+	if (rc)
+		goto err_out_unreg;
+
 	printk (KERN_INFO "%s: RTL-8139C+ at 0x%lx, "
 		"%02x:%02x:%02x:%02x:%02x:%02x, "
 		"IRQ %d\n",
@@ -1833,6 +1827,8 @@ static int cp_init_one (struct pci_dev *
 
 	return 0;
 
+err_out_unreg:
+	unregister_netdev(dev);
 err_out_iomap:
 	iounmap(regs);
 err_out_res:
@@ -1853,6 +1849,7 @@ static void cp_remove_one (struct pci_de
 
 	if (!dev)
 		BUG();
+	free_irq(dev->irq, dev);
 	unregister_netdev(dev);
 	iounmap(cp->regs);
 	if (cp->wol_enabled) pci_set_power_state (pdev, PCI_D0);


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

* Re: [PATCH] Register interrupt handler when net device is registered. Avoids missing
  2005-11-08  6:45 [PATCH] Register interrupt handler when net device is registered. Avoids missing Pierre Ossman
@ 2005-11-13  2:52 ` Herbert Xu
  2005-11-13 11:09   ` Pierre Ossman
  0 siblings, 1 reply; 3+ messages in thread
From: Herbert Xu @ 2005-11-13  2:52 UTC (permalink / raw)
  To: Pierre Ossman; +Cc: akpm, linux-kernel

Pierre Ossman <drzeus@drzeus.cx> wrote:
> interrupts if the interrupt mask gets out of sync.

What about fixing the interrupt mask instead rather than keeping
the IRQ handler registered all time?

BTW, you should submit this via Jeff Garzik <jgarzik@pobox.com> and
netdev@vger.kernel.org.

Thanks,
-- 
Visit Openswan at http://www.openswan.org/
Email: Herbert Xu ~{PmV>HI~} <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

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

* Re: [PATCH] Register interrupt handler when net device is registered. Avoids missing
  2005-11-13  2:52 ` Herbert Xu
@ 2005-11-13 11:09   ` Pierre Ossman
  0 siblings, 0 replies; 3+ messages in thread
From: Pierre Ossman @ 2005-11-13 11:09 UTC (permalink / raw)
  To: Herbert Xu; +Cc: akpm, linux-kernel

Herbert Xu wrote:
> Pierre Ossman <drzeus@drzeus.cx> wrote:
> 
>>interrupts if the interrupt mask gets out of sync.
> 
> 
> What about fixing the interrupt mask instead rather than keeping
> the IRQ handler registered all time?
> 

The best solution would be to put the device in the same state as it
normally is when it is down. But I do not know the network subsystem or
the 8139c+ well enough to do this myself.

> BTW, you should submit this via Jeff Garzik <jgarzik@pobox.com> and
> netdev@vger.kernel.org.
> 

I did. I also cc:d the author of the suspend code. No one answered.

Rgds
Pierre

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

end of thread, other threads:[~2005-11-13 11:09 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-08  6:45 [PATCH] Register interrupt handler when net device is registered. Avoids missing Pierre Ossman
2005-11-13  2:52 ` Herbert Xu
2005-11-13 11:09   ` Pierre Ossman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox