From patchwork Fri Jul 12 15:40:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 812477 Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011068.outbound.protection.outlook.com [52.101.70.68]) (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 704D0175564; Fri, 12 Jul 2024 15:41:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.70.68 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720798862; cv=fail; b=ug35LZenioaKjs5EMYSfn5zTcFmZghgn0w21yQAG/pCWgkgGV3lLcO16IMr0xwOpFAChGNzMjoJFCCQNpu131CDbYZRDFwpxg6gg8L0t2164AOwsFyiT/q9CCH/KADaF1ssqhNHHWMq9KWG5Fkkr661BT+4uFyn447p0WnYb8eE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1720798862; c=relaxed/simple; bh=LZF8fiRnNfUEj0/JG74LN2cwxbM6N8hCxC0T75KalPE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=GmHE2jzCyDYl0TiJAIUPgxstA32yBm0osAjeZ245RIJTn7tN20iRQ4WPv7I+VLY9Jvklt/+p8nJbBjRH5Awq5YH1jZDc4ppv8Tm2nYcdSfEWTNyEIRbnj+dZXEh1teYvtEOgpyRcePznOVIyMXRiR9FgClMcuqD4+HW5KqwKgpE= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=neKsav5K; arc=fail smtp.client-ip=52.101.70.68 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="neKsav5K" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=BQtv4FBxdHlSmlxMzxuTav0ydzRDlYgUabr1ALzgBVVjeRYYJXzMk9H+6Ou+PTJFz04148iPVbZrNrGG3YTenzYupwedzBg/v8kj03SYvCy6rp3VAR80ihaqtaEeLREgbxX/s/qkaJ+8dWKf0T/77Yua+qkA/+EQDb9KzHaqO5gPE7u8QILINROBKQtu1fDNP/mI4FdQejbfhAgsmkdWfHCYotqqLzZx+TqTeWYouKbd2lJxOeYnx5oH7yLP2YPHfivxVSxlYPHtW+dt4RkYjJdKcJ+P9TSE8bKFVkEAWW3d9DnvZ1MxMYeWXBLPS3pMhjgAt4B44fUZtE7LrgzpTg== 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=ZB2TN56YA6B2HFvGdRxxQfGotLFBN47dmzc4O7jlKXM=; b=cT8bC8Q/V7qpERFHYJ1Pwco3AD/3Ugr6J2rByXmGm0wTauQOK4qZlYac5Msk9DQdoso6oL+GzopqC4II5jE2maWs5szO9R6JuYwyAaU1HyaqrzSI+9G4fR0l4pCp262CKl4W2VzXngJXI3uIy0keacQk/Z/OwfR9UuZMOAGCNyNU5Yb/Qql3FAl9ceJEPDnINpD+33oywrk6YK0V0iXnUImNRGjyjbGsG8MuyGtThD9dZGA5SbW5rAAGXvv0z/ZHmVJ9oc5xQhXlplE1uVpBUk+jp9vDgTRnUd+pJmBxyQ0HD/HTl0nFpGghH/6gAYO6ymRHmKgNI/Z3SB+umOxtKw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZB2TN56YA6B2HFvGdRxxQfGotLFBN47dmzc4O7jlKXM=; b=neKsav5K4E109bgYqwhF+C4LhnrObcWzykcEbGCcPdkei6oSkDlLmuYKARnrQcoNvtovK8+CaoKucowyTCQvmJXxzH9taNdREObcn0F7jAHw/nI/GwAlFHkGV/yd7KaX4vSd2V1jiussJgwajm3nnKE2Kk14wzGCkgWRnR4t/9g= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by GVXPR04MB9803.eurprd04.prod.outlook.com (2603:10a6:150:111::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35; Fri, 12 Jul 2024 15:40:59 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.7762.020; Fri, 12 Jul 2024 15:40:59 +0000 From: Frank Li Date: Fri, 12 Jul 2024 11:40:29 -0400 Subject: [PATCH 3/4] usb: dwc3: core: add a core init flag for device mode resume Message-Id: <20240712-dwc-mp-v1-3-295e5c4e3ec9@nxp.com> References: <20240712-dwc-mp-v1-0-295e5c4e3ec9@nxp.com> In-Reply-To: <20240712-dwc-mp-v1-0-295e5c4e3ec9@nxp.com> To: Mathias Nyman , Greg Kroah-Hartman , Thinh Nguyen , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org, jun.li@nxp.com, Frank Li , Peter Chen X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1720798845; l=1856; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=HDrRGCYGDwol4RWWe1IyBNwBksEIqTK/O4gYUc10XcQ=; b=dTuD710yiij6BtutucldXRLgymp/G1IPzLfJEl9747mFaSdIBXCD5juypswY0CkHmDpGjI+cd BFjuQ43vp0eCqCvsHXr0PlTBDAiO76Vf5S8XA4VEhXNwRxjIi91kddW X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0075.namprd13.prod.outlook.com (2603:10b6:a03:2c4::20) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::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: PAXPR04MB9642:EE_|GVXPR04MB9803:EE_ X-MS-Office365-Filtering-Correlation-Id: 914973b3-a8d5-4246-723d-08dca28906e2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|366016|376014|7416014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?8rpKCJkarO2IML1rZokarplT2ApKQ6D?= =?utf-8?q?AlUDKc3jKkm45vLHl70UHEnlrAiTLd9YySyFsSRASi7/+vYqx1USyt+EiwSkrVOW6?= =?utf-8?q?Syao/WsVQbaCCk8CoGgJQp3iFJKQlSxAIPJvoBvSqqv/ppcwYqHOYM7u58HLdQr1n?= =?utf-8?q?L7tbGJaJsBzYQifMo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hnZNDXNTp/uVyfSz+RZDgCeDOftQGt?= =?utf-8?q?OoxUvY2Kr7S2NS6GRCkeE+Y8JQUx3dUtwyjw3h/NA7GUUsDUVFVfioHFgZXZXj4Ni?= =?utf-8?q?sjDQ9kmp3mzspWiyrKkVgcnEzFOYNgpX2Gfwsjp+9Vp+nGHF7UUZayfBsdoMajZYQ?= =?utf-8?q?D5j6MxaSpqkT9FmqtdxrKBE2YSaQ7kZ5B5cdZ6yB4TG+qMQuwDgPSp7cAUhns4Zdr?= =?utf-8?q?B93YRL8gfrAcrpy9Zdl1v0kvMVIr/ex6Y8sIAQ5luJZTOKXQULCy2noQCRwpa73Ls?= =?utf-8?q?hMWxjC3+iqDIewf5gEpucLTPIyU92O5LkA=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:PAXPR04MB9642.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(1800799024)(366016)(376014)(7416014)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?64k20Pth3gVmfLuubRd9sqYWljNL?= =?utf-8?q?8y6EO6aDcMaBOoPijs35IVCDfKc+5M06LWuKENzYc539JkMUUudPrduQc9SNfy9vG?= =?utf-8?q?OBn2MOfWDrQgbLWn3GqhLCz/qUZXpkmL7UxVG9VeR8L/zECagP9o/oEEKBZIusjOu?= =?utf-8?q?KQs9t9GGHBNUSPYIC1F/OB6X6c0dcJg4S2+R6mYOVRENT7m5HCTTsfdIErI1AWGve?= =?utf-8?q?7HhohxgG2nmHIyLtpmW9xYeasQOXvsgCKLpM8IO2LIMcu+uPP9K5cRXQZ6Ykw8JtZ?= =?utf-8?q?RYn16yKv9gv6rQYq+d9PrfpHDeSXBAt15YyQedF00SARnxIEn2nvKaIFVRLj8tE/K?= =?utf-8?q?t4R+qlsjCORWv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uJVVFB3ohXr7n6NfFJTdYa9pOAYmqFSWDUFs6E8tdN4uYotAqis?= =?utf-8?q?cJ1tK7hz7iaBEJwi4rI0V9HCZ4gemxsQD9PN6oM8UbDnJhiPvhqga+tuxzCnhS2mA?= =?utf-8?q?AsR98iAO58ptRyDT7e8CCUf4R1t8JZcAhlkn57OIubnsaExkrxUkXx3d47tc2FED5?= =?utf-8?q?aadF39piPm7XV1rAkhqE/yfWcAbl7niJC9bdLhcmvgAazV3RPiNv8PksikQJkldg/?= =?utf-8?q?W2gCZAolHqmAq8kXu8YSsCd5AKaOKoWKqQBB4yD08f0TmTBQrUwOJmrg=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 914973b3-a8d5-4246-723d-08dca28906e2 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jul 2024 15:40:59.0460 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3zYy44mx0Qf9/n/64Wmp3hCLlxSV8x7nOxlNs98Z9cmnNZbeG3rjat+5fZ0rFOMzDwS1FkwfdwsCzWXb/CutAQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB9803 From: Li Jun The runtime resume will happen before system resume if system wakeup by device mode wakeup event(e.g, VBUS). Add a flag to avoid init twice. Reviewed-by: Peter Chen Signed-off-by: Li Jun Signed-off-by: Frank Li --- drivers/usb/dwc3/core.c | 13 +++++++++++++ drivers/usb/dwc3/core.h | 1 + 2 files changed, 14 insertions(+) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index 734de2a8bd212..d60917fad8c52 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -950,6 +950,8 @@ static void dwc3_core_exit(struct dwc3 *dwc) dwc3_phy_exit(dwc); dwc3_clk_disable(dwc); reset_control_assert(dwc->reset); + + dwc->core_inited = false; } static bool dwc3_core_is_valid(struct dwc3 *dwc) @@ -1446,6 +1448,8 @@ static int dwc3_core_init(struct dwc3 *dwc) dwc3_writel(dwc->regs, DWC3_LLUCTL, reg); } + dwc->core_inited = true; + return 0; err_power_off_phy: @@ -2375,6 +2379,15 @@ static int dwc3_resume_common(struct dwc3 *dwc, pm_message_t msg) switch (dwc->current_dr_role) { case DWC3_GCTL_PRTCAP_DEVICE: + /* + * system resume may come after runtime resume + * e.g. rpm suspend -> pm suspend -> wakeup + * -> rpm resume -> system resume, so if already + * runtime resumed, system resume should skip it. + */ + if (dwc->core_inited) + break; + ret = dwc3_core_init_for_resume(dwc); if (ret) return ret; diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 1e561fd8b86e2..8a4bfd9a25b19 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1195,6 +1195,7 @@ struct dwc3 { struct clk *utmi_clk; struct clk *pipe_clk; + bool core_inited; struct reset_control *reset; struct usb_phy *usb2_phy;