From: Adam Belay <abelay@MIT.EDU>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: linux-pci@atrey.karlin.mff.cuni.cz,
Kernel development list <linux-kernel@vger.kernel.org>,
Linux-pm mailing list <linux-pm@lists.osdl.org>
Subject: Re: Bug in PCI core
Date: Fri, 13 Oct 2006 04:50:27 -0400 [thread overview]
Message-ID: <1160729427.26091.98.camel@localhost.localdomain> (raw)
In-Reply-To: <1160701263.4792.179.camel@localhost.localdomain>
On Fri, 2006-10-13 at 11:01 +1000, Benjamin Herrenschmidt wrote:
> On Wed, 2006-10-11 at 16:41 -0400, Alan Stern wrote:
> > When a PCI device is suspended, its driver calls pci_save_state() so that
> > the config space can be restored when the device is resumed. Then the
> > driver calls pci_set_power_state().
> >
> > However pci_set_power_state() calls pci_block_user_cfg_access(), and that
> > routine calls pci_save_state() again. This overwrites the saved state
> > with data in which memory, I/O, and bus master accesses are disabled. As
> > a result, when the device is resumed it doesn't work.
> >
> > Obviously pci_block_user_cfg_access() needs to be fixed. I don't know the
> > right way to fix it; hopefully somebody else does.
>
> Well, blocking user cfg access snapshots the config space to be able to
> respond to user space while the device is offline. Maybe it should be
> done from a separate config space image buffer ? ugh....
>
> Ben.
Personally, I don't think exposing a cached version of the PCI config
space when direct device access is prohibited is the right approach
here. We really shouldn't be lying about the internal state of PCI
devices (the cached version could be quite inaccurate). After all, if
the device is in D3cold, then the spec claims it's perfectly valid for
it to not respond to PCI configuration access.
I can only assume this hack was done to satisfy some terribly broken
userspace app. It's not surprising that even reading PCI config can
easily crash systems. However, it's the responsibility of those apps
with permission to access the PCI sysfs interface, not the kernel, to be
aware of these constraints.
The PCI configuration space cache was originally introduced to support
power management. However, it's mostly incorrect, as it unnecessarily
stores the values of read only registers (and even BIST which is
potentially dangerous). A while back I posted a series of patches that
address this issue, and the net result was that the config cache stays
around wasting memory because of the pci_block_user_cfg_access()
dependency despite being useless to PCI PM.
I'd like to propose that we have the pci config sysfs interface return
-EIO when it's blocked (e.g. active BIST or D3cold). This accurately
reflects the state of the device to userspace, reduces complexity, and
could potentially save some memory per PCI device instance.
Thanks,
Adam
next prev parent reply other threads:[~2006-10-13 8:50 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-11 20:41 Bug in PCI core Alan Stern
2006-10-13 1:01 ` [linux-pm] " Benjamin Herrenschmidt
2006-10-13 8:50 ` Adam Belay [this message]
2006-10-13 9:16 ` Benjamin Herrenschmidt
2006-10-13 9:31 ` Martin Mares
2006-10-13 12:25 ` [linux-pm] " Benjamin Herrenschmidt
2006-10-13 14:29 ` Alan Stern
2006-10-13 15:26 ` [linux-pm] " Alan Cox
2006-10-13 15:29 ` Arjan van de Ven
2006-10-13 16:06 ` Alan Cox
2006-10-13 16:34 ` Adam Belay
2006-10-13 16:36 ` [linux-pm] " Matthew Wilcox
2006-10-13 17:09 ` Alan Cox
2006-10-13 16:49 ` Matthew Wilcox
2006-10-13 17:34 ` Alan Cox
2006-10-13 17:13 ` Arjan van de Ven
2006-10-13 17:57 ` Alan Stern
2006-10-13 19:18 ` [linux-pm] " Matthew Wilcox
2006-10-13 20:59 ` Alan Stern
2006-10-13 19:30 ` Adam Belay
2006-10-13 23:00 ` Benjamin Herrenschmidt
2006-10-14 2:33 ` Alan Stern
2006-10-14 3:04 ` [linux-pm] " Roland Dreier
2006-10-14 3:07 ` Matthew Wilcox
2006-10-14 3:19 ` Bill Randle
2006-10-14 5:47 ` Greg KH
2006-10-13 17:01 ` Adam Belay
2006-10-13 16:40 ` Adam Belay
2006-10-13 20:48 ` [linux-pm] " Pavel Machek
2006-10-14 5:34 ` Greg KH
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=1160729427.26091.98.camel@localhost.localdomain \
--to=abelay@mit.edu \
--cc=benh@kernel.crashing.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@atrey.karlin.mff.cuni.cz \
--cc=linux-pm@lists.osdl.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