]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
PCI: Move is_pciehp check out of pciehp_is_native()
authorLukas Wunner <lukas@wunner.de>
Sun, 13 Jul 2025 14:31:04 +0000 (16:31 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Tue, 29 Jul 2025 16:45:39 +0000 (11:45 -0500)
pci_bridge_d3_possible() seeks to forbid runtime power management on:

* Non Hot-Plug Capable PCIe ports which are nevertheless ACPI slots
  (recognizable as: bridge->is_hotplug_bridge && !bridge->is_pciehp)

* Hot-Plug Capable PCIe ports for which platform firmware has not granted
  PCIe Native Hot-Plug control to the operating system
  (recognizable as: bridge->is_pciehp && !pciehp_is_native(bridge))

Somewhat confusingly, the check for is_hotplug_bridge is in
pci_bridge_d3_possible(), whereas the one for is_pciehp is in
pciehp_is_native().

For clarity, check is_pciehp directly in pci_bridge_d3_possible()
(and in the other caller of pciehp_is_native(), hotplug_is_native()).

Rephrase the code comment preceding these checks to no longer mention
"System Management Mode", which is an x86 term inappropriate in generic
PCI code.  Likewise no longer mention "Thunderbolt on non-Macs", because
there is nothing Thunderbolt-specific about these checks.  It used to be
the case that non-Macs relied on the platform for Thunderbolt tunnel
management and hotplug, but they've since moved to OS-native tunnel
management (as Macs always have), hence the code comment is no longer
accurate.

There is a subsequent check for is_hotplug_bridge further down in
pci_bridge_d3_possible().  Change the check to is_pciehp because any
ports matching "bridge->is_hotplug_bridge && !bridge->is_pciehp" are
already filtered out at the top of the function.

Do the same for another check in acpi_pci_bridge_d3(), which is called
from pci_bridge_d3_possible() via platform_pci_bridge_d3().

No functional change intended.

Signed-off-by: Lukas Wunner <lukas@wunner.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Link: https://patch.msgid.link/18b2c2110ad0f27a34b189d793310b9c4f2f24a0.1752390102.git.lukas@wunner.de
drivers/pci/pci-acpi.c
drivers/pci/pci.c
include/linux/pci_hotplug.h

index efe478e5073e5f81630a6cce1710e2af6f19e370..ed7ed66a595b3595de3b9c4d0715bce39e0c64e5 100644 (file)
@@ -820,9 +820,6 @@ bool pciehp_is_native(struct pci_dev *bridge)
        if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))
                return false;
 
-       if (!bridge->is_pciehp)
-               return false;
-
        if (pcie_ports_native)
                return true;
 
@@ -1000,7 +997,7 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev)
        struct acpi_device *adev, *rpadev;
        const union acpi_object *obj;
 
-       if (acpi_pci_disabled || !dev->is_hotplug_bridge)
+       if (acpi_pci_disabled || !dev->is_pciehp)
                return false;
 
        adev = ACPI_COMPANION(&dev->dev);
index 23d8fe98ddf9ed1e5bac22a33e92d31bd49ede81..749994dad9dcadc480c93ae4b95377858d25736b 100644 (file)
@@ -3050,10 +3050,14 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
                        return false;
 
                /*
-                * Hotplug ports handled by firmware in System Management Mode
-                * may not be put into D3 by the OS (Thunderbolt on non-Macs).
+                * Hotplug ports handled by platform firmware may not be put
+                * into D3 by the OS, e.g. ACPI slots ...
                 */
-               if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge))
+               if (bridge->is_hotplug_bridge && !bridge->is_pciehp)
+                       return false;
+
+               /* ... or PCIe hotplug ports not handled natively by the OS. */
+               if (bridge->is_pciehp && !pciehp_is_native(bridge))
                        return false;
 
                if (pci_bridge_d3_force)
@@ -3072,7 +3076,7 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
                 * by vendors for runtime D3 at least until 2018 because there
                 * was no OS support.
                 */
-               if (bridge->is_hotplug_bridge)
+               if (bridge->is_pciehp)
                        return false;
 
                if (dmi_check_system(bridge_d3_blacklist))
index ec77ccf1fc4d1b77e4e5b136f452973bb2f18b4d..ddf79641917f0f801b2c388c55714bfe3b71f741 100644 (file)
@@ -104,6 +104,7 @@ static inline bool shpchp_is_native(struct pci_dev *bridge) { return true; }
 
 static inline bool hotplug_is_native(struct pci_dev *bridge)
 {
-       return pciehp_is_native(bridge) || shpchp_is_native(bridge);
+       return (bridge->is_pciehp && pciehp_is_native(bridge)) ||
+              shpchp_is_native(bridge);
 }
 #endif