All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Jesse Barnes <jbarnes@virtuousgeek.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	pm list <linux-pm@lists.linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>,
	Linux PCI <linux-pci@vger.kernel.org>
Subject: Re: [PATCH 3/7] PCI PM: Fix saving of device state in pci_legacy_suspend
Date: Wed, 04 Feb 2009 12:56:53 +1100	[thread overview]
Message-ID: <1233712613.16867.136.camel@pasglop> (raw)
In-Reply-To: <200902040159.10258.rjw@sisk.pl>

On Wed, 2009-02-04 at 01:59 +0100, Rafael J. Wysocki wrote:
> From: Rafael J. Wysocki <rjw@sisk.pl>
> 
> Make pci_legacy_suspend() save the state of the device if it is
> in PCI_UNKNOWN after its suspend callback has run and warn only if
> the power state of the device has been changed by its suspend
> callback.
> 
> Also, use WARN_ONCE(), which is more useful, in pci_legacy_suspend(),
> so that the name of the offending function is printed.
> 
> Additionaly, remove the unnecessary line of code setting
> pci_dev->state_saved.

Minor nit: Should the warning be preceeded by a message ? The reason is,
right now, all we get is a backtrace, it doesn't actually tell you which
device or driver caused it which makes it pretty pointless.

I think you should add a printk(KERN_ERR... just before that which gives
those informations along with a little blurb along the lines of "driver
changed device state without saving config space state").

> Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
> Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  drivers/pci/pci-driver.c |   10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> Index: linux-2.6/drivers/pci/pci-driver.c
> ===================================================================
> --- linux-2.6.orig/drivers/pci/pci-driver.c
> +++ linux-2.6/drivers/pci/pci-driver.c
> @@ -355,6 +355,8 @@ static int pci_legacy_suspend(struct dev
>  	int i = 0;
>  
>  	if (drv && drv->suspend) {
> +		pci_power_t prev = pci_dev->current_state;
> +
>  		pci_dev->state_saved = false;
>  
>  		i = drv->suspend(pci_dev, state);
> @@ -365,12 +367,16 @@ static int pci_legacy_suspend(struct dev
>  		if (pci_dev->state_saved)
>  			goto Fixup;
>  
> -		if (WARN_ON_ONCE(pci_dev->current_state != PCI_D0))
> +		if (pci_dev->current_state != PCI_D0
> +		    && pci_dev->current_state != PCI_UNKNOWN) {
> +			WARN_ONCE(pci_dev->current_state != prev,
> +				"PCI PM: Device state not saved by %pF\n",
> +				drv->suspend);
>  			goto Fixup;
> +		}
>  	}
>  
>  	pci_save_state(pci_dev);
> -	pci_dev->state_saved = true;
>  	/*
>  	 * This is for compatibility with existing code with legacy PM support.
>  	 */


  parent reply	other threads:[~2009-02-04  1:58 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-02-04  0:54 [PATCH 0/7] PCI PM: Fixes and refinements Rafael J. Wysocki
2009-02-04  0:56 ` [PATCH 1/7] PCI PM: Fix handling of devices without drivers Rafael J. Wysocki
2009-02-04  1:53   ` Benjamin Herrenschmidt
2009-02-04  1:53   ` Benjamin Herrenschmidt
2009-02-04  2:23   ` Linus Torvalds
2009-02-04  2:49     ` Benjamin Herrenschmidt
2009-02-04  2:49     ` Benjamin Herrenschmidt
2009-02-04 12:12       ` Rafael J. Wysocki
2009-02-04 12:12       ` Rafael J. Wysocki
2009-02-04 12:10     ` Rafael J. Wysocki
2009-02-04 12:10     ` Rafael J. Wysocki
2009-02-04  2:23   ` Linus Torvalds
2009-02-04  0:56 ` Rafael J. Wysocki
2009-02-04  0:57 ` [PATCH 2/7] PCI PM: Check if the state has been saved before trying to restore it Rafael J. Wysocki
2009-02-04  1:54   ` Benjamin Herrenschmidt
2009-02-04  1:54   ` Benjamin Herrenschmidt
2009-02-04  0:57 ` Rafael J. Wysocki
2009-02-04  0:59 ` [PATCH 3/7] PCI PM: Fix saving of device state in pci_legacy_suspend Rafael J. Wysocki
2009-02-04  1:56   ` Benjamin Herrenschmidt
2009-02-04  1:56   ` Benjamin Herrenschmidt [this message]
2009-02-04 10:14     ` Frans Pop
2009-02-04 21:38       ` Benjamin Herrenschmidt
2009-02-04 21:38       ` Benjamin Herrenschmidt
2009-02-04 21:53         ` Frans Pop
2009-02-04 21:53         ` Frans Pop
2009-02-04 21:56         ` Linus Torvalds
2009-02-04 21:56         ` Linus Torvalds
2009-02-05  0:40           ` Benjamin Herrenschmidt
2009-02-05  0:40           ` Benjamin Herrenschmidt
2009-02-05  0:57             ` Michael Ellerman
2009-02-05  0:57             ` Michael Ellerman
2009-02-05  1:29               ` Benjamin Herrenschmidt
2009-02-05  1:29               ` Benjamin Herrenschmidt
2009-02-05  2:58                 ` Michael Ellerman
2009-02-05  2:58                 ` Michael Ellerman
2009-02-05  4:06                   ` Benjamin Herrenschmidt
2009-02-05  4:06                   ` Benjamin Herrenschmidt
2009-02-04 10:14     ` Frans Pop
2009-02-04  0:59 ` Rafael J. Wysocki
2009-02-04  1:00 ` [PATCH 4/7] PCI PCIe portdrv: Simplify suspend and resume Rafael J. Wysocki
2009-02-04  1:00 ` Rafael J. Wysocki
2009-02-04  1:01 ` [PATCH 5/7] PCI PM: Do not disable and enable bridges during suspend-resume Rafael J. Wysocki
2009-02-04  1:01 ` Rafael J. Wysocki
2009-02-04  1:02 ` [PATCH 6/7] PCI PM: Read power state from device after trying to change it on resume Rafael J. Wysocki
2009-02-04  1:02 ` Rafael J. Wysocki
2009-02-04  1:09 ` [PATCH 7/7] PCI PM: Let the core be more careful with respect to drivers using new framework Rafael J. Wysocki
2009-02-04  1:09 ` Rafael J. Wysocki
2009-02-04  2:05   ` Benjamin Herrenschmidt
2009-02-05  0:47     ` Rafael J. Wysocki
2009-02-05  0:47     ` Rafael J. Wysocki
2009-02-05  1:18       ` Benjamin Herrenschmidt
2009-02-05  1:18       ` Benjamin Herrenschmidt
2009-02-04  2:05   ` Benjamin Herrenschmidt
2009-02-05  1:23 ` [PATCH 0/7] PCI PM: Fixes and refinements Jesse Barnes
2009-02-05  1:48   ` Rafael J. Wysocki
2009-02-05  1:48   ` Rafael J. Wysocki
2009-02-05  1:23 ` Jesse Barnes

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=1233712613.16867.136.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@lists.linux-foundation.org \
    --cc=rjw@sisk.pl \
    --cc=torvalds@linux-foundation.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.