Bjorn suggests to "set host->native_pcie_hotplug up front based on CONFIG_HOTPLUG_PCI_PCIE and pcie_ports_native, and pciehp_is_native() would collapse to just an accessor for host->native_pcie_hotplug". Unfortunately only half of this is possible: The check for pcie_ports_native can indeed be moved out of pciehp_is_native() and into acpi_pci_root_create(). The check for CONFIG_HOTPLUG_PCI_PCIE however cannot be eliminated: get_port_device_capability() needs to know whether platform firmware has granted PCIe Native Hot-Plug control to the operating system. If it has and CONFIG_HOTPLUG_PCI_PCIE is disabled, the function disables hotplug interrupts in case BIOS left them enabled. If host->native_pcie_hotplug would be set up front based on CONFIG_HOTPLUG_PCI_PCIE, it would later on be impossible for get_port_device_capability() to tell whether it can safely disable hotplug interrupts: It wouldn't know whether Native Hot-Plug control was granted. Link: https://lore.kernel.org/r/20250627025607.GA1650254@bhelgaas/ Suggested-by: Bjorn Helgaas <bhelgaas@xxxxxxxxxx> Signed-off-by: Lukas Wunner <lukas@xxxxxxxxx> --- drivers/acpi/pci_root.c | 3 ++- drivers/pci/pci-acpi.c | 3 --- drivers/pci/pcie/portdrv.c | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 74ade4160314..f3de0dc9c533 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -1028,7 +1028,8 @@ struct pci_bus *acpi_pci_root_create(struct acpi_pci_root *root, goto out_release_info; host_bridge = to_pci_host_bridge(bus->bridge); - if (!(root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)) + if (!pcie_ports_native && + !(root->osc_control_set & OSC_PCI_EXPRESS_NATIVE_HP_CONTROL)) host_bridge->native_pcie_hotplug = 0; if (!(root->osc_control_set & OSC_PCI_SHPC_NATIVE_HP_CONTROL)) host_bridge->native_shpc_hotplug = 0; diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index ed7ed66a595b..b513826ea293 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c @@ -820,9 +820,6 @@ bool pciehp_is_native(struct pci_dev *bridge) if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE)) return false; - if (pcie_ports_native) - return true; - host = pci_find_host_bridge(bridge->bus); return host->native_pcie_hotplug; } diff --git a/drivers/pci/pcie/portdrv.c b/drivers/pci/pcie/portdrv.c index d1b68c18444f..fa83ebdcfecb 100644 --- a/drivers/pci/pcie/portdrv.c +++ b/drivers/pci/pcie/portdrv.c @@ -223,7 +223,7 @@ static int get_port_device_capability(struct pci_dev *dev) if (dev->is_pciehp && (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT || pci_pcie_type(dev) == PCI_EXP_TYPE_DOWNSTREAM) && - (pcie_ports_native || host->native_pcie_hotplug)) { + host->native_pcie_hotplug) { services |= PCIE_PORT_SERVICE_HP; /* -- 2.47.2