From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: Frans Pop <elendil@planet.nl>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
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>,
USB list <linux-usb@vger.kernel.org>
Subject: Re: [patch,rfc] usb: restore config before enabling device on resume
Date: Sat, 6 Dec 2008 14:48:30 +0100 [thread overview]
Message-ID: <200812061448.31468.rjw@sisk.pl> (raw)
In-Reply-To: <200812061020.19546.elendil@planet.nl>
On Saturday, 6 of December 2008, Frans Pop wrote:
> On Thursday 04 December 2008, Linus Torvalds wrote:
> > Greg, Jesse, can you think about and look at the USB PCI resume
> > ordering?
> [...]
> > In many ways the bigger worry is actually in the totally unrelated USB
> > UHCI and EHCI drivers that resume _before_ the bridge does:
> >
> > uhci_hcd 0000:00:1d.2: enabling device (0000 -> 0001)
> > uhci_hcd 0000:00:1d.2: PCI INT C -> GSI 18 (level, low) -> IRQ 18
> > uhci_hcd 0000:00:1d.2: setting latency timer to 64
> > uhci_hcd 0000:00:1d.2: restoring config space at offset 0xf (was 0x300, writing 0x30b)
> > uhci_hcd 0000:00:1d.2: restoring config space at offset 0x8 (was 0x1, writing 0x2101)
> > usb usb7: root hub lost power or was reset
> > ehci_hcd 0000:00:1d.7: enabling device (0000 -> 0002)
> > ehci_hcd 0000:00:1d.7: PCI INT A -> GSI 20 (level, low) -> IRQ 20
> > ehci_hcd 0000:00:1d.7: setting latency timer to 64
> > ehci_hcd 0000:00:1d.7: restoring config space at offset 0xf (was 0x100, writing 0x10a)
> > ehci_hcd 0000:00:1d.7: restoring config space at offset 0x4 (was 0x0, writing 0xe0648000)
> >
> > and the worry I have here is that we actually enable the device
> > _before_ we've restored the BAR information. That sounds very iffy. It
> > sounds doubly iffy in the 'resume from hibernate' case, where we are
> > going to have an already-set-up PCI bus and the config space values are
> > going to all be live as we reprogram them.
> >
> > That "restoring config space at offset 0x8" thing is where we restore
> > the BAR (dword 0x8 = offset 0x20 = PCI_BASE_ADDRESS_4), and we're
> > changing it from 0x1 to 0x2101, with the IO BAR enabled. In this case,
> > the old value meant that the BAR started out disabled, but hibernate
> > would have been different.
> >
> > So I'd _much_ rather have seen the sequence have the BAR restore
> > sequence be something like
> >
> > uhci_hcd 0000:00:1d.2: restoring config space at offset 0xf (was 0x300, writing 0x30b)
> > uhci_hcd 0000:00:1d.2: restoring config space at offset 0x8 (was 0x1, writing 0x2101)
> > uhci_hcd 0000:00:1d.2: enabling device (0000 -> 0001)
> > uhci_hcd 0000:00:1d.2: PCI INT C -> GSI 18 (level, low) -> IRQ 18
> > uhci_hcd 0000:00:1d.2: setting latency timer to 64
> >
> > instead. Possibly even with an explicit disable of the
> > memory/IO/busmaster bits before the whole sequence.
>
> I've taken a very naive look at this, basically by comparing what usb
> (usb/core/hcd-pci.c) is doing compared to other drivers.
>
> I used the following command to get an overview:
> $ git grep -E -n -C5 "pci_(enable_device|set_master|restore_state|power_state.*D0)"
> (The line numbers give some indication whether work is split over functions.)
>
> Most drivers seem to do some variation of the following, which looks
> logical and is in line with Documentation/power/pci.txt:
> pci_set_power_state(dev, PCI_D0);
> pci_restore_state(dev);
> pci_enable_device(dev);
> pci_set_master(dev);
>
> But quite a lot of drivers (including usb and e.g. ide/setup-pci.c) do
> something like:
> pci_enable_device(dev);
> pci_set_master(dev);
> pci_restore_state(dev);
>
> Maybe the whole tree should get a review for this?
I think so.
> Anyway, I gave the patch below a try on both my notebook and desktop.
> My desktop has USB keyboard and mouse and the notebook has wireless and
> a fingerprint scanner on USB. Everything still worked after resume.
>
> Diff of the resume dmesg of my motebook attached. Looks better I think?
Yes, to me it does.
In fact, I think you could even move the pci_restore_state(dev) into
usb_hcd_pci_resume_early() that would be executed with interrupts off and
drop the pci_set_power_state(dev, PCI_D0); entirely (the
pci_enable_device(dev); would invoke it anyway).
Thanks,
Rafael
PS
Please append patches instead of attaching them, they are a lot easier to
discuss this way.
next prev parent reply other threads:[~2008-12-06 13:49 UTC|newest]
Thread overview: 136+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-02 2:20 Regression from 2.6.26: Hibernation (possibly suspend) broken on Toshiba R500 (bisected) 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
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 [this message]
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
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=200812061448.31468.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=linux-usb@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