diff mbox series

[v4,03/10] PCI: Detect root port of internal USB4 controllers

Message ID 20220215000200.242799-4-mario.limonciello@amd.com (mailing list archive)
State Superseded
Headers show
Series Overhaul `is_thunderbolt` | expand

Commit Message

Mario Limonciello Feb. 15, 2022, 12:01 a.m. UTC
The root port used for PCIe tunneling is the root of the hierarchy used
for all PCIe devices that are connected downstream.  Tunnels are created
and destroyed by the USB4 SW CM.  So this port should be marked as external
meaning all devices connected to it are appropriately marked as removable
for downstream drivers to detect.

This can be done by looking for the device property specified in
the ACPI tables `usb4-host-interface`.

Suggested-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Link: https://docs.microsoft.com/en-us/windows-hardware/drivers/pci/dsd-for-pcie-root-ports#mapping-native-protocols-pcie-displayport-tunneled-through-usb4-to-usb4-host-routers
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/pci/pci-acpi.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c
index a42dbf448860..695dbd88b8b7 100644
--- a/drivers/pci/pci-acpi.c
+++ b/drivers/pci/pci-acpi.c
@@ -1335,12 +1335,21 @@  static void pci_acpi_optimize_delay(struct pci_dev *pdev,
 
 static void pci_acpi_set_external_facing(struct pci_dev *dev)
 {
-	u8 val;
+	u8 val = 0;
 
 	if (pci_pcie_type(dev) != PCI_EXP_TYPE_ROOT_PORT)
 		return;
-	if (device_property_read_u8(&dev->dev, "ExternalFacingPort", &val))
-		return;
+	device_property_read_u8(&dev->dev, "ExternalFacingPort", &val);
+
+	/* check for root port for PCIe tunnels on integrated controllers */
+	if (!val) {
+		struct acpi_device *adev = ACPI_COMPANION(&dev->dev);
+
+		if (!adev)
+			return;
+		val = fwnode_property_present(acpi_fwnode_handle(adev),
+					      "usb4-host-interface");
+	}
 
 	/*
 	 * These root ports expose PCIe (including DMA) outside of the