* Improve PCI config space writeback.
@ 2006-04-16 22:42 Dave Jones
2006-04-17 0:27 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 3+ messages in thread
From: Dave Jones @ 2006-04-16 22:42 UTC (permalink / raw)
To: Linux Kernel
At least one laptop blew up on resume from suspend with a black screen
due to a lack of this patch. By only writing back config space that
is different, we minimise the possibility of accidents like this.
Signed-off-by: Dave Jones <davej@redhat.com>
--- linux-2.6.16.noarch/drivers/pci/pci.c~ 2006-04-16 17:36:34.000000000 -0500
+++ linux-2.6.16.noarch/drivers/pci/pci.c 2006-04-16 17:37:42.000000000 -0500
@@ -461,9 +461,17 @@ int
pci_restore_state(struct pci_dev *dev)
{
int i;
+ int val;
- for (i = 0; i < 16; i++)
- pci_write_config_dword(dev,i * 4, dev->saved_config_space[i]);
+ for (i = 0; i < 16; i++) {
+ pci_read_config_dword(dev, i * 4, &val);
+ if (val != dev->saved_config_space[i]) {
+ printk (KERN_DEBUG "PM: Writing back config space on device %s at offset %x. (Was %x, writing %x)\n",
+ pci_name(dev), i,
+ val, (int) dev->saved_config_space[i]);
+ pci_write_config_dword(dev,i * 4, dev->saved_config_space[i]);
+ }
+ }
pci_restore_msi_state(dev);
pci_restore_msix_state(dev);
return 0;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Improve PCI config space writeback.
2006-04-16 22:42 Improve PCI config space writeback Dave Jones
@ 2006-04-17 0:27 ` Benjamin Herrenschmidt
2006-04-17 1:16 ` Dave Jones
0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2006-04-17 0:27 UTC (permalink / raw)
To: Dave Jones; +Cc: Linux Kernel
On Sun, 2006-04-16 at 17:42 -0500, Dave Jones wrote:
> At least one laptop blew up on resume from suspend with a black screen
> due to a lack of this patch. By only writing back config space that
> is different, we minimise the possibility of accidents like this.
>
> Signed-off-by: Dave Jones <davej@redhat.com>
I think it's a mistake to restore the command register before the rest.
It should be restored last.
>
> --- linux-2.6.16.noarch/drivers/pci/pci.c~ 2006-04-16 17:36:34.000000000 -0500
> +++ linux-2.6.16.noarch/drivers/pci/pci.c 2006-04-16 17:37:42.000000000 -0500
> @@ -461,9 +461,17 @@ int
> pci_restore_state(struct pci_dev *dev)
> {
> int i;
> + int val;
>
> - for (i = 0; i < 16; i++)
> - pci_write_config_dword(dev,i * 4, dev->saved_config_space[i]);
> + for (i = 0; i < 16; i++) {
> + pci_read_config_dword(dev, i * 4, &val);
> + if (val != dev->saved_config_space[i]) {
> + printk (KERN_DEBUG "PM: Writing back config space on device %s at offset %x. (Was %x, writing %x)\n",
> + pci_name(dev), i,
> + val, (int) dev->saved_config_space[i]);
> + pci_write_config_dword(dev,i * 4, dev->saved_config_space[i]);
> + }
> + }
> pci_restore_msi_state(dev);
> pci_restore_msix_state(dev);
> return 0;
> -
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Improve PCI config space writeback.
2006-04-17 0:27 ` Benjamin Herrenschmidt
@ 2006-04-17 1:16 ` Dave Jones
0 siblings, 0 replies; 3+ messages in thread
From: Dave Jones @ 2006-04-17 1:16 UTC (permalink / raw)
To: Benjamin Herrenschmidt; +Cc: Linux Kernel
On Mon, Apr 17, 2006 at 10:27:07AM +1000, Ben Herrenschmidt wrote:
> On Sun, 2006-04-16 at 17:42 -0500, Dave Jones wrote:
> > At least one laptop blew up on resume from suspend with a black screen
> > due to a lack of this patch. By only writing back config space that
> > is different, we minimise the possibility of accidents like this.
> >
> > Signed-off-by: Dave Jones <davej@redhat.com>
>
> I think it's a mistake to restore the command register before the rest.
> It should be restored last.
Adam Belay had a patch that did this, and a bunch of other similar
things (like making sure we never set BIST when restoring).
There are likely a number of similar possible improvements.
Dave
--
http://www.codemonkey.org.uk
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2006-04-17 1:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-04-16 22:42 Improve PCI config space writeback Dave Jones
2006-04-17 0:27 ` Benjamin Herrenschmidt
2006-04-17 1:16 ` Dave Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox