From patchwork Mon Apr 8 12:48:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 787434 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.17]) (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 9D4CA6CDDC for ; Mon, 8 Apr 2024 12:48:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.17 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712580491; cv=none; b=VeGA7nTWSBz1YnSYqXarla8ofnQWd7ba+zGc2k26zD/Q/JvggrTqRB8/nbil444dJ+FSxhcXaz1r9TVNJhq51kHXF5Q+hkChqOizfyMfAVGn7FzBmIh5b5JIXeqzMYwrzVVH4fgpe+hdgQpuQMcngMMjWDmrP30FKxKSNwu6K0s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712580491; c=relaxed/simple; bh=tEER5V8oua3LXDYSVx60SqScTANyqQZWAFAPcLviHqI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=WtafAj0P9wUvt/xK5I5e+O6QFtkhDjyThDWWHeUQy/JKETFIBmXmPQyPjzvYLAYtJ7/mrHcJ5XMMVKP//q/kjE3phs4gmKCoa1pqnoUwocQYFrwtbj6oX1h7A/+AYYaKRW+kqi9Mxy0nvKZIeWX0R9XbET3oPlZ808FMdzLWUpw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=RTF/wiWq; arc=none smtp.client-ip=192.198.163.17 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="RTF/wiWq" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712580490; x=1744116490; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=tEER5V8oua3LXDYSVx60SqScTANyqQZWAFAPcLviHqI=; b=RTF/wiWq3ERPTRgSmnQSf2cHVeKIkaAjdqd62EOpBLx/JJY9hKll9xgp dD8qKEvDbcumx/rOK6OP9k/Lp/gaLvRAv+uJ7GxhG8LMNl/AU5xvJ76l2 Zj+gkEmBu2INpMbKhWO2MkdKeBqliWGNP+qmdu9RpTeXRu6aeKKiuk+Q6 c+8A4XNFBSRCSRq2bOUm27K1djcxqLHZaGD1TWVYHzrzz/laOwe3qpTW6 djEg0czySmMaucq8AgNz1LnUshAYAHO/xeZRScf3DKZ13QN+r4AkL2mPu F8knTz2/Rj7FZZaPdJoXpMhqpldUt74rUiWEdjLG/iTJvO5m6xZFoNpdc Q==; X-CSE-ConnectionGUID: JjRSerZ0QWWQpd2Cx46L4g== X-CSE-MsgGUID: hD5CmM3RTviPy7UNGKkVWA== X-IronPort-AV: E=McAfee;i="6600,9927,11037"; a="7721282" X-IronPort-AV: E=Sophos;i="6.07,186,1708416000"; d="scan'208";a="7721282" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa111.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 05:48:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11037"; a="937091421" X-IronPort-AV: E=Sophos;i="6.07,186,1708416000"; d="scan'208";a="937091421" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Apr 2024 05:48:05 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id 02584194; Mon, 8 Apr 2024 15:48:03 +0300 (EEST) From: Mika Westerberg To: Yehezkel Bernat , Michael Jamet , Lukas Wunner , Andreas Noever Cc: Gil Fine , linux-usb@vger.kernel.org, Mika Westerberg Subject: [PATCH 1/2] thunderbolt: Fix wake configurations after device unplug Date: Mon, 8 Apr 2024 15:48:02 +0300 Message-ID: <20240408124803.12329-1-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Gil Fine Currently we don't configure correctly the wake events after unplug of device router. What can happen is that the downstream ports of host router will be configured to wake on: USB4-wake and wake-on-disconnect, but not on wake-on-connect. This may cause the later plugged device not to wake the domain and fail in enumeration. Fix this by clearing downstream port's "USB4 Port is Configured" bit, after unplug of a device router. Signed-off-by: Gil Fine Cc: stable@vger.kernel.org Signed-off-by: Mika Westerberg --- drivers/thunderbolt/switch.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/drivers/thunderbolt/switch.c b/drivers/thunderbolt/switch.c index 6ffc4e81ffed..4edfd6e34e31 100644 --- a/drivers/thunderbolt/switch.c +++ b/drivers/thunderbolt/switch.c @@ -3180,22 +3180,29 @@ void tb_switch_unconfigure_link(struct tb_switch *sw) { struct tb_port *up, *down; - if (sw->is_unplugged) - return; if (!tb_route(sw) || tb_switch_is_icm(sw)) return; + /* + * Unconfigure downstream port so that wake-on-connect can be + * configured after router unplug. No need to unconfigure upstream port + * since its router is unplugged. + */ up = tb_upstream_port(sw); - if (tb_switch_is_usb4(up->sw)) - usb4_port_unconfigure(up); - else - tb_lc_unconfigure_port(up); - down = up->remote; if (tb_switch_is_usb4(down->sw)) usb4_port_unconfigure(down); else tb_lc_unconfigure_port(down); + + if (sw->is_unplugged) + return; + + up = tb_upstream_port(sw); + if (tb_switch_is_usb4(up->sw)) + usb4_port_unconfigure(up); + else + tb_lc_unconfigure_port(up); } static void tb_switch_credits_init(struct tb_switch *sw) From patchwork Mon Apr 8 13:00:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 787433 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) (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 838E37BAF7 for ; Mon, 8 Apr 2024 13:01:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.12 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712581290; cv=none; b=dxY1be96d2gMImAY29d9m5gpgkPG43WOCt5ijrhzIJwUH/843FrUccrwhemkDP9aP0LkM69OA/ZArFnAOHzG7pdGNXnMdv6N1+0Zvi2us+tmx52eo2V+J/wIWWGG5JuZG31Mk+cxJpgSljRwdLWgi53d72gpaloe6pUCkgzF7vQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712581290; c=relaxed/simple; bh=WswkIFO0ig2Sn6KRG1ink79eLsSAWWf8lE3yZEvy9sg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NYDHHL9Rr587feqtPMJ7hq/d7/nmDwGjxPtq8mpCA9YeTHRNJ9KYiUueze88U8Hb/yqgEnZRw6nk4ixfSc0PR1uqWgpIjVjwABPSr2FTY30P5qbdM15nwUam71s6qHefXmaKQqgOI6/RKZw6LDRVDnh6F9pKLYfiTkLtTov01So= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=none smtp.mailfrom=linux.intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=Vi1PKeDR; arc=none smtp.client-ip=192.198.163.12 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="Vi1PKeDR" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1712581288; x=1744117288; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=WswkIFO0ig2Sn6KRG1ink79eLsSAWWf8lE3yZEvy9sg=; b=Vi1PKeDR5LazMAwUGvMEN/7YeWCjl6RaI2xZA9df2tc2sDwR2HfKjZOc 5OJN/cVS4W1nJwixiwPD1vwUkRqGOdORzbo8+gXFDveExc7yHYnx4aLps FBpBtTov6b3UMAHU7q4C61Sy6svZTlpkj3PvEJ3n/etm1lFoT+0uvNi7s MwAJXcicxrS+GZ2ZIZOeKhRmoIMMtI8+T4b5ukGlYWJ1EMNGYDg3JdjGw v2AyuGXDKDdBPGld1YgwdBk/IfSljQ3YnKkfKeleBZYA2VWtCcjmftNIA T8DMOFY3z8J/boPotLSJ7QYhRhHFP2lYeCkK0YvK+SSuiMSMHHWgULukg w==; X-CSE-ConnectionGUID: PsI3ZKJLQe+Oi4wu6QKPvw== X-CSE-MsgGUID: yag0as7CSY6bJtTjTxVN6g== X-IronPort-AV: E=McAfee;i="6600,9927,11038"; a="11630689" X-IronPort-AV: E=Sophos;i="6.07,186,1708416000"; d="scan'208";a="11630689" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Apr 2024 06:00:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,11037"; a="937091485" X-IronPort-AV: E=Sophos;i="6.07,186,1708416000"; d="scan'208";a="937091485" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 08 Apr 2024 06:00:33 -0700 Received: by black.fi.intel.com (Postfix, from userid 1001) id DEFAD194; Mon, 8 Apr 2024 16:00:31 +0300 (EEST) From: Mika Westerberg To: Yehezkel Bernat , Michael Jamet , Lukas Wunner , Andreas Noever Cc: Gil Fine , linux-usb@vger.kernel.org, Mika Westerberg Subject: [PATCH 2/2] thunderbolt: Allow USB3 bandwidth to be lower than maximum supported Date: Mon, 8 Apr 2024 16:00:31 +0300 Message-ID: <20240408130031.51616-2-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240408130031.51616-1-mika.westerberg@linux.intel.com> References: <20240408130031.51616-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 From: Gil Fine Currently USB3 tunnel setup fails if USB4 link available bandwidth is too low to allow USB3 Maximum Supported Link Rate. In reality, this limitation is not needed, and may cause failure of USB3 tunnel establishment, if USB4 link available bandwidth is lower than USB3 Maximum Supported Link Rate. E.g. if we connect to USB4 v1 host router, a USB4 v1 device router, via 10 Gb/s cable. Hence, here we discard this limitation, and now we only limit USB3 bandwidth allocation to be not higher than 90% of USB3 Max Supported Link Rate (for first USB3 tunnel only). Signed-off-by: Gil Fine Signed-off-by: Mika Westerberg --- drivers/thunderbolt/tunnel.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/thunderbolt/tunnel.c b/drivers/thunderbolt/tunnel.c index cb6609a56a03..fdc5e8e12ca8 100644 --- a/drivers/thunderbolt/tunnel.c +++ b/drivers/thunderbolt/tunnel.c @@ -2064,26 +2064,21 @@ struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up, { struct tb_tunnel *tunnel; struct tb_path *path; - int max_rate = 0; + int max_rate; - /* - * Check that we have enough bandwidth available for the new - * USB3 tunnel. - */ - if (max_up > 0 || max_down > 0) { + if (!tb_route(down->sw) && (max_up > 0 || max_down > 0)) { + /* + * For USB3 isochronous transfers, we allow bandwidth which is + * not higher than 90% of maximum supported bandwidth by USB3 + * adapters. + */ max_rate = tb_usb3_max_link_rate(down, up); if (max_rate < 0) return NULL; - /* Only 90% can be allocated for USB3 isochronous transfers */ max_rate = max_rate * 90 / 100; - tb_port_dbg(up, "required bandwidth for USB3 tunnel %d Mb/s\n", + tb_port_dbg(up, "maximum required bandwidth for USB3 tunnel %d Mb/s\n", max_rate); - - if (max_rate > max_up || max_rate > max_down) { - tb_port_warn(up, "not enough bandwidth for USB3 tunnel\n"); - return NULL; - } } tunnel = tb_tunnel_alloc(tb, 2, TB_TUNNEL_USB3); @@ -2115,8 +2110,8 @@ struct tb_tunnel *tb_tunnel_alloc_usb3(struct tb *tb, struct tb_port *up, tunnel->paths[TB_USB3_PATH_UP] = path; if (!tb_route(down->sw)) { - tunnel->allocated_up = max_rate; - tunnel->allocated_down = max_rate; + tunnel->allocated_up = min(max_rate, max_up); + tunnel->allocated_down = min(max_rate, max_down); tunnel->init = tb_usb3_init; tunnel->consumed_bandwidth = tb_usb3_consumed_bandwidth;