public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Adam Belay <ambx1@neo.rr.com>
To: Andrew Morton <akpm@osdl.org>,
	Davide Rossetti <davide.rossetti@roma1.infn.it>,
	Karsten Keil <kkeil@suse.de>
Cc: Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fix tulip suspend/resume
Date: Wed, 8 Jun 2005 21:48:03 -0400	[thread overview]
Message-ID: <20050609014803.GA29932@neo.rr.com> (raw)
In-Reply-To: <42A734D8.5000909@roma1.infn.it>

On Wed, Jun 08, 2005 at 08:11:36PM +0200, Davide Rossetti wrote:
> 
> >Looks OK and also work on my HW.
> >
> >Andrew, can you please take this updated version, it is much cleaner and
> >safer, because it handle the IRQ correctly.
> >
> > 
> >
> >>--- a/drivers/net/tulip/tulip_core.c	2005-05-27 22:06:00.000000000 -0400
> >>+++ b/drivers/net/tulip/tulip_core.c	2005-06-07 16:34:13.641177456 -0400
> >>@@ -1756,11 +1756,19 @@
> >>{
> >>	struct net_device *dev = pci_get_drvdata(pdev);
> >>
> >>-	if (dev && netif_running (dev) && netif_device_present (dev)) {
> >>-		netif_device_detach (dev);
> >>-		tulip_down (dev);
> >>-		/* pci_power_off(pdev, -1); */
> >>-	}
> >>+	if (!dev)
> >>+		return -EINVAL;
> >>+
> >>+	if (netif_running(dev))
> >>+		tulip_down(dev);
> >>+
> >>+	netif_device_detach(dev);
> >>+	pci_save_state(pdev);
> >>+
> >>+	free_irq(dev->irq, dev);
> >>   
> >>
> isn't it safer to swap these last two guys ?? in theory there could be 
> an IRQ betwen pci_save_state() and free_irq()...

Well, so not exactly.  The issue here was that we might access the hardware
while it's:
a.) physically powered down
b.) making a power transition

In this case, the device is still powered on, so there shouldn't be a problem.
However, changing the order shouldn't break anything.  If you think it would
be cleaner this way and someone is willing to confirm that it still works,
then we can change it to the patch below.

Thanks,
Adam

Here's an updated patch:


[PM] fix suspend/resume for tulip based cards

This patch allows the tulip driver to suspend and resume properly.  It was
originally written by Karsten Keil and then modified by Adam Belay.

Signed-off-by: Karsten Keil <kkeil@suse.de>
Signed-off-by: Adam Belay <abelay@novell.com>

--- a/drivers/net/tulip/tulip_core.c	2005-05-27 22:06:00.000000000 -0400
+++ b/drivers/net/tulip/tulip_core.c	2005-06-08 21:28:26.111797528 -0400
@@ -1756,11 +1756,19 @@
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
 
-	if (dev && netif_running (dev) && netif_device_present (dev)) {
-		netif_device_detach (dev);
-		tulip_down (dev);
-		/* pci_power_off(pdev, -1); */
-	}
+	if (!dev)
+		return -EINVAL;
+
+	if (netif_running(dev))
+		tulip_down(dev);
+
+	netif_device_detach(dev);
+	free_irq(dev->irq, dev);
+
+	pci_save_state(pdev);
+	pci_disable_device(pdev);
+	pci_set_power_state(pdev, pci_choose_state(pdev, state));
+
 	return 0;
 }
 
@@ -1768,15 +1776,26 @@
 static int tulip_resume(struct pci_dev *pdev)
 {
 	struct net_device *dev = pci_get_drvdata(pdev);
+	int retval;
 
-	if (dev && netif_running (dev) && !netif_device_present (dev)) {
-#if 1
-		pci_enable_device (pdev);
-#endif
-		/* pci_power_on(pdev); */
-		tulip_up (dev);
-		netif_device_attach (dev);
+	if (!dev)
+		return -EINVAL;
+
+	pci_set_power_state(pdev, PCI_D0);
+	pci_restore_state(pdev);
+
+	pci_enable_device(pdev);
+
+	if ((retval = request_irq(dev->irq, &tulip_interrupt, SA_SHIRQ, dev->name, dev))) {
+		printk (KERN_ERR "tulip: request_irq failed in resume\n");
+		return retval;
 	}
+
+	netif_device_attach(dev);
+
+	if (netif_running(dev))
+		tulip_up(dev);
+
 	return 0;
 }
 

  reply	other threads:[~2005-06-09  3:03 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-06 22:46 [PATCH] fix tulip suspend/resume Karsten Keil
2005-06-07  0:04 ` Linus Torvalds
2005-06-07  2:50   ` Adam Belay
2005-06-07  3:34     ` Benjamin Herrenschmidt
2005-06-07  3:58       ` Adam Belay
2005-06-07  4:26         ` Benjamin Herrenschmidt
2005-06-07  5:34           ` Adam Belay
2005-06-07  5:50             ` Benjamin Herrenschmidt
2005-06-07 10:55     ` Karsten Keil
2005-06-07 20:58       ` Adam Belay
2005-06-08  0:26         ` Benjamin Herrenschmidt
2005-06-08  2:16           ` Adam Belay
2005-06-08 12:23             ` Pavel Machek
2005-06-08 23:00               ` Benjamin Herrenschmidt
2005-06-09  0:04                 ` Pavel Machek
2005-06-09  0:38                   ` Adam Belay
2005-06-09 10:51                     ` Pavel Machek
2005-06-09  2:49                   ` Nigel Cunningham
2005-06-09  8:27                   ` Karsten Keil
2005-06-08 12:19           ` Pavel Machek
2005-06-08  6:39         ` Karsten Keil
2005-06-08 18:11           ` Davide Rossetti
2005-06-09  1:48             ` Adam Belay [this message]
2005-06-07 11:52   ` Stefan Seyfried
2005-06-07  2:15 ` Benjamin Herrenschmidt
2005-06-07  2:57   ` Adam Belay
2005-06-07  3:32     ` Benjamin Herrenschmidt
2005-06-07  3:42       ` Adam Belay
2005-06-07  4:29         ` Benjamin Herrenschmidt
2005-06-07  5:03           ` Adam Belay
2005-06-07  5:51             ` Nigel Cunningham
2005-06-07  5:55               ` Benjamin Herrenschmidt
2005-06-07 15:10   ` Pavel Machek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20050609014803.GA29932@neo.rr.com \
    --to=ambx1@neo.rr.com \
    --cc=akpm@osdl.org \
    --cc=davide.rossetti@roma1.infn.it \
    --cc=kkeil@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox