@@ -178,8 +178,12 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
/* No printks while decoding is disabled! */
if (!dev->mmio_always_on) {
pci_read_config_word(dev, PCI_COMMAND, &orig_cmd);
- pci_write_config_word(dev, PCI_COMMAND,
- orig_cmd & ~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO));
+ if (orig_cmd & (PCI_COMMAND_MEMORY | PCI_COMMAND_IO)) {
+ pci_write_config_word(dev,
+ PCI_COMMAND,
+ orig_cmd &
+ ~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO));
+ }
}
res->name = pci_name(dev);
@@ -293,7 +297,8 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
fail:
res->flags = 0;
out:
- if (!dev->mmio_always_on)
+ if (!dev->mmio_always_on &&
+ (orig_cmd & (PCI_COMMAND_MEMORY | PCI_COMMAND_IO)))
pci_write_config_word(dev, PCI_COMMAND, orig_cmd);
if (bar_too_big)
While I tracked an another bug, I noticed that the PCI command register is quite often updated here unnecessarily. Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com> --- drivers/pci/probe.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)