From patchwork Tue Feb 6 13:03:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 13547235 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 AA98C130AD5 for ; Tue, 6 Feb 2024 13:04:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707224643; cv=none; b=PB3R3EwEqlqxTsE+pCdpjJxMGSG3wviMHEePCF7jUvqkqBRLJVYFP8j0Waia4CHY9oAx9/w9kzCoxVtMHRWm4W3AcocVtwQoCSw3rMDiupYy03JxoWQBNQiBNp6A1CrLTRi5JDpuSzd3a/Ae5OcEV3/wxLAHZuCK6W8sfdtNm3s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707224643; c=relaxed/simple; bh=BMpyZSB+/DXjAyPNqf20LCTgX2m6iZ4bG6DG0g0gck0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XhJK0T+1clKehOLMz70E9Hrq1phpdwIEnnNkM9Tqfa28Xtp6Cv8HV7PbR+oQtxVxYFFsLWWiufB0/jQokyRJbXHjRaedeCHIBh/GKnY6NFqySaMRBC6Yn6V7JbBxx4TlNUfYlT/9OmOAKwP8/3APKXTdLQClH6fNbsZQWwAif40= 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=jcm57zI+; arc=none smtp.client-ip=192.198.163.7 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="jcm57zI+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707224641; x=1738760641; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=BMpyZSB+/DXjAyPNqf20LCTgX2m6iZ4bG6DG0g0gck0=; b=jcm57zI+ljGQY4H05SzvmkhF00ZZBfrvuEeDu1I6ccVXlzL4TPsTPqAD NVVCX2XNyj1mC+y6IlhBiKFu8FIzVV3C1P/nKW/1zVb70F67ZChPXcgfr Ene8qLMXI/QLKImVhksWIL0+R4C0LzooI0eBg4BjNPwaxNamwZjhdUNVw 9L/2l1m7S42C7v1RMsNQd9le62QCbytrWNR39TE4bvxPzPD+u4MCfnV/B B4eh93y+Rht9lWjbqHjt+C6t8lR2dHviQVRLNMlF155ZljWKKi1O+NGfl t/5ZSLazBvGrSevA+NhWErMJwq/wGhveln2QuTeMGVgi9L1nYAPSPcZWb g==; X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="26185054" X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="26185054" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 05:03:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="909631994" X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="909631994" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 06 Feb 2024 05:03:56 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id 04A7EB84; Tue, 6 Feb 2024 15:03:54 +0200 (EET) From: Mika Westerberg To: linux-usb@vger.kernel.org Cc: Yehezkel Bernat , Michael Jamet , Lukas Wunner , Andreas Noever , Sanath S , Mario Limonciello , Mika Westerberg Subject: [PATCH 1/3] thunderbolt: Reset only non-USB4 host routers in resume Date: Tue, 6 Feb 2024 15:03:52 +0200 Message-ID: <20240206130354.1208816-2-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206130354.1208816-1-mika.westerberg@linux.intel.com> References: <20240206130354.1208816-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 There is no need to reset the USB4 host routers on resume because they are reset already and this may cause problems if the link does not come up soon enough. For this reason limit this to happen in non-USB4 host routers only (that's Apple systems with Intel Thunderbolt controllers). Fixes: 59a54c5f3dbd ("thunderbolt: Reset topology created by the boot firmware") Cc: Sanath S Signed-off-by: Mika Westerberg --- drivers/thunderbolt/tb.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index 9a261560d0f4..f127088b6ebd 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -2710,8 +2710,12 @@ static int tb_resume_noirq(struct tb *tb) tb_dbg(tb, "resuming...\n"); - /* remove any pci devices the firmware might have setup */ - tb_switch_reset(tb->root_switch); + /* + * For non-USB4 hosts (Apple systems) remove any PCIe devices + * the firmware might have setup. + */ + if (!tb_switch_is_usb4(tb->root_switch)) + tb_switch_reset(tb->root_switch); tb_switch_resume(tb->root_switch); tb_free_invalid_tunnels(tb); From patchwork Tue Feb 6 13:03:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 13547233 Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.7]) (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 28F7F12F382 for ; Tue, 6 Feb 2024 13:03:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=192.198.163.7 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707224640; cv=none; b=fif94sYrvuIYfh8fIhJE4ZSHaD+8y7JIkUhbyKlUOLet67OLKLuUe+XmuChnQIj5W5J4sbmJOOwUWGWoxJceTVCrjflQc5/OR14HN0+kwgnlVz1Y3vCDFdMfdl5vu6WUbUN+UChHVLLL30bQO31ZytFONsHUGHTM2oOQu61P1aQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707224640; c=relaxed/simple; bh=tEYJTZobOhb6mVQoly1IcMHB+yMhUn4vnHML1wc/Zgw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=e0WAIKeFDMKCiky6To4+sFiXYBUysm1394qZHKZkElRMbdux0BratNLaPdHLHKzqzDqgIFH/HJjh869jbY/1ym6MF5ga7juS6+Dajd/eX5Fk1HCchxA+iu0TPx44h1ailNLTqMIEFOZtdod2uGXd/7aV2JblNwzNGFs3S8U+us4= 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=nDvivrn+; arc=none smtp.client-ip=192.198.163.7 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="nDvivrn+" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707224638; x=1738760638; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=tEYJTZobOhb6mVQoly1IcMHB+yMhUn4vnHML1wc/Zgw=; b=nDvivrn+YPoJiW4pWeoJ9Wqn9qqipsKoLVRhDZLNzhpiYEbfqNWWlG43 vrbF7v3nI0m4l6lHtcTpaMFURoo8wxzr1fQ6T8MkY40Jdp7c7SD/hM9+k /DxliLL2p2ZyrdZSEzs8/H5B222F5zHBGoWlRVbZk2E6ILUDqxMoggDnB Qpnkals5KcOe9SWvTcsQhHDX6NOLE0iErK+vF4NyJv9n/uuCnU2f9hovu gP81WGKlp6O90R7nwMXTgrZ6faMOJwZow+GJYrOxWWz7ONtZgBMa29IwJ oEe+iNSEaakFdkT9LsicbdvVhU+m0Xu8ERSF18w76h0TcF5b9QiqAOZPV A==; X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="26185045" X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="26185045" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmvoesa101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 05:03:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="909631989" X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="909631989" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga002.fm.intel.com with ESMTP; 06 Feb 2024 05:03:56 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id 101ECF3C; Tue, 6 Feb 2024 15:03:55 +0200 (EET) From: Mika Westerberg To: linux-usb@vger.kernel.org Cc: Yehezkel Bernat , Michael Jamet , Lukas Wunner , Andreas Noever , Sanath S , Mario Limonciello , Mika Westerberg Subject: [PATCH 2/3] thunderbolt: Skip discovery also in USB4 v2 host Date: Tue, 6 Feb 2024 15:03:53 +0200 Message-ID: <20240206130354.1208816-3-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206130354.1208816-1-mika.westerberg@linux.intel.com> References: <20240206130354.1208816-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 If the host router is reset, there is no point running discovery as the links are down. Furthermore this prevents CL-state enabling. For this reason skip discovery in USB4 v2 host the same way we do with USB4 v1. Signed-off-by: Mika Westerberg --- drivers/thunderbolt/nhi.c | 20 ++++++-------------- drivers/thunderbolt/tb.c | 11 ++++++++--- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index e8a4623dc531..91e26b982b0b 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c @@ -1221,7 +1221,7 @@ static void nhi_check_iommu(struct tb_nhi *nhi) str_enabled_disabled(port_ok)); } -static bool nhi_reset(struct tb_nhi *nhi) +static void nhi_reset(struct tb_nhi *nhi) { ktime_t timeout; u32 val; @@ -1229,11 +1229,11 @@ static bool nhi_reset(struct tb_nhi *nhi) val = ioread32(nhi->iobase + REG_CAPS); /* Reset only v2 and later routers */ if (FIELD_GET(REG_CAPS_VERSION_MASK, val) < REG_CAPS_VERSION_2) - return false; + return; if (!host_reset) { dev_dbg(&nhi->pdev->dev, "skipping host router reset\n"); - return false; + return; } iowrite32(REG_RESET_HRR, nhi->iobase + REG_RESET); @@ -1244,14 +1244,12 @@ static bool nhi_reset(struct tb_nhi *nhi) val = ioread32(nhi->iobase + REG_RESET); if (!(val & REG_RESET_HRR)) { dev_warn(&nhi->pdev->dev, "host router reset successful\n"); - return true; + return; } usleep_range(10, 20); } while (ktime_before(ktime_get(), timeout)); dev_warn(&nhi->pdev->dev, "timeout resetting host router\n"); - - return false; } static int nhi_init_msi(struct tb_nhi *nhi) @@ -1333,7 +1331,6 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id) struct device *dev = &pdev->dev; struct tb_nhi *nhi; struct tb *tb; - bool reset; int res; if (!nhi_imr_valid(pdev)) @@ -1367,12 +1364,7 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id) nhi_check_quirks(nhi); nhi_check_iommu(nhi); - - /* - * Only USB4 v2 hosts support host reset so if we already did - * that then don't do it again when the domain is initialized. - */ - reset = nhi_reset(nhi) ? false : host_reset; + nhi_reset(nhi); res = nhi_init_msi(nhi); if (res) @@ -1399,7 +1391,7 @@ static int nhi_probe(struct pci_dev *pdev, const struct pci_device_id *id) dev_dbg(dev, "NHI initialized, starting thunderbolt\n"); - res = tb_domain_add(tb, reset); + res = tb_domain_add(tb, host_reset); if (res) { /* * At this point the RX/TX rings might already have been diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c index f127088b6ebd..64dd22e1f5b2 100644 --- a/drivers/thunderbolt/tb.c +++ b/drivers/thunderbolt/tb.c @@ -2584,6 +2584,7 @@ static int tb_scan_finalize_switch(struct device *dev, void *data) static int tb_start(struct tb *tb, bool reset) { struct tb_cm *tcm = tb_priv(tb); + bool discover = true; int ret; tb->root_switch = tb_switch_alloc(tb, &tb->dev, 0); @@ -2629,9 +2630,13 @@ static int tb_start(struct tb *tb, bool reset) * reset the ports to handle it as new hotplug for USB4 v1 * routers (for USB4 v2 and beyond we already do host reset). */ - if (reset && usb4_switch_version(tb->root_switch) == 1) { - tb_switch_reset(tb->root_switch); - } else { + if (reset && tb_switch_is_usb4(tb->root_switch)) { + discover = false; + if (usb4_switch_version(tb->root_switch) == 1) + tb_switch_reset(tb->root_switch); + } + + if (discover) { /* 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 */ From patchwork Tue Feb 6 13:03:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 13547232 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.20]) (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 4036712FF68 for ; Tue, 6 Feb 2024 13:03:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707224640; cv=none; b=QxNBfFzaNPDCYOtUTFHPQNivvb1FBExiw03g/5qo7mML+u7rIcusCQ3q2of5FwdkaTIEFquGZD8Gz1XET+dHMM1l+tHZ7XqGnmjuchKzJAlfHBAfR0OQvhVLJT83rxOwkgT0/osraECC3jIwAJb7EbR1Lj47S9SnSnFf3WTJrDw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707224640; c=relaxed/simple; bh=DG2ETpLs4dhZ4JwGEa3PYT8ZwSlOq4693Qx5hX3e8iE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UbYJTnpSdYkH/R/iFxW/bKcX0FdWs/GHLiGksLik7i4J31tXvDI12hAwaSPVINEkZZOVkVn2cWlcbazT7+rQV7BQQxHarqRxHysqK6bhOis9Z4rt1MXN+E3LbEntQl1GIFHwaNZfITKtN1xtZQ7agPYU+a38KUlBF/iEG+XnVeE= 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=lsx5pjKp; arc=none smtp.client-ip=198.175.65.20 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="lsx5pjKp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1707224639; x=1738760639; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=DG2ETpLs4dhZ4JwGEa3PYT8ZwSlOq4693Qx5hX3e8iE=; b=lsx5pjKpnio8OgJSmVuwef5D8ufnZXmL8sHlUZ0VtQDO0Jh+Q/xR0yQM AlyfJuAPqyaRlqmNMseloVxC08HCEuodkpZqOcSX+lmYDrYTkIjQDg5zH thctUIVapF3atqYf1HIqjJSdMmmFlXBGRHWLLQ53QXXUzeTHIlL/cGUOx c9nX+I7DV0Ch8FSTA6XsttmLGGbyuH9GSY1zdT2txBue/PO9blUxsHLhE iEPcBH3vi9Jx70rrxfSuzLUU3J+CVD/bGuOCbvmXMsKmG2axjfi/8q2Bc dX/YI0aQgIUtUnU7YLjZ5O5+J//leTyYY9EKshSoDtNNT+cKJ747O2ogC g==; X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="642154" X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="642154" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orvoesa112.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Feb 2024 05:03:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="933455849" X-IronPort-AV: E=Sophos;i="6.05,247,1701158400"; d="scan'208";a="933455849" Received: from black.fi.intel.com ([10.237.72.28]) by fmsmga001.fm.intel.com with ESMTP; 06 Feb 2024 05:03:56 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id 17062F4D; Tue, 6 Feb 2024 15:03:55 +0200 (EET) From: Mika Westerberg To: linux-usb@vger.kernel.org Cc: Yehezkel Bernat , Michael Jamet , Lukas Wunner , Andreas Noever , Sanath S , Mario Limonciello , Mika Westerberg Subject: [PATCH 3/3] thunderbolt: Correct typo in host_reset parameter Date: Tue, 6 Feb 2024 15:03:54 +0200 Message-ID: <20240206130354.1208816-4-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240206130354.1208816-1-mika.westerberg@linux.intel.com> References: <20240206130354.1208816-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 It should say USB4 now since we reset by default all USB4 host routers. Signed-off-by: Mika Westerberg --- drivers/thunderbolt/nhi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/thunderbolt/nhi.c b/drivers/thunderbolt/nhi.c index 91e26b982b0b..7af2642b97cb 100644 --- a/drivers/thunderbolt/nhi.c +++ b/drivers/thunderbolt/nhi.c @@ -48,7 +48,7 @@ static bool host_reset = true; module_param(host_reset, bool, 0444); -MODULE_PARM_DESC(host_reset, "reset USBv2 host router (default: true)"); +MODULE_PARM_DESC(host_reset, "reset USB4 host router (default: true)"); static int ring_interrupt_index(const struct tb_ring *ring) {