From: Linus Torvalds Date: Thu, 31 Dec 2020 22:05:12 +0000 (+0000) Subject: pci: test for unexpectedly disabled bridges X-Git-Tag: howlett/maple_spf/20210104~71 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=4d2bf17cec4cdaa0e22b0729db18c7264d65acc5;p=users%2Fjedix%2Flinux-maple.git pci: test for unexpectedly disabled bridges The all-ones value is not just a "device didn't exist" case, it's also potentially a quite valid value, so not restoring it would be wrong. What *would* be interesting is to hear where the bad values came from in the first place. It sounds like the device state is saved after the PCI bus controller in front of the device has been crapped on, resulting in the PCI config cycles never reaching the device at all. Something along this patch (together with suspend/resume debugging output) migth help pinpoint it. But it really sounds like something totally brokenly turned off the PCI bridge (some ACPI shutdown crud? I wouldn't be entirely surprised) Cc: Greg KH Signed-off-by: Andrew Morton --- diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index b9fecc25d213..99c189f3ae93 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -1541,6 +1541,15 @@ static void pci_restore_ltr_state(struct pci_dev *dev) int pci_save_state(struct pci_dev *dev) { int i; + u32 val; + + /* Unable to read PCI device/manufacturer state? Something is seriously wrong! */ + if (pci_read_config_dword(dev, 0, &val) || val == 0xffffffff) { + printk("Broken read from PCI device %s\n", pci_name(dev)); + WARN_ON(1); + return -1; + } + /* XXX: 100% dword access ok here? */ for (i = 0; i < 16; i++) { pci_read_config_dword(dev, i * 4, &dev->saved_config_space[i]);