From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Frans Pop <elendil@planet.nl>, Greg KH <greg@kroah.com>,
Ingo Molnar <mingo@elte.hu>,
jbarnes@virtuousgeek.org, lenb@kernel.org,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
tiwai@suse.de, Andrew Morton <akpm@linux-foundation.org>
Subject: Re: Regression from 2.6.26: Hibernation (possibly suspend) broken on Toshiba R500 (bisected)
Date: Fri, 5 Dec 2008 23:01:44 +0100 [thread overview]
Message-ID: <200812052301.45450.rjw@sisk.pl> (raw)
In-Reply-To: <alpine.LFD.2.00.0812051312160.3386@nehalem.linux-foundation.org>
On Friday, 5 of December 2008, Linus Torvalds wrote:
>
> On Thu, 4 Dec 2008, Linus Torvalds wrote:
> >
> > The third thing that worries me is the _very_ early occurrence of
> >
> > ACPI: Waking up from system sleep state S3
> > APIC error on CPU1: 00(40)
> > ACPI: EC: non-query interrupt received, switching to interrupt mode
> >
> > Now, that "APIC error" thing is worrisome. It's worrisome for multiple
> > reasons:
> >
> > - errors are never good (0x40 means "received illegal vector", whatever
> > caused _that_)
> >
> > - more importantly, it seems to imply that interrupts are enabled on
> > CPU1, and they sure as hell shouldn't be enabled at this stage!
> >
> > Do we perhaps have a SMP resume bug where we resume the other CPU's
> > with interrupts enabled?
> >
> > - the "ACPI: EC: non-query interrupt received, switching to interrupt
> > mode" thing is from ACPI, and _also_ implies that interrupts are on.
> >
> > Why are interrupts enabled that early? I really don't like seeing
> > interrupts enabled before we've even done the basic PCI resume.
>
> Oh, I finally started looking more at this.
>
> It's because the PCI layer uses the late resume for resuming. Which is
> horrid. It really shouldn't. Resuming your device after interrupts were
> enabled really sounds like a disaster. *Especially* if the device was
> active before, either because of hibernation or simply because firmware
> pre-initialized it to some "live" state (which could easily happen with
> ethernet in particular).
>
> I do wonder why the PCI layer wants to resume things so late. It sounds
> totally insane to do things like resume the PCI bridge setup long *after*
> you have resumed other devices early. So by doing the default resume late,
> it just means that nobody can possibly use the early resume, and now
> everybody needs to resume everything with interrupts already going full
> blast.
>
> IOW, the _sane_ thing would be to do something like the following patch
> does, namely:
>
> - if the driver has a suspend or suspend_early function, _only_ call that
> (whether legacy or not)
>
> - otherwise, do the default suspend/resume late/early with interrupts
> disabled.
>
> which means that by default, we'll do all save-restore of the PCI state
> close to the actual CPU suspend event as possible.
>
> Of course, hibernate probably depends on ->suspend() saving state, which
> it won't. Again, if thats' the case, then that's just hibernate (again)
> being totally fundamentally broken, and messing with STR functions.
No, hibernate doesn't care whether ->suspend() or ->suspend_late() saves
the state, if that's what you mean. Also, we have the hibernation-specific
callbacks in the new framework anyway.
> Rafael?
Well, actually I think we should go further and save the standard config
registers of _all_ PCI devices in the _late() callbacks (ie. with interrupts
disabled) and restore them in the _early() callbacks.
I don't really understand why pci_restore_state() is not called by the core
and every single driver calls it by itself. Moreover, many of them
call pci_set_power_state(dev, PCI_D0) before calling pci_restore_state(),
although this is not really necessary, because they subsequently call
pci_enable_device() which calls pci_set_power_state(dev, PCI_D0) again.
IOW, I would split the resume of PCI devices into two parts, the first of
which will call pci_restore_state() with interrupts disabled and the second
will do the remaining stuff.
> I have neither tested the patch nor even tried to compile it - it's meant
> to be an example and get people thinking about this, rather than anything
> else.
I'm going to try it, though, and see what happens. ;-)
Thanks,
Rafael
> ---
> drivers/pci/pci-driver.c | 20 ++++++++++----------
> 1 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index b4cdd69..6395983 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -346,8 +346,6 @@ static int pci_legacy_suspend(struct device *dev, pm_message_t state)
> if (drv && drv->suspend) {
> i = drv->suspend(pci_dev, state);
> suspend_report_result(drv->suspend, i);
> - } else {
> - pci_default_pm_suspend(pci_dev);
> }
> return i;
> }
> @@ -361,7 +359,8 @@ static int pci_legacy_suspend_late(struct device *dev, pm_message_t state)
> if (drv && drv->suspend_late) {
> i = drv->suspend_late(pci_dev, state);
> suspend_report_result(drv->suspend_late, i);
> - }
> + } else if (!drv || !drv->suspend)
> + pci_default_pm_suspend(pci_dev);
> return i;
> }
>
> @@ -373,8 +372,6 @@ static int pci_legacy_resume(struct device *dev)
>
> if (drv && drv->resume)
> error = drv->resume(pci_dev);
> - else
> - error = pci_default_pm_resume(pci_dev);
> return error;
> }
>
> @@ -386,6 +383,8 @@ static int pci_legacy_resume_early(struct device *dev)
>
> if (drv && drv->resume_early)
> error = drv->resume_early(pci_dev);
> + else if (!drv || !drv->resume)
> + error = pci_default_pm_resume(pci_dev);
> return error;
> }
>
> @@ -420,8 +419,6 @@ static int pci_pm_suspend(struct device *dev)
> if (drv->pm->suspend) {
> error = drv->pm->suspend(dev);
> suspend_report_result(drv->pm->suspend, error);
> - } else {
> - pci_default_pm_suspend(pci_dev);
> }
> } else {
> error = pci_legacy_suspend(dev, PMSG_SUSPEND);
> @@ -441,7 +438,8 @@ static int pci_pm_suspend_noirq(struct device *dev)
> if (drv->pm->suspend_noirq) {
> error = drv->pm->suspend_noirq(dev);
> suspend_report_result(drv->pm->suspend_noirq, error);
> - }
> + } else if (!drv->pm->suspend)
> + pci_default_pm_suspend(pci_dev);
> } else {
> error = pci_legacy_suspend_late(dev, PMSG_SUSPEND);
> }
> @@ -458,8 +456,7 @@ static int pci_pm_resume(struct device *dev)
> pci_fixup_device(pci_fixup_resume, pci_dev);
>
> if (drv && drv->pm) {
> - error = drv->pm->resume ? drv->pm->resume(dev) :
> - pci_default_pm_resume(pci_dev);
> + error = drv->pm->resume ? drv->pm->resume(dev) : 0;
> } else {
> error = pci_legacy_resume(dev);
> }
> @@ -467,6 +464,7 @@ static int pci_pm_resume(struct device *dev)
> return error;
> }
>
> +
> static int pci_pm_resume_noirq(struct device *dev)
> {
> struct pci_dev *pci_dev = to_pci_dev(dev);
> @@ -478,6 +476,8 @@ static int pci_pm_resume_noirq(struct device *dev)
> if (drv && drv->pm) {
> if (drv->pm->resume_noirq)
> error = drv->pm->resume_noirq(dev);
> + else if (!drv->pm->resume)
> + error = pci_default_pm_resume(pci_dev);
> } else {
> error = pci_legacy_resume_early(dev);
> }
>
>
--
Everyone knows that debugging is twice as hard as writing a program
in the first place. So if you're as clever as you can be when you write it,
how will you ever debug it? --- Brian Kernighan
next prev parent reply other threads:[~2008-12-05 22:02 UTC|newest]
Thread overview: 137+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-02 2:20 Rafael J. Wysocki
2008-12-02 3:32 ` Linus Torvalds
2008-12-02 3:42 ` Linus Torvalds
2008-12-02 4:31 ` Frans Pop
2008-12-02 4:46 ` Linus Torvalds
2008-12-02 5:29 ` Frans Pop
2008-12-02 5:56 ` Frans Pop
2008-12-02 15:46 ` Linus Torvalds
2008-12-02 17:46 ` Frans Pop
2008-12-02 18:17 ` Linus Torvalds
2008-12-05 8:53 ` MSI changes in .28 Frans Pop
2008-12-05 9:09 ` Yinghai Lu
2008-12-05 12:20 ` Ingo Molnar
2008-12-05 13:04 ` Eric Dumazet
2008-12-05 17:49 ` H. Peter Anvin
2008-12-02 4:13 ` Regression from 2.6.26: Hibernation (possibly suspend) broken on Toshiba R500 (bisected) Frans Pop
2008-12-02 4:36 ` Linus Torvalds
2008-12-02 22:38 ` Rafael J. Wysocki
2008-12-02 23:37 ` Linus Torvalds
2008-12-03 0:00 ` Rafael J. Wysocki
2008-12-03 0:05 ` Rafael J. Wysocki
2008-12-03 0:31 ` Rafael J. Wysocki
2008-12-03 0:41 ` Linus Torvalds
2008-12-03 1:22 ` Rafael J. Wysocki
2008-12-03 2:02 ` Linus Torvalds
2008-12-03 7:40 ` Rafael J. Wysocki
2008-12-03 7:52 ` Rafael J. Wysocki
2008-12-03 11:20 ` Rafael J. Wysocki
2008-12-03 15:53 ` Linus Torvalds
2008-12-04 1:23 ` Rafael J. Wysocki
2008-12-04 4:40 ` Linus Torvalds
2008-12-04 8:21 ` Frans Pop
2008-12-04 22:01 ` Rafael J. Wysocki
2008-12-04 11:29 ` Frans Pop
2008-12-04 16:17 ` Linus Torvalds
2008-12-04 18:00 ` Frans Pop
2008-12-04 20:03 ` Linus Torvalds
2008-12-05 21:26 ` Linus Torvalds
2008-12-05 22:01 ` Rafael J. Wysocki [this message]
2008-12-05 22:14 ` Linus Torvalds
2008-12-06 0:04 ` Rafael J. Wysocki
2008-12-06 0:50 ` Linus Torvalds
2008-12-06 1:18 ` Rafael J. Wysocki
2008-12-06 1:55 ` Linus Torvalds
2008-12-06 2:18 ` Rafael J. Wysocki
2008-12-06 13:53 ` Rafael J. Wysocki
2008-12-06 2:45 ` Greg KH
2009-01-28 12:00 ` Frans Pop
2009-01-29 14:11 ` Ingo Molnar
2009-01-29 14:48 ` Rafael J. Wysocki
2009-01-29 16:44 ` Alexey Starikovskiy
2009-01-30 4:35 ` Frans Pop
2008-12-06 9:20 ` [patch,rfc] usb: restore config before enabling device on resume Frans Pop
2008-12-06 13:48 ` Rafael J. Wysocki
2008-12-06 15:02 ` Frans Pop
2008-12-10 14:06 ` "APIC error on CPU1: 00(40)" during resume (was: Regression from 2.6.26: Hibernation (possibly suspend) broken on Toshiba R500) Frans Pop
2008-12-10 15:51 ` Linus Torvalds
2008-12-10 16:05 ` Frans Pop
2008-12-10 16:26 ` Linus Torvalds
2008-12-10 16:52 ` Matthew Garrett
2008-12-10 17:13 ` Linus Torvalds
2008-12-10 17:33 ` Ingo Molnar
2008-12-10 18:41 ` Maxim Levitsky
2008-12-20 21:31 ` "APIC error on CPU1: 00(40)" during resume Frans Pop
2008-12-21 8:29 ` Ingo Molnar
2008-12-23 4:28 ` Len Brown
2008-12-04 22:46 ` Regression from 2.6.26: Hibernation (possibly suspend) broken on Toshiba R500 (bisected) Rafael J. Wysocki
2008-12-04 22:40 ` Rafael J. Wysocki
2008-12-04 23:22 ` Linus Torvalds
2008-12-04 23:45 ` Rafael J. Wysocki
2008-12-05 0:07 ` Linus Torvalds
2008-12-05 0:20 ` Rafael J. Wysocki
2008-12-05 6:55 ` Frans Pop
2008-12-04 22:09 ` Rafael J. Wysocki
2008-12-04 22:20 ` Linus Torvalds
2008-12-04 23:31 ` Rafael J. Wysocki
2008-12-05 0:03 ` Linus Torvalds
2008-12-05 0:45 ` Linus Torvalds
2008-12-05 1:08 ` Rafael J. Wysocki
2008-12-05 1:45 ` Linus Torvalds
2008-12-05 2:55 ` Linus Torvalds
2008-12-05 3:25 ` Linus Torvalds
2008-12-05 6:44 ` Frans Pop
2008-12-05 8:27 ` Frans Pop
2008-12-05 12:00 ` Rafael J. Wysocki
2008-12-05 15:57 ` Linus Torvalds
2008-12-05 21:32 ` Rafael J. Wysocki
2008-12-05 17:25 ` Jesse Barnes
2008-12-02 15:49 ` Rafael J. Wysocki
2008-12-06 14:05 ` [PATCH 0/3] Fix hibernation regression on Toshiba Portege R500 Rafael J. Wysocki
2008-12-06 14:07 ` [PATCH 1/3] PCI: Rework default handling of suspend and resume Rafael J. Wysocki
2008-12-06 17:07 ` Linus Torvalds
2008-12-06 17:22 ` Rafael J. Wysocki
2008-12-06 17:33 ` Linus Torvalds
2008-12-06 17:43 ` Rafael J. Wysocki
2008-12-06 18:00 ` Linus Torvalds
2008-12-06 21:24 ` Rafael J. Wysocki
2008-12-07 4:44 ` Jesse Barnes
2008-12-07 5:41 ` Greg KH
2008-12-07 12:47 ` Rafael J. Wysocki
2008-12-07 16:44 ` Linus Torvalds
2008-12-07 21:02 ` Rafael J. Wysocki
2008-12-07 17:26 ` Greg KH
2008-12-07 23:34 ` [PATCH 1/3] PCI: Rework default handling of suspend and resume (rebased) Rafael J. Wysocki
2008-12-06 18:30 ` [linux-pm] [PATCH 1/3] PCI: Rework default handling of suspend and resume Alan Stern
2008-12-06 21:36 ` Rafael J. Wysocki
2008-12-06 22:24 ` Linus Torvalds
2008-12-06 23:25 ` Arjan van de Ven
2008-12-06 23:35 ` Alan Cox
2008-12-07 6:00 ` Linus Torvalds
2008-12-07 6:03 ` Linus Torvalds
2008-12-07 13:39 ` Rafael J. Wysocki
2008-12-07 16:34 ` Linus Torvalds
2008-12-14 9:28 ` Pavel Machek
2008-12-07 17:18 ` Arjan van de Ven
2008-12-07 9:44 ` Takashi Iwai
2008-12-07 0:02 ` Alan Stern
2008-12-07 13:14 ` Rafael J. Wysocki
2008-12-06 21:09 ` Alan Cox
2008-12-06 21:50 ` Rafael J. Wysocki
2008-12-06 14:07 ` [PATCH 2/3] PCI: Suspend and resume PCI Express ports with interrupts disabled Rafael J. Wysocki
2008-12-06 17:15 ` Linus Torvalds
2008-12-06 17:25 ` Rafael J. Wysocki
2008-12-06 17:38 ` Linus Torvalds
2008-12-06 17:46 ` Rafael J. Wysocki
2008-12-07 2:18 ` Jesse Barnes
2008-12-07 12:53 ` Rafael J. Wysocki
2008-12-06 14:09 ` [PATCH 3/3] Sound (HDA Intel): Restore PCI configuration space with interrupts off Rafael J. Wysocki
2008-12-07 4:45 ` Jesse Barnes
2008-12-07 9:47 ` Takashi Iwai
2008-12-11 7:07 ` Takashi Iwai
2008-12-11 20:03 ` Rafael J. Wysocki
2008-12-11 20:27 ` Takashi Iwai
2008-12-11 20:38 ` Rafael J. Wysocki
2008-12-12 6:32 ` Takashi Iwai
2008-12-06 19:30 ` [PATCH 0/3] Fix hibernation regression on Toshiba Portege R500 Frans Pop
2008-12-02 7:53 Regression from 2.6.26: Hibernation (possibly suspend) broken on Toshiba R500 (bisected) Frans Pop
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=200812052301.45450.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=akpm@linux-foundation.org \
--cc=elendil@planet.nl \
--cc=greg@kroah.com \
--cc=jbarnes@virtuousgeek.org \
--cc=lenb@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tiwai@suse.de \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome