Skip to content

Commit c2f9de5

Browse files
l1kbjorn-helgaas
authored andcommitted
PCI: Move is_pciehp check out of pciehp_is_native()
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
1 parent c6036c3 commit c2f9de5

3 files changed

Lines changed: 11 additions & 9 deletions

File tree

drivers/pci/pci-acpi.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -820,9 +820,6 @@ bool pciehp_is_native(struct pci_dev *bridge)
820820
if (!IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))
821821
return false;
822822

823-
if (!bridge->is_pciehp)
824-
return false;
825-
826823
if (pcie_ports_native)
827824
return true;
828825

@@ -1000,7 +997,7 @@ bool acpi_pci_bridge_d3(struct pci_dev *dev)
1000997
struct acpi_device *adev, *rpadev;
1001998
const union acpi_object *obj;
1002999

1003-
if (acpi_pci_disabled || !dev->is_hotplug_bridge)
1000+
if (acpi_pci_disabled || !dev->is_pciehp)
10041001
return false;
10051002

10061003
adev = ACPI_COMPANION(&dev->dev);

drivers/pci/pci.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3050,10 +3050,14 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
30503050
return false;
30513051

30523052
/*
3053-
* Hotplug ports handled by firmware in System Management Mode
3054-
* may not be put into D3 by the OS (Thunderbolt on non-Macs).
3053+
* Hotplug ports handled by platform firmware may not be put
3054+
* into D3 by the OS, e.g. ACPI slots ...
30553055
*/
3056-
if (bridge->is_hotplug_bridge && !pciehp_is_native(bridge))
3056+
if (bridge->is_hotplug_bridge && !bridge->is_pciehp)
3057+
return false;
3058+
3059+
/* ... or PCIe hotplug ports not handled natively by the OS. */
3060+
if (bridge->is_pciehp && !pciehp_is_native(bridge))
30573061
return false;
30583062

30593063
if (pci_bridge_d3_force)
@@ -3072,7 +3076,7 @@ bool pci_bridge_d3_possible(struct pci_dev *bridge)
30723076
* by vendors for runtime D3 at least until 2018 because there
30733077
* was no OS support.
30743078
*/
3075-
if (bridge->is_hotplug_bridge)
3079+
if (bridge->is_pciehp)
30763080
return false;
30773081

30783082
if (dmi_check_system(bridge_d3_blacklist))

include/linux/pci_hotplug.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ static inline bool shpchp_is_native(struct pci_dev *bridge) { return true; }
104104

105105
static inline bool hotplug_is_native(struct pci_dev *bridge)
106106
{
107-
return pciehp_is_native(bridge) || shpchp_is_native(bridge);
107+
return (bridge->is_pciehp && pciehp_is_native(bridge)) ||
108+
shpchp_is_native(bridge);
108109
}
109110
#endif

0 commit comments

Comments
 (0)