netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	auke-jan.h.kok@intel.com, e1000-devel@lists.sourceforge.net
Subject: Re: [PATCH] e100: do not go D3 in shutdown unless system is powering off
Date: Wed, 22 Apr 2009 00:17:19 +0200	[thread overview]
Message-ID: <200904220017.19670.rjw@sisk.pl> (raw)
In-Reply-To: <20090421215248.GF6147@vespa.holoscopio.com>

On Tuesday 21 April 2009, Thadeu Lima de Souza Cascardo wrote:
> On Mon, Apr 20, 2009 at 09:13:59PM +0200, Rafael J. Wysocki wrote:
> > On Monday 20 April 2009, Thadeu Lima de Souza Cascardo wrote:
> > > After experimenting with kexec with the last merges after 2.6.29, I've
> > > had some problems when probing e100. It would not read the eeprom. After
> > > some bisects, I realized this has been like that since forever (at least
> > > 2.6.18). The problem is that shutdown is doing the same thing that
> > > suspend does and puts the device in D3 state. I couldn't find a way to
> > > get the device back to a sane state in the probe function. So, based on
> > > some similar patches from Rafael J. Wysocki for e1000, e1000e and ixgbe,
> > > I wrote this one for e100.
> > > 
> > > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
> > > ---
> > >  drivers/net/e100.c |   27 +++++++++++++++++++++------
> > >  1 files changed, 21 insertions(+), 6 deletions(-)
> > > 
> > > diff --git a/drivers/net/e100.c b/drivers/net/e100.c
> > > index c0f8443..3db7b29 100644
> > > --- a/drivers/net/e100.c
> > > +++ b/drivers/net/e100.c
> > > @@ -2728,7 +2728,7 @@ static void __devexit e100_remove(struct pci_dev *pdev)
> > >  #define E100_82552_SMARTSPEED   0x14   /* SmartSpeed Ctrl register */
> > >  #define E100_82552_REV_ANEG     0x0200 /* Reverse auto-negotiation */
> > >  #define E100_82552_ANEG_NOW     0x0400 /* Auto-negotiate now */
> > > -static int e100_suspend(struct pci_dev *pdev, pm_message_t state)
> > > +static int __e100_shutdown(struct pci_dev *pdev, bool *enable_wake)
> > >  {
> > >  	struct net_device *netdev = pci_get_drvdata(pdev);
> > >  	struct nic *nic = netdev_priv(netdev);
> > > @@ -2749,19 +2749,31 @@ static int e100_suspend(struct pci_dev *pdev, pm_message_t state)
> > >  			           E100_82552_SMARTSPEED, smartspeed |
> > >  			           E100_82552_REV_ANEG | E100_82552_ANEG_NOW);
> > >  		}
> > > -		if (pci_enable_wake(pdev, PCI_D3cold, true))
> > > -			pci_enable_wake(pdev, PCI_D3hot, true);
> > > +		*enable_wake = true;
> > >  	} else {
> > > -		pci_enable_wake(pdev, PCI_D3hot, false);
> > > +		*enable_wake = false;
> > >  	}
> > >  
> > >  	pci_disable_device(pdev);
> > > -	pci_set_power_state(pdev, PCI_D3hot);
> > >  
> > >  	return 0;
> > >  }
> > >  
> > > +static void __e100_power_off(struct pci_dev *pdev, bool wake)
> > > +{
> > > +	pci_enable_wake(pdev, PCI_D3hot, wake);
> > > +	pci_set_power_state(pdev, PCI_D3hot);
> > > +}
> > > +
> > >  #ifdef CONFIG_PM
> > > +static int e100_suspend(struct pci_dev *pdev, pm_message_t state)
> > > +{
> > > +	bool wake;
> > > +	int retval = __e100_shutdown(pdev, &wake);
> > 
> > I'd call pci_prepare_to_sleep() here if wake is 'true' instead of the
> > __e100_power_off(), because there is a chance the platform will prefer some
> > other power state to put the device into.
> > 
> > In fact, looking at the entire driver's code, I think you could just call
> > pci_prepare_to_sleep(pdev) here instead of __e100_power_off(pdev, wake)
> > and discard the value of wake.
> > 
> 
> If there is no advantage in using pci_enable_wake with false in the case
> the device cannot WOL or ASF, I will just use pci_prepare_to_sleep and
> drop this enable_wake/wake variable in both suspend and shutdown. Any
> reason we should use pci_enable_wake with false?

In principle there is one.  Namely, if you call it with 'false', it will call
the platform (eg. ACPI) to disable the wake-up functionality of the device,
which generally may be necessary.

Also, pci_prepare_to_sleep() is really designed for suspend/hibernation,
because it first finds the appropriate state to put the device into and that
depends on the target sleep state of the system.

So, I'd recommend using pci_prepare_to_sleep() in .suspend() and the
pci_enable_wake()/pci_set_power_state() combo in .shutdown() (if the system
is going for power off).

Thanks,
Rafael

  reply	other threads:[~2009-04-21 22:18 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-20 14:27 [PATCH] e100: do not go D3 in shutdown unless system is powering off Thadeu Lima de Souza Cascardo
2009-04-20 19:13 ` Rafael J. Wysocki
2009-04-21 21:52   ` Thadeu Lima de Souza Cascardo
2009-04-21 22:17     ` Rafael J. Wysocki [this message]
2009-04-22  1:38       ` [PATCH v2] " Thadeu Lima de Souza Cascardo
2009-04-22  4:38       ` [PATCH v2 fixed] " Thadeu Lima de Souza Cascardo
2009-04-22  5:46         ` Jeff Kirsher
2009-04-22 19:37           ` Thadeu Lima de Souza Cascardo
2009-04-22 20:22             ` Jeff Kirsher
2009-04-22 20:55               ` Rafael J. Wysocki

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=200904220017.19670.rjw@sisk.pl \
    --to=rjw@sisk.pl \
    --cc=auke-jan.h.kok@intel.com \
    --cc=cascardo@holoscopio.com \
    --cc=e1000-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@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;
as well as URLs for NNTP newsgroup(s).