* [PATCH 0/3] thunderbolt: Host router reset improvements
@ 2024-02-06 13:03 Mika Westerberg
2024-02-06 13:03 ` [PATCH 1/3] thunderbolt: Reset only non-USB4 host routers in resume Mika Westerberg
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Mika Westerberg @ 2024-02-06 13:03 UTC (permalink / raw)
To: linux-usb
Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
Sanath S, Mario Limonciello, Mika Westerberg
Hi all,
This series improves the host router reset support for both USB4 v1 and
v2 routers.
Mika Westerberg (3):
thunderbolt: Reset only non-USB4 host routers in resume
thunderbolt: Skip discovery also in USB4 v2 host
thunderbolt: Correct typo in host_reset parameter
drivers/thunderbolt/nhi.c | 22 +++++++---------------
drivers/thunderbolt/tb.c | 19 ++++++++++++++-----
2 files changed, 21 insertions(+), 20 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/3] thunderbolt: Reset only non-USB4 host routers in resume
2024-02-06 13:03 [PATCH 0/3] thunderbolt: Host router reset improvements Mika Westerberg
@ 2024-02-06 13:03 ` Mika Westerberg
2024-02-06 13:03 ` [PATCH 2/3] thunderbolt: Skip discovery also in USB4 v2 host Mika Westerberg
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2024-02-06 13:03 UTC (permalink / raw)
To: linux-usb
Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
Sanath S, Mario Limonciello, Mika Westerberg
There is no need to reset the USB4 host routers on resume because they
are reset already and this may cause problems if the link does not come
up soon enough. For this reason limit this to happen in non-USB4 host
routers only (that's Apple systems with Intel Thunderbolt controllers).
Fixes: 59a54c5f3dbd ("thunderbolt: Reset topology created by the boot firmware")
Cc: Sanath S <Sanath.S@amd.com>
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/tb.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index 9a261560d0f4..f127088b6ebd 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -2710,8 +2710,12 @@ static int tb_resume_noirq(struct tb *tb)
tb_dbg(tb, "resuming...\n");
- /* remove any pci devices the firmware might have setup */
- tb_switch_reset(tb->root_switch);
+ /*
+ * For non-USB4 hosts (Apple systems) remove any PCIe devices
+ * the firmware might have setup.
+ */
+ if (!tb_switch_is_usb4(tb->root_switch))
+ tb_switch_reset(tb->root_switch);
tb_switch_resume(tb->root_switch);
tb_free_invalid_tunnels(tb);
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/3] thunderbolt: Skip discovery also in USB4 v2 host
2024-02-06 13:03 [PATCH 0/3] thunderbolt: Host router reset improvements Mika Westerberg
2024-02-06 13:03 ` [PATCH 1/3] thunderbolt: Reset only non-USB4 host routers in resume Mika Westerberg
@ 2024-02-06 13:03 ` Mika Westerberg
2024-02-06 13:03 ` [PATCH 3/3] thunderbolt: Correct typo in host_reset parameter Mika Westerberg
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2024-02-06 13:03 UTC (permalink / raw)
To: linux-usb
Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
Sanath S, Mario Limonciello, Mika Westerberg
If the host router is reset, there is no point running discovery as the
links are down. Furthermore this prevents CL-state enabling. For this
reason skip discovery in USB4 v2 host the same way we do with USB4 v1.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/nhi.c | 20 ++++++--------------
drivers/thunderbolt/tb.c | 11 ++++++++---
2 files changed, 14 insertions(+), 17 deletions(-)
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index e8a4623dc531..91e26b982b0b 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -1221,7 +1221,7 @@ static void nhi_check_iommu(struct tb_nhi *nhi)
str_enabled_disabled(port_ok));
}
-static bool nhi_reset(struct tb_nhi *nhi)
+static void nhi_reset(struct tb_nhi *nhi)
{
ktime_t timeout;
u32 val;
@@ -1229,11 +1229,11 @@ static bool nhi_reset(struct tb_nhi *nhi)
val = ioread32(nhi->iobase + REG_CAPS);
/* Reset only v2 and later routers */
if (FIELD_GET(REG_CAPS_VERSION_MASK, val) < REG_CAPS_VERSION_2)
- return false;
+ return;
if (!host_reset) {
dev_dbg(&nhi->pdev->dev, "skipping host router reset\n");
- return false;
+ return;
}
iowrite32(REG_RESET_HRR, nhi->iobase + REG_RESET);
@@ -1244,14 +1244,12 @@ static bool nhi_reset(struct tb_nhi *nhi)
val = ioread32(nhi->iobase + REG_RESET);
if (!(val & REG_RESET_HRR)) {
dev_warn(&nhi->pdev->dev, "host router reset successful\n");
- return true;
+ return;
}
usleep_range(10, 20);
} while (ktime_before(ktime_get(), timeout));
dev_warn(&nhi->pdev->dev, "timeout resetting host router\n");
-
- return false;
}
static int nhi_init_msi(struct tb_nhi *nhi)
@@ -1333,7 +1331,6 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
struct device *dev = &pdev->dev;
struct tb_nhi *nhi;
struct tb *tb;
- bool reset;
int res;
if (!nhi_imr_valid(pdev))
@@ -1367,12 +1364,7 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
nhi_check_quirks(nhi);
nhi_check_iommu(nhi);
-
- /*
- * Only USB4 v2 hosts support host reset so if we already did
- * that then don't do it again when the domain is initialized.
- */
- reset = nhi_reset(nhi) ? false : host_reset;
+ nhi_reset(nhi);
res = nhi_init_msi(nhi);
if (res)
@@ -1399,7 +1391,7 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id)
dev_dbg(dev, "NHI initialized, starting thunderbolt\n");
- res = tb_domain_add(tb, reset);
+ res = tb_domain_add(tb, host_reset);
if (res) {
/*
* At this point the RX/TX rings might already have been
diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c
index f127088b6ebd..64dd22e1f5b2 100644
--- a/drivers/thunderbolt/tb.c
+++ b/drivers/thunderbolt/tb.c
@@ -2584,6 +2584,7 @@ static int tb_scan_finalize_switch(struct device *dev, void *data)
static int tb_start(struct tb *tb, bool reset)
{
struct tb_cm *tcm = tb_priv(tb);
+ bool discover = true;
int ret;
tb->root_switch = tb_switch_alloc(tb, &tb->dev, 0);
@@ -2629,9 +2630,13 @@ static int tb_start(struct tb *tb, bool reset)
* reset the ports to handle it as new hotplug for USB4 v1
* routers (for USB4 v2 and beyond we already do host reset).
*/
- if (reset && usb4_switch_version(tb->root_switch) == 1) {
- tb_switch_reset(tb->root_switch);
- } else {
+ if (reset && tb_switch_is_usb4(tb->root_switch)) {
+ discover = false;
+ if (usb4_switch_version(tb->root_switch) == 1)
+ tb_switch_reset(tb->root_switch);
+ }
+
+ if (discover) {
/* Full scan to discover devices added before the driver was loaded. */
tb_scan_switch(tb->root_switch);
/* Find out tunnels created by the boot firmware */
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 3/3] thunderbolt: Correct typo in host_reset parameter
2024-02-06 13:03 [PATCH 0/3] thunderbolt: Host router reset improvements Mika Westerberg
2024-02-06 13:03 ` [PATCH 1/3] thunderbolt: Reset only non-USB4 host routers in resume Mika Westerberg
2024-02-06 13:03 ` [PATCH 2/3] thunderbolt: Skip discovery also in USB4 v2 host Mika Westerberg
@ 2024-02-06 13:03 ` Mika Westerberg
2024-02-06 15:42 ` [PATCH 0/3] thunderbolt: Host router reset improvements Mario Limonciello
2024-02-13 9:11 ` Mika Westerberg
4 siblings, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2024-02-06 13:03 UTC (permalink / raw)
To: linux-usb
Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
Sanath S, Mario Limonciello, Mika Westerberg
It should say USB4 now since we reset by default all USB4 host routers.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
drivers/thunderbolt/nhi.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index 91e26b982b0b..7af2642b97cb 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -48,7 +48,7 @@
static bool host_reset = true;
module_param(host_reset, bool, 0444);
-MODULE_PARM_DESC(host_reset, "reset USBv2 host router (default: true)");
+MODULE_PARM_DESC(host_reset, "reset USB4 host router (default: true)");
static int ring_interrupt_index(const struct tb_ring *ring)
{
--
2.43.0
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] thunderbolt: Host router reset improvements
2024-02-06 13:03 [PATCH 0/3] thunderbolt: Host router reset improvements Mika Westerberg
` (2 preceding siblings ...)
2024-02-06 13:03 ` [PATCH 3/3] thunderbolt: Correct typo in host_reset parameter Mika Westerberg
@ 2024-02-06 15:42 ` Mario Limonciello
2024-02-13 9:11 ` Mika Westerberg
4 siblings, 0 replies; 6+ messages in thread
From: Mario Limonciello @ 2024-02-06 15:42 UTC (permalink / raw)
To: Mika Westerberg, linux-usb
Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
Sanath S
On 2/6/2024 07:03, Mika Westerberg wrote:
> Hi all,
>
> This series improves the host router reset support for both USB4 v1 and
> v2 routers.
>
> Mika Westerberg (3):
> thunderbolt: Reset only non-USB4 host routers in resume
> thunderbolt: Skip discovery also in USB4 v2 host
> thunderbolt: Correct typo in host_reset parameter
>
> drivers/thunderbolt/nhi.c | 22 +++++++---------------
> drivers/thunderbolt/tb.c | 19 ++++++++++++++-----
> 2 files changed, 21 insertions(+), 20 deletions(-)
>
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/3] thunderbolt: Host router reset improvements
2024-02-06 13:03 [PATCH 0/3] thunderbolt: Host router reset improvements Mika Westerberg
` (3 preceding siblings ...)
2024-02-06 15:42 ` [PATCH 0/3] thunderbolt: Host router reset improvements Mario Limonciello
@ 2024-02-13 9:11 ` Mika Westerberg
4 siblings, 0 replies; 6+ messages in thread
From: Mika Westerberg @ 2024-02-13 9:11 UTC (permalink / raw)
To: linux-usb
Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
Sanath S, Mario Limonciello
On Tue, Feb 06, 2024 at 03:03:51PM +0200, Mika Westerberg wrote:
> Hi all,
>
> This series improves the host router reset support for both USB4 v1 and
> v2 routers.
>
> Mika Westerberg (3):
> thunderbolt: Reset only non-USB4 host routers in resume
> thunderbolt: Skip discovery also in USB4 v2 host
> thunderbolt: Correct typo in host_reset parameter
All applied to thunderbolt.git/next.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-02-13 9:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-06 13:03 [PATCH 0/3] thunderbolt: Host router reset improvements Mika Westerberg
2024-02-06 13:03 ` [PATCH 1/3] thunderbolt: Reset only non-USB4 host routers in resume Mika Westerberg
2024-02-06 13:03 ` [PATCH 2/3] thunderbolt: Skip discovery also in USB4 v2 host Mika Westerberg
2024-02-06 13:03 ` [PATCH 3/3] thunderbolt: Correct typo in host_reset parameter Mika Westerberg
2024-02-06 15:42 ` [PATCH 0/3] thunderbolt: Host router reset improvements Mario Limonciello
2024-02-13 9:11 ` Mika Westerberg
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).