From patchwork Tue Mar 8 08:49:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1602807 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=Wsru/xtB; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KCTXQ0DCjz9sGG for ; Tue, 8 Mar 2022 19:49:26 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nRVWw-0001zW-FL; Tue, 08 Mar 2022 08:49:18 +0000 Received: from mail-pl1-f176.google.com ([209.85.214.176]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nRVWs-0001yY-QZ for kernel-team@lists.ubuntu.com; Tue, 08 Mar 2022 08:49:15 +0000 Received: by mail-pl1-f176.google.com with SMTP id t19so12887069plr.5 for ; Tue, 08 Mar 2022 00:49:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qow2EuTN3uilqZvLolHTMpqlpqhQ1z5cZfswvyRPyRI=; b=Wsru/xtBLbFt2QDydMYhtImamtVRNQuZ2x3N8WMFWf+HVwFApoJwrjpcZuK2kEifMQ pKL4G6eK0u5I9BngVB1O75FdoyteIQlH5h2AY/kfzpsmzNtfo/KDYYVPyHpP7QHcVgw9 t4ny7safmLHUq6W4agQ87vQEFtKU9YM478oEhh3MzH+AUuXthLoi+TU7LMov/xrP4HBx Xs/CLkgJBb11yOQyqdJu5G1WpKUZukaPbSDjXNFslV2v9AbdxrJGU5nbCD35N3bOg2y8 4GJEa78c0aZ5po+dQ64wtmbk2z9mRZ1uO1nksP1jvUUcWXexZPBqUOhxAyXyuca5pbMX 92LA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Qow2EuTN3uilqZvLolHTMpqlpqhQ1z5cZfswvyRPyRI=; b=liCJMc/E185Sja6WEQ70j/3/4V47Ez7czkoHj9lXPOpQsJ7uEJJMdQh8oBan52S30h cbx51fL2Y3gAkMZsjUleUumoSSmUEwPXD9YjsJwQgEPk6zjz8QtRBg2NpxKRrHqPVnoe yhzf6IuGwQWtWSy3vbuBsFxu1eHvDtcuOnHFJscAjFpDIEx8QBfWQwRCx2D1W15oUmi8 Sr6n0hqmB8dAM0KqGQVLxXiFy6EDFt+iBLx0tSn86uzRMAZ7n7Z9MUjJuvjRiazbhEf6 4I3vNs1hCuzeCVF/McwRc84gsqHpKd8CUEVqb29pW+45pGem36Wm3EmxkIuc+fV/gJ0a k5cw== X-Gm-Message-State: AOAM533TtXxS+o5hfNI9CTLsEB24WqFGMOYNUeXJHG5MWRw2XZwZg3A+ iYFxoYSxsiEDTXxLf1Y+DRoaGIInD1I= X-Google-Smtp-Source: ABdhPJxKcNiV9F/2/Pkf6FFYg8rH9Vn6zqQqgEpLFygMS3Zhj8O3w57pOXB9ISIYtqNPh6raP5AUMw== X-Received: by 2002:a17:902:ce81:b0:151:a817:c077 with SMTP id f1-20020a170902ce8100b00151a817c077mr16232406plg.138.1646729352252; Tue, 08 Mar 2022 00:49:12 -0800 (PST) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id 23-20020a17090a0b9700b001b8f602eaeasm1950678pjr.53.2022.03.08.00.49.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 00:49:11 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 1/5][SRU][J] thunderbolt: Tear down existing tunnels when resuming from hibernate Date: Tue, 8 Mar 2022 16:49:05 +0800 Message-Id: <20220308084909.2043184-2-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308084909.2043184-1-acelan.kao@canonical.com> References: <20220308084909.2043184-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.214.176; envelope-from=acelan@gmail.com; helo=mail-pl1-f176.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mika Westerberg BugLink: https://bugs.launchpad.net/bugs/1955016 If the boot firmware implements connection manager of its own it may not create the paths in the same way or order we do. For example it may create first PCIe tunnel and then USB3 tunnel. When we restore our tunnels (first de-activating them) we may be doing that over completely different tunnels and that leaves them possibly non-functional. For this reason we re-use the tunnel discovery functionality and find out all the existing tunnels, and tear them down. Once that is done we can restore our tunnels. Signed-off-by: Mika Westerberg (cherry picked from commit 43bddb26e20af916249b5318200cfe1734c1700c) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/thunderbolt/path.c | 42 +++++++++++++--------- drivers/thunderbolt/tb.c | 68 +++++++++++++++++++++++++++--------- drivers/thunderbolt/tb.h | 5 ++- drivers/thunderbolt/tunnel.c | 27 ++++++++------ drivers/thunderbolt/tunnel.h | 9 +++-- 5 files changed, 104 insertions(+), 47 deletions(-) diff --git a/drivers/thunderbolt/path.c b/drivers/thunderbolt/path.c index 564e2f42cebd..299712accfe9 100644 --- a/drivers/thunderbolt/path.c +++ b/drivers/thunderbolt/path.c @@ -85,11 +85,12 @@ static int tb_path_find_src_hopid(struct tb_port *src, * @dst_hopid: HopID to the @dst (%-1 if don't care) * @last: Last port is filled here if not %NULL * @name: Name of the path + * @alloc_hopid: Allocate HopIDs for the ports * * Follows a path starting from @src and @src_hopid to the last output - * port of the path. Allocates HopIDs for the visited ports. Call - * tb_path_free() to release the path and allocated HopIDs when the path - * is not needed anymore. + * port of the path. Allocates HopIDs for the visited ports (if + * @alloc_hopid is true). Call tb_path_free() to release the path and + * allocated HopIDs when the path is not needed anymore. * * Note function discovers also incomplete paths so caller should check * that the @dst port is the expected one. If it is not, the path can be @@ -99,7 +100,8 @@ static int tb_path_find_src_hopid(struct tb_port *src, */ struct tb_path *tb_path_discover(struct tb_port *src, int src_hopid, struct tb_port *dst, int dst_hopid, - struct tb_port **last, const char *name) + struct tb_port **last, const char *name, + bool alloc_hopid) { struct tb_port *out_port; struct tb_regs_hop hop; @@ -156,6 +158,7 @@ struct tb_path *tb_path_discover(struct tb_port *src, int src_hopid, path->tb = src->sw->tb; path->path_length = num_hops; path->activated = true; + path->alloc_hopid = alloc_hopid; path->hops = kcalloc(num_hops, sizeof(*path->hops), GFP_KERNEL); if (!path->hops) { @@ -177,13 +180,14 @@ struct tb_path *tb_path_discover(struct tb_port *src, int src_hopid, goto err; } - if (tb_port_alloc_in_hopid(p, h, h) < 0) + if (alloc_hopid && tb_port_alloc_in_hopid(p, h, h) < 0) goto err; out_port = &sw->ports[hop.out_port]; next_hop = hop.next_hop; - if (tb_port_alloc_out_hopid(out_port, next_hop, next_hop) < 0) { + if (alloc_hopid && + tb_port_alloc_out_hopid(out_port, next_hop, next_hop) < 0) { tb_port_release_in_hopid(p, h); goto err; } @@ -263,6 +267,8 @@ struct tb_path *tb_path_alloc(struct tb *tb, struct tb_port *src, int src_hopid, return NULL; } + path->alloc_hopid = true; + in_hopid = src_hopid; out_port = NULL; @@ -345,17 +351,19 @@ struct tb_path *tb_path_alloc(struct tb *tb, struct tb_port *src, int src_hopid, */ void tb_path_free(struct tb_path *path) { - int i; - - for (i = 0; i < path->path_length; i++) { - const struct tb_path_hop *hop = &path->hops[i]; - - if (hop->in_port) - tb_port_release_in_hopid(hop->in_port, - hop->in_hop_index); - if (hop->out_port) - tb_port_release_out_hopid(hop->out_port, - hop->next_hop_index); + if (path->alloc_hopid) { + int i; + + for (i = 0; i < path->path_length; i++) { + const struct tb_path_hop *hop = &path->hops[i]; + + if (hop->in_port) + tb_port_release_in_hopid(hop->in_port, + hop->in_hop_index); + if (hop->out_port) + tb_port_release_out_hopid(hop->out_port, + hop->next_hop_index); + } } kfree(path->hops); diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index 2897a77d44c3..a231191b06c6 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -105,10 +105,11 @@ static void tb_remove_dp_resources(struct tb_switch *sw) } } -static void tb_discover_tunnels(struct tb_switch *sw) +static void tb_switch_discover_tunnels(struct tb_switch *sw, + struct list_head *list, + bool alloc_hopids) { struct tb *tb = sw->tb; - struct tb_cm *tcm = tb_priv(tb); struct tb_port *port; tb_switch_for_each_port(sw, port) { @@ -116,24 +117,41 @@ static void tb_discover_tunnels(struct tb_switch *sw) switch (port->config.type) { case TB_TYPE_DP_HDMI_IN: - tunnel = tb_tunnel_discover_dp(tb, port); + tunnel = tb_tunnel_discover_dp(tb, port, alloc_hopids); break; case TB_TYPE_PCIE_DOWN: - tunnel = tb_tunnel_discover_pci(tb, port); + tunnel = tb_tunnel_discover_pci(tb, port, alloc_hopids); break; case TB_TYPE_USB3_DOWN: - tunnel = tb_tunnel_discover_usb3(tb, port); + tunnel = tb_tunnel_discover_usb3(tb, port, alloc_hopids); break; default: break; } - if (!tunnel) - continue; + if (tunnel) + list_add_tail(&tunnel->list, list); + } + tb_switch_for_each_port(sw, port) { + if (tb_port_has_remote(port)) { + tb_switch_discover_tunnels(port->remote->sw, list, + alloc_hopids); + } + } +} + +static void tb_discover_tunnels(struct tb *tb) +{ + struct tb_cm *tcm = tb_priv(tb); + struct tb_tunnel *tunnel; + + tb_switch_discover_tunnels(tb->root_switch, &tcm->tunnel_list, true); + + list_for_each_entry(tunnel, &tcm->tunnel_list, list) { if (tb_tunnel_is_pci(tunnel)) { struct tb_switch *parent = tunnel->dst_port->sw; @@ -146,13 +164,6 @@ static void tb_discover_tunnels(struct tb_switch *sw) pm_runtime_get_sync(&tunnel->src_port->sw->dev); pm_runtime_get_sync(&tunnel->dst_port->sw->dev); } - - list_add_tail(&tunnel->list, &tcm->tunnel_list); - } - - tb_switch_for_each_port(sw, port) { - if (tb_port_has_remote(port)) - tb_discover_tunnels(port->remote->sw); } } @@ -1369,7 +1380,7 @@ static int tb_start(struct tb *tb) /* 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 */ - tb_discover_tunnels(tb->root_switch); + tb_discover_tunnels(tb); /* * If the boot firmware did not create USB 3.x tunnels create them * now for the whole topology. @@ -1429,6 +1440,8 @@ static int tb_resume_noirq(struct tb *tb) { struct tb_cm *tcm = tb_priv(tb); struct tb_tunnel *tunnel, *n; + unsigned int usb3_delay = 0; + LIST_HEAD(tunnels); tb_dbg(tb, "resuming...\n"); @@ -1439,8 +1452,31 @@ static int tb_resume_noirq(struct tb *tb) tb_free_invalid_tunnels(tb); tb_free_unplugged_children(tb->root_switch); tb_restore_children(tb->root_switch); - list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) + + /* + * If we get here from suspend to disk the boot firmware or the + * restore kernel might have created tunnels of its own. Since + * we cannot be sure they are usable for us we find and tear + * them down. + */ + tb_switch_discover_tunnels(tb->root_switch, &tunnels, false); + list_for_each_entry_safe_reverse(tunnel, n, &tunnels, list) { + if (tb_tunnel_is_usb3(tunnel)) + usb3_delay = 500; + tb_tunnel_deactivate(tunnel); + tb_tunnel_free(tunnel); + } + + /* Re-create our tunnels now */ + list_for_each_entry_safe(tunnel, n, &tcm->tunnel_list, list) { + /* USB3 requires delay before it can be re-activated */ + if (tb_tunnel_is_usb3(tunnel)) { + msleep(usb3_delay); + /* Only need to do it once */ + usb3_delay = 0; + } tb_tunnel_restart(tunnel); + } if (!list_empty(&tcm->tunnel_list)) { /* * the pcie links need some time to get going. diff --git a/drivers/thunderbolt/tb.h b/drivers/thunderbolt/tb.h index 725104c83e3d..3fae40670b72 100644 --- a/drivers/thunderbolt/tb.h +++ b/drivers/thunderbolt/tb.h @@ -354,6 +354,7 @@ enum tb_path_port { * when deactivating this path * @hops: Path hops * @path_length: How many hops the path uses + * @alloc_hopid: Does this path consume port HopID * * A path consists of a number of hops (see &struct tb_path_hop). To * establish a PCIe tunnel two paths have to be created between the two @@ -374,6 +375,7 @@ struct tb_path { bool clear_fc; struct tb_path_hop *hops; int path_length; + bool alloc_hopid; }; /* HopIDs 0-7 are reserved by the Thunderbolt protocol */ @@ -957,7 +959,8 @@ int tb_dp_port_enable(struct tb_port *port, bool enable); struct tb_path *tb_path_discover(struct tb_port *src, int src_hopid, struct tb_port *dst, int dst_hopid, - struct tb_port **last, const char *name); + struct tb_port **last, const char *name, + bool alloc_hopid); struct tb_path *tb_path_alloc(struct tb *tb, struct tb_port *src, int src_hopid, struct tb_port *dst, int dst_hopid, int link_nr, const char *name); diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c index bb5cc480fc9a..a473cc7d9a8d 100644 --- a/drivers/thunderbolt/tunnel.c +++ b/drivers/thunderbolt/tunnel.c @@ -207,12 +207,14 @@ static int tb_pci_init_path(struct tb_path *path) * tb_tunnel_discover_pci() - Discover existing PCIe tunnels * @tb: Pointer to the domain structure * @down: PCIe downstream adapter + * @alloc_hopid: Allocate HopIDs from visited ports * * If @down adapter is active, follows the tunnel to the PCIe upstream * adapter and back. Returns the discovered tunnel or %NULL if there was * no tunnel. */ -struct tb_tunnel *tb_tunnel_discover_pci(struct tb *tb, struct tb_port *down) +struct tb_tunnel *tb_tunnel_discover_pci(struct tb *tb, struct tb_port *down, + bool alloc_hopid) { struct tb_tunnel *tunnel; struct tb_path *path; @@ -233,7 +235,7 @@ struct tb_tunnel *tb_tunnel_discover_pci(struct tb *tb, struct tb_port *down) * case. */ path = tb_path_discover(down, TB_PCI_HOPID, NULL, -1, - &tunnel->dst_port, "PCIe Up"); + &tunnel->dst_port, "PCIe Up", alloc_hopid); if (!path) { /* Just disable the downstream port */ tb_pci_port_enable(down, false); @@ -244,7 +246,7 @@ struct tb_tunnel *tb_tunnel_discover_pci(struct tb *tb, struct tb_port *down) goto err_free; path = tb_path_discover(tunnel->dst_port, -1, down, TB_PCI_HOPID, NULL, - "PCIe Down"); + "PCIe Down", alloc_hopid); if (!path) goto err_deactivate; tunnel->paths[TB_PCI_PATH_DOWN] = path; @@ -761,6 +763,7 @@ static int tb_dp_init_video_path(struct tb_path *path) * tb_tunnel_discover_dp() - Discover existing Display Port tunnels * @tb: Pointer to the domain structure * @in: DP in adapter + * @alloc_hopid: Allocate HopIDs from visited ports * * If @in adapter is active, follows the tunnel to the DP out adapter * and back. Returns the discovered tunnel or %NULL if there was no @@ -768,7 +771,8 @@ static int tb_dp_init_video_path(struct tb_path *path) * * Return: DP tunnel or %NULL if no tunnel found. */ -struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in) +struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in, + bool alloc_hopid) { struct tb_tunnel *tunnel; struct tb_port *port; @@ -787,7 +791,7 @@ struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in) tunnel->src_port = in; path = tb_path_discover(in, TB_DP_VIDEO_HOPID, NULL, -1, - &tunnel->dst_port, "Video"); + &tunnel->dst_port, "Video", alloc_hopid); if (!path) { /* Just disable the DP IN port */ tb_dp_port_enable(in, false); @@ -797,14 +801,15 @@ struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in) if (tb_dp_init_video_path(tunnel->paths[TB_DP_VIDEO_PATH_OUT])) goto err_free; - path = tb_path_discover(in, TB_DP_AUX_TX_HOPID, NULL, -1, NULL, "AUX TX"); + path = tb_path_discover(in, TB_DP_AUX_TX_HOPID, NULL, -1, NULL, "AUX TX", + alloc_hopid); if (!path) goto err_deactivate; tunnel->paths[TB_DP_AUX_PATH_OUT] = path; tb_dp_init_aux_path(tunnel->paths[TB_DP_AUX_PATH_OUT]); path = tb_path_discover(tunnel->dst_port, -1, in, TB_DP_AUX_RX_HOPID, - &port, "AUX RX"); + &port, "AUX RX", alloc_hopid); if (!path) goto err_deactivate; tunnel->paths[TB_DP_AUX_PATH_IN] = path; @@ -1343,12 +1348,14 @@ static void tb_usb3_init_path(struct tb_path *path) * tb_tunnel_discover_usb3() - Discover existing USB3 tunnels * @tb: Pointer to the domain structure * @down: USB3 downstream adapter + * @alloc_hopid: Allocate HopIDs from visited ports * * If @down adapter is active, follows the tunnel to the USB3 upstream * adapter and back. Returns the discovered tunnel or %NULL if there was * no tunnel. */ -struct tb_tunnel *tb_tunnel_discover_usb3(struct tb *tb, struct tb_port *down) +struct tb_tunnel *tb_tunnel_discover_usb3(struct tb *tb, struct tb_port *down, + bool alloc_hopid) { struct tb_tunnel *tunnel; struct tb_path *path; @@ -1369,7 +1376,7 @@ struct tb_tunnel *tb_tunnel_discover_usb3(struct tb *tb, struct tb_port *down) * case. */ path = tb_path_discover(down, TB_USB3_HOPID, NULL, -1, - &tunnel->dst_port, "USB3 Down"); + &tunnel->dst_port, "USB3 Down", alloc_hopid); if (!path) { /* Just disable the downstream port */ tb_usb3_port_enable(down, false); @@ -1379,7 +1386,7 @@ struct tb_tunnel *tb_tunnel_discover_usb3(struct tb *tb, struct tb_port *down) tb_usb3_init_path(tunnel->paths[TB_USB3_PATH_DOWN]); path = tb_path_discover(tunnel->dst_port, -1, down, TB_USB3_HOPID, NULL, - "USB3 Up"); + "USB3 Up", alloc_hopid); if (!path) goto err_deactivate; tunnel->paths[TB_USB3_PATH_UP] = path; diff --git a/drivers/thunderbolt/tunnel.h b/drivers/thunderbolt/tunnel.h index eea14e24f7e0..03e56076b5bc 100644 --- a/drivers/thunderbolt/tunnel.h +++ b/drivers/thunderbolt/tunnel.h @@ -64,10 +64,12 @@ struct tb_tunnel { int allocated_down; }; -struct tb_tunnel *tb_tunnel_discover_pci(struct tb *tb, struct tb_port *down); +struct tb_tunnel *tb_tunnel_discover_pci(struct tb *tb, struct tb_port *down, + bool alloc_hopid); struct tb_tunnel *tb_tunnel_alloc_pci(struct tb *tb, struct tb_port *up, struct tb_port *down); -struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in); +struct tb_tunnel *tb_tunnel_discover_dp(struct tb *tb, struct tb_port *in, + bool alloc_hopid); struct tb_tunnel *tb_tunnel_alloc_dp(struct tb *tb, struct tb_port *in, struct tb_port *out, int max_up, int max_down); @@ -77,7 +79,8 @@ struct tb_tunnel *tb_tunnel_alloc_dma(struct tb *tb, struct tb_port *nhi, int receive_ring); bool tb_tunnel_match_dma(const struct tb_tunnel *tunnel, int transmit_path, int transmit_ring, int receive_path, int receive_ring); -struct tb_tunnel *tb_tunnel_discover_usb3(struct tb *tb, struct tb_port *down); +struct tb_tunnel *tb_tunnel_discover_usb3(struct tb *tb, struct tb_port *down, + bool alloc_hopid); struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up, struct tb_port *down, int max_up, int max_down); From patchwork Tue Mar 8 08:49:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1602806 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=QUpkz3Tn; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KCTXP6cpVz9sGF for ; Tue, 8 Mar 2022 19:49:25 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nRVWw-0001zr-OQ; Tue, 08 Mar 2022 08:49:18 +0000 Received: from mail-pj1-f43.google.com ([209.85.216.43]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nRVWu-0001yf-7a for kernel-team@lists.ubuntu.com; Tue, 08 Mar 2022 08:49:16 +0000 Received: by mail-pj1-f43.google.com with SMTP id k5-20020a17090a3cc500b001befa0d3102so1396356pjd.1 for ; Tue, 08 Mar 2022 00:49:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=c+oQAZXsn/tVLVtqUQdd3uA2il8q73V95NqMTLy8Km4=; b=QUpkz3TnEtEMocZU+NzeGPE9aMRJjuT7SE7gQox2Pp5HIOTIkMVhH5BIWhTE8/CYF9 gZ6bQVVExlqGYgO9qZpQzVe8D68Ow64qGftoDcqz98kYGQ2jQiDpi377eY5kPmHE9FGO nQp0xir5CU2XbT+nDZ09xAqBaG8eNc5pSJxUhdK3ony8c217cym1qnrm936XrolfUSBu 7f/CqVbjYRVF2o7tH7GEcECCc5jjq90whYA7fJgy+LoCOrq4UDb8K04jLf4bFYqOjWnE jKABXX0o3rLqAkhu9C9ITshDyE6b4bNEZho6Ukh6kNKFLkdq3hhpPNnoqj8vNZquu1st BXnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=c+oQAZXsn/tVLVtqUQdd3uA2il8q73V95NqMTLy8Km4=; b=c7vJo+AW5RHJQtlaShyyy9DmqsbzDurxk7O8ri3mF3sihEQCBzhvDXYmDwfYxwX/gr WzYiQQKwZq8to/ZDwJwqpGLnaZ6mDkw66b8fzZOLgWB5KcqebEJjCe3LxMoONu6sIw+h h3gaSfKm/Biv6GMYAnfx6XlsU259HT3+nSAh0+A4xCKdh1fAzIAKWteSUjZHOuahfR3s kEcHEip2h6M3pnQl2sylLWXk5sV5bbclJm6YcebqC8z9qQWE4tbKOSBtbVTK7a/KY3q7 OGtGPJWKVVIWJziwBJQNzjndUuAdKvHDeEcHwRRUkDtg5XcveaNb4rQ1RxvmYrb3gx2j dO0A== X-Gm-Message-State: AOAM531yGgZll3I6eZLxisJRNjqvzS2ux/PPwYVmOsl/WQ7Q6WlTqc4L ZbVwnA7NbxHfi2A3kCy6V+kM+GZmhtQ= X-Google-Smtp-Source: ABdhPJxlJOkLsziFtxaYnaoVQLUUcNmEQ3HwBUKjTtP4eYHB8b0zrvD+JGnEX0UDsuVU696NpfQ8YA== X-Received: by 2002:a17:902:bd95:b0:14f:40ab:270e with SMTP id q21-20020a170902bd9500b0014f40ab270emr16276179pls.101.1646729354158; Tue, 08 Mar 2022 00:49:14 -0800 (PST) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id f194-20020a6238cb000000b004f6ce898c61sm12379013pfa.77.2022.03.08.00.49.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 00:49:13 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 2/5][SRU][J] thunderbolt: Runtime resume USB4 port when retimers are scanned Date: Tue, 8 Mar 2022 16:49:06 +0800 Message-Id: <20220308084909.2043184-3-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308084909.2043184-1-acelan.kao@canonical.com> References: <20220308084909.2043184-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.43; envelope-from=acelan@gmail.com; helo=mail-pj1-f43.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mika Westerberg BugLink: https://bugs.launchpad.net/bugs/1955016 Sometimes when plugging in a USB4 device we might see following error: thunderbolt 1-0:3.1: runtime PM trying to activate child device 1-0:3.1 but parent (usb4_port3) is not active This happens because the parent USB4 port was still runtime suspended. Fix this by runtime resuming the USB4 port before scanning the retimers below it. Signed-off-by: Mika Westerberg (cherry picked from commit 1e56c88adecc2dfe14973fa47898861a839e62d4) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/thunderbolt/retimer.c | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/drivers/thunderbolt/retimer.c b/drivers/thunderbolt/retimer.c index 722694052f4a..8c29bd556ae0 100644 --- a/drivers/thunderbolt/retimer.c +++ b/drivers/thunderbolt/retimer.c @@ -324,15 +324,10 @@ struct device_type tb_retimer_type = { static int tb_retimer_add(struct tb_port *port, u8 index, u32 auth_status) { - struct usb4_port *usb4; struct tb_retimer *rt; u32 vendor, device; int ret; - usb4 = port->usb4; - if (!usb4) - return -EINVAL; - ret = usb4_port_retimer_read(port, index, USB4_SB_VENDOR_ID, &vendor, sizeof(vendor)); if (ret) { @@ -374,7 +369,7 @@ static int tb_retimer_add(struct tb_port *port, u8 index, u32 auth_status) rt->port = port; rt->tb = port->sw->tb; - rt->dev.parent = &usb4->dev; + rt->dev.parent = &port->usb4->dev; rt->dev.bus = &tb_bus_type; rt->dev.type = &tb_retimer_type; dev_set_name(&rt->dev, "%s:%u.%u", dev_name(&port->sw->dev), @@ -453,6 +448,13 @@ int tb_retimer_scan(struct tb_port *port, bool add) { u32 status[TB_MAX_RETIMER_INDEX + 1] = {}; int ret, i, last_idx = 0; + struct usb4_port *usb4; + + usb4 = port->usb4; + if (!usb4) + return 0; + + pm_runtime_get_sync(&usb4->dev); /* * Send broadcast RT to make sure retimer indices facing this @@ -460,7 +462,7 @@ int tb_retimer_scan(struct tb_port *port, bool add) */ ret = usb4_port_enumerate_retimers(port); if (ret) - return ret; + goto out; /* * Enable sideband channel for each retimer. We can do this @@ -490,8 +492,10 @@ int tb_retimer_scan(struct tb_port *port, bool add) break; } - if (!last_idx) - return 0; + if (!last_idx) { + ret = 0; + goto out; + } /* Add on-board retimers if they do not exist already */ for (i = 1; i <= last_idx; i++) { @@ -507,7 +511,11 @@ int tb_retimer_scan(struct tb_port *port, bool add) } } - return 0; +out: + pm_runtime_mark_last_busy(&usb4->dev); + pm_runtime_put_autosuspend(&usb4->dev); + + return ret; } static int remove_retimer(struct device *dev, void *data) From patchwork Tue Mar 8 08:49:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1602808 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=NOZmf4RO; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KCTXR1Rn0z9sGF for ; Tue, 8 Mar 2022 19:49:27 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nRVWx-00020c-Eg; Tue, 08 Mar 2022 08:49:19 +0000 Received: from mail-pj1-f41.google.com ([209.85.216.41]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nRVWv-0001z2-LG for kernel-team@lists.ubuntu.com; Tue, 08 Mar 2022 08:49:17 +0000 Received: by mail-pj1-f41.google.com with SMTP id mr24-20020a17090b239800b001bf0a375440so1596688pjb.4 for ; Tue, 08 Mar 2022 00:49:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=e9Ogh+splgFluTKxILC7HBS5Q53xvMJ6xDQ0OFvUlHE=; b=NOZmf4RODOiQls2jNBMdg92K22zDh/OImBXRgWvM+u0KmCrKHQ1VyCak8JQ0X/sPcA +1N728enER/saCWm5Wwmfo2AF/3cZptKm808cMLMLzAeRAXu9Z77Zm32BsUfWCdsnriS sJKK/26aDaWG+TA+DHHvwnudYrVmu99Pm/EBy76ADPOnHaqAc1JSll4uxVg8IMBusEIg 1tpd2NnlGIDzNpVcAx5IGahyUwoo0D4oDz8ntaTA8PG/ZoVHpxj6qRsgCJ92fAr69HS/ B1IFekjzPmaeAbwxGwc1K4JvM6ChIyeAUuYImoqQzlqrfVT8VM3orfSRkpmahYAGoqCS 0SwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=e9Ogh+splgFluTKxILC7HBS5Q53xvMJ6xDQ0OFvUlHE=; b=LlMdk3cL9joVC+w70xOI4CVWZeiOCvkQUcRsyHzwwgNlf+ri5V2RZQGHmlNtvP1zRs rq9RwzDXL1CHn01NprvccrUhIJsKJy6niRa3eLsNkSqWSMeKTMnkGmfpyokGi/Cxa/KH fV2GlifdMi0z0rEs+ljHDw39LGHFDs4ce0lPg6Oa1FXGEP/y/YXNreOr5AboJ6tZX6SX V0mmOX76oZ0mJNv/iP2J5MR0pJD8+rz6NHODHjoOaHzDYDd/xmPSnPlBwMZ2HCLRHzHT DSOoQVfHE58oMpMaIhGA+W+U37Du14gkFzLXx8aXgx0CMII4evVG/jclgERcIwnpyGhw 9bww== X-Gm-Message-State: AOAM532QVKis74DUtt3CSCKeMjzGUrpzJRVXM+gb1swTn6lH9cLLsOQJ zmo26a+mHBgXsU885ZlvIkjFRACjVuM= X-Google-Smtp-Source: ABdhPJzJSDVzmG5V5s8F0ctItebvXlgtV3V/drDYFX3qfncXyjolRjDnHWfdoRgpRlbiF9GcnOWQRA== X-Received: by 2002:a17:903:1246:b0:151:94d9:eeb2 with SMTP id u6-20020a170903124600b0015194d9eeb2mr16092149plh.165.1646729355731; Tue, 08 Mar 2022 00:49:15 -0800 (PST) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id u18-20020a056a00125200b004f71576f8fesm4889052pfi.86.2022.03.08.00.49.15 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 00:49:15 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 3/5][SRU][J] thunderbolt: Do not allow subtracting more NFC credits than configured Date: Tue, 8 Mar 2022 16:49:07 +0800 Message-Id: <20220308084909.2043184-4-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308084909.2043184-1-acelan.kao@canonical.com> References: <20220308084909.2043184-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.41; envelope-from=acelan@gmail.com; helo=mail-pj1-f41.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mika Westerberg BugLink: https://bugs.launchpad.net/bugs/1955016 This might happen if the boot firmware uses different amount of NFC credits than what the router suggests, or we are dealing with pre-USB4 device. Signed-off-by: Mika Westerberg (cherry picked from commit 6cb27a04fb779717c4a3d20233b93596885838cf) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/thunderbolt/switch.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 3014146081c1..463cfdc0b42f 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -623,6 +623,9 @@ int tb_port_add_nfc_credits(struct tb_port *port, int credits) return 0; nfc_credits = port->config.nfc_credits & ADP_CS_4_NFC_BUFFERS_MASK; + if (credits < 0) + credits = max_t(int, -nfc_credits, credits); + nfc_credits += credits; tb_port_dbg(port, "adding %d NFC credits to %lu", credits, From patchwork Tue Mar 8 08:49:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1602809 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=TwmOL1aU; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KCTXV0bcMz9sGF for ; Tue, 8 Mar 2022 19:49:30 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nRVX1-00026f-Oo; Tue, 08 Mar 2022 08:49:23 +0000 Received: from mail-pf1-f177.google.com ([209.85.210.177]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nRVWz-0001zd-0H for kernel-team@lists.ubuntu.com; Tue, 08 Mar 2022 08:49:21 +0000 Received: by mail-pf1-f177.google.com with SMTP id s11so16720434pfu.13 for ; Tue, 08 Mar 2022 00:49:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Aa6AwolJK4vRbN+BUIq/jWtwrDQRm3w65hry3eTojBw=; b=TwmOL1aUacjTeql0qN0SmkynSnLRWx0oVo/hFfTn2yBDlto7krT02e59JateexlWVj TWfT/I+NSyFhBEve3RFD9YoopLxtnv4jmQ1UlOMUDFIWQpAPpiD/Jb16lkyk/ZyS0mjS TG+WpdkEY87pDS+0P/UUl5X7kd3ur+Nwf/CX6lh7NGlO6AvGQ2JajW7nFrFpTgrhRC0X Cn0P8Ct3SgawKPKjSD+s8ejIiyGXYXHD0JEQ8tIR9SXAHZ6dFvPFTNCbPOxMkF3Gehrh RlnLN0XeYmPw+87t4cYKu/XOpF7YGX/qS70eFBbJFGfAxI2RWU1YsnRxrLt2kxWd9zWU /sxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=Aa6AwolJK4vRbN+BUIq/jWtwrDQRm3w65hry3eTojBw=; b=UPgs8bYsI1mdT5+WIFJnFx33xGjPqacBRSrujKu2Yk/BRe5AAcc+kCczU5gIg0oiNL h4iy02+3EEWEGyMwpEvf+LKJ2EN7FK3CmSIqHGt+FhVLbNQA0sdrAiudFPWu8Oo4GjVQ 9Wj8RAFpc9KLHNRMvsXmgy+AkWefhcgJzaE/ig6Pnrk5kIvfagYhQ5ZIT7Zx9jR39odh Ytm/SdEusGXaSme5F1CPphJoXn36xTssVWntKGmSWNpr2aD3Q51TdIpwJWfip+6WmIOU 6D3aTZ1ABYxmSzV2GuTgVgfiXqXmpbDAhh2LsxGeRWJwBA21jpwdGyPuVMlGaPVq5AuB jeLw== X-Gm-Message-State: AOAM533h+ZlbPSqxo3HTlGtDvL0XVPZpxdBXZYsHnY8vMBTDCaojy7dm BCTcenNkcDDm6sHHP+KyQ2UiTvakz90= X-Google-Smtp-Source: ABdhPJx3zea6RzlTKlfBBHXTCp/ld2MLxPX1JLJH/RhLqY5D8pp4N8O6hItXlnXaz9cEmAFFnd30vg== X-Received: by 2002:a05:6a00:d5b:b0:4f6:bc0b:9b35 with SMTP id n27-20020a056a000d5b00b004f6bc0b9b35mr17200619pfv.25.1646729357741; Tue, 08 Mar 2022 00:49:17 -0800 (PST) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id c7-20020aa78e07000000b004f6e4d8ccc8sm9359446pfr.163.2022.03.08.00.49.17 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 00:49:17 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 4/5][SRU][J] thunderbolt: Do not program path HopIDs for USB4 routers Date: Tue, 8 Mar 2022 16:49:08 +0800 Message-Id: <20220308084909.2043184-5-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308084909.2043184-1-acelan.kao@canonical.com> References: <20220308084909.2043184-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.210.177; envelope-from=acelan@gmail.com; helo=mail-pf1-f177.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mika Westerberg BugLink: https://bugs.launchpad.net/bugs/1955016 These fields are marked read-only for USB4 routers so do not touch them in that case. Update the kernel-doc of tb_dp_port_set_hops() to reflect this too. Signed-off-by: Mika Westerberg (cherry picked from commit e5bb88e961e5e3e72e3cc3a866a232115bd15e1e) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/thunderbolt/switch.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 463cfdc0b42f..e00f4b878b56 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -1322,7 +1322,9 @@ int tb_dp_port_hpd_clear(struct tb_port *port) * @aux_tx: AUX TX Hop ID * @aux_rx: AUX RX Hop ID * - * Programs specified Hop IDs for DP IN/OUT port. + * Programs specified Hop IDs for DP IN/OUT port. Can be called for USB4 + * router DP adapters too but does not program the values as the fields + * are read-only. */ int tb_dp_port_set_hops(struct tb_port *port, unsigned int video, unsigned int aux_tx, unsigned int aux_rx) @@ -1330,6 +1332,9 @@ int tb_dp_port_set_hops(struct tb_port *port, unsigned int video, u32 data[2]; int ret; + if (tb_switch_is_usb4(port->sw)) + return 0; + ret = tb_port_read(port, data, TB_CFG_PORT, port->cap_adap + ADP_DP_CS_0, ARRAY_SIZE(data)); if (ret) From patchwork Tue Mar 8 08:49:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AceLan Kao X-Patchwork-Id: 1602810 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20210112 header.b=pAQH/x36; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KCTXV2Ts9z9sGG for ; Tue, 8 Mar 2022 19:49:30 +1100 (AEDT) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1nRVX2-00027R-Cp; Tue, 08 Mar 2022 08:49:24 +0000 Received: from mail-pj1-f50.google.com ([209.85.216.50]) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1nRVWz-00021j-Kv for kernel-team@lists.ubuntu.com; Tue, 08 Mar 2022 08:49:21 +0000 Received: by mail-pj1-f50.google.com with SMTP id ge19-20020a17090b0e1300b001bcca16e2e7so1601889pjb.3 for ; Tue, 08 Mar 2022 00:49:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JdPaFgpESqxD5KesI6RsU6V9ZoNYPZwid54wk3QcCxo=; b=pAQH/x36Ji+XYiS5QVwHBB7xF5yWquPrW6ObeRYBG3T6Pr0DGLHWGVV8ql+PCHiCAI 3RtaSu4FGWQ5TleMgOxBrEe596++wF6iqbXfWACiWIWeJYlmIBH3qdluEOJix45VNEuK CRj/tzkvkzEWcbWqYdvOemXQel4llVnQBSvtUy7RrkDPCpk7aBuvS/Ou9g3/qfxnOa5R KObqs5AQQc4cNdioqp6CZLLZ+FaQyZXs7XbYMLPO1bId2qwNljaSCQ4qquBQdXha0gZg MwWcItVfv8zaQ0TvGQ+jy1gA4aztL7S9gMb6qnoGeHJOUqRrask5GBTuwuQlYlG6EueN ZFeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=JdPaFgpESqxD5KesI6RsU6V9ZoNYPZwid54wk3QcCxo=; b=rTGi4lUbEEd9RcCxZf6fv+RZGBW7y1FqGYo0sz1p2TRpA+dqBs6Cz/21rXj0g2TqMs BvivtLtxTz3qSdoxrIbr9EzWKgOjMs8d5+UZj0RaeEfZjUNvcQbfSS3+xJblQI3KGkt2 +ZtEbDXhmOs7rkCI813cx/wkaR9NsNlY075S6MKVXNaUHmpp9zNpPCMT9u8LCdw+fguc Nx949DI4c7AYil864NYMmvDlni2w///ONS2Av/3dGz/fpAwxnlZW2tME+sdivCBf1u87 PE636SKVod6z5tC4g1GL2jOcH0qWpLRrB/prdmQS/MYvN3YuLPe0wWLIaRR1wncRCiRM 5GKA== X-Gm-Message-State: AOAM5333DCF0DTKY4cqy07DCGvTCeDbd6YoVhV3K/lURSP5WSY3BR/Sf zcdTD29UuroZeFNdbDyzRgaYlah40yI= X-Google-Smtp-Source: ABdhPJxMd1yGPnvLb0l6Xv0y9Jm8HzQeo+K+QbVi9HwGE5Y+Dmgc6SuEtycasfWQ48vu/IVIdJvkNg== X-Received: by 2002:a17:90a:8c14:b0:1be:e8cc:96bb with SMTP id a20-20020a17090a8c1400b001bee8cc96bbmr3535929pjo.176.1646729359305; Tue, 08 Mar 2022 00:49:19 -0800 (PST) Received: from localhost (220-135-95-34.hinet-ip.hinet.net. [220.135.95.34]) by smtp.gmail.com with ESMTPSA id z21-20020a17090a8b9500b001bf74f8bb3asm1948095pjn.24.2022.03.08.00.49.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Mar 2022 00:49:18 -0800 (PST) From: AceLan Kao To: kernel-team@lists.ubuntu.com Subject: [PATCH 5/5][SRU][J] thunderbolt: Add debug logging of DisplayPort resource allocation Date: Tue, 8 Mar 2022 16:49:09 +0800 Message-Id: <20220308084909.2043184-6-acelan.kao@canonical.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220308084909.2043184-1-acelan.kao@canonical.com> References: <20220308084909.2043184-1-acelan.kao@canonical.com> MIME-Version: 1.0 Received-SPF: pass client-ip=209.85.216.50; envelope-from=acelan@gmail.com; helo=mail-pj1-f50.google.com X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mika Westerberg BugLink: https://bugs.launchpad.net/bugs/1955016 Add more debugging around DP resource allocation/de-allocation. Signed-off-by: Mika Westerberg (cherry picked from commit ce05b997426df4c5321358e369f1f32f257c57a9) Signed-off-by: Chia-Lin Kao (AceLan) --- drivers/thunderbolt/switch.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index e00f4b878b56..13f9230104d7 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -3056,9 +3056,20 @@ bool tb_switch_query_dp_resource(struct tb_switch *sw, struct tb_port *in) */ int tb_switch_alloc_dp_resource(struct tb_switch *sw, struct tb_port *in) { + int ret; + if (tb_switch_is_usb4(sw)) - return usb4_switch_alloc_dp_resource(sw, in); - return tb_lc_dp_sink_alloc(sw, in); + ret = usb4_switch_alloc_dp_resource(sw, in); + else + ret = tb_lc_dp_sink_alloc(sw, in); + + if (ret) + tb_sw_warn(sw, "failed to allocate DP resource for port %d\n", + in->port); + else + tb_sw_dbg(sw, "allocated DP resource for port %d\n", in->port); + + return ret; } /** @@ -3081,6 +3092,8 @@ void tb_switch_dealloc_dp_resource(struct tb_switch *sw, struct tb_port *in) if (ret) tb_sw_warn(sw, "failed to de-allocate DP resource for port %d\n", in->port); + else + tb_sw_dbg(sw, "released DP resource for port %d\n", in->port); } struct tb_sw_lookup {