diff --git a/src/device/Kconfig b/src/device/Kconfig index abef6a8d15..8bfdd2e445 100644 --- a/src/device/Kconfig +++ b/src/device/Kconfig @@ -555,6 +555,43 @@ config PCIEXP_HOTPLUG help Allocate resources for PCIe hotplug bridges +if PCIEXP_HOTPLUG + +config PCIEXP_HOTPLUG_BUSES + int "PCI Express Hotplug Buses" + default 32 + help + This is the number of buses allocated for hotplug PCI express + bridges, for use by hotplugged child devices. The default is 32 + buses. + +config PCIEXP_HOTPLUG_MEM + hex "PCI Express Hotplug Memory" + default 0x800000 + help + This is the amount of memory space, in bytes, to allocate to + hotplug PCI express bridges, for use by hotplugged child devices. + This size should be page-aligned. The default is 8 MiB. + +config PCIEXP_HOTPLUG_PREFETCH_MEM + hex "PCI Express Hotplug Prefetch Memory" + default 0x10000000 + help + This is the amount of pre-fetchable memory space, in bytes, to + allocate to hot-plug PCI express bridges, for use by hotplugged + child devices. This size should be page-aligned. The default is + 256 MiB. + +config PCIEXP_HOTPLUG_IO + hex "PCI Express Hotplug I/O Space" + default 0x2000 + help + This is the amount of I/O space to allocate to hot-plug PCI + express bridges, for use by hotplugged child devices. The default + is 8 KiB. + +endif # PCIEXP_HOTPLUG + endif # PCIEXP_PLUGIN_SUPPORT config EARLY_PCI_BRIDGE diff --git a/src/device/pci_device.c b/src/device/pci_device.c index 1dfc9cd272..47c0e9f2d2 100644 --- a/src/device/pci_device.c +++ b/src/device/pci_device.c @@ -870,10 +870,8 @@ static struct device_operations *get_pci_bridge_ops(struct device *dev) unsigned int pciexpos; pciexpos = pci_find_capability(dev, PCI_CAP_ID_PCIE); if (pciexpos) { - u16 flags, sltcap; + u16 flags; flags = pci_read_config16(dev, pciexpos + PCI_EXP_FLAGS); - sltcap = pci_read_config16(dev, pciexpos + PCI_EXP_SLTCAP); - printk(BIOS_DEBUG, "%s sltcap %x\n", dev_path(dev), sltcap); switch ((flags & PCI_EXP_FLAGS_TYPE) >> 4) { case PCI_EXP_TYPE_ROOT_PORT: case PCI_EXP_TYPE_UPSTREAM: @@ -881,10 +879,12 @@ static struct device_operations *get_pci_bridge_ops(struct device *dev) printk(BIOS_DEBUG, "%s subordinate bus PCI Express\n", dev_path(dev)); #if CONFIG(PCIEXP_HOTPLUG) + u16 sltcap; + sltcap = pci_read_config16(dev, pciexpos + PCI_EXP_SLTCAP); if (sltcap & PCI_EXP_SLTCAP_HPC) { printk(BIOS_DEBUG, "%s hot-plug capable\n", dev_path(dev)); return &default_pciexp_hotplug_ops_bus; - } else + } #endif /* CONFIG(PCIEXP_HOTPLUG) */ return &default_pciexp_ops_bus; case PCI_EXP_TYPE_PCI_BRIDGE: diff --git a/src/device/pciexp_device.c b/src/device/pciexp_device.c index 67b305ec7a..012cb58272 100644 --- a/src/device/pciexp_device.c +++ b/src/device/pciexp_device.c @@ -476,10 +476,6 @@ struct device_operations default_pciexp_ops_bus = { }; #if CONFIG(PCIEXP_HOTPLUG) -#define PCIEXP_HOTPLUG_BUSES 32 -#define PCIEXP_HOTPLUG_MEM (8 * 1024 * 1024) -#define PCIEXP_HOTPLUG_PREFETCH_MEM (256 * 1024 * 1024) -#define PCIEXP_HOTPLUG_IO (8 * 1024) static void pciexp_hotplug_dummy_read_resources(struct device *dev) { @@ -487,30 +483,27 @@ static void pciexp_hotplug_dummy_read_resources(struct device *dev) // Add extra memory space resource = new_resource(dev, 0x10); - resource->size = PCIEXP_HOTPLUG_MEM; - resource->align = 22; - resource->gran = 22; + resource->size = CONFIG_PCIEXP_HOTPLUG_MEM; + resource->align = 12; + resource->gran = 12; resource->limit = 0xffffffff; resource->flags |= IORESOURCE_MEM; - printk(BIOS_DEBUG, "%s: add 0x%llx of memory space\n", __func__, resource->size); // Add extra prefetchable memory space resource = new_resource(dev, 0x14); - resource->size = PCIEXP_HOTPLUG_PREFETCH_MEM; - resource->align = 22; - resource->gran = 22; + resource->size = CONFIG_PCIEXP_HOTPLUG_PREFETCH_MEM; + resource->align = 12; + resource->gran = 12; resource->limit = 0xffffffffffffffff; resource->flags |= IORESOURCE_MEM | IORESOURCE_PREFETCH; - printk(BIOS_DEBUG, "%s: add 0x%llx of prefetch memory space\n", __func__, resource->size); // Add extra I/O space resource = new_resource(dev, 0x18); - resource->size = PCIEXP_HOTPLUG_IO; + resource->size = CONFIG_PCIEXP_HOTPLUG_IO; resource->align = 12; resource->gran = 12; resource->limit = 0xffff; resource->flags |= IORESOURCE_IO; - printk(BIOS_DEBUG, "%s: add 0x%llx of I/O space\n", __func__, resource->size); } static struct device_operations pciexp_hotplug_dummy_ops = { @@ -519,23 +512,12 @@ static struct device_operations pciexp_hotplug_dummy_ops = { void pciexp_hotplug_scan_bridge(struct device *dev) { - dev->hotplug_buses = PCIEXP_HOTPLUG_BUSES; - printk( - BIOS_DEBUG, - "%s set hotplug_buses to %d\n", - dev_path(dev), - dev->hotplug_buses - ); + dev->hotplug_buses = CONFIG_PCIEXP_HOTPLUG_BUSES; /* Normal PCIe Scan */ pciexp_scan_bridge(dev); /* Add dummy slot to preserve resources, must happen after bus scan */ - printk( - BIOS_DEBUG, - "%s: add hotplug dummy device\n", - dev_path(dev) - ); struct device *dummy; struct device_path dummy_path = { .type = DEVICE_PATH_NONE }; dummy = alloc_dev(dev->link_list, &dummy_path);