aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci
diff options
context:
space:
mode:
authorZoltan Kiss <zoltan.kiss@citrix.com>2013-08-22 18:19:18 -0400
committerBjorn Helgaas <bhelgaas@google.com>2013-08-23 11:21:19 -0400
commit808e34e2cd6bc74a2311b6a00d12a52e37fb50c0 (patch)
tree140b13a3e3946b3695176ea9c989e658d8a1b09e /drivers/pci
parentda27f4b3ec77a04672345381cbfeeb841d427327 (diff)
PCI: Disable decoding for BAR sizing only when it was actually enabled
We disable BARs while sizing them so we don't cause conflicts with other devices (see 253d2e5498 and bbffe43524). But if device decoding is already disabled before we size the BAR, we don't need to disable it again. [bhelgaas: changelog, add PCI_COMMAND_DECODING_ENABLE for readability] Signed-off-by: Zoltan Kiss <zoltan.kiss@citrix.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci')
-rw-r--r--drivers/pci/probe.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index cf57fe79450a..b50386dc72e0 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -156,6 +156,8 @@ static inline unsigned long decode_bar(struct pci_dev *dev, u32 bar)
156 return flags; 156 return flags;
157} 157}
158 158
159#define PCI_COMMAND_DECODE_ENABLE (PCI_COMMAND_MEMORY | PCI_COMMAND_IO)
160
159/** 161/**
160 * pci_read_base - read a PCI BAR 162 * pci_read_base - read a PCI BAR
161 * @dev: the PCI device 163 * @dev: the PCI device
@@ -178,8 +180,10 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
178 /* No printks while decoding is disabled! */ 180 /* No printks while decoding is disabled! */
179 if (!dev->mmio_always_on) { 181 if (!dev->mmio_always_on) {
180 pci_read_config_word(dev, PCI_COMMAND, &orig_cmd); 182 pci_read_config_word(dev, PCI_COMMAND, &orig_cmd);
181 pci_write_config_word(dev, PCI_COMMAND, 183 if (orig_cmd & PCI_COMMAND_DECODE_ENABLE) {
182 orig_cmd & ~(PCI_COMMAND_MEMORY | PCI_COMMAND_IO)); 184 pci_write_config_word(dev, PCI_COMMAND,
185 orig_cmd & ~PCI_COMMAND_DECODE_ENABLE);
186 }
183 } 187 }
184 188
185 res->name = pci_name(dev); 189 res->name = pci_name(dev);
@@ -293,7 +297,8 @@ int __pci_read_base(struct pci_dev *dev, enum pci_bar_type type,
293fail: 297fail:
294 res->flags = 0; 298 res->flags = 0;
295out: 299out:
296 if (!dev->mmio_always_on) 300 if (!dev->mmio_always_on &&
301 (orig_cmd & PCI_COMMAND_DECODE_ENABLE))
297 pci_write_config_word(dev, PCI_COMMAND, orig_cmd); 302 pci_write_config_word(dev, PCI_COMMAND, orig_cmd);
298 303
299 if (bar_too_big) 304 if (bar_too_big)