[PATCH] PCI: Improve PCI config space writeback
authorDave Jones <davej@redhat.com>
Wed, 19 Apr 2006 04:06:51 +0000 (21:06 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sun, 11 Jun 2006 21:02:27 +0000 (14:02 -0700)
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>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/pci/pci.c

index 2329f941a0dcd11fa1f18c13f5129347c91581f7..d2520451f36b7e797b596945715261964bb142fe 100644 (file)
@@ -461,9 +461,19 @@ int
 pci_restore_state(struct pci_dev *dev)
 {
        int i;
-
-       for (i = 0; i < 16; i++)
-               pci_write_config_dword(dev,i * 4, dev->saved_config_space[i]);
+       int val;
+
+       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;