Skip to contentSkip to conversation

PCI/PM: Call .bridge_d3() hook only if non-NULL

PATCH In review Bjorn Helgaas 2 participants 3 messages Apr 15, 2020 – Apr 24, 2020 PCI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI/PM: Call .bridge_d3() hook only if non-NULL

From: Bjorn Helgaas <[email protected]>

26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports") added the struct pci_platform_pm_ops.bridge_d3() function pointer and platform_pci_bridge_d3() to use it.

The .bridge_d3() op is implemented by acpi_pci_platform_pm, but not by mid_pci_platform_pm. We don't expect platform_pci_bridge_d3() to be called on Intel MID platforms, but nothing in the code itself would prevent that.

Check the .bridge_d3() pointer for NULL before calling it.

Fixes 26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports")
Cc Mika Westerberg <[email protected]>
---
 drivers/pci/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/pci.c +3 -1
index 595fcf59843f..dfa7ec008963 100644
@@ -868,7 +868,9 @@ static inline bool platform_pci_need_resume(struct pci_dev *dev)
 
 static inline bool platform_pci_bridge_d3(struct pci_dev *dev)
 {
-	return pci_platform_pm ? pci_platform_pm->bridge_d3(dev) : false;
+	if (pci_platform_pm && pci_platform_pm->bridge_d3)
+		return pci_platform_pm->bridge_d3(dev);
+	return false;
 }
 
 /**
Signature · 1 line
2.26.0.110.g2183baf09c-goog
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports") added the struct pci_platform_pm_ops.bridge_d3() function pointer and platform_pci_bridge_d3() to use it.

The .bridge_d3() op is implemented by acpi_pci_platform_pm, but not by mid_pci_platform_pm. We don't expect platform_pci_bridge_d3() to be called on Intel MID platforms, but nothing in the code itself would prevent that.

Quoted 5 lines

Check the .bridge_d3() pointer for NULL before calling it.

Fixes 26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports")
Cc Mika Westerberg <[email protected]>

Thanks!

#2 lore raw
In reply to Bjorn Helgaas
Quoted 10 lines · Bjorn Helgaas

From: Bjorn Helgaas <[email protected]>

26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports") added the struct pci_platform_pm_ops.bridge_d3() function pointer and platform_pci_bridge_d3() to use it.

The .bridge_d3() op is implemented by acpi_pci_platform_pm, but not by mid_pci_platform_pm. We don't expect platform_pci_bridge_d3() to be called on Intel MID platforms, but nothing in the code itself would prevent that.

Quoted 5 lines

Check the .bridge_d3() pointer for NULL before calling it.

Fixes 26ad34d510a8 ("PCI / ACPI: Whitelist D3 for more PCIe hotplug ports")
Cc Mika Westerberg <[email protected]>

Applied with Mika's reviewed-by to pci/pm for v5.8.

Quoted 22 lines
---
 drivers/pci/pci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/pci/pci.c +3 -1
index 595fcf59843f..dfa7ec008963 100644
@@ -868,7 +868,9 @@ static inline bool platform_pci_need_resume(struct pci_dev *dev)
 
 static inline bool platform_pci_bridge_d3(struct pci_dev *dev)
 {
-	return pci_platform_pm ? pci_platform_pm->bridge_d3(dev) : false;
+	if (pci_platform_pm && pci_platform_pm->bridge_d3)
+		return pci_platform_pm->bridge_d3(dev);
+	return false;
 }
 
 /**
Signature · 1 line
2.26.0.110.g2183baf09c-goog