Skip to content

Commit 77ac2e2

Browse files
committed
Merge branch 'pci/enumeration'
- Simplify pci_read_bridge_bases() logic (Ilpo Järvinen) * pci/enumeration: PCI: Simplify pci_read_bridge_bases() logic PCI: Move struct pci_bus_resource into bus.c PCI: Remove unused PCI_SUBTRACTIVE_DECODE
2 parents dd97612 + 32ec7b3 commit 77ac2e2

File tree

5 files changed

+26
-38
lines changed

5 files changed

+26
-38
lines changed

arch/s390/pci/pci_bus.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ static int zpci_bus_prepare_device(struct zpci_dev *zdev)
5353
zpci_setup_bus_resources(zdev);
5454
for (i = 0; i < PCI_STD_NUM_BARS; i++) {
5555
if (zdev->bars[i].res)
56-
pci_bus_add_resource(zdev->zbus->bus, zdev->bars[i].res, 0);
56+
pci_bus_add_resource(zdev->zbus->bus, zdev->bars[i].res);
5757
}
5858
}
5959

arch/x86/pci/fixup.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ static void pci_amd_enable_64bit_bar(struct pci_dev *dev)
757757
dev_info(&dev->dev, "adding root bus resource %pR (tainting kernel)\n",
758758
res);
759759
add_taint(TAINT_FIRMWARE_WORKAROUND, LOCKDEP_STILL_OK);
760-
pci_bus_add_resource(dev->bus, res, 0);
760+
pci_bus_add_resource(dev->bus, res);
761761
}
762762

763763
base = ((res->start >> 8) & AMD_141b_MMIO_BASE_MMIOBASE_MASK) |

drivers/pci/bus.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818

1919
#include "pci.h"
2020

21+
/*
22+
* The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
23+
* to P2P or CardBus bridge windows) go in a table. Additional ones (for
24+
* buses below host bridges or subtractive decode bridges) go in the list.
25+
* Use pci_bus_for_each_resource() to iterate through all the resources.
26+
*/
27+
28+
struct pci_bus_resource {
29+
struct list_head list;
30+
struct resource *res;
31+
};
32+
2133
void pci_add_resource_offset(struct list_head *resources, struct resource *res,
2234
resource_size_t offset)
2335
{
@@ -46,8 +58,7 @@ void pci_free_resource_list(struct list_head *resources)
4658
}
4759
EXPORT_SYMBOL(pci_free_resource_list);
4860

49-
void pci_bus_add_resource(struct pci_bus *bus, struct resource *res,
50-
unsigned int flags)
61+
void pci_bus_add_resource(struct pci_bus *bus, struct resource *res)
5162
{
5263
struct pci_bus_resource *bus_res;
5364

@@ -58,7 +69,6 @@ void pci_bus_add_resource(struct pci_bus *bus, struct resource *res,
5869
}
5970

6071
bus_res->res = res;
61-
bus_res->flags = flags;
6272
list_add_tail(&bus_res->list, &bus->resources);
6373
}
6474

drivers/pci/probe.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -543,15 +543,15 @@ void pci_read_bridge_bases(struct pci_bus *child)
543543
pci_read_bridge_mmio(child->self, child->resource[1], false);
544544
pci_read_bridge_mmio_pref(child->self, child->resource[2], false);
545545

546-
if (dev->transparent) {
547-
pci_bus_for_each_resource(child->parent, res) {
548-
if (res && res->flags) {
549-
pci_bus_add_resource(child, res,
550-
PCI_SUBTRACTIVE_DECODE);
551-
pci_info(dev, " bridge window %pR (subtractive decode)\n",
552-
res);
553-
}
554-
}
546+
if (!dev->transparent)
547+
return;
548+
549+
pci_bus_for_each_resource(child->parent, res) {
550+
if (!res || !res->flags)
551+
continue;
552+
553+
pci_bus_add_resource(child, res);
554+
pci_info(dev, " bridge window %pR (subtractive decode)\n", res);
555555
}
556556
}
557557

@@ -1034,7 +1034,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)
10341034
if (res->flags & IORESOURCE_BUS)
10351035
pci_bus_insert_busn_res(bus, bus->number, res->end);
10361036
else
1037-
pci_bus_add_resource(bus, res, 0);
1037+
pci_bus_add_resource(bus, res);
10381038

10391039
if (offset) {
10401040
if (resource_type(res) == IORESOURCE_IO)

include/linux/pci.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -636,27 +636,6 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
636636

637637
int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);
638638

639-
/*
640-
* The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond
641-
* to P2P or CardBus bridge windows) go in a table. Additional ones (for
642-
* buses below host bridges or subtractive decode bridges) go in the list.
643-
* Use pci_bus_for_each_resource() to iterate through all the resources.
644-
*/
645-
646-
/*
647-
* PCI_SUBTRACTIVE_DECODE means the bridge forwards the window implicitly
648-
* and there's no way to program the bridge with the details of the window.
649-
* This does not apply to ACPI _CRS windows, even with the _DEC subtractive-
650-
* decode bit set, because they are explicit and can be programmed with _SRS.
651-
*/
652-
#define PCI_SUBTRACTIVE_DECODE 0x1
653-
654-
struct pci_bus_resource {
655-
struct list_head list;
656-
struct resource *res;
657-
unsigned int flags;
658-
};
659-
660639
#define PCI_REGION_FLAG_MASK 0x0fU /* These bits of resource flags tell us the PCI region flags */
661640

662641
struct pci_bus {
@@ -1509,8 +1488,7 @@ void pci_add_resource(struct list_head *resources, struct resource *res);
15091488
void pci_add_resource_offset(struct list_head *resources, struct resource *res,
15101489
resource_size_t offset);
15111490
void pci_free_resource_list(struct list_head *resources);
1512-
void pci_bus_add_resource(struct pci_bus *bus, struct resource *res,
1513-
unsigned int flags);
1491+
void pci_bus_add_resource(struct pci_bus *bus, struct resource *res);
15141492
struct resource *pci_bus_resource_n(const struct pci_bus *bus, int n);
15151493
void pci_bus_remove_resources(struct pci_bus *bus);
15161494
void pci_bus_remove_resource(struct pci_bus *bus, struct resource *res);

0 commit comments

Comments
 (0)