From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: linux-phy@lists.infradead.org, vkoul@kernel.org,
neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v18 4/7] phy: rockchip: usbdp: Fix power state handling
Date: Thu, 19 Nov 2026 20:02:09 +0000 [thread overview]
Message-ID: <sashiko-outbox-224002@kernel.org> (raw)
In-Reply-To: <20261119-b4-rockchip-usbdp-cleanup-part3-v18-4-fb325e336494@collabora.com>
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] phy: rockchip: usbdp: skipped port disable in
rk_udphy_usb3_phy_exit()
--
commit ba46047a3c1d57adb2502e31c9007c6898aa6365
Author: Sebastian Reichel <sebastian.reichel@collabora.com>
phy: rockchip: usbdp: Fix power state handling
This commit replaces rk_udphy_power_on() and rk_udphy_power_off() with a
single rk_udphy_update_power_state() helper that derives the target PHY
state from udphy->hw_mode and udphy->sw_mode.
> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index de8f01bd04672..140bec887a5ef 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
[ ... ]
> @@ -1029,70 +1029,93 @@ void rk_udphy_register_reset_handler(struct phy *phy,
> }
> EXPORT_SYMBOL_GPL(rk_udphy_register_reset_handler);
>
> -static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode)
> +static int rk_udphy_update_power_state(struct rk_udphy *udphy)
> {
> + bool usb3_port_enable;
> + u8 target_mode;
> int ret;
>
> - if (!(udphy->hw_mode & mode)) {
> - dev_info(udphy->dev, "mode 0x%02x is not support\n", mode);
> + /*
> + * Initialize PHY mode according to the hardware setup (either described
> + * in DT or negotiated via the Type-C controller) instead of requesting
> + * only the needed PHY side, because that would break the USB/DP data
> + * streams when the other PHY is being requested. This is not an issue
> + * during the Type-C negotiation as that happens during the hotplug phase
> + * and not during normal operation. Also disable everything if the
> + * software has not requested anything, as there shouldn't be any active
> + * data streams in that case.
> + */
> + target_mode = udphy->hw_mode;
> + if (udphy->sw_mode == UDPHY_MODE_NONE)
> + target_mode = UDPHY_MODE_NONE;
> +
> + usb3_port_enable = !udphy->hs && (target_mode & UDPHY_MODE_USB);
> +
> + if (!udphy->phy_needs_reinit && udphy->status == target_mode) {
> + if (udphy->sw_mode & UDPHY_MODE_USB)
> + rk_udphy_u3_port_disable(udphy, !usb3_port_enable);
> return 0;
> }
>
> - if (udphy->status == UDPHY_MODE_NONE) {
> - rk_udphy_run_reset_handler(udphy, true);
> + /* Avoid to re-init disabled PHY */
> + if (udphy->status == target_mode && target_mode == UDPHY_MODE_NONE)
> + return 0;
> +
> + /*
> + * Inform DWC3 driver, that we are about to reset the PHY, so that it can
> + * assert its PIPE reset lines and avoid DWC3 getting into a buggy state.
> + * This is intentionally done for a PHY disable, since that also changes
> + * the clocks routed to the PHY.
> + */
> + rk_udphy_run_reset_handler(udphy, true);
>
> + /*
> + * Disable USB3 port, which among other things re-routes a DWC3 clock to
> + * avoid SErrors when the DWC3 registers are accessed while the PHY is
> + * disabled. This is only done, when the DWC3 is running as the accessed
> + * GRF registers and in PD_USB.
> + */
> + if (udphy->sw_mode & UDPHY_MODE_USB) {
> rk_udphy_u3_port_disable(udphy, true);
> udelay(10);
> + }
>
> + if (udphy->status == UDPHY_MODE_NONE) {
> + /* Power up (incl. clocks) */
> ret = rk_udphy_setup(udphy);
> if (ret) {
> rk_udphy_run_reset_handler(udphy, false);
> return ret;
> }
> -
> - if (!udphy->hs && udphy->hw_mode & UDPHY_MODE_USB)
> - rk_udphy_u3_port_disable(udphy, false);
> - udphy->phy_needs_reinit = false;
> -
> - rk_udphy_run_reset_handler(udphy, false);
> - } else if (udphy->phy_needs_reinit) {
> - rk_udphy_run_reset_handler(udphy, true);
> -
> - rk_udphy_u3_port_disable(udphy, true);
> - udelay(10);
> -
> + } else if (target_mode == UDPHY_MODE_NONE) {
> + /* Power down (incl. clocks) */
> + rk_udphy_disable(udphy);
[ ... ]
> @@ -1369,13 +1392,12 @@ static int rk_udphy_usb3_phy_exit(struct phy *phy)
>
> guard(mutex)(&udphy->mutex);
>
> - udphy->sw_mode &= ~UDPHY_MODE_USB;
> -
> - /* DP only or high-speed */
> - if (!(udphy->hw_mode & UDPHY_MODE_USB) || udphy->hs)
> + if (udphy->hs)
> return 0;
>
> - rk_udphy_power_off(udphy, UDPHY_MODE_USB);
> + udphy->sw_mode &= ~UDPHY_MODE_USB;
> +
> + rk_udphy_update_power_state(udphy);
>
> return 0;
> }
[Severity: High]
Does clearing UDPHY_MODE_USB from udphy->sw_mode before calling
rk_udphy_update_power_state() cause rk_udphy_run_reset_handler() and
rk_udphy_u3_port_disable(udphy, true) to be skipped on USB3 exit and PHY
disable?
Both rk_udphy_run_reset_handler() and the rk_udphy_u3_port_disable() calls
in rk_udphy_update_power_state() check udphy->sw_mode & UDPHY_MODE_USB.
Because UDPHY_MODE_USB is already cleared here (and target_mode ==
UDPHY_MODE_NONE is only reached when udphy->sw_mode == UDPHY_MODE_NONE),
those checks are always false when exiting the USB3 PHY or powering down
the PHY via rk_udphy_disable(). That leaves the USB3 port enabled in
usbgrf without notifying DWC3 or re-routing the DWC3 PIPE clock away from
the disabled PHY, which can trigger an SError when DWC3 registers are
accessed while the PHY is powered down.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261119-b4-rockchip-usbdp-cleanup-part3-v18-0-fb325e336494@collabora.com?part=4
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-11-19 20:02 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-19 19:40 [PATCH v18 0/7] phy: rockchip: usbdp: Fix runtime muxing between USB3 and DP Sebastian Reichel
2026-11-19 19:40 ` [PATCH v18 1/7] phy: rockchip: usbdp: Disable USB3 port during normal power-on Sebastian Reichel
2026-11-19 19:40 ` [PATCH v18 2/7] phy: rockchip: usbdp: Drop -EPROBE_DEFER hack Sebastian Reichel
2026-11-19 19:40 ` [PATCH v18 3/7] phy: rockchip: usbdp: Rename mode to hw_mode Sebastian Reichel
2026-11-19 19:40 ` [PATCH v18 4/7] phy: rockchip: usbdp: Fix power state handling Sebastian Reichel
2026-11-19 20:02 ` sashiko-bot [this message]
2026-11-19 19:40 ` [PATCH v18 5/7] phy: rockchip: usbdp: Re-init PHY on mux change Sebastian Reichel
2026-11-19 19:54 ` sashiko-bot
2026-11-19 19:40 ` [PATCH v18 6/7] phy: rockchip: usbdp: Add USB-C state without DP enabled Sebastian Reichel
2026-11-19 20:02 ` sashiko-bot
2026-11-19 19:40 ` [PATCH v18 7/7] phy: rockchip: usbdp: Add DP lane setup to power state update Sebastian Reichel
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-224002@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=sebastian.reichel@collabora.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox