Skip to content

Commit

Permalink
PCI: Pass bridge device, not bus, when updating bridge windows
Browse files Browse the repository at this point in the history
pci_setup_bridge_io(), pci_setup_bridge_mmio(), and
pci_setup_bridge_mmio_pref() program the windows of PCI-PCI bridges.
Previously they accepted a pointer to the pci_bus of the secondary bus,
then looked up the bridge leading to that bus.  Pass the bridge directly,
which will make it more convenient for future callers.

No functional change.

[bhelgaas: changelog, split into separate patch]
Link: https://bugzilla.kernel.org/show_bug.cgi?id=85491
Reported-by: Marek Kordik <[email protected]>
Fixes: 5b28541 ("PCI: Restrict 64-bit prefetchable bridge windows to 64-bit resources")
Signed-off-by: Yinghai Lu <[email protected]>
Signed-off-by: Bjorn Helgaas <[email protected]>
CC: [email protected]	# v3.16+
  • Loading branch information
Yinghai Lu authored and bjorn-helgaas committed Jan 16, 2015
1 parent c3e59ee commit 3f2f4dc
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions drivers/pci/setup-bus.c
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,8 @@ EXPORT_SYMBOL(pci_setup_cardbus);
config space writes, so it's quite possible that an I/O window of
the bridge will have some undesirable address (e.g. 0) after the
first write. Ditto 64-bit prefetchable MMIO. */
static void pci_setup_bridge_io(struct pci_bus *bus)
static void pci_setup_bridge_io(struct pci_dev *bridge)
{
struct pci_dev *bridge = bus->self;
struct resource *res;
struct pci_bus_region region;
unsigned long io_mask;
Expand All @@ -545,7 +544,7 @@ static void pci_setup_bridge_io(struct pci_bus *bus)
io_mask = PCI_IO_1K_RANGE_MASK;

/* Set up the top and bottom of the PCI I/O segment for this bus. */
res = bus->resource[0];
res = &bridge->resource[PCI_BRIDGE_RESOURCES + 0];
pcibios_resource_to_bus(bridge->bus, &region, res);
if (res->flags & IORESOURCE_IO) {
pci_read_config_word(bridge, PCI_IO_BASE, &l);
Expand All @@ -568,15 +567,14 @@ static void pci_setup_bridge_io(struct pci_bus *bus)
pci_write_config_dword(bridge, PCI_IO_BASE_UPPER16, io_upper16);
}

static void pci_setup_bridge_mmio(struct pci_bus *bus)
static void pci_setup_bridge_mmio(struct pci_dev *bridge)
{
struct pci_dev *bridge = bus->self;
struct resource *res;
struct pci_bus_region region;
u32 l;

/* Set up the top and bottom of the PCI Memory segment for this bus. */
res = bus->resource[1];
res = &bridge->resource[PCI_BRIDGE_RESOURCES + 1];
pcibios_resource_to_bus(bridge->bus, &region, res);
if (res->flags & IORESOURCE_MEM) {
l = (region.start >> 16) & 0xfff0;
Expand All @@ -588,9 +586,8 @@ static void pci_setup_bridge_mmio(struct pci_bus *bus)
pci_write_config_dword(bridge, PCI_MEMORY_BASE, l);
}

static void pci_setup_bridge_mmio_pref(struct pci_bus *bus)
static void pci_setup_bridge_mmio_pref(struct pci_dev *bridge)
{
struct pci_dev *bridge = bus->self;
struct resource *res;
struct pci_bus_region region;
u32 l, bu, lu;
Expand All @@ -602,7 +599,7 @@ static void pci_setup_bridge_mmio_pref(struct pci_bus *bus)

/* Set up PREF base/limit. */
bu = lu = 0;
res = bus->resource[2];
res = &bridge->resource[PCI_BRIDGE_RESOURCES + 2];
pcibios_resource_to_bus(bridge->bus, &region, res);
if (res->flags & IORESOURCE_PREFETCH) {
l = (region.start >> 16) & 0xfff0;
Expand Down Expand Up @@ -630,13 +627,13 @@ static void __pci_setup_bridge(struct pci_bus *bus, unsigned long type)
&bus->busn_res);

if (type & IORESOURCE_IO)
pci_setup_bridge_io(bus);
pci_setup_bridge_io(bridge);

if (type & IORESOURCE_MEM)
pci_setup_bridge_mmio(bus);
pci_setup_bridge_mmio(bridge);

if (type & IORESOURCE_PREFETCH)
pci_setup_bridge_mmio_pref(bus);
pci_setup_bridge_mmio_pref(bridge);

pci_write_config_word(bridge, PCI_BRIDGE_CONTROL, bus->bridge_ctl);
}
Expand Down

0 comments on commit 3f2f4dc

Please sign in to comment.