All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: Roadbobek <admin@roadbobek.com>
Cc: linux-usb@vger.kernel.org, linux-sunxi@lists.linux.dev,
	linux-phy@lists.infradead.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH 2/2] phy: sun4i-usb: Assert reset before deasserting in phy init
Date: Tue, 17 Nov 2026 13:25:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-218872@kernel.org> (raw)
In-Reply-To: <20261117-usb-sunxi-reset-fix-v1-2-c2b76e0e84e1@roadbobek.com>

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@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@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

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: Roadbobek <admin@roadbobek.com>
Cc: linux-usb@vger.kernel.org, linux-sunxi@lists.linux.dev,
	linux-phy@lists.infradead.org, vkoul@kernel.org,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH 2/2] phy: sun4i-usb: Assert reset before deasserting in phy init
Date: Tue, 17 Nov 2026 13:25:59 +0000	[thread overview]
Message-ID: <sashiko-outbox-218872@kernel.org> (raw)
In-Reply-To: <20261117-usb-sunxi-reset-fix-v1-2-c2b76e0e84e1@roadbobek.com>

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@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@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

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

  parent reply	other threads:[~2026-11-17 13:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 13:00 [PATCH 0/2] usb/phy: sunxi: Assert reset before deasserting on init Roadbobek
2026-11-17 13:00 ` Roadbobek via B4 Relay
2026-11-17 13:00 ` Roadbobek via B4 Relay
2026-11-17 13:00 ` [PATCH 1/2] usb: musb: " Roadbobek
2026-11-17 13:00   ` Roadbobek via B4 Relay
2026-11-17 13:00   ` Roadbobek via B4 Relay
2026-11-17 13:05   ` Philipp Zabel
2026-11-17 13:05     ` Philipp Zabel
2026-11-17 13:09   ` sashiko-bot
2026-11-17 13:09     ` sashiko-bot
2026-11-17 13:00 ` [PATCH 2/2] phy: sun4i-usb: Assert reset before deasserting in phy init Roadbobek
2026-11-17 13:00   ` Roadbobek via B4 Relay
2026-11-17 13:00   ` Roadbobek via B4 Relay
2026-11-17 13:04   ` Philipp Zabel
2026-11-17 13:04     ` Philipp Zabel
2026-11-17 13:25   ` sashiko-bot [this message]
2026-11-17 13:25     ` sashiko-bot
2026-11-17 13:04 ` [PATCH 0/2] usb/phy: sunxi: Assert reset before deasserting on init Philipp Zabel
2026-11-17 13:04   ` Philipp Zabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-218872@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=admin@roadbobek.com \
    --cc=linux-phy@lists.infradead.org \
    --cc=linux-sunxi@lists.linux.dev \
    --cc=linux-usb@vger.kernel.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.