Skip to contentSkip to conversation

thunderbolt: Support for Intel Alder Lake and improvements

PATCH In review Mika Westerberg 2 participants 8 messages Jun 7, 2021 – Jun 11, 2021

Subsystems (2)
lore
Share & tools
lore
#2 lore raw

PATCH 2/5 thunderbolt: Add device links only when software connection manager is used

In reply to Mika Westerberg

We only need to set up the device links when software connection manager path is used. The firmware connection manager does not need them and if they are present they may even cause problems.

---
 drivers/thunderbolt/nhi.c | 67 ---------------------------------------
 drivers/thunderbolt/tb.c  | 67 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 67 insertions(+), 67 deletions(-)
drivers/thunderbolt/nhi.c +0 -67
index a0386d1e3fc9..478bf6701145 100644
@@ -17,7 +17,6 @@
 #include <linux/module.h>
 #include <linux/delay.h>
 #include <linux/property.h>
-#include <linux/platform_data/x86/apple.h>
 
 #include "nhi.h"
 #include "nhi_regs.h"
@@ -1127,69 +1126,6 @@ static bool nhi_imr_valid(struct pci_dev *pdev)
 	return true;
 }
 
-/*
- * During suspend the Thunderbolt controller is reset and all PCIe
- * tunnels are lost. The NHI driver will try to reestablish all tunnels
- * during resume. This adds device links between the tunneled PCIe
- * downstream ports and the NHI so that the device core will make sure
- * NHI is resumed first before the rest.
- */
-static void tb_apple_add_links(struct tb_nhi *nhi)
-{
-	struct pci_dev *upstream, *pdev;
-
-	if (!x86_apple_machine)
-		return;
-
-	switch (nhi->pdev->device) {
-	case PCI_DEVICE_ID_INTEL_LIGHT_RIDGE:
-	case PCI_DEVICE_ID_INTEL_CACTUS_RIDGE_4C:
-	case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_2C_NHI:
-	case PCI_DEVICE_ID_INTEL_FALCON_RIDGE_4C_NHI:
-		break;
-	default:
-		return;
-	}
-
-	upstream = pci_upstream_bridge(nhi->pdev);
-	while (upstream) {
-		if (!pci_is_pcie(upstream))
-			return;
-		if (pci_pcie_type(upstream) == PCI_EXP_TYPE_UPSTREAM)
-			break;
-		upstream = pci_upstream_bridge(upstream);
-	}
-
-	if (!upstream)
-		return;
-
-	/*
-	 * For each hotplug downstream port, create add device link
-	 * back to NHI so that PCIe tunnels can be re-established after
-	 * sleep.
-	 */
-	for_each_pci_bridge(pdev, upstream->subordinate) {
-		const struct device_link *link;
-
-		if (!pci_is_pcie(pdev))
-			continue;
-		if (pci_pcie_type(pdev) != PCI_EXP_TYPE_DOWNSTREAM ||
-		    !pdev->is_hotplug_bridge)
-			continue;
-
-		link = device_link_add(&pdev->dev, &nhi->pdev->dev,
-				       DL_FLAG_AUTOREMOVE_SUPPLIER |
-				       DL_FLAG_PM_RUNTIME);
-		if (link) {
-			dev_dbg(&nhi->pdev->dev, "created link from %s\n",
-				dev_name(&pdev->dev));
-		} else {
-			dev_warn(&nhi->pdev->dev, "device link creation from %s failed\n",
-				 dev_name(&pdev->dev));
-		}
-	}
-}
-
 static struct tb *nhi_select_cm(struct tb_nhi *nhi)
 {
 	struct tb *tb;
@@ -1278,9 +1214,6 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 			return res;
 	}
 
