Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp5115144rdb; Tue, 12 Dec 2023 21:49:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IEILJUbLRn8KuV941JzUoRXItSBOdNivTS5ub2HHEe+Qjql8DXoJBWel+4+t6CUnD4awk1V X-Received: by 2002:a17:902:ecca:b0:1d0:969b:4c0b with SMTP id a10-20020a170902ecca00b001d0969b4c0bmr8290705plh.101.1702446576477; Tue, 12 Dec 2023 21:49:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702446576; cv=none; d=google.com; s=arc-20160816; b=Blw0rs0tmHgyvi8jm5IZnELMSQ2KqbFg4pgZx3aUxNxIErvhJ/beaZpo25tAUHivL8 SbroMTmT69TPWki+ISzo11BsjmJoEJ++qu+NvUnAn6rP7Ujd0DZkQE476GKeD/rcHphc ZfJslygij6Z2HBT6uwJyxcCqhXVvmCXVA7iz0zaN6nk144Rac7P0rUIHDLaH8t9THRB4 tu1ZD15rkk2mj5dBnQ0xwvP3GFAU8heh1O+OrGLGrcdDuI1L+oiuJJeMFoX4VnZygRQU aA9hSwXGGUa4OOmQ1qiM+fG7Qds5SSjuiAf3EsCl7XPkbGgXPOfiM0F/g475DhFZx0Bt lDaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=iKuvfqlr69CSXgMdXBgQ6CXRNeoZh6hQbiapgoZEiDA=; fh=JVYJ431iTAgXtLeSxtg6aSQZvqV2ivz+awLcZ3Jv578=; b=0YZIDedCJMVEcSLmqyHST5g4bWeGx2qGFuHi6JaHI13zEvYhqKQh/9OYvyC0yeWs3i +qRKuRXz5FL4cWrSzhA35PehSvn43veDT2kub/1K7RvipT3ggD0LzSH9VCZbKuFdfVuK D8n+NP5+wpKenCqMXoNq09ERPVp64WAUWEyMdcIPBc7W2uuE6cNfzAiawA7ZZxxkybuG V0LG3HH058sJWkzHmd5z/U+ir41dyYGETNNsCyw6fm3OY+c6Kk/RMCCVboTd0/Ywe3fj fRkgfcUwarxShrGShRRKcQ0IKOUVIXMfL+7Zoya/mkWcWfg42K7Qq3Xeh5IgGQiV98pR mniA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dQl/4FVO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id t4-20020a170902e84400b001d09c96ba02si9191983plg.124.2023.12.12.21.49.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 21:49:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="dQl/4FVO"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id EEB0380AD513; Tue, 12 Dec 2023 21:49:33 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231392AbjLMFtN (ORCPT + 99 others); Wed, 13 Dec 2023 00:49:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36030 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229476AbjLMFtM (ORCPT ); Wed, 13 Dec 2023 00:49:12 -0500 Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.10]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9B46BD5; Tue, 12 Dec 2023 21:49:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1702446559; x=1733982559; h=date:from:to:cc:subject:message-id:references: mime-version:in-reply-to; bh=SsaQkpHhN6qwDUl/4cB55YY56chz5bCm3Ro9s3TVmKM=; b=dQl/4FVOeDEG0GoZjjoax0TKTaMEZjWbDLCvjFezGzwmQ0ClcIB+DF3z PalY1rztemxAYFLgx/i0Mp5+Rn/ZjrGG3w8FNFG7HNkAjKXrok2qomVQZ bfMYbxmvNWi9E+y2/1olJ/uS2oeCCWU8P6kKgAtoZOpONaxi7cS6dlrUX 3QUpqo/VTiVGGn5htyne0/06zv/8ej7TKugHPEC3QSYY6qZnaSLKpErpT CowMGwspMOQoKvD39ZIg5F64k7LFmHXwfTLNFKEUaHgva8Go6ftjfRmz2 E++JzfxwYXx+1LlCeP4hFN3jpZEuumqtZlgUAz2dyrUMbrxdYgwuFFIRW A==; X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="8277349" X-IronPort-AV: E=Sophos;i="6.04,272,1695711600"; d="scan'208";a="8277349" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orvoesa102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Dec 2023 21:49:18 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10922"; a="749989441" X-IronPort-AV: E=Sophos;i="6.04,272,1695711600"; d="scan'208";a="749989441" Received: from black.fi.intel.com ([10.237.72.28]) by orsmga006.jf.intel.com with ESMTP; 12 Dec 2023 21:49:15 -0800 Received: by black.fi.intel.com (Postfix, from userid 1001) id 62FE91A7; Wed, 13 Dec 2023 07:49:14 +0200 (EET) Date: Wed, 13 Dec 2023 07:49:14 +0200 From: Mika Westerberg To: Sanath S Cc: mario.limonciello@amd.com, andreas.noever@gmail.com, michael.jamet@intel.com, YehezkelShB@gmail.com, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [Patch v2 2/2] thunderbolt: Teardown tunnels and reset downstream ports created by boot firmware Message-ID: <20231213054914.GI1074920@black.fi.intel.com> References: <20231212191635.2022520-1-Sanath.S@amd.com> <20231212191635.2022520-3-Sanath.S@amd.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20231212191635.2022520-3-Sanath.S@amd.com> X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Tue, 12 Dec 2023 21:49:34 -0800 (PST) On Wed, Dec 13, 2023 at 12:46:35AM +0530, Sanath S wrote: > Boot firmware might have created tunnels of its own. Since we cannot > be sure they are usable for us. Tear them down and reset the ports > to handle it as a new hotplug for USB3 routers. > > Suggested-by: Mario Limonciello > Signed-off-by: Sanath S > --- > drivers/thunderbolt/tb.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/thunderbolt/tb.c b/drivers/thunderbolt/tb.c > index fd49f86e0353..febd0b6972e3 100644 > --- a/drivers/thunderbolt/tb.c > +++ b/drivers/thunderbolt/tb.c > @@ -2598,6 +2598,17 @@ static int tb_start(struct tb *tb) > tb_switch_tmu_enable(tb->root_switch); > /* Full scan to discover devices added before the driver was loaded. */ > tb_scan_switch(tb->root_switch); > + /* > + * Boot firmware might have created tunnels of its own. Since we cannot > + * be sure they are usable for us, Tear them down and reset the ports > + * to handle it as new hotplug for USB4 routers. > + */ > + if (tb_switch_is_usb4(tb->root_switch)) { > + tb_switch_discover_tunnels(tb->root_switch, > + &tcm->tunnel_list, false); Why this is needed? It should be enough, to do simply something like this: if (tb_switch_is_usb4(tb->root_switch)) tb_switch_reset(tb->root_switch); and continue with the rest of the function. The tb_switch_reset() then resets the downstream ports synchronously so when it returns there is nothing to be discover. (We can use the tb_switch_reset() here, it already exists and is performing TBT 1 specific things but you can make it handle downstream port reset in case of USB4). You don't need to touch the ->hotplug_active or anything else here. > + tcm->hotplug_active = true; > + return tb_switch_reset_ports(tb->root_switch); > + } > /* Find out tunnels created by the boot firmware */ > tb_discover_tunnels(tb); > /* Add DP resources from the DP tunnels created by the boot firmware */ > -- > 2.34.1