Add hotplug_buses to device struct to allow removal of hack

This commit is contained in:
Jeremy Soller
2019-10-09 21:28:04 -06:00
parent 9f16fa4e74
commit e2e360e3f8
3 changed files with 32 additions and 12 deletions

View File

@@ -1217,13 +1217,15 @@ static void pci_bridge_route(struct bus *link, scan_state state)
if (state == PCI_ROUTE_SCAN) {
link->secondary = parent->subordinate + 1;
link->subordinate = link->secondary;
if (dev->vendor == 0x8086 && dev->device == 0x15e7 && PCI_SLOT(dev->path.pci.devfn) == 1) {
printk(BIOS_DEBUG, "system76: HACK: add 32 to subordinate\n");
link->subordinate += 32;
}
printk(BIOS_DEBUG, "system76: pci_bridge_route: assigning link secondary %d subordinate %d\n", link->secondary, link->subordinate);
link->subordinate = link->secondary + dev->hotplug_buses;
printk(
BIOS_DEBUG,
"system76: %s: %s: assigning link secondary %d subordinate %d\n",
__func__,
dev_path(dev),
link->secondary,
link->subordinate
);
}
if (state == PCI_ROUTE_CLOSE) {
@@ -1259,7 +1261,13 @@ static void pci_bridge_route(struct bus *link, scan_state state)
if (state == PCI_ROUTE_FINAL) {
pci_write_config16(dev, PCI_COMMAND, link->bridge_cmd);
parent->subordinate = link->subordinate;
printk(BIOS_DEBUG, "system76: pci_bridge_route: assigning link subordinate %d\n", link->subordinate);
printk(
BIOS_DEBUG,
"system76: %s: %s: assigning parent subordinate %d\n",
__func__,
dev_path(dev),
parent->subordinate
);
}
}

View File

@@ -52,15 +52,26 @@ static struct device_operations slot_dev_ops = {
.read_resources = slot_dev_read_resources,
};
static bool tbt_is_hotplug_bridge(struct device *dev) {
return PCI_SLOT(dev->path.pci.devfn) == 1;
}
static void tbt_pciexp_scan_bridge(struct device *dev) {
printk(BIOS_DEBUG, "tbt_pciexp_scan_bridge %s: scan bridge\n", dev_path(dev));
printk(BIOS_DEBUG, "%s: %s: scan bridge\n", __func__, dev_path(dev));
bool is_hotplug = tbt_is_hotplug_bridge(dev);
if (is_hotplug) {
/* Add hotplug buses, must happen before bus scan */
printk(BIOS_DEBUG, "%s: %s: add hotplug buses\n", __func__, dev_path(dev));
dev->hotplug_buses = 32;
}
/* Normal PCIe Scan */
pciexp_scan_bridge(dev);
/* Add dummy slot to preserve resources */
if (PCI_SLOT(dev->path.pci.devfn) == 1) {
printk(BIOS_DEBUG, "tbt_pciexp_scan_bridge %s: add dummy device\n", dev_path(dev));
if (is_hotplug) {
/* Add dummy slot to preserve resources, must happen after bus scan */
printk(BIOS_DEBUG, "%s: %s: add dummy device\n", __func__, dev_path(dev));
struct device *slot;
struct device_path slot_path = { .type = DEVICE_PATH_NONE };
slot = alloc_dev(dev->link_list, &slot_path);

View File

@@ -129,6 +129,7 @@ struct device {
unsigned int disable_pcie_aspm : 1;
unsigned int hidden : 1; /* set if we should hide from UI */
u8 command;
uint16_t hotplug_buses; /* hotplug buses to allocate */
/* Base registers for this device. I/O, MEM and Expansion ROM */
DEVTREE_CONST struct resource *resource_list;