From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=amd.com header.i=@amd.com header.b="n4dmVWyR" Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2070.outbound.protection.outlook.com [40.107.237.70]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E547812B; Wed, 13 Dec 2023 02:35:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ygfg6hkyLsZtOvAvAG8JQ7fb9KesUajYU1VHFgpDIj6JnqVyCJXBGgWy85q0BuThU0nha2qxKHNJzKxiOrtsIVXWqY6zvi7SGQRSkXfeIoNBn9/Ey7InVQsl0L3V2Y7FX5DPAK+Ym/np+uyeHRazjVI+WcRYNekR8M6JI+7l3DCiZBoDq6F3ik4LfKcuR0ZdJ21ZsjwFKvRV4Tzyve3DNCXBDJm93rbBkDrE72TjFvhPqRK5gQC9Bq6NpbsLBRsTAlrOPnyufZrkBMfIh+Op3H1dlHkm5Q+DjaAsPC6/hJJLwo8c8BR6H14JxADed4uGpPpcMQ7XjYIlT/9D1pRS5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=oJWm9Rx+UtwUZYZFJkczuFMdP7EjzEq2ZomOQRsasbU=; b=XhKjRMhrmxCghHt7o/Pr79QH1ie3dh6UvxWjdBsHdQrvvPR/pwZX2pyom+4RY/7llUvUrBV9H2lV052iERomtBiBxXXHyZMMBtlnG1SBDcetQijzoDhcEEtZCyGy+kv7S8rjCJG7CRKsKzKIBzL1B2CVIKWVT3iY97TCOjxbElvX9uh0JRTpa5f4Ac6IResPHAWQeKcOQhi96AX/0GPvyQvewYh7/ZaW8KBz8Q1UaF3RE9xFxdkGC3UVqywLrbw47OHKA66jBh6nuKqN5KxaLGZdDxgbo5BOU/YBQmapC3T5qjKDWLE4/0zDM0BojBequ+GZ5DUt73R8Ke4R8VQCVQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=oJWm9Rx+UtwUZYZFJkczuFMdP7EjzEq2ZomOQRsasbU=; b=n4dmVWyRbLZpLmczzUyTYl/wW97IEOBWbi74rcEIEAh2yLY1Fzjg9JRatNoLb0ACiVwqXHq4+TDlB/UF4pMUfJgpJuD3I/b/Km9XWsAxxUspXQnKCWjGuGeS30W9qACP77hXNeQ2Ths1zawSBHzLWg/6x4narJqNWRACt/1RFeU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=amd.com; Received: from MW4PR12MB7016.namprd12.prod.outlook.com (2603:10b6:303:218::14) by SA1PR12MB6895.namprd12.prod.outlook.com (2603:10b6:806:24e::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.26; Wed, 13 Dec 2023 10:35:06 +0000 Received: from MW4PR12MB7016.namprd12.prod.outlook.com ([fe80::1f1b:e85b:abf0:3d3c]) by MW4PR12MB7016.namprd12.prod.outlook.com ([fe80::1f1b:e85b:abf0:3d3c%6]) with mapi id 15.20.7091.022; Wed, 13 Dec 2023 10:35:06 +0000 Message-ID: Date: Wed, 13 Dec 2023 16:04:57 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: [Patch v2 2/2] thunderbolt: Teardown tunnels and reset downstream ports created by boot firmware Content-Language: en-US To: Mika Westerberg , 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 References: <20231212191635.2022520-1-Sanath.S@amd.com> <20231212191635.2022520-3-Sanath.S@amd.com> <20231213054914.GI1074920@black.fi.intel.com> <20231213061805.GK1074920@black.fi.intel.com> <20231213062306.GL1074920@black.fi.intel.com> From: Sanath S In-Reply-To: <20231213062306.GL1074920@black.fi.intel.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-ClientProxiedBy: PN2PR01CA0218.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c01:ea::10) To MW4PR12MB7016.namprd12.prod.outlook.com (2603:10b6:303:218::14) Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: MW4PR12MB7016:EE_|SA1PR12MB6895:EE_ X-MS-Office365-Filtering-Correlation-Id: bd63527b-82d5-4077-ec11-08dbfbc72bff X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bQ1yueQKTDarkYS34B2LhfUJGWOZ7XQc70uuVXtZgiBQvooL1oJW2qGy/McUYewwBGObGb36WP8y1uWXHirHbNI56fM0NFcsxQOchrJXlBKVURIKl17vLQIlR306231obt6QcHdv92lAee8G/qSElcy3/udv6J27kV63VQ9LCObDdxEeZeETp2ioaGTRnRDFJgLKu5bvs3b4C/iRMZPU3gXDWAzBNAGZ3plzYyN+HEPG8UEc3Q346CPR7GQh2R6DQnqwOt+ugSQn5iXN7zxMijIJxqp1pGpqn5PkvHDOnJj9nMQJivojlQk//5bNTxYrkYxYuBaloguDdHPK81OX23cURVmBFFxNKCPQxLxn3O8HBrHjqaPJgnPAwh4eJT5dcNwYDMhcR2rSAHNmK/vPzASpi7NRzKZYsJ9eST8uaR1Fgu7BO/mhj20M/7PJe045qAFMg74qdv/W01jyChUhj9C7GcGDcwkP1smcOX0MhmBVL0jNEarFYESJhsEbaraNrxCSRvDsr2BNLTVYALhAMzgSUYeKZ3bX96GVpdO31bbCaoTwf/uBV9PS330zWQ0cdkC1ndEFkTfXDyQaFGfoB0MxoUmG7AvpU/a11QOgzmFPs4jYq/9J+dKT2pc55rYJD506YtR3cnOgN0ITB6imLw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR12MB7016.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(396003)(346002)(366004)(136003)(376002)(230922051799003)(64100799003)(1800799012)(186009)(451199024)(66574015)(2616005)(26005)(6506007)(6512007)(6666004)(53546011)(83380400001)(8676002)(5660300002)(4326008)(8936002)(41300700001)(2906002)(6486002)(478600001)(316002)(6636002)(66556008)(66946007)(110136005)(66476007)(31696002)(38100700002)(36756003)(31686004)(45980500001)(43740500002);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?aTdRUU9oSjZRUG9CQzNxem5CZHZMcUx6ckVmNVJ5cVJiaUMyRUR5L256a1dx?= =?utf-8?B?dHJTVWFrYjd4bVZaRllNSTFRTnFGVFJkK0hRbWxaOFAxdUdKRExEamZ1VlA2?= =?utf-8?B?MkFCcE5uckhOUGhnZHlRNE9GaFNzZnU5T1h0NVBXUnVBNWRHcUgvTno0Yys0?= =?utf-8?B?VUdKK1MzUUcrblV5WkpsZzU1ZUJ0c01SczlUNmhwNFFwdmk4dnBYd1oxUk9l?= =?utf-8?B?QzQzYVFRWVF0THJYWWFLbU1QYmVKT0JpTmFYTW50U3VIUzhXaDVUUktiT3VN?= =?utf-8?B?YmhaVXRGZUtZaDFOVGlDNHpqaXVxN3pRdk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R4?= =?utf-8?Q?K9MidB1Oq7xSWGCKnV60w5mr3?= X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: bd63527b-82d5-4077-ec11-08dbfbc72bff X-MS-Exchange-CrossTenant-AuthSource: MW4PR12MB7016.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Dec 2023 10:35:06.3567 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /sPjR0WE0h4UDwaoFjr+5mHTgOtajIDHhrEN4X4lwEbG08tfx5W1aq99V91+izCjx+jBa773pLNOTJhTk8mKpA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA1PR12MB6895 On 12/13/2023 11:53 AM, Mika Westerberg wrote: > On Wed, Dec 13, 2023 at 08:18:06AM +0200, Mika Westerberg wrote: >> On Wed, Dec 13, 2023 at 07:49:14AM +0200, Mika Westerberg wrote: >>> 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); If we don't tear down of tunnels before performing the DPR, the PCIe enumeration is failing. PCIe link is not coming up after DPR. Below log is missing without performing path deactivation before performing DPR and hence PCIe enumeration is not initiated. [  746.630865] pcieport 0000:00:03.1: pciehp: Slot(0-1): Card present [  746.630885] pcieport 0000:00:03.1: pciehp: Slot(0-1): Link Up I think when we do a DPR, it internally does some handling with PCI Path Enable bit(PE). So, deactivation of PCIe path is necessary for DPR to work. >> Actually this needs to be done only for USB4 v1 routers since we already >> reset USB4 v2 hosts so something like: >> >> /* >> * Reset USB4 v1 host router to get rid of possible tunnels the >> * boot firmware created. This makes sure all the tunnels are >> * created by us and thus have known configuration. >> * >> * For USB4 v2 and beyond we do this in nhi_reset() using the >> * host router reset interface. >> */ >> if (usb4_switch_version(tb->root_switch) == 1) >> tb_switch_reset(tb->root_switch); >> >> (possibly add similar comment to the nhi_reset() to refer this one). > Oh, and would it be possible to tie this with the "host_reset" parameter > too somehow? I guess it could be moved to "tb.c" and "tb.h" and then > check it from nhi.c as already done and then here so this would become: > > if (host_reset && usb4_switch_version(tb->root_switch) == 1) > tb_switch_reset(tb->root_switch); Is host_reset necessary for USB4 v1 routers ? I did not use host_reset in this case. If its needed, then we have to modify to enable host_reset in nhi.c as well. > With the idea that the user has a "chicken bit" to disable this > behaviour (and consistent one with USB4 v2). Feel free to make it look > nicer though.