linux-usb.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma()
@ 2023-05-17  8:40 Mika Westerberg
  2023-05-17  8:40 ` [PATCH 2/7] thunderbolt: Log function name of the called quirk Mika Westerberg
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Mika Westerberg @ 2023-05-17  8:40 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
	Mika Westerberg

Ring 0 cannot be used for anything else than control channel messages.
For this reason add a check to tb_tunnel_alloc_dma() and fail if someone
tries to do that.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tunnel.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index 9099ae73e78f..dd3b5613ad2c 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -1452,6 +1452,10 @@ struct tb_tunnel *tb_tunnel_alloc_dma(struct tb *tb, struct tb_port *nhi,
 	struct tb_path *path;
 	int credits;
 
+	/* Ring 0 is reserved for control channel */
+	if (WARN_ON(!receive_ring || !transmit_ring))
+		return NULL;
+
 	if (receive_ring > 0)
 		npaths++;
 	if (transmit_ring > 0)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/7] thunderbolt: Log function name of the called quirk
  2023-05-17  8:40 [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() Mika Westerberg
@ 2023-05-17  8:40 ` Mika Westerberg
  2023-05-17  8:40 ` [PATCH 3/7] thunderbolt: Add debug log for link controller power quirk Mika Westerberg
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2023-05-17  8:40 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
	Mika Westerberg

This is useful when debugging whether a quirk has been matched or not.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/quirks.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/thunderbolt/quirks.c b/drivers/thunderbolt/quirks.c
index 1157b8869bcc..928689b66126 100644
--- a/drivers/thunderbolt/quirks.c
+++ b/drivers/thunderbolt/quirks.c
@@ -105,6 +105,7 @@ void tb_check_quirks(struct tb_switch *sw)
 		if (q->device && q->device != sw->device)
 			continue;
 
+		tb_sw_dbg(sw, "running %ps\n", q->hook);
 		q->hook(sw);
 	}
 }
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/7] thunderbolt: Add debug log for link controller power quirk
  2023-05-17  8:40 [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() Mika Westerberg
  2023-05-17  8:40 ` [PATCH 2/7] thunderbolt: Log function name of the called quirk Mika Westerberg
@ 2023-05-17  8:40 ` Mika Westerberg
  2023-05-17  8:41 ` [PATCH 4/7] thunderbolt: Allow specifying custom credits for DMA tunnels Mika Westerberg
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2023-05-17  8:40 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
	Mika Westerberg