-	tb_apple_add_links(nhi);
-	tb_acpi_add_links(nhi);
-
 	tb = nhi_select_cm(nhi);
 	if (!tb) {
 		dev_err(&nhi->pdev->dev,
drivers/thunderbolt/tb.c +67 -0

84 lines not on this page · raw message

Signature · 1 line
2.30.2
#1 lore raw

PATCH 1/5 thunderbolt: Bond lanes only when dual_link_port != NULL in alloc_dev_default()

In reply to Mika Westerberg

We should not dereference ->dual_link_port if it is NULL and lane bonding is requested. For this reason move lane bonding configuration happen inside the block where ->dual_link_port != NULL.

Fixes 54509f5005ca ("thunderbolt: Add KUnit tests for path walking")
---
 drivers/thunderbolt/test.c | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)
drivers/thunderbolt/test.c +11 -11
index cf34c1ecf5d5..ba5afd471766 100644
@@ -303,18 +303,18 @@ static struct tb_switch *alloc_dev_default(struct kunit *test,
 	if (port->dual_link_port && upstream_port->dual_link_port) {
 		port->dual_link_port->remote = upstream_port->dual_link_port;
 		upstream_port->dual_link_port->remote = port->dual_link_port;
-	}
 
-	if (bonded) {
-		/* Bonding is used */
-		port->bonded = true;
-		port->total_credits *= 2;
-		port->dual_link_port->bonded = true;
-		port->dual_link_port->total_credits = 0;
-		upstream_port->bonded = true;
-		upstream_port->total_credits *= 2;
-		upstream_port->dual_link_port->bonded = true;
-		upstream_port->dual_link_port->total_credits = 0;
+		if (bonded) {
+			/* Bonding is used */
+			port->bonded = true;
+			port->total_credits *= 2;
+			port->dual_link_port->bonded = true;
+			port->dual_link_port->total_credits = 0;
+			upstream_port->bonded = true;
+			upstream_port->total_credits *= 2;
+			upstream_port->dual_link_port->bonded = true;
+			upstream_port->dual_link_port->total_credits = 0;
+		}
 	}
 
 	return sw;
Signature · 1 line
2.30.2
#0 lore raw

cover thunderbolt: Support for Intel Alder Lake and improvements

Hi all,

This series adds support for Intel Alder Lake which is the successor of Tiger Lake. The integrated Thunderbolt/USB4 controller is pretty close to the one found in Tiger Lake too.

In addition there are few improvements for issues reported by Dan Carpenter and kernel test robot.

The series applies on top of thunderbolt.git/next.

Azhar Shaikh (1):
thunderbolt: Add support for Intel Alder Lake

Gil Fine (1):
thunderbolt: Poll 10ms for REG_FW_STS_NVM_AUTH_DONE to be set

Mika Westerberg (3):
thunderbolt: Bond lanes only when dual_link_port != NULL in alloc_dev_default()
thunderbolt: Add device links only when software connection manager is used
thunderbolt: No need to include <linux/acpi.h> in usb4_port.c

 drivers/thunderbolt/icm.c       | 20 ++++++----
 drivers/thunderbolt/nhi.c       | 71 ++-------------------------------
 drivers/thunderbolt/nhi.h       |  2 +
 drivers/thunderbolt/tb.c        | 67 +++++++++++++++++++++++++++++++
 drivers/thunderbolt/test.c      | 22 +++++-----
 drivers/thunderbolt/usb4_port.c |  1 -
 6 files changed, 97 insertions(+), 86 deletions(-)
Signature · 1 line
2.30.2
#3 lore raw

PATCH 3/5 thunderbolt: Poll 10ms for REG_FW_STS_NVM_AUTH_DONE to be set

From: Gil Fine <[email protected]>

In Intel Tiger Lake and beyond it takes some time after the force power is set until the firmware connection manager is ready. So instead of reading it once we poll it for 10ms before giving up.

---
 drivers/thunderbolt/icm.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
drivers/thunderbolt/icm.c +11 -7
index 2f30b816705a..0f25cf9fe519 100644
@@ -1677,14 +1677,18 @@ static void icm_icl_rtd3_veto(struct tb *tb, const struct icm_pkg_header *hdr)
 
 static bool icm_tgl_is_supported(struct tb *tb)
 {
-	u32 val;
+	unsigned long end = jiffies + msecs_to_jiffies(10);
 
-	/*
-	 * If the firmware is not running use software CM. This platform
-	 * should fully support both.
-	 */
-	val = ioread32(tb->nhi->iobase + REG_FW_STS);
-	return !!(val & REG_FW_STS_NVM_AUTH_DONE);
+	do {
+		u32 val;
+
+		val = ioread32(tb->nhi->iobase + REG_FW_STS);
+		if (val & REG_FW_STS_NVM_AUTH_DONE)
+			return true;
+		usleep_range(100, 500);
+	} while (time_before(jiffies, end));
+
+	return false;
 }
 
 static void icm_handle_notification(struct work_struct *work)
Signature · 1 line
2.30.2
#4 lore raw

PATCH 4/5 thunderbolt: No need to include <linux/acpi.h> in usb4_port.c

In reply to Mika Westerberg

This include is not needed so drop it.

---
 drivers/thunderbolt/usb4_port.c | 1 -
 1 file changed, 1 deletion(-)
drivers/thunderbolt/usb4_port.c +0 -1
index 765c74179598..29e2a4f9c9f5 100644
@@ -6,7 +6,6 @@
  * Author: Mika Westerberg <[email protected]>
  */
 
-#include <linux/acpi.h>
 #include <linux/pm_runtime.h>
 
 #include "tb.h"
Signature · 1 line
2.30.2
#5 lore raw

PATCH 5/5 thunderbolt: Add support for Intel Alder Lake

In reply to Mika Westerberg

From: Azhar Shaikh <[email protected]>

Alder Lake has the same integrated Thunderbolt/USB4 controller as Intel Tiger Lake. By default it is still using firmware based connection manager so we can use most of the Tiger Lake flows.

Add the Alder Lake PCI IDs to the driver list of supported devices.

---
 drivers/thunderbolt/icm.c | 2 ++
 drivers/thunderbolt/nhi.c | 4 ++++
 drivers/thunderbolt/nhi.h | 2 ++
 3 files changed, 8 insertions(+)
drivers/thunderbolt/icm.c +2 -0
index 0f25cf9fe519..6255f1ef9599 100644
@@ -2509,6 +2509,8 @@ struct tb *icm_probe(struct tb_nhi *nhi)
 	case PCI_DEVICE_ID_INTEL_TGL_NHI1:
 	case PCI_DEVICE_ID_INTEL_TGL_H_NHI0:
 	case PCI_DEVICE_ID_INTEL_TGL_H_NHI1:
+	case PCI_DEVICE_ID_INTEL_ADL_NHI0:
+	case PCI_DEVICE_ID_INTEL_ADL_NHI1:
 		icm->is_supported = icm_tgl_is_supported;
 		icm->driver_ready = icm_icl_driver_ready;
 		icm->set_uuid = icm_icl_set_uuid;
drivers/thunderbolt/nhi.c +4 -0
index 478bf6701145..fa44332845a1 100644
@@ -1333,6 +1333,10 @@ static struct pci_device_id nhi_ids[] = {
 	  .driver_data = (kernel_ulong_t)&icl_nhi_ops },
 	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_TGL_H_NHI1),
 	  .driver_data = (kernel_ulong_t)&icl_nhi_ops },
