Skip to content

Commit 281e1f1

Browse files
committed
PCI: Supply bridge device, not secondary bus, to read window details
Previously we logged information about devices *below* the bridge before logging information about the bridge itself, e.g., pci 0000:00:01.0: [8086:1901] type 01 class 0x060400 pci 0000:01:00.0: [10de:13b6] type 00 class 0x030200 pci 0000:01:00.0: reg 0x10: [mem 0xec000000-0xecffffff] pci 0000:00:01.0: PCI bridge to [bus 01] pci 0000:00:01.0: bridge window [io 0xe000-0xefff] This is partly because the bridge windows are read in this path: pci_scan_child_bus_extend for (devfn = 0; devfn < 256; devfn += 8) pci_scan_slot(bus, devfn) # scan below bridge pcibios_fixup_bus(bus) pci_read_bridge_bases(bus) # read bridge windows pci_read_bridge_io(bus) Remove the assumption that the secondary (child) pci_bus already exists by passing in the bridge device (instead of the pci_bus) and a resource pointer when reading bridge windows. A future change can use this to log the bridge details before we enumerate the devices below the bridge. No functional change intended. Signed-off-by: Bjorn Helgaas <[email protected]>
1 parent 6f32099 commit 281e1f1

File tree

1 file changed

+6
-15
lines changed

1 file changed

+6
-15
lines changed

drivers/pci/probe.c

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,11 @@ static void pci_read_bases(struct pci_dev *dev, unsigned int howmany, int rom)
344344
}
345345
}
346346

347-
static void pci_read_bridge_io(struct pci_bus *child)
347+
static void pci_read_bridge_io(struct pci_dev *dev, struct resource *res)
348348
{
349-
struct pci_dev *dev = child->self;
350349
u8 io_base_lo, io_limit_lo;
351350
unsigned long io_mask, io_granularity, base, limit;
352351
struct pci_bus_region region;
353-
struct resource *res;
354352

355353
io_mask = PCI_IO_RANGE_MASK;
356354
io_granularity = 0x1000;
@@ -360,7 +358,6 @@ static void pci_read_bridge_io(struct pci_bus *child)
360358
io_granularity = 0x400;
361359
}
362360

363-
res = child->resource[0];
364361
pci_read_config_byte(dev, PCI_IO_BASE, &io_base_lo);
365362
pci_read_config_byte(dev, PCI_IO_LIMIT, &io_limit_lo);
366363
base = (io_base_lo & io_mask) << 8;
@@ -384,15 +381,12 @@ static void pci_read_bridge_io(struct pci_bus *child)
384381
}
385382
}
386383

387-
static void pci_read_bridge_mmio(struct pci_bus *child)
384+
static void pci_read_bridge_mmio(struct pci_dev *dev, struct resource *res)
388385
{
389-
struct pci_dev *dev = child->self;
390386
u16 mem_base_lo, mem_limit_lo;
391387
unsigned long base, limit;
392388
struct pci_bus_region region;
393-
struct resource *res;
394389

395-
res = child->resource[1];
396390
pci_read_config_word(dev, PCI_MEMORY_BASE, &mem_base_lo);
397391
pci_read_config_word(dev, PCI_MEMORY_LIMIT, &mem_limit_lo);
398392
base = ((unsigned long) mem_base_lo & PCI_MEMORY_RANGE_MASK) << 16;
@@ -406,16 +400,13 @@ static void pci_read_bridge_mmio(struct pci_bus *child)
406400
}
407401
}
408402

409-
static void pci_read_bridge_mmio_pref(struct pci_bus *child)
403+
static void pci_read_bridge_mmio_pref(struct pci_dev *dev, struct resource *res)
410404
{
411-
struct pci_dev *dev = child->self;
412405
u16 mem_base_lo, mem_limit_lo;
413406
u64 base64, limit64;
414407
pci_bus_addr_t base, limit;
415408
struct pci_bus_region region;
416-
struct resource *res;
417409

418-
res = child->resource[2];
419410
pci_read_config_word(dev, PCI_PREF_MEMORY_BASE, &mem_base_lo);
420411
pci_read_config_word(dev, PCI_PREF_MEMORY_LIMIT, &mem_limit_lo);
421412
base64 = (mem_base_lo & PCI_PREF_RANGE_MASK) << 16;
@@ -527,9 +518,9 @@ void pci_read_bridge_bases(struct pci_bus *child)
527518
for (i = 0; i < PCI_BRIDGE_RESOURCE_NUM; i++)
528519
child->resource[i] = &dev->resource[PCI_BRIDGE_RESOURCES+i];
529520

530-
pci_read_bridge_io(child);
531-
pci_read_bridge_mmio(child);
532-
pci_read_bridge_mmio_pref(child);
521+
pci_read_bridge_io(child->self, child->resource[0]);
522+
pci_read_bridge_mmio(child->self, child->resource[1]);
523+
pci_read_bridge_mmio_pref(child->self, child->resource[2]);
533524

534525
if (dev->transparent) {
535526
pci_bus_for_each_resource(child->parent, res) {

0 commit comments

Comments
 (0)