aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pci/probe.c
diff options
context:
space:
mode:
authorBjorn Helgaas <bhelgaas@google.com>2012-07-09 15:38:57 -0400
committerBjorn Helgaas <bhelgaas@google.com>2012-07-09 21:52:04 -0400
commit2b28ae1912e5ce5bb0527e352ae6ff04e76183d1 (patch)
treef8fb930ee1277c1e59c3db8bb802867e2c2d9a59 /drivers/pci/probe.c
parent5dde383e2ef5e22fe7db689dc38c1aabfb801449 (diff)
PCI: reimplement P2P bridge 1K I/O windows (Intel P64H2)
9d265124d051 and 15a260d53f7c added quirks for P2P bridges that support I/O windows that start/end at 1K boundaries, not just the 4K boundaries defined by the PCI spec. For details, see the IOBL_ADR register and the EN1K bit in the CNF register in the Intel 82870P2 (P64H2). These quirks complicate the code that reads P2P bridge windows (pci_read_bridge_io() and pci_cfg_fake_ranges()) because the bridge I/O resource is updated in the HEADER quirk, in pci_read_bridge_io(), in pci_setup_bridge(), and again in the FINAL quirk. This is confusing and makes it impossible to reassign the bridge windows after FINAL quirks are run. This patch adds support for 1K windows in the generic paths, so the HEADER quirk only has to enable this support. The FINAL quirk, which used to undo damage done by pci_setup_bridge(), is no longer needed. This removes "if (!res->start) res->start = ..." from pci_read_bridge_io(); that was part of 9d265124d051 to avoid overwriting the resource filled in by the quirk. Since pci_read_bridge_io() itself now knows about granularity, the quirk no longer updates the resource and this test is no longer needed. Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Diffstat (limited to 'drivers/pci/probe.c')
-rw-r--r--drivers/pci/probe.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 9c5d2a992999..ef24cf765b2f 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -269,15 +269,23 @@ static void __devinit pci_read_bridge_io(struct pci_bus *child)
269{ 269{
270 struct pci_dev *dev = child->self; 270 struct pci_dev *dev = child->self;
271 u8 io_base_lo, io_limit_lo; 271 u8 io_base_lo, io_limit_lo;
272 unsigned long base, limit; 272 unsigned long io_mask, io_granularity, base, limit;
273 struct pci_bus_region region; 273 struct pci_bus_region region;
274 struct resource *res, res2; 274 struct resource *res;
275
276 io_mask = PCI_IO_RANGE_MASK;
277 io_granularity = 0x1000;
278 if (dev->io_window_1k) {
279 /* Support 1K I/O space granularity */
280 io_mask = PCI_IO_1K_RANGE_MASK;
281 io_granularity = 0x400;
282 }
275 283
276 res = child->resource[0]; 284 res = child->resource[0];
277 pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo); 285 pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo);
278 pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo); 286 pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo);
279 base = (io_base_lo & PCI_IO_RANGE_MASK) << 8; 287 base = (io_base_lo & io_mask) << 8;
280 limit = (io_limit_lo & PCI_IO_RANGE_MASK) << 8; 288 limit = (io_limit_lo & io_mask) << 8;
281 289
282 if ((io_base_lo & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) { 290 if ((io_base_lo & PCI_IO_RANGE_TYPE_MASK) == PCI_IO_RANGE_TYPE_32) {
283 u16 io_base_hi, io_limit_hi; 291 u16 io_base_hi, io_limit_hi;
@@ -289,14 +297,9 @@ static void __devinit pci_read_bridge_io(struct pci_bus *child)
289 297
290 if (base <= limit) { 298 if (base <= limit) {
291 res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO; 299 res->flags = (io_base_lo & PCI_IO_RANGE_TYPE_MASK) | IORESOURCE_IO;
292 res2.flags = res->flags;
293 region.start = base; 300 region.start = base;
294 region.end = limit + 0xfff; 301 region.end = limit + io_granularity - 1;
295 pcibios_bus_to_resource(dev, &res2, &region); 302 pcibios_bus_to_resource(dev, res, &region);
296 if (!res->start)
297 res->start = res2.start;
298 if (!res->end)
299 res->end = res2.end;
300 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res); 303 dev_printk(KERN_DEBUG, &dev->dev, " bridge window %pR\n", res);
301 } 304 }
302} 305}