+	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ADL_NHI0),
+	  .driver_data = (kernel_ulong_t)&icl_nhi_ops },
+	{ PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_ADL_NHI1),
+	  .driver_data = (kernel_ulong_t)&icl_nhi_ops },
 
 	/* Any USB4 compliant host */
 	{ PCI_DEVICE_CLASS(PCI_CLASS_SERIAL_USB_USB4, ~0) },
drivers/thunderbolt/nhi.h +2 -0
index 69770beca792..69083aab2736 100644
@@ -72,6 +72,8 @@ extern const struct tb_nhi_ops icl_nhi_ops;
 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_BRIDGE	0x15ea
 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_4C_NHI		0x15eb
 #define PCI_DEVICE_ID_INTEL_TITAN_RIDGE_DD_BRIDGE	0x15ef
+#define PCI_DEVICE_ID_INTEL_ADL_NHI0			0x463e
+#define PCI_DEVICE_ID_INTEL_ADL_NHI1			0x466d
 #define PCI_DEVICE_ID_INTEL_ICL_NHI1			0x8a0d
 #define PCI_DEVICE_ID_INTEL_ICL_NHI0			0x8a17
 #define PCI_DEVICE_ID_INTEL_TGL_NHI0			0x9a1b
Signature · 1 line
2.30.2
maintainer Reviewed-by on the v1 series
#6 lore raw
In reply to Mika Westerberg
Quoted 23 lines · Mika Westerberg

