Instead of the complex handling of INTX and MWI in PCi devres, let's simply restore the original vale of PCI_COMMAND in pcim_release(). Only side effect I've seen so far is that the "enabling device" info message is printed each time a driver is re-probed after a EPROBE_DEFER. I propose to silence this message by changing it to debug level. Signed-off-by: Heiner Kallweit <hkallweit1@xxxxxxxxx> --- drivers/pci/devres.c | 8 ++------ drivers/pci/probe.c | 3 +++ include/linux/pci.h | 1 + 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/pci/devres.c b/drivers/pci/devres.c index 2c562b9ea..7766f4df4 100644 --- a/drivers/pci/devres.c +++ b/drivers/pci/devres.c @@ -172,14 +172,10 @@ static void pcim_release(struct device *gendev, void *res) if (this->region_mask & (1 << i)) pci_release_region(dev, i); - if (this->mwi) - pci_clear_mwi(dev); - - if (this->restore_intx) - pci_intx(dev, this->orig_intx); - if (this->enabled && !this->pinned) pci_disable_device(dev); + + pci_write_config_word(dev, PCI_COMMAND, dev->pci_command); } /* diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 1325fbae2..60052c979 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -2558,6 +2558,9 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) pci_init_capabilities(dev); + /* Store original register value */ + pci_read_config_word(dev, PCI_COMMAND, &dev->pci_command); + /* * Add the device to our list of discovered devices * and the bus list for fixup functions, etc. diff --git a/include/linux/pci.h b/include/linux/pci.h index 16493426a..92c3c99c9 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -352,6 +352,7 @@ struct pci_dev { u8 rom_base_reg; /* Config register controlling ROM */ u8 pin; /* Interrupt pin this device uses */ u16 pcie_flags_reg; /* Cached PCIe Capabilities Register */ + u16 pci_command; /* Restore original value in pci_disable_device */ unsigned long *dma_alias_mask;/* Mask of enabled devfn aliases */ struct pci_driver *driver; /* Driver bound to this device */ -- 2.44.0