From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from BN1PR04CU002.outbound.protection.outlook.com (mail-eastus2azon11020112.outbound.protection.outlook.com [52.101.56.112]) (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 820A36BB5B; Mon, 14 Jul 2025 15:15:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.56.112 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752506155; cv=fail; b=lN47zDsOqPipfINJFyK2Hwb4T8hGBOihELiylD+/DZaVZLpBIvPjym2rdlyytgfLfj8rJ4LDPQ7e+0iqqajLvLnuM6lMjxIAofbcnu2T5c63IV0IZpDPzNXAYqfYtZPI1WMZBpdO0OAdEdJnuWzRu3dGEcti+TcTxeDw1iGuJTI= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752506155; c=relaxed/simple; bh=A56Psng3IOBuQ+hR1mqZFhtcijrUlbwsKHNIWOaQrW4=; h=Date:From:To:Cc:Subject:Message-ID:References:Content-Type: Content-Disposition:In-Reply-To:MIME-Version; b=KYWvs9uVVS1ZRuKB1ZLQAK4Yi2txQqPvqE6oMMtDe+jqQdIGsLlKJcB9cXr99pHTOHjzPrv5+Kllpvdla0tsXTQqfKy94OxzPysGz2pyNnj9jjL9McLtVQ8ryfdT6hZGt7Mc2Zf7DhXk3rRR4Zcl4qmzIPPRA7fRCajDgb7VO3k= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inmusicbrands.com; spf=pass smtp.mailfrom=inmusicbrands.com; dkim=pass (1024-bit key) header.d=inmusicbrands.com header.i=@inmusicbrands.com header.b=G6egAU5o; arc=fail smtp.client-ip=52.101.56.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=inmusicbrands.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=inmusicbrands.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=inmusicbrands.com header.i=@inmusicbrands.com header.b="G6egAU5o" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jk2IqVgMNJ9O1tLnhnQqoagsZw178bQ3iNEdlEwTrh4h7gHdhl4uKGVPPAHiEbfjyChmTX8oTR9xmb8Ss1mXVyi41RHkmGhfwr0bFRBzd2UJJ2aU2lIDfC1g0tXNi+KF1mb1iCK2o+pLXhrScfIEy4NfppEmwAOdo2auAzTbjKTBXs0RpJRnqxc0McQzaumf4YMCpyw7KtRSASE6ZF3pZ3vFFcPWneif/BlpL1BmsWuXl+kK5xzciYrVo+AdT85P9dI4eedGc7ghOYUG5GzVl+TH6HH0qyIFeI03VgVC7iCKIgHgoDhl8SSuxUiqjLHFjCnKuvlsKlcZXxJmyMN0WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=9ygSKGZL8Na83xJlW8HqlTS26a5PsVkiYYDDUARydCI=; b=KsPS3myTnyEIomHLSBL/+PvVLzJRSUAHmIhZ4wE6V3V6Ff/jbMiFvgAPPpNooAsNBIFKfb1JMcOSkZuW4gG+wFYpSLBXUn+CDKj5ehSkW1KEelBYNQ2rSm/S0GbsZvpBHAegFbdxeU/Ul8EbpW4KjaoX8aR83aViBAuct2CevG7BmneZn/IydD64vgo7VN02VJufG8vSL5uPY69pH1NaJ8HMHuqmRc/wXqpabxmcf2tpykdJcIzK2ZFGMp1JBRpb1wwNOh4z+k7tDLBqKX/fLs87WZwa8v8zp3qI+Iqo4zYtjsOYFamBLPmYKbso3Y9O61fSaq3cGh1RONdUzUMl3A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=inmusicbrands.com; dmarc=pass action=none header.from=inmusicbrands.com; dkim=pass header.d=inmusicbrands.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=inmusicbrands.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=9ygSKGZL8Na83xJlW8HqlTS26a5PsVkiYYDDUARydCI=; b=G6egAU5oA4Knn2YdT69BP9TCGU3IWOiMtNYWXmWbylbXk4vXmhIUkBVAVJAR7Pvh3iAekhxtlGTRmiGNdsVRcTv3q0YNkRCjBQyHu7M4zxov4kLy8yKgmkfwA9mLy7p2VbXIt7IaglHJaLTiqkEY4+Wzeo5vgl1tL4TnLQiPW14= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=inmusicbrands.com; Received: from MW4PR08MB8282.namprd08.prod.outlook.com (2603:10b6:303:1bd::18) by SA2PR08MB6716.namprd08.prod.outlook.com (2603:10b6:806:11c::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8922.33; Mon, 14 Jul 2025 15:15:42 +0000 Received: from MW4PR08MB8282.namprd08.prod.outlook.com ([fe80::55b3:31f1:11c0:4401]) by MW4PR08MB8282.namprd08.prod.outlook.com ([fe80::55b3:31f1:11c0:4401%7]) with mapi id 15.20.8922.023; Mon, 14 Jul 2025 15:15:40 +0000 Date: Mon, 14 Jul 2025 16:15:32 +0100 From: John Keeping To: Thinh Nguyen Cc: "linux-rockchip@lists.infradead.org" , Vinod Koul , Kishon Vijay Abraham I , Heiko Stuebner , Greg Kroah-Hartman , Sebastian Reichel , Nicolas Frattaroli , Neil Armstrong , "linux-usb@vger.kernel.org" , "linux-phy@lists.infradead.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: Re: [RFC/PATCH 1/2] usb: dwc3: disable for USB_ROLE_NONE Message-ID: References: <20250710152252.2532020-1-jkeeping@inmusicbrands.com> <20250710152252.2532020-2-jkeeping@inmusicbrands.com> <20250712001131.ax3rw24h3deekxfv@synopsys.com> Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250712001131.ax3rw24h3deekxfv@synopsys.com> X-ClientProxiedBy: LO2P265CA0160.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:9::28) To MW4PR08MB8282.namprd08.prod.outlook.com (2603:10b6:303:1bd::18) 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: MW4PR08MB8282:EE_|SA2PR08MB6716:EE_ X-MS-Office365-Filtering-Correlation-Id: fb44d944-6b74-4f7b-8379-08ddc2e94b59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?0muWFhu+jsXp1WDpSsQ6WpMKg+FRXzQY9xpCbmPQN4s0uDwxgrUgfO6RcWnn?= =?us-ascii?Q?yW1X+DTxU/Do1ZADAqnvvHS6X9td6uAGr3XaaOitWrq7vsrKKVSgtadtKxex?= =?us-ascii?Q?9LlNLCepIxDW3tBGKABFKrNBUWt3uQQP5meYQkEu99dgGuRJu5pSB8cjtiys?= =?us-ascii?Q?cnRVxTZln7n+82BIkTTCSmWnXGspPWxoOSS9jdDn5SlyNXmexL5rol/tinFi?= =?us-ascii?Q?j1lO2oAax6oAIC2H5L+0gSXAiPLn1PdvAmZNUMr5FDVloo41wKFm3SEHE3Z5?= =?us-ascii?Q?HD4t7h4ARSxSbh5tl8I8TWL1l2cp2BNexiq7lflFrCRBvZuYOa6RhL8cqPfL?= =?us-ascii?Q?Itmluq4EUh7nGpOQSnN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?Q?+nVnZGhI58eSIcywlMxdHDhX8rkHYAdg98X/MSyyCa3Cp1ldb5qxsuCIHKs8?= =?us-ascii?Q?S+eXpr79PU/fvlM6++tuSauHSazKIfJd2i8u/PrvY3p+gvFIWw3yToQvC8Pa?= =?us-ascii?Q?vX7imMeuSNK4I1MxDEsZ6WXPtuZcmFzvWUfqK1m8BOusIlR+ZopOnCfwWGGe?= =?us-ascii?Q?Prwy837iAS1EIudlFOhiUzIneOUqyPQHmWXV8Ic3X8B/mIzz6RwkfQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:MW4PR08MB8282.namprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(52116014)(38350700014);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?wzAEQy2pRTc+RXH+nSa5S5ZLviB9wpHnDeSVTxO3pPR//T9UTUZ2YtSSSkm3?= =?us-ascii?Q?HMgCBFF+L6oLS5nexHNmYn2SOUOi0RwDmrv1cEM0LAQzpJcgl2qi+MgLi8H7?= =?us-ascii?Q?KM3UgK9OaCAJ9sZHGQGh0j5hNPMbTGSHXgXA5T+heRUG2K15o+NJBd+QRZ8u?= =?us-ascii?Q?jUB819xmdN59x6DzqsKQF6S6A7NgKf2Z8bikXSrEqQ7rv1DrqmfF9bOZ7cu7?= =?us-ascii?Q?c1ZAyJgf3wC9Gdni5bv9dDnu8xDoAe+JdE8KLk5WzYNHU4PY4lYsgHBc0qWP?= =?us-ascii?Q?XAJ8tqC+36M8SOJFU3RgRPx3RW5aX59ZFP7Mh4DkLT7qns7DVEHPf88XTCG1?= =?us-ascii?Q?rwYDvyhIO54l93AlzRYF28KirwhsKL72kh7qC+2pz4mD3+uUY3Op6YqzIMKA?= =?us-ascii?Q?/vOKAeTegvKtPMEVG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I+PYC?= =?us-ascii?Q?tsB3wlfWK5Gh2CqgpjhB6faJpb8ww36ogq8tjjlyCBANmqsQxNo6WVvD6zYI?= =?us-ascii?Q?wXFX9GutdNV/x09mgAe+z7WkMpRdYlVBOaHO6xft81gxWDKq/MAgkrwaIFoY?= =?us-ascii?Q?wmANAFWY3alOh7a/LQjILrZmedsDfdUjelZIka5oon9zCJMoPAJDopapiM1X?= =?us-ascii?Q?Ue5Wb0T58GwOl082jdUYGiS0i8eDXI7AHeigOjxA0Z9iwgTq13HBcRffSl7/?= =?us-ascii?Q?7qDJ/DyR+QADp0uGGMTgUPjmYpbk0TtfZ9DjoGeGsXYZTZfSQE8rBpH/9R8D?= =?us-ascii?Q?0w=3D=3D?= X-OriginatorOrg: inmusicbrands.com X-MS-Exchange-CrossTenant-Network-Message-Id: fb44d944-6b74-4f7b-8379-08ddc2e94b59 X-MS-Exchange-CrossTenant-AuthSource: MW4PR08MB8282.namprd08.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Jul 2025 15:15:40.6539 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 24507e43-fb7c-4b60-ab03-f78fafaf0a65 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: BIRFrvxbTCO5LNAgtmpW08oNvGwPaCGcjmcYnGRSQc8NuBGat/I+QBZUOLcFS+ceCWzoyMc/v9nbdZJQLqfGkfzijnH6lOwAex7K7/aMqZI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA2PR08MB6716 On Sat, Jul 12, 2025 at 12:11:38AM +0000, Thinh Nguyen wrote: > On Thu, Jul 10, 2025, John Keeping wrote: > > When the phy is acting as a Type C mux, it may need to reset when the > > cable direction changes. But this should not happen while DWC3 is > > trying to use the USB connection. > > > > In this case, there must be a connection manager to notify the phy of > > the orientation change and tcpm_mux_set() ensures this happens before > > DWC3's role switch is informed of a change. > > > > It should not be possible to go directly from device->device or > > host->host with a change in orientation without transitioning through > > the "none" role as the cable is unplugged. So ensuring that DWC3 always > > The controller is either host or device mode. It's odd to use "none" to > indicate connection. There is no connection in this state. When the type C controller indicates that the role is "none" then there cannot be a USB connection. > > informs the phy of the new mode whenever a plug is detected should be > > sufficient for the phy to safely reset itself at a time that is safe for > > DWC3. > > Couldn't the phy do this as it detects connection/disconnection. I don't think the phy can detect a connection. If it is configured for the wrong orientation then it will not monitor the correct data lines. The phy hardware does not signal any interrupts to the CPU for the driver to react to. > It seems what you need is a full controller initialization upon new > connection on orientation change, and you're using role_switch selecting > "none" to do so. I'm not sure whether a complete initialization is necessary, but what I want to avoid is the phy resetting while the controller is part-way through device enumeration or setting up a gadget configuration. It may be that simply avoiding resetting the phy if the orientation is unchanged is enough to avoid some of this problem, but I suspect there are still problems if the clocks from the phy to the controller are stopped unexpectedly. However, I have run some tests of this change and it looks promising. > I'm not sure if role-switch has the right interface to do so. Perhaps we > can introduce one? I don't think we should change the behavior of the > current flow and apply that to all other platforms. I don't think it's unreasonable for the controller to be idle when there is an external type C controller notifying the connection state. The hardware setup looks like this, with the Linux type C code notifying the phy driver of the orientation change and the DWC3 driver of the role change: +------+ | DWC3 |<----+ +--^---+ | | | +--v--+ | +---->| PHY | |Role | +--^--+ | Orientation | | | | +----v----+ | +---+ FUSB302 +----+ +---------+ The advantage of using the role hook is that we are guaranteed that it is called after the phy has been notified of the orientation change. Do you have an idea of a new interface? Or do you think it is safe to reset the phy underneath the controller when that will halt the clocks from the phy to the controller for some period of time? Regards, John