From patchwork Tue Nov 14 12:12:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 744419 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8C283E479 for ; Tue, 14 Nov 2023 12:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="QEqBocKr" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.88]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78AD2181 for ; Tue, 14 Nov 2023 04:12:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699963928; x=1731499928; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=YDpC/cus29rCYqsWzZsWq7h4fDSCS/7uHz4X/LtHCCI=; b=QEqBocKrGA+4BxzcK/0MJ88KDd6eEqI18x7ydcNxsWUeABN59e7T7eXm LvvGnN5Ku44HYlf981/343qeFp6yyDblgPQXc7AKrkmbug5i5Zy48Rb38 cG4hpmUbBFJkIXXQkgPkPC5z4bPryUMgkZW9AqzxsrWlHoGTmYEXNf8F1 waD4EtfxI035rV5cvn305ivre3Azy3TgtJMaV95wCvEd5dDufaSNSq3J3 hzvBcR+q6nW5+fVIKH+eFZex+6N3lTgqThhdpZ2hQB2PUQRxtN/0fKWzO 98+DSq2cctj+DOL0nUV/qUGYA8eDVmVoJ5+PN+B/HIhF36koLcs/jepB5 w==; X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="421740651" X-IronPort-AV: E=Sophos;i="6.03,302,1694761200"; d="scan'208";a="421740651" Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 04:12:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="764645532" X-IronPort-AV: E=Sophos;i="6.03,302,1694761200"; d="scan'208";a="764645532" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga002.jf.intel.com with ESMTP; 14 Nov 2023 04:12:05 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id ABA4C5C2; Tue, 14 Nov 2023 14:12:03 +0200 (EET) From: Mika Westerberg To: Yehezkel Bernat , Michael Jamet , Lukas Wunner , Andreas Noever Cc: linux-usb@vger.kernel.org, Gil Fine , Pengfei Xu , Mika Westerberg Subject: [PATCH 1/3] thunderbolt: Set lane bonding bit only for downstream port Date: Tue, 14 Nov 2023 14:12:01 +0200 Message-ID: <20231114121203.203762-1-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.42.0 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Gil Fine Fix the lane bonding procedure to follow the steps described in USB4 Connection Manager guide. Hence, set the lane bonding bit only for downstream port. This is needed for certain ASMedia device, otherwise lane bonding fails and the device disconnects. Cc: stable@vger.kernel.org Signed-off-by: Gil Fine Signed-off-by: Mika Westerberg --- drivers/thunderbolt/switch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 1e15ffa79295..9e5cc285cc8d 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -1143,7 +1143,7 @@ int tb_port_lane_bonding_enable(struct tb_port *port) * Only set bonding if the link was not already bonded. This * avoids the lane adapter to re-enter bonding state. */ - if (width == TB_LINK_WIDTH_SINGLE) { + if (width == TB_LINK_WIDTH_SINGLE && !tb_is_upstream_port(port)) { ret = tb_port_set_lane_bonding(port, true); if (ret) goto err_lane1; From patchwork Tue Nov 14 12:12:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 743975 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BC2B43D984 for ; Tue, 14 Nov 2023 12:12:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="ItETBIgC" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0002013A for ; Tue, 14 Nov 2023 04:12:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699963927; x=1731499927; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=iuosgsgdj4lr2656w0w8jzBRqkuJSTSKY1ft/oL1w48=; b=ItETBIgCklYvvpXa4saDUVTQNPYmpldRFhpdk0eFFLHYL4Wwy3LaE0JQ ojYiz6g+SXkAMBqKuduqsMLqimfhxr3BA4P5U+fGJbqnC+aZyLM/UJ2Mp ckngMYIe7eF8mYKhOZwGUi0ubRkNskSJ3xMDGPphHlAx6SjM2DPdVhas6 itdJWt3Rmoew0loIx20W8HNsNVY28F7oFyf22BVkHVqxq0G3hwbyxq9vK 9GW/l5HzeAshWiQSQDDttWIBb0ynTIVoK9vvsvL7+YP2PFr84kQLD/PP0 kKcavyTBpQdRgOk7X3l7ACGwOGai8SMxnuMBlD2sXtTrSFhbfmY+NWNVZ w==; X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="390436937" X-IronPort-AV: E=Sophos;i="6.03,302,1694761200"; d="scan'208";a="390436937" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 04:12:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="799508550" X-IronPort-AV: E=Sophos;i="6.03,302,1694761200"; d="scan'208";a="799508550" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 14 Nov 2023 04:12:04 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id B6E3D125; Tue, 14 Nov 2023 14:12:03 +0200 (EET) From: Mika Westerberg To: Yehezkel Bernat , Michael Jamet , Lukas Wunner , Andreas Noever Cc: linux-usb@vger.kernel.org, Gil Fine , Pengfei Xu , Mika Westerberg Subject: [PATCH 2/3] thunderbolt: Send uevent after asymmetric/symmetric switch Date: Tue, 14 Nov 2023 14:12:02 +0200 Message-ID: <20231114121203.203762-2-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114121203.203762-1-mika.westerberg@linux.intel.com> References: <20231114121203.203762-1-mika.westerberg@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 We should send uevent to userspace whenever the link speed or width changes but tb_switch_asym_enable() and tb_switch_asym_disable() set the sw->link_width already so tb_switch_update_link_attributes() never noticed the change. Fix this so that we let tb_switch_update_link_attributes() update the fields accordingly. Fixes: 81af2952e606 ("thunderbolt: Add support for asymmetric link") Reported-by: Pengfei Xu Tested-by: Pengfei Xu Signed-off-by: Mika Westerberg --- drivers/thunderbolt/switch.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 9e5cc285cc8d..44e9b09de47a 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -2880,6 +2880,7 @@ static int tb_switch_lane_bonding_disable(struct tb_switch *sw) return tb_port_wait_for_link_width(down, TB_LINK_WIDTH_SINGLE, 100); } +/* Note updating sw->link_width done in tb_switch_update_link_attributes() */ static int tb_switch_asym_enable(struct tb_switch *sw, enum tb_link_width width) { struct tb_port *up, *down, *port; @@ -2919,10 +2920,10 @@ static int tb_switch_asym_enable(struct tb_switch *sw, enum tb_link_width width) return ret; } - sw->link_width = width; return 0; } +/* Note updating sw->link_width done in tb_switch_update_link_attributes() */ static int tb_switch_asym_disable(struct tb_switch *sw) { struct tb_port *up, *down; @@ -2957,7 +2958,6 @@ static int tb_switch_asym_disable(struct tb_switch *sw) return ret; } - sw->link_width = TB_LINK_WIDTH_DUAL; return 0; } From patchwork Tue Nov 14 12:12:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 744418 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A58613E476 for ; Tue, 14 Nov 2023 12:12:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="O5RVN4dg" Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 778D6184 for ; Tue, 14 Nov 2023 04:12:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1699963929; x=1731499929; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=p/0zQaq2B5Ejy364nV20zrd8ckkQZEyY4NKv4xvdtqQ=; b=O5RVN4dg6zsbjAU93Jx/tTN53mIsbzcPMg4IrNPXahKyOicYgZBZvnzC OMrHVD0e/I7SvXPUsy1jKJxjEmaLTahv8/Z8PXZXRjX6W/IvWRK13qRk9 +kxU3Fpxag6DQJYHmLuYB7BvrxG1uyHSXq25o5/Oj5SoBh27D8d4ExKBe US5G/X4qhnXZA03z4gsypbv3KltEIv91ZQZcMuEvrdbUfm94uuarZCCl5 GngITa3xML2I/es1uGM13C+PepVaIwGId/v4vYzpcnrcYJ4fgzcHmYxIv LJPuyFqMoG4F1odpYzu0xVSS/KmBIHojdZeddqaJvgLHWs7vinP/+WtGD A==; X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="390436940" X-IronPort-AV: E=Sophos;i="6.03,302,1694761200"; d="scan'208";a="390436940" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 14 Nov 2023 04:12:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10893"; a="799508553" X-IronPort-AV: E=Sophos;i="6.03,302,1694761200"; d="scan'208";a="799508553" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga001.jf.intel.com with ESMTP; 14 Nov 2023 04:12:05 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id BCAC45E2; Tue, 14 Nov 2023 14:12:03 +0200 (EET) From: Mika Westerberg To: Yehezkel Bernat , Michael Jamet , Lukas Wunner , Andreas Noever Cc: linux-usb@vger.kernel.org, Gil Fine , Pengfei Xu , Mika Westerberg Subject: [PATCH 3/3] thunderbolt: Only add device router DP IN to the head of the DP resource list Date: Tue, 14 Nov 2023 14:12:03 +0200 Message-ID: <20231114121203.203762-3-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231114121203.203762-1-mika.westerberg@linux.intel.com> References: <20231114121203.203762-1-mika.westerberg@linux.intel.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When pairing DP IN and DP OUT adapters for DisplayPort tunneling, we should prioritize the possible external GPU DP IN adapters to take advantage of the its capabilities. However the commit in question did this for host router DP IN adapters too and that changes ordering of the initial DP IN resources in such way that resuming from suspend may end up using different resource and that may confuse the user. Fix this so that we only put DP IN adapters of device routers to the top of the resource list and leave host routers as is. Fixes: 274baf695b08 ("thunderbolt: Add DP IN added last in the head of the list of DP resources") Reported-by: Pengfei Xu Signed-off-by: Mika Westerberg --- drivers/thunderbolt/tb.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index 5acdeb766860..fd49f86e0353 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -213,7 +213,17 @@ static void tb_add_dp_resources(struct tb_switch *sw) if (!tb_switch_query_dp_resource(sw, port)) continue; - list_add(&port->list, &tcm->dp_resources); + /* + * If DP IN on device router exist, position it at the + * beginning of the DP resources list, so that it is used + * before DP IN of the host router. This way external GPU(s) + * will be prioritized when pairing DP IN to a DP OUT. + */ + if (tb_route(sw)) + list_add(&port->list, &tcm->dp_resources); + else + list_add_tail(&port->list, &tcm->dp_resources); + tb_port_dbg(port, "DP IN resource available\n"); } }