From: Mika Westerberg <mika.westerberg@linux.intel.com>
To: linux-usb@vger.kernel.org
Cc: Michael Jamet <michael.jamet@intel.com>,
Yehezkel Bernat <YehezkelShB@gmail.com>,
Andreas Noever <andreas.noever@gmail.com>,
Isaac Hazan <isaac.hazan@intel.com>,
Lukas Wunner <lukas@wunner.de>,
"David S . Miller" <davem@davemloft.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
netdev@vger.kernel.org
Subject: [PATCH v2 07/10] thunderbolt: Make it possible to allocate one directional DMA tunnel
Date: Tue, 10 Nov 2020 12:19:54 +0300 [thread overview]
Message-ID: <20201110091957.17472-8-mika.westerberg@linux.intel.com> (raw)
In-Reply-To: <20201110091957.17472-1-mika.westerberg@linux.intel.com>
With DMA tunnels it is possible that the service using it does not
require bi-directional paths so make RX and TX optional (but of course
one of them needs to be set).
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Yehezkel Bernat <YehezkelShB@gmail.com>
---
drivers/thunderbolt/tunnel.c | 50 ++++++++++++++++++++++--------------
1 file changed, 31 insertions(+), 19 deletions(-)
diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c
index 829b6ccdd5d4..dcdf9c7a9cae 100644
--- a/drivers/thunderbolt/tunnel.c
+++ b/drivers/thunderbolt/tunnel.c
@@ -34,9 +34,6 @@
#define TB_DP_AUX_PATH_OUT 1
#define TB_DP_AUX_PATH_IN 2
-#define TB_DMA_PATH_OUT 0
-#define TB_DMA_PATH_IN 1
-
static const char * const tb_tunnel_names[] = { "PCI", "DP", "DMA", "USB3" };
#define __TB_TUNNEL_PRINT(level, tunnel, fmt, arg...) \
@@ -829,10 +826,10 @@ static void tb_dma_init_path(struct tb_path *path, unsigned int isb,
* @nhi: Host controller port
* @dst: Destination null port which the other domain is connected to
* @transmit_ring: NHI ring number used to send packets towards the
- * other domain
+ * other domain. Set to %0 if TX path is not needed.
* @transmit_path: HopID used for transmitting packets
* @receive_ring: NHI ring number used to receive packets from the
- * other domain
+ * other domain. Set to %0 if RX path is not needed.
* @reveive_path: HopID used for receiving packets
*
* Return: Returns a tb_tunnel on success or NULL on failure.
@@ -843,10 +840,19 @@ struct tb_tunnel *tb_tunnel_alloc_dma(struct tb *tb, struct tb_port *nhi,
int receive_path)
{
struct tb_tunnel *tunnel;
+ size_t npaths = 0, i = 0;
struct tb_path *path;
u32 credits;
- tunnel = tb_tunnel_alloc(tb, 2, TB_TUNNEL_DMA);
+ if (receive_ring)
+ npaths++;
+ if (transmit_ring)
+ npaths++;
+
+ if (WARN_ON(!npaths))
+ return NULL;
+
+ tunnel = tb_tunnel_alloc(tb, npaths, TB_TUNNEL_DMA);
if (!tunnel)
return NULL;
@@ -856,22 +862,28 @@ struct tb_tunnel *tb_tunnel_alloc_dma(struct tb *tb, struct tb_port *nhi,
credits = tb_dma_credits(nhi);
- path = tb_path_alloc(tb, dst, receive_path, nhi, receive_ring, 0, "DMA RX");
- if (!path) {
- tb_tunnel_free(tunnel);
- return NULL;
+ if (receive_ring) {
+ path = tb_path_alloc(tb, dst, receive_path, nhi, receive_ring, 0,
+ "DMA RX");
+ if (!path) {
+ tb_tunnel_free(tunnel);
+ return NULL;
+ }
+ tb_dma_init_path(path, TB_PATH_NONE, TB_PATH_SOURCE | TB_PATH_INTERNAL,
+ credits);
+ tunnel->paths[i++] = path;
}
- tb_dma_init_path(path, TB_PATH_NONE, TB_PATH_SOURCE | TB_PATH_INTERNAL,
- credits);
- tunnel->paths[TB_DMA_PATH_IN] = path;
- path = tb_path_alloc(tb, nhi, transmit_ring, dst, transmit_path, 0, "DMA TX");
- if (!path) {
- tb_tunnel_free(tunnel);
- return NULL;
+ if (transmit_ring) {
+ path = tb_path_alloc(tb, nhi, transmit_ring, dst, transmit_path, 0,
+ "DMA TX");
+ if (!path) {
+ tb_tunnel_free(tunnel);
+ return NULL;
+ }
+ tb_dma_init_path(path, TB_PATH_SOURCE, TB_PATH_ALL, credits);
+ tunnel->paths[i++] = path;
}
- tb_dma_init_path(path, TB_PATH_SOURCE, TB_PATH_ALL, credits);
- tunnel->paths[TB_DMA_PATH_OUT] = path;
return tunnel;
}
--
2.28.0
next prev parent reply other threads:[~2020-11-10 9:20 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-10 9:19 [PATCH v2 00/10] thunderbolt: Add DMA traffic test driver Mika Westerberg
2020-11-10 9:19 ` [PATCH v2 01/10] thunderbolt: Do not clear USB4 router protocol adapter IFC and ISE bits Mika Westerberg
2020-11-10 9:19 ` [PATCH v2 02/10] thunderbolt: Find XDomain by route instead of UUID Mika Westerberg
2020-11-10 9:19 ` [PATCH v2 03/10] thunderbolt: Create XDomain devices for loops back to the host Mika Westerberg
2020-11-10 9:19 ` [PATCH v2 04/10] thunderbolt: Add link_speed and link_width to XDomain Mika Westerberg
2020-11-10 9:19 ` [PATCH v2 05/10] thunderbolt: Add functions for enabling and disabling lane bonding on XDomain Mika Westerberg
2020-11-10 9:19 ` [PATCH v2 06/10] thunderbolt: Create debugfs directory automatically for services Mika Westerberg
2020-11-10 9:19 ` Mika Westerberg [this message]
2020-11-10 9:19 ` [PATCH v2 08/10] thunderbolt: Add support for end-to-end flow control Mika Westerberg
2020-11-10 9:19 ` [PATCH v2 09/10] thunderbolt: Add DMA traffic test driver Mika Westerberg
2020-11-10 9:19 ` [PATCH v2 10/10] MAINTAINERS: Add Isaac as maintainer of Thunderbolt " Mika Westerberg
2020-11-10 9:30 ` [PATCH v2 00/10] thunderbolt: Add " Greg Kroah-Hartman
2020-11-11 7:23 ` Mika Westerberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201110091957.17472-8-mika.westerberg@linux.intel.com \
--to=mika.westerberg@linux.intel.com \
--cc=YehezkelShB@gmail.com \
--cc=andreas.noever@gmail.com \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=isaac.hazan@intel.com \
--cc=linux-usb@vger.kernel.org \
--cc=lukas@wunner.de \
--cc=michael.jamet@intel.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).