[PATCH 2/2] phy: sun4i-usb: Assert reset before deasserting in phy init
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Tue Nov 17 05:25:59 PST 2026
Thank you for your contribution! Sashiko AI review found 3 potential
issues to consider:
- [High] phy: sun4i-usb: single-word handle in Signed-off-by trailer
- [Medium] phy: sun4i-usb: sun4i_usb_phy_init() asserts shared PHY2
reset
- [Low] phy: sun4i-usb: missing Fixes trailer for sun4i_usb_phy_init()
reset fix
It also noticed 1 related pre-existing issue this patch does not
introduce:
- [Medium] phy: sun4i-usb: clock reference imbalance in
sun4i_usb_phy_init() [1]
--
commit 12bd7c6ca5df3e2bb05ffe3f4ddfe21723f76996
Author: Roadbobek <admin at roadbobek.com>
> phy: sun4i-usb: Assert reset before deasserting in phy init
>
> When a bootloader initializes USB before booting Linux without
> first tearing down the controller, phy->reset may already be
> deasserted when sun4i_usb_phy_init() runs.
>
> Because reset_control_deassert() alone is a no-op on an
> already deasserted reset line, stale USB PHY state can
> persist across the bootloader-to-kernel handoff.
>
> Assert phy->reset briefly before deasserting it in
> sun4i_usb_phy_init() so the PHY starts cleanly regardless of
> prior bootloader USB usage. Tested on an Allwinner A33 Q8
> tablet (Laser MID-786).
>
> Signed-off-by: Roadbobek <admin at roadbobek.com>
[Severity: High]
The Author header and Signed-off-by trailer use a single-word handle
(Roadbobek). Documentation/process/submitting-patches.rst requires a
known real identity (full human name) for the Developer's Certificate of
Origin and does not allow pseudonyms or handles.
[Severity: Low]
Should this bug fix include a Fixes trailer?
Fixes: ba4bdc9e1dc0 ("PHY: sunxi: Add driver for sunxi usb phy")
> diff --git a/drivers/phy/allwinner/phy-sun4i-usb.c b/drivers/phy/allwinner/phy-sun4i-usb.c
> index f26eed0db17ef..05e6dcf035a1a 100644
> --- a/drivers/phy/allwinner/phy-sun4i-usb.c
> +++ b/drivers/phy/allwinner/phy-sun4i-usb.c
> @@ -270,6 +270,8 @@ static int sun4i_usb_phy_init(struct phy *_phy)
> return ret;
> }
>
> + reset_control_assert(phy->reset);
> + usleep_range(10, 20);
> ret = reset_control_deassert(phy->reset);
> if (ret) {
> clk_disable_unprepare(phy->clk2);
[Severity: Medium]
Can asserting phy->reset here disrupt other active USB PHYs when PHY2 is
initialized on SoCs with needs_phy2_siddq set (such as the Allwinner
H616)?
When sun4i_usb_phy_init() runs for PHY0, PHY1 or PHY3 on those SoCs, it
directly deasserts data->phys[2].reset and clears hci_phy_ctl_clear in
PHY2's PMU without going through phy_init(phy2->phy):
drivers/phy/allwinner/phy-sun4i-usb.c:sun4i_usb_phy_init() {
/* Some PHYs on some SoCs need the help of PHY2 to work. */
if (data->cfg->needs_phy2_siddq && phy->index != 2) {
struct sun4i_usb_phy *phy2 = &data->phys[2];
...
ret = reset_control_deassert(phy2->reset);
}
Because sun4i_usb_phy_probe() acquires each reset via
devm_reset_control_get() (exclusive, non-refcounted), later initializing
PHY2 for ehci2/ohci2 will now pulse data->phys[2].reset low for 10-20 us
(or leave it asserted if reset_control_deassert() fails) while PHY0, PHY1
or PHY3 are already active and relying on PHY2 remaining out of reset
with SIDDQ cleared.
[Severity: Medium]
This problem wasn't introduced by this patch, but in the needs_phy2_siddq
block right below in sun4i_usb_phy_init(), does [1]
clk_disable_unprepare(phy->clk2) disable the wrong clock after enabling
phy2->clk2?
drivers/phy/allwinner/phy-sun4i-usb.c:sun4i_usb_phy_init() {
ret = clk_prepare_enable(phy2->clk2);
if (ret) {
...
}
if (phy2->pmu && data->cfg->hci_phy_ctl_clear) {
val = readl(phy2->pmu + REG_HCI_PHY_CTL);
val &= ~data->cfg->hci_phy_ctl_clear;
writel(val, phy2->pmu + REG_HCI_PHY_CTL);
}
clk_disable_unprepare(phy->clk2);
}
Initializing PHY0, PHY1 or PHY3 leaks a prepare/enable reference on
phy2->clk2, while prematurely disabling phy->clk2 and causing an
underflow in sun4i_usb_phy_exit().
[1] https://sashiko.dev/#/bug/linux-16c490f9-c5d0-4103-a9d3-3f6814c64cb4
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261117-usb-sunxi-reset-fix-v1-0-c2b76e0e84e1@roadbobek.com?part=2
More information about the linux-phy
mailing list