Add a debug log to this quirk as well so we can see what quirks have
been applied when debugging.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/quirks.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/thunderbolt/quirks.c b/drivers/thunderbolt/quirks.c
index 928689b66126..854d84148850 100644
--- a/drivers/thunderbolt/quirks.c
+++ b/drivers/thunderbolt/quirks.c
@@ -10,6 +10,7 @@
 static void quirk_force_power_link(struct tb_switch *sw)
 {
 	sw->quirks |= QUIRK_FORCE_POWER_LINK_CONTROLLER;
+	tb_sw_dbg(sw, "forcing power to link controller\n");
 }
 
 static void quirk_dp_credit_allocation(struct tb_switch *sw)
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/7] thunderbolt: Allow specifying custom credits for DMA tunnels
  2023-05-17  8:40 [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() Mika Westerberg
  2023-05-17  8:40 ` [PATCH 2/7] thunderbolt: Log function name of the called quirk Mika Westerberg
  2023-05-17  8:40 ` [PATCH 3/7] thunderbolt: Add debug log for link controller power quirk Mika Westerberg
@ 2023-05-17  8:41 ` Mika Westerberg
  2023-05-17  8:41 ` [PATCH 5/7] thunderbolt: Add MODULE_DESCRIPTION Mika Westerberg
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2023-05-17  8:41 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
	Mika Westerberg

The default ones should be find but this allows the user to tweak the
credits to get more performance out of the P2P connection.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/tunnel.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index dd3b5613ad2c..3bf2628a5dcd 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -41,9 +41,14 @@
  * Number of credits we try to allocate for each DMA path if not limited
  * by the host router baMaxHI.
  */
-#define TB_DMA_CREDITS			14U
+#define TB_DMA_CREDITS			14
 /* Minimum number of credits for DMA path */
-#define TB_MIN_DMA_CREDITS		1U
+#define TB_MIN_DMA_CREDITS		1
+
+static unsigned int dma_credits = TB_DMA_CREDITS;
+module_param(dma_credits, uint, 0444);
+MODULE_PARM_DESC(dma_credits, "specify custom credits for DMA tunnels (default: "
+                __MODULE_STRING(TB_DMA_CREDITS) ")");
 
 static bool bw_alloc_mode = true;
 module_param(bw_alloc_mode, bool, 0444);
@@ -95,7 +100,7 @@ static unsigned int tb_available_credits(const struct tb_port *port,
 	pcie = tb_acpi_may_tunnel_pcie() ? sw->max_pcie_credits : 0;
 
 	if (tb_acpi_is_xdomain_allowed()) {
-		spare = min_not_zero(sw->max_dma_credits, TB_DMA_CREDITS);
+		spare = min_not_zero(sw->max_dma_credits, dma_credits);
 		/* Add some credits for potential second DMA tunnel */
 		spare += TB_MIN_DMA_CREDITS;
 	} else {
@@ -1472,7 +1477,7 @@ struct tb_tunnel *tb_tunnel_alloc_dma(struct tb *tb, struct tb_port *nhi,
 	tunnel->dst_port = dst;
 	tunnel->deinit = tb_dma_deinit;
 
-	credits = min_not_zero(TB_DMA_CREDITS, nhi->sw->max_dma_credits);
+	credits = min_not_zero(dma_credits, nhi->sw->max_dma_credits);
 
 	if (receive_ring > 0) {
 		path = tb_path_alloc(tb, dst, receive_path, nhi, receive_ring, 0,
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 5/7] thunderbolt: Add MODULE_DESCRIPTION
  2023-05-17  8:40 [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() Mika Westerberg
                   ` (2 preceding siblings ...)
  2023-05-17  8:41 ` [PATCH 4/7] thunderbolt: Allow specifying custom credits for DMA tunnels Mika Westerberg
@ 2023-05-17  8:41 ` Mika Westerberg
  2023-05-17  8:41 ` [PATCH 6/7] thunderbolt: dma_test: Update MODULE_DESCRIPTION Mika Westerberg
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2023-05-17  8:41 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
	Mika Westerberg

Add description about the driver to the module. No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/nhi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c
index d76e923fbc6a..e5a8f9861f9b 100644
--- a/drivers/thunderbolt/nhi.c
+++ b/drivers/thunderbolt/nhi.c
@@ -1464,6 +1464,7 @@ static struct pci_device_id nhi_ids[] = {
 };
 
 MODULE_DEVICE_TABLE(pci, nhi_ids);
+MODULE_DESCRIPTION("Thunderbolt/USB4 core driver");
 MODULE_LICENSE("GPL");
 
 static struct pci_driver nhi_driver = {
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 6/7] thunderbolt: dma_test: Update MODULE_DESCRIPTION
  2023-05-17  8:40 [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() Mika Westerberg
                   ` (3 preceding siblings ...)
  2023-05-17  8:41 ` [PATCH 5/7] thunderbolt: Add MODULE_DESCRIPTION Mika Westerberg
@ 2023-05-17  8:41 ` Mika Westerberg
  2023-05-17  8:41 ` [PATCH 7/7] thunderbolt: Drop retimer vendor check Mika Westerberg
  2023-05-24  6:42 ` [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() Mika Westerberg
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2023-05-17  8:41 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
	Mika Westerberg

Make the description match the core driver and the networking with
Thunderbolt/USB4 prefix. No functional changes.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/dma_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/thunderbolt/dma_test.c b/drivers/thunderbolt/dma_test.c
index 14bb6dec6c4b..58496f889d03 100644
--- a/drivers/thunderbolt/dma_test.c
+++ b/drivers/thunderbolt/dma_test.c
@@ -756,5 +756,5 @@ module_exit(dma_test_exit);
 
 MODULE_AUTHOR("Isaac Hazan <isaac.hazan@intel.com>");
 MODULE_AUTHOR("Mika Westerberg <mika.westerberg@linux.intel.com>");
-MODULE_DESCRIPTION("DMA traffic test driver");
+MODULE_DESCRIPTION("Thunderbolt/USB4 DMA traffic test driver");
 MODULE_LICENSE("GPL v2");
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 7/7] thunderbolt: Drop retimer vendor check
  2023-05-17  8:40 [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() Mika Westerberg
                   ` (4 preceding siblings ...)
  2023-05-17  8:41 ` [PATCH 6/7] thunderbolt: dma_test: Update MODULE_DESCRIPTION Mika Westerberg
@ 2023-05-17  8:41 ` Mika Westerberg
  2023-05-24  6:42 ` [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() Mika Westerberg
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2023-05-17  8:41 UTC (permalink / raw)
  To: linux-usb
  Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever,
	Mika Westerberg

This is not needed anymore as we already handle unknown vendor in NVM
functions.

Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
---
 drivers/thunderbolt/retimer.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/thunderbolt/retimer.c b/drivers/thunderbolt/retimer.c
index 9cc28197dbc4..ccc2f0e7adba 100644
--- a/drivers/thunderbolt/retimer.c
+++ b/drivers/thunderbolt/retimer.c
@@ -341,12 +341,6 @@ static int tb_retimer_add(struct tb_port *port, u8 index, u32 auth_status)
 		return ret;
 	}
 
-	if (vendor != PCI_VENDOR_ID_INTEL && vendor != 0x8087) {
-		tb_port_info(port, "retimer NVM format of vendor %#x is not supported\n",
-			     vendor);
-		return -EOPNOTSUPP;
-	}
-
 	/*
 	 * Check that it supports NVM operations. If not then don't add
 	 * the device at all.
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma()
  2023-05-17  8:40 [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() Mika Westerberg
                   ` (5 preceding siblings ...)
  2023-05-17  8:41 ` [PATCH 7/7] thunderbolt: Drop retimer vendor check Mika Westerberg
@ 2023-05-24  6:42 ` Mika Westerberg
  6 siblings, 0 replies; 8+ messages in thread
From: Mika Westerberg @ 2023-05-24  6:42 UTC (permalink / raw)
  To: linux-usb; +Cc: Yehezkel Bernat, Michael Jamet, Lukas Wunner, Andreas Noever

On Wed, May 17, 2023 at 11:40:57AM +0300, Mika Westerberg wrote:
> Ring 0 cannot be used for anything else than control channel messages.
> For this reason add a check to tb_tunnel_alloc_dma() and fail if someone
> tries to do that.
> 
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>

All applied to thunderbolt.git/next.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-05-24  6:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-17  8:40 [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() Mika Westerberg
2023-05-17  8:40 ` [PATCH 2/7] thunderbolt: Log function name of the called quirk Mika Westerberg
2023-05-17  8:40 ` [PATCH 3/7] thunderbolt: Add debug log for link controller power quirk Mika Westerberg
2023-05-17  8:41 ` [PATCH 4/7] thunderbolt: Allow specifying custom credits for DMA tunnels Mika Westerberg
2023-05-17  8:41 ` [PATCH 5/7] thunderbolt: Add MODULE_DESCRIPTION Mika Westerberg
2023-05-17  8:41 ` [PATCH 6/7] thunderbolt: dma_test: Update MODULE_DESCRIPTION Mika Westerberg
2023-05-17  8:41 ` [PATCH 7/7] thunderbolt: Drop retimer vendor check Mika Westerberg
2023-05-24  6:42 ` [PATCH 1/7] thunderbolt: Check for ring 0 in tb_tunnel_alloc_dma() 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).