| Message ID | CE85F490F5646A2C+20260813130542.2425068-1-raoxu@uniontech.com (mailing list archive) |
|---|---|
| State | New |
| Headers |
Return-Path: <linux-sunxi+bounces-25143-sunxi=pue.re@lists.linux.dev> X-Original-To: noreply@patchwork.local Delivered-To: noreply@patchwork.local Received: from sin.lore.kernel.org (sin.lore.kernel.org [104.64.211.4]) by mxe881.netcup.net (Postfix) with ESMTPS id DBF341C3BC6 for <noreply@patchwork.local>; Thu, 13 Aug 2026 15:07:26 +0200 (CEST) Authentication-Results: mxe881; dkim=pass header.d=uniontech.com; spf=pass (sender IP is 104.64.211.4) smtp.mailfrom=linux-sunxi+bounces-25143-noreply=patchwork.local@lists.linux.dev smtp.helo=sin.lore.kernel.org Received-SPF: pass (mxe881: domain of lists.linux.dev designates 104.64.211.4 as permitted sender) client-ip=104.64.211.4; envelope-from=linux-sunxi+bounces-25143-noreply=patchwork.local@lists.linux.dev; helo=sin.lore.kernel.org; Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by sin.lore.kernel.org (Postfix) with ESMTP id B3F1A3008C8E for <noreply@patchwork.local>; Thu, 13 Aug 2026 13:07:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6F3084756D0; Thu, 13 Aug 2026 13:07:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b="Icyn6c8y" X-Original-To: linux-sunxi@lists.linux.dev Received: from smtpbgeu1.qq.com (smtpbgeu1.qq.com [52.59.177.22]) (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 521244746D5 for <linux-sunxi@lists.linux.dev>; Thu, 13 Aug 2026 13:07:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=52.59.177.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786626439; cv=none; b=Z98a4xTyIfk5igEvQUiFHEuxQnGrOWh0AWQ+YFTYs4kdYDzkwUovdCsm7a0bPCTgkFiS+DfR2bjDIGsbZeUwMERu1s1PDWvf25Ry6aW4vsaijvEpP/A4mlA+DIRv0zFPuTdtRMLW8S0pJGLcr8ucWWI9pUys6KndFW4cBs/FaGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786626439; c=relaxed/simple; bh=iKlsdRlRYxYc1v0CKgJEbY5DgTP+wXoI6/8725kvTKc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=svviFlxHUwQuWY/I4jX+26kmEvs+hZFSEJWNIOSNqCyME34p0pX5y/WX1hD/SUXZpfzEj7ZNbf9HZTc6u8rOV8bQlP2NtN17QSjk4z38yV8YXQH1DRdSgE7pWk89P+fsMyy1+1CUxYSQ1ziXmhpwsjbx3ZVcDx1QTHRnBKq4boM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com; spf=pass smtp.mailfrom=uniontech.com; dkim=pass (1024-bit key) header.d=uniontech.com header.i=@uniontech.com header.b=Icyn6c8y; arc=none smtp.client-ip=52.59.177.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=uniontech.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=uniontech.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uniontech.com; s=onoh2408; t=1786626376; bh=nJ3DjTBgFoGEsLV5b+erjzQOcSw5I5/IyYlcPZdcDEs=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=Icyn6c8yhdHQAlx4W0szQLanIZtkiDmin71gdpSPyrvseqstoBx/3lutSSjhE90S8 GZbfZ2S1RauSutzc7fuyy5YGfq5Aj2ebY5wBgKQKKdyHSc//gthF2A4QW62oNaZoYe VkdeR+IUVzzcuvVy3vbpHo70JmH2RByS/iRVgOVg= X-QQ-mid: esmtpgz12t1786626355t9ca26cba X-QQ-Originating-IP: dHhI7VBaezRAp4X4gI1x1FX2IMsrpI09Qjr/PigbalE= Received: from PEN202512010004 ( [113.57.152.160]) by bizesmtp.qq.com (ESMTP) with id ; Thu, 13 Aug 2026 21:05:53 +0800 (CST) X-QQ-SSF: 0000000000000000000000000000000 X-QQ-GoodBg: 1 X-BIZMAIL-ID: 588101152483150386 EX-QQ-RecipientCnt: 12 From: raoxu <raoxu@uniontech.com> To: vkoul@kernel.org Cc: wens@kernel.org, jernej.skrabec@gmail.com, samuel@sholland.org, neil.armstrong@linaro.org, andre.przywara@arm.com, marco.crivellari@suse.com, linux-phy@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, raoxu@uniontech.com Subject: [PATCH v2] phy: allwinner: sun4i-usb: disable the PHY2 PMU clock after SIDDQ setup Date: Thu, 13 Aug 2026 21:05:42 +0800 Message-ID: <CE85F490F5646A2C+20260813130542.2425068-1-raoxu@uniontech.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-sunxi@lists.linux.dev List-Id: <linux-sunxi.lists.linux.dev> List-Subscribe: <mailto:linux-sunxi+subscribe@lists.linux.dev> List-Unsubscribe: <mailto:linux-sunxi+unsubscribe@lists.linux.dev> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-QQ-SENDSIZE: 520 Feedback-ID: esmtpgz:uniontech.com:qybglogicsvrgz:qybglogicsvrgz6b-0 X-QQ-XMAILINFO: MvyKdZyVtFx3ogxxWRGDkb3wjkVowJkMY7zgE3kzwgOz3wTrVGElr46w 3Stlq7ADwX6crnNIfcueySAkOPttnBR3+N0tWSpJ+Hf8bILjwodltDfDMAys3dpWJ5A2Sr/ kzkC6/fws1aw9SZgCdts4gEKQNjSQ/VxciLKeYWzg+FkQbef38BKrY/8HtMgagSH+DyDaUC A3Az1uhdWcVii3UHm8GHeDCcFLwNUyz/B4aQkA78dbQl4j/8x49oy4H08kvKj6Nd7xIS8tS qhHF9mujbFd8JKTe1XDICdF27ULL1pE/p1xIgDtH5qoNkzHU2V2TES9Z6dV9f+skkLfuN9x E/c5PvOI3Y8rByc1gcS6U98anIjR8ToinuSCtecagKaM3CR7ra+CAR7ALMctB57Qe08oKB1 Cj6uh7xNk+RUl9cxw9xqwEp1Oq6nB7864/6o/fZ5g7Etfj68ZmNLjSM+LtaegcmJ/V2a+Wh Aos1SVlPZ3t3JubC8C5c06YAN59cXkmyfRM6ZajPi94c5xnqkVx5N0XWN9TGZ99AMvaD7be B0IBl4Wnev9FLc6rWF9IvEVYq+jIslNiR1WENa0ClGt1/hHImu/ZCv706b5Iko4znp6AMdK rJagUlF24IeEriPsfY+Nm9MmFjax2O3oWZiRCOCK/sQsrMJpdI9phgMbTEPY9xnv1fItS06 69hyGvKKHqeK9RIspeXqEOTiWQs2UDZjlqmme1KWokWX2TZhgKeGcYhryy78+Q5k5PfTYDg GzIZ7J9SU0/vNnZxzD6W625AV0NmYmsKlWBoGnTv/sPZk0No5biElFnueUOT4UCnuF26Weu 8ZB8oXUqEOkdQZU6hy6ZwAjgrDR/uccHiJSjrbYbpHuotLsCbhiFDlUJ+eFBLi8UfkZnL+g 2zL+8mTfbRoNvcc2PTbYQXLNIVEuj8Go9gAVuhA5amJLYWNLnJhLQDurUBtG2vuBa0m7AA6 F+jBCXCms9N2koilwDDuDkL4a3rHLRUXNQg2Qjw2y3EKz5PizeTUUzS/4FnOygjZalRCwll ErQo+qK/vGO565+9eNg1UZ3aWlVkQL9HVdGs50bMUHehIe1YdTDrq0TmOjySWE9Hdu8xA4z w== X-QQ-XMRINFO: NS+P29fieYNwqS3WCnRCOn9D1NpZuCnCRA== X-QQ-RECHKSPAM: 0 X-Rspamd-Server: rspamd-worker-8404 X-Spamd-Result: default: False [-0.66 / 15.00]; BAYES_HAM(-5.50)[100.00%]; RBL_SENDERSCORE(2.00)[104.64.211.4:from]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; MAILLIST(-0.15)[generic]; MIME_GOOD(-0.10)[text/plain]; BAD_REP_POLICIES(0.10)[]; HAS_LIST_UNSUB(-0.01)[]; TO_DN_NONE(0.00)[]; FREEMAIL_CC(0.00)[kernel.org,gmail.com,sholland.org,linaro.org,arm.com,suse.com,lists.infradead.org,lists.linux.dev,vger.kernel.org,uniontech.com]; R_SPF_ALLOW(0.00)[+ip4:104.64.211.4]; DKIM_TRACE(0.00)[uniontech.com:+]; RCPT_COUNT_TWELVE(0.00)[12]; TAGGED_RCPT(0.00)[]; DMARC_POLICY_ALLOW(0.00)[uniontech.com,none]; PRECEDENCE_BULK(0.00)[]; R_DKIM_ALLOW(0.00)[uniontech.com:s=onoh2408]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FORGED_RECIPIENTS_MAILLIST(0.00)[]; FROM_HAS_DN(0.00)[]; ASN(0.00)[asn:63949, ipnet:104.64.192.0/19, country:SG]; ARC_ALLOW(0.00)[subspace.kernel.org:s=arc-20240116:i=1]; TAGGED_FROM(0.00)[bounces-25143-noreply=patchwork.local]; FORGED_SENDER_MAILLIST(0.00)[]; FROM_NEQ_ENVFROM(0.00)[raoxu@uniontech.com,linux-sunxi@lists.linux.dev]; RCVD_COUNT_FIVE(0.00)[5] X-Rspamd-Queue-Id: DBF341C3BC6 X-MORS-Enabled: yes X-MORS-DOMAIN: patchwork.local X-MORS-HOSTING: hosting172546 X-MORS-USER: hosting172546 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= |
| Series |
[v2] phy: allwinner: sun4i-usb: disable the PHY2 PMU clock after SIDDQ setup
|
|
Commit Message
raoxu
Aug. 13, 2026, 1:05 p.m. UTC
From: Xu Rao <raoxu@uniontech.com> sun4i_usb_phy_init() temporarily enables PHY2's clk2 when a SoC needs PHY2 SIDDQ setup while initializing another PHY. However, after updating PHY2's PMU register it disables the clk2 pointer from the PHY currently being initialized instead. Only PHY2 on H616 has a clk2 clock. No other PHY on H616 has a clk2 clock, so phy->clk2 is NULL in this path and disabling it is a no-op. This is why disabling the wrong clock did not cause an additional functional failure. The temporary phy2->clk2 enable therefore remains unmatched, leaking a clock enable reference each time this path is executed. Disable the same PHY2 clk2 that was enabled for the auxiliary PMU access. Fixes: b45c6d80325b ("phy: sun4i-usb: Introduce port2 SIDDQ quirk") Reviewed-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Xu Rao <raoxu@uniontech.com> --- Changes in v2: - Explain why disabling phy->clk2 did not cause additional harm: no other PHY on H616 has clk2, so phy->clk2 is NULL and the operation is a no-op. - Clarify that the concrete issue is the unmatched PHY2 clk2 enable. - Add the Fixes tag and Andre's Reviewed-by. drivers/phy/allwinner/phy-sun4i-usb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.50.1
Comments
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: Pre-existing issues: - [High] Exclusive reset `phy2->reset` is forcefully asserted on exit, breaking other concurrently active PHYs that rely on the shared PHY2 hardware. - [Medium] Incorrect teardown order for `phy2` in `sun4i_usb_phy_exit()` disables the clock before asserting the reset. -- --- Patch [1]: [PATCH v2] phy: allwinner: sun4i-usb: disable the PHY2 PMU clock after SIDDQ setup --- commit c3b10e6864aadde53d10b7e0b2a5fcb7d0d76e08 Author: Xu Rao <raoxu@uniontech.com> Subject: phy: allwinner: sun4i-usb: disable the PHY2 PMU clock after SIDDQ setup This patch fixes a clock enable leak in sun4i_usb_phy_init() by properly disabling PHY2's clk2 instead of the currently initialized PHY's clk2. It corrects an unmatched clk_prepare_enable() for the auxiliary PMU access. > diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c > index e2fbf8ccf99e1..839856c09e305 100644 > --- a/drivers/phy/allwinner/phy-sun4i-usb.c > +++ b/drivers/phy/allwinner/phy-sun4i-usb.c > @@ -318,7 +318,7 @@ static int sun4i_usb_phy_init(struct phy *_phy) > writel(val, phy2->pmu + REG_HCI_PHY_CTL); > } > > - clk_disable_unprepare(phy->clk2); > + clk_disable_unprepare(phy2->clk2); > } > > if (phy->pmu && data->cfg->hci_phy_ctl_clear) { [Severity: Medium] This isn't a bug introduced by this patch, but looking at how PHY2 is torn down later in sun4i_usb_phy_exit(): drivers/phy/allwinner/phy-sun4i-usb.c:sun4i_usb_phy_exit() { if (data->cfg->needs_phy2_siddq && phy->index != 2) { struct sun4i_usb_phy *phy2 = &data->phys[2]; clk_disable_unprepare(phy2->clk); reset_control_assert(phy2->reset); } [ ... ] } Is the clock and reset teardown order correct here? The teardown order disables the clock before asserting the reset, which reverses the initialization order. Asserting a hardware reset without the IP block's clock running can sometimes fail to propagate the reset state or cause a bus lockup. [Severity: High] This is also a pre-existing issue, but does asserting this shared phy2->reset line on exit break other concurrently active PHYs that rely on PHY2? Because phy->reset is requested in sun4i_usb_phy_probe() as an exclusive reset: drivers/phy/allwinner/phy-sun4i-usb.c:sun4i_usb_phy_probe() { [ ... ] snprintf(name, sizeof(name), "usb%d_reset", i); phy->reset = devm_reset_control_get(dev, name); [ ... ] } The reset framework won't refcount it, so unconditionally calling reset_control_assert(phy2->reset) will force the hardware line into reset immediately. This could tear down the shared hardware resource regardless of other active PHYs using it.
diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c index e2fbf8ccf99e..839856c09e30 100644 --- a/drivers/phy/allwinner/phy-sun4i-usb.c +++ b/drivers/phy/allwinner/phy-sun4i-usb.c @@ -318,7 +318,7 @@ static int sun4i_usb_phy_init(struct phy *_phy) writel(val, phy2->pmu + REG_HCI_PHY_CTL); } - clk_disable_unprepare(phy->clk2); + clk_disable_unprepare(phy2->clk2); } if (phy->pmu && data->cfg->hci_phy_ctl_clear) {