Hi all,

This series adds support for Intel Alder Lake which is the successor of Tiger Lake. The integrated Thunderbolt/USB4 controller is pretty close to the one found in Tiger Lake too.

In addition there are few improvements for issues reported by Dan Carpenter and kernel test robot.

The series applies on top of thunderbolt.git/next.

Azhar Shaikh (1):
thunderbolt: Add support for Intel Alder Lake

Gil Fine (1):
thunderbolt: Poll 10ms for REG_FW_STS_NVM_AUTH_DONE to be set

Mika Westerberg (3):
thunderbolt: Bond lanes only when dual_link_port != NULL in alloc_dev_default()
thunderbolt: Add device links only when software connection manager is used
thunderbolt: No need to include <linux/acpi.h> in usb4_port.c

Quoted 8 lines
 drivers/thunderbolt/icm.c       | 20 ++++++----
 drivers/thunderbolt/nhi.c       | 71 ++-------------------------------
 drivers/thunderbolt/nhi.h       |  2 +
 drivers/thunderbolt/tb.c        | 67 +++++++++++++++++++++++++++++++
 drivers/thunderbolt/test.c      | 22 +++++-----
 drivers/thunderbolt/usb4_port.c |  1 -
 6 files changed, 97 insertions(+), 86 deletions(-)
author Applied
#7 lore raw
Quoted 34 lines · Yehezkel Bernat
Quoted 23 lines · Mika Westerberg

Hi all,

This series adds support for Intel Alder Lake which is the successor of Tiger Lake. The integrated Thunderbolt/USB4 controller is pretty close to the one found in Tiger Lake too.

In addition there are few improvements for issues reported by Dan Carpenter and kernel test robot.

The series applies on top of thunderbolt.git/next.

Azhar Shaikh (1):
thunderbolt: Add support for Intel Alder Lake

Gil Fine (1):
thunderbolt: Poll 10ms for REG_FW_STS_NVM_AUTH_DONE to be set

Mika Westerberg (3):
thunderbolt: Bond lanes only when dual_link_port != NULL in alloc_dev_default()
thunderbolt: Add device links only when software connection manager is used
thunderbolt: No need to include <linux/acpi.h> in usb4_port.c

Quoted 8 lines
 drivers/thunderbolt/icm.c       | 20 ++++++----
 drivers/thunderbolt/nhi.c       | 71 ++-------------------------------
 drivers/thunderbolt/nhi.h       |  2 +
 drivers/thunderbolt/tb.c        | 67 +++++++++++++++++++++++++++++++
 drivers/thunderbolt/test.c      | 22 +++++-----
 drivers/thunderbolt/usb4_port.c |  1 -
 6 files changed, 97 insertions(+), 86 deletions(-)
Quoted 1 line

Thanks!

Applied all to thunderbolt.git/next.