From patchwork Tue Nov 5 07:14:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 841021 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2084.outbound.protection.outlook.com [40.107.104.84]) (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 A2C831FDFA0 for ; Tue, 5 Nov 2024 07:14:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730790886; cv=fail; b=rOQdHcotFbuS+TnhT0Ewqf5O5JqpYSn54PuWiloH08f1E2v/gayRbfHRAs5y4gU0JcC+9Wq+1usDcbv82nU1pJsBE5uazgDLAqLWDzW5fHP/nnIVXSXmB7BV0bwhzv9G+PS5UG7kBCl4mXtigroDnDWowzgYhDNRGMNQcslkoAU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730790886; c=relaxed/simple; bh=/ZqZcXYMqX4GuDh32ue2GWkPAHo4Ec33sO9ac+tqYEU=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=XpOgnZ0Ppvu/G4GOIj30UdZE5TUmdLaXWiaY/ukzKjkipBA7MQ1zuWiSfs0O74buhcdRUdW2vjd2w3lZi+0fyPcNAPeMuOZ6Jy2XKRpDM1FTklX9C8kG+3s9fuayK9Dm8H1/I/MdOvNXhGf1XErbDEGEpIF/Sm/Z0rraBNIi47w= 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=bMoQfZz+; arc=fail smtp.client-ip=40.107.104.84 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 (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="bMoQfZz+" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZD+uoRUxEd+2sbkniJS3WGZLZudm68ltc3pXzKGEPro6gqxWD3avTw3zrlRWIHX23ZafwVU5jHRVJQ9VW29JIhT/tH58ojcgBpx56bFf26lAlwRwZytZsEBLa3lmvAeah89IU7kkR2pUyow5vCWSsOQlQf7X+CjxTz1hHedIf8FEghK3tk0bdmwSEuT7xGUETzkRCa7oVYjmf/P/gpd8cY+TzevmYZHj8/m1HVLTYj9acVmZOAPMD/y0Yu/ywj7crlAcG1Xo/Ih8IockO29G7GKVwSKLrDE6Y+qpzUZXffcyhgFzuZXxmC8s2MRV3fQut9P6reNHTJ7CuHIODvkq+w== 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=quyPFDbIzZLGMYpEHZgYiMhdzE46xw4JfcsH/glwvow=; b=XiyTSQHkvyYi9HoEPCzW4yPpi/MVNn93XyI3f+YtgTwWQELlU2cL8K8IdJd1LqsQUk+j18qQw415VDWY502VxUKrAPC8Y95aLWZvBVWsIPt+W/PSU28sqKPwpNpYqx/MYVEvgY66Wj8AKbqPw59iHwGVEwCBQ5ompqRw5j/Ly9baD0qdS293OcnlmArsqVPHKZ2xJh7hgEhQXWkQjjhZA7EZPVJChGTKWrczn3IfvtsuvrBI2sjHLAl87NRfUcdT3uG0nL87USyUMKKQfFDE/SwJtw3xQ1uB5mTViW+kLZmt7nc5kqJDai82njghjdvMADQiKscIa/hEZDypUEE4lw== 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=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=quyPFDbIzZLGMYpEHZgYiMhdzE46xw4JfcsH/glwvow=; b=bMoQfZz+xWb7c6U/OQQpdd+74+xYPPWOwtRLwV34tRVrL9eavFv6Tr0jGmEzk9xhJbMiCydoqGODK/Cn0hUgLrLthQpO/Lce/N7n+o/FFAaBL32x6crA7tWBRrjGUL6seznaerKVvOtmY7Brs7vgRoEzbqKMRAGNk8RHvztZ6iFs6JupoPhYrkfeUolaFlyLlZ5dM8jqdLMSy3tvasuYOsfnJpciF0Mwv9SVAX57VDwHe5+H5b7IioiVAcIZn+385b89/5WgsfiAeQLl6bzcQc8wP0cAl/rCZe6TgUhbPtUEYZjb5OX5cGyWLzyICqvWpo7YCycDQ7kWsi2HFnNwLw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) by GVXPR04MB10851.eurprd04.prod.outlook.com (2603:10a6:150:21e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8114.30; Tue, 5 Nov 2024 07:14:41 +0000 Received: from DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7]) by DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7%5]) with mapi id 15.20.8114.028; Tue, 5 Nov 2024 07:14:41 +0000 From: Xu Yang To: Thinh.Nguyen@synopsys.com, gregkh@linuxfoundation.org, rogerq@kernel.org, d-gole@ti.com Cc: linux-usb@vger.kernel.org, imx@lists.linux.dev, jun.li@nxp.com Subject: [PATCH] usb: dwc3: core: avoid reading register after bus clk is disabled Date: Tue, 5 Nov 2024 15:14:26 +0800 Message-Id: <20241105071426.2411166-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SG2PR03CA0127.apcprd03.prod.outlook.com (2603:1096:4:91::31) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) 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: DU2PR04MB8822:EE_|GVXPR04MB10851:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e1f7b04-31cc-4109-e9a8-08dcfd69845c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|52116014|376014|1800799024|366016|38350700014; X-Microsoft-Antispam-Message-Info: qpA4lxckRXfA5IWJDGk3CohtmMRe7XtuBk1/VlQedqOFceYlG80TlqBK3z5l+gdhoV44kQgVVDrLiuaC5GHMf4b34yYx6yKgCORxmuvb3epONvh89vP43iYaVN4JZWubufbO3Qz6Mzt33hFPUNdOjeIzZnVu33D3Y8BzzXCUfVef0ohLkKwqgTV+taHAZ0buaS7bylyI3DGiayQWHd6WSImbSKpx27SuQ6MkOrM3WYQ+RWtRX/eHN/Wcw0zV0DjiZUj/OL+2neZ8CRAlZFpPMdiF8J6YUgzipY1fPcQfu3Xte8y2D0rDFMqQLO90+9wCSdnCbDj26gX+85J8/FPNimc/Mf9Ie6AXqvFr4c7/UjItT1UZLDbWeF7dZub6AzLg454Dt9O6YPBDHr55Hz4lI4YSqL292u97OB+sy4k79cp8CLEcpV19wn3N+KCHDBUTgHiuMt6GN4GU917g+bg/JhVW0GMPKsuOTH8zp6Q5p+GO1hZc6LDIMuoRJtcENW3yWnJ4cfRdtwDQfVKo5l4xiV9kuEBE9GXcdCyOWBtPsQCPLs8X3zSwgyv1zZJuRPigsVTumrT6x9FzakrbsurNDOTno/JbWVFSCBZnLmbgg9NnGkzcvdoji7GX+5CUV7S2xLFxpz5vFK1XORdXMDXl+Aqb0/KeCyGwrhNlKv+qscY9M80b4HP4xDe9iANQ55RrmvOpq53NZ4E7ZKN7ahLNOIll4Fb4gf0P29rvFtNOJzkllMT1fkNye0ESWMqWVgbvdKNpmfo9Kt2toOs2bWgb5AnfBniA85TvzZ5ebptzfqFaeqp07S40363T/OownswzuHfYaJx2GNV/Mu2+MU3UXKQpei4TdgmlO9gWniVJ5FQfJD+6/0DcixWIwASphWeQv8WCfw0rLMsYK/2UU88hK907w3PUPeqqBxtYu0ZnYIRswtMESESmCu+e38eaqp1p95Ih9q0VR2/oyJyVb0u8RmxnfWcTlr9YDAOaoTCnQlZ28ugfmSY/5wRiEOdwhMuQnYxgKj97Ub3TWp30JqXQDRE3YIRR2IdiGRK41Z5565q9u6AzjfpD4hdwe3+oWFI4DwrkiD++o3sJVQ8Xn6CzMOYfABY6EjhAMOvvYYHVZ0lhrYxicOZhmkZ0jmUZ0OqSN8uKhw19iA0uNoXN02bdXGUD32f9+vNhg+eurA82jH7BF/LZnqSXMS9ywWhuvF811Ra9TXBuHSeQBxNc7FMfwVjahgrkRbG2yRYSmERiaRVplwu+daBPk+Fl3MRHym1v7SgS+rOwWKwoLyINERVHB/5yGMR29mbaw0VxwxjOH2QCWwO/Rzro5O5VVJlZZ6XNpR85YFAjwshXe356/HjUTZQxorpKSGgIdp9mlQ5qqQQ= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU2PR04MB8822.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(52116014)(376014)(1800799024)(366016)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exch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tVlkioNltefbMycrtFyIXvYa5RysVji+214pEtzuZQwByCM+rfFznsXbN11WUSi+49Rc8LDuQBLh71IUB0W0fJt/3pAs7DJ+mSST9WMXYLselxDTYXJsxoxzSpX5Rtrq/OvPNTOMTvsxV4Jwmz9kx8IWNSuyUdCXbiB+kuOTuLp8A6pGSrxiy34I/zXkh97wTx8z33f+ha6uPxlfFiiAW4OxpoYFdGW5jq378GF2Bsml+FBbEPSG93fST/F5pgXYktY1/S6KR82VTIr9wu5Jm7yQ2wQ+jdC5oTmzAxcSvnXBbAo3h406HAN/xDyd+K2DcwOTGcrtMTbkeImavlHKxDFVlC66bOzNFpYz0AeyHHyOikifPEBV5z8SkX8DXN54tMcO4LjqJ2lJFho1K1bhevk6NQuM7P0p10mz6C2psuUYuL2uZ90SaBrSJuysT+Ch2UMXiZvWaDAR0pdKSZ2JsCB69M9Lol5oa385IiiunvwHBO4rhTSYAeKUPD9gfeN5OC1MzofikZMW4DrAxC X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8e1f7b04-31cc-4109-e9a8-08dcfd69845c X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Nov 2024 07:14:41.6857 (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: T881h7u5Dhg24/+pQl+WSwSo08mJwyjaG78OPOv4mATdDj8SCwAW82Mtedy9LCxVIjpjhnuK8hQJ7JRuqaGe0A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB10851 The driver may go through below sequence when works as device mode: dwc3_suspend() dwc3_suspend_common() dwc3_core_exit() dwc3_clk_disable() clk_disable_unprepare(dwc->bus_clk); dwc3_enable_susphy() dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(i)); Then the driver will read dwc3 register after bus clk is disabled. If this happens, the kernel will hang there. This will move dwc3_enable_susphy() ahead to avoid such issue. Fixes: 705e3ce37bcc ("usb: dwc3: core: Fix system suspend on TI AM62 platforms") Cc: stable@vger.kernel.org Signed-off-by: Xu Yang --- drivers/usb/dwc3/core.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index de434f78c560..b0f1e32d426f 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -2347,6 +2347,15 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) (dwc3_readl(dwc->regs, DWC3_GUSB3PIPECTL(0)) & DWC3_GUSB3PIPECTL_SUSPHY); + if (!PMSG_IS_AUTO(msg)) { + /* + * TI AM62 platform requires SUSPHY to be + * enabled for system suspend to work. + */ + if (!dwc->susphy_state) + dwc3_enable_susphy(dwc, true); + } + switch (dwc->current_dr_role) { case DWC3_GCTL_PRTCAP_DEVICE: if (pm_runtime_suspended(dwc->dev)) @@ -2398,15 +2407,6 @@ static int dwc3_suspend_common(struct dwc3 *dwc, pm_message_t msg) break; } - if (!PMSG_IS_AUTO(msg)) { - /* - * TI AM62 platform requires SUSPHY to be - * enabled for system suspend to work. - */ - if (!dwc->susphy_state) - dwc3_enable_susphy(dwc, true); - } - return 0; }