From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: olteanv@gmail.com, robh@kernel.org, conor+dt@kernel.org,
devicetree@vger.kernel.org, vkoul@kernel.org,
neil.armstrong@linaro.org, linux-phy@lists.infradead.org
Subject: Re: [PATCH v13 03/35] phy: rockchip: usbdp: Do not lose USB3 PHY status
Date: Tue, 14 Jul 2026 19:49:09 +0000 [thread overview]
Message-ID: <20260714194910.13B941F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714-rockchip-usbdp-cleanup-v13-3-6cb3e769d4c5@collabora.com>
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [High] State desynchronization on PHY setup failure causes double clock disable.
- [High] USB status bit permanently sticks when transitioning to DP-only mode, causing a permanent hardware power leak.
Pre-existing issues:
- [High] USB3 port remains permanently disabled after Type-C transitions from DP-only to DP+USB.
- [High] Clock resource leak on probe failure and module unload if the bootloader left the PHY enabled.
- [High] Data race in `rk_udphy_dp_phy_configure` leading to corrupted DP lane configuration.
--
--- Patch [3]: [PATCH v13 03/35] phy: rockchip: usbdp: Do not lose USB3 PHY status ---
commit d46c4c27785a2f2be7f57da59562db8997835bf3
Author: Sebastian Reichel <sebastian.reichel@collabora.com>
phy: rockchip: usbdp: Do not lose USB3 PHY status
This patch modifies the Rockchip USB/DP combo PHY driver to prevent the status
variable from being cleared during a DP mode change. This ensures that the
tracking information for USB3 is not lost when re-initializing the PHY.
> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index a5ffdf7a6e76b..12dfdd470a782 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> @@ -1008,7 +1008,6 @@ static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode)
> rk_udphy_u3_port_disable(udphy, false);
> udphy->mode_change = false;
> } else if (udphy->mode_change) {
> - udphy->status = UDPHY_MODE_NONE;
[Severity: High]
If rk_udphy_setup() fails in the subsequent step (e.g., due to a PLL lock
timeout), could this cause a state desynchronization?
By no longer clearing the status here, the previous active flags remain if the
setup fails:
drivers/phy/rockchip/phy-rockchip-usbdp.c:rk_udphy_power_on() {
...
} else if (udphy->mode_change) {
if (udphy->mode == UDPHY_MODE_DP)
rk_udphy_u3_port_disable(udphy, true);
rk_udphy_disable(udphy);
ret = rk_udphy_setup(udphy);
if (ret)
return ret;
...
}
When the consumer unwinds the failure and calls phy_power_off(), the driver
will see the non-zero status, clear the bit, and invoke rk_udphy_disable() a
second time on already disabled clocks. Will this cause the clock enable
refcount to underflow and generate a kernel warning?
[Severity: High]
Additionally, does removing this clearance cause a permanent hardware power
leak when transitioning to a DP-only mode?
If the Type-C port negotiates a DP-only mode, udphy->mode changes to
UDPHY_MODE_DP, but the UDPHY_MODE_USB bit now persists in udphy->status from
prior initialization.
Later, if the USB core suspends or unbinds, rk_udphy_usb3_phy_exit() is called:
drivers/phy/rockchip/phy-rockchip-usbdp.c:rk_udphy_usb3_phy_exit() {
...
/* DP only or high-speed */
if (!(udphy->mode & UDPHY_MODE_USB) || udphy->hs)
goto unlock;
rk_udphy_power_off(udphy, UDPHY_MODE_USB);
...
}
Because udphy->mode is UDPHY_MODE_DP, it skips the call to
rk_udphy_power_off(), meaning the UDPHY_MODE_USB bit is never cleared.
When the DP consumer eventually powers off, rk_udphy_disable() is skipped
because status remains non-zero, leaving the clocks permanently enabled.
> if (udphy->mode == UDPHY_MODE_DP)
> rk_udphy_u3_port_disable(udphy, true);
[Severity: High]
This is a pre-existing issue, but does this block fail to explicitly re-enable
the USB3 port when transitioning to a mode that requires it?
When transitioning from a DP-only mode to a DP+USB combo mode, udphy->mode
changes to UDPHY_MODE_DP_USB and udphy->mode_change is set to true.
During rk_udphy_power_on(), the code previously disabled the U3 port when
entering DP-only mode. However, when transitioning back to DP+USB, the code
skips the initial UDPHY_MODE_NONE block and enters the
else if (udphy->mode_change) block, which entirely lacks a call to explicitly
re-enable the port via rk_udphy_u3_port_disable(udphy, false).
Will the GRF register retain the disabled state indefinitely, silently
breaking USB3 functionality?
[Severity: High]
This isn't a bug introduced by this patch, but does the driver leak clock
resources if the bootloader left the PHY enabled and probe fails?
In rk_udphy_get_initial_status(), if it detects the PHY was already enabled
by the bootloader, it intentionally skips disabling the clocks:
drivers/phy/rockchip/phy-rockchip-usbdp.c:rk_udphy_get_initial_status() {
...
regmap_read(udphy->pma_regmap, CMN_LANE_MUX_AND_EN_OFFSET, &value);
if (FIELD_GET(CMN_DP_LANE_MUX_ALL, value) &&
FIELD_GET(CMN_DP_LANE_EN_ALL, value))
udphy->status = UDPHY_MODE_DP;
else
rk_udphy_disable(udphy);
...
}
Since there is no devm cleanup action registered for these manually enabled
clocks, if a subsequent probe step like devm_phy_create() fails, probe
returns an error without disabling them. Furthermore, since the platform
driver lacks a .remove callback, will the module leak these clocks if it is
cleanly unloaded?
[Severity: High]
This is a pre-existing issue, but is there a data race in
rk_udphy_dp_phy_configure() that could lead to corrupted DP lane configuration?
drivers/phy/rockchip/phy-rockchip-usbdp.c:rk_udphy_dp_phy_configure() {
...
if (dp->set_voltages) {
for (i = 0; i < udphy->lanes; i++) {
lane = udphy->dp_lane_sel[i];
...
}
The udphy->dp_lane_sel and udphy->lane_mux_sel arrays are read without
holding udphy->mutex.
Concurrently, if a Type-C orientation flip occurs, the TCPM worker thread
calls rk_udphy_orien_sw_set(), which mutates these exact arrays under
udphy->mutex.
If the DP driver performs link training concurrently with an orientation flip,
could it read partially updated lane arrays and write invalid voltage swing
configurations to incorrect lane registers on the PHY?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260714-rockchip-usbdp-cleanup-v13-0-6cb3e769d4c5@collabora.com?part=3
next prev parent reply other threads:[~2026-07-14 19:49 UTC|newest]
Thread overview: 55+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 19:26 [PATCH v13 00/35] phy: rockchip: usbdp: Clean up the mess Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 01/35] dt-bindings: phy: rockchip-usbdp: add improved ports scheme Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 02/35] phy: rockchip: usbdp: Update mode_change after error handling Sebastian Reichel
2026-07-14 19:54 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 03/35] phy: rockchip: usbdp: Do not lose USB3 PHY status Sebastian Reichel
2026-07-14 19:49 ` sashiko-bot [this message]
2026-07-14 19:26 ` [PATCH v13 04/35] phy: rockchip: usbdp: Fix devm_clk_bulk_get_all check Sebastian Reichel
2026-07-14 19:48 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 05/35] phy: rockchip: usbdp: Handle missing clock-names DT property gracefully Sebastian Reichel
2026-07-14 20:00 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 06/35] phy: rockchip: usbdp: Drop seamless DP takeover Sebastian Reichel
2026-07-14 20:01 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 07/35] phy: rockchip: usbdp: Keep clocks running on PHY re-init Sebastian Reichel
2026-07-14 19:47 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 08/35] phy: rockchip: usbdp: Amend SSC modulation deviation Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 09/35] phy: rockchip: usbdp: Fix LFPS detect threshold control Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 10/35] phy: rockchip: usbdp: Add missing mode_change update Sebastian Reichel
2026-07-14 19:49 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 11/35] phy: rockchip: usbdp: Support single-lane DP Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 12/35] phy: rockchip: usbdp: Limit DP lane count to muxed lanes Sebastian Reichel
2026-07-14 20:11 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 13/35] phy: rockchip: usbdp: Rename DP lane functions Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 14/35] phy: rockchip: usbdp: Use FIELD_PREP_WM16_CONST Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 15/35] phy: rockchip: usbdp: Cleanup DP lane selection function Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 16/35] phy: rockchip: usbdp: Register DP aux bridge Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 17/35] phy: rockchip: usbdp: Drop DP HPD handling Sebastian Reichel
2026-07-14 20:03 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 18/35] phy: rockchip: usbdp: Rename mode_change to phy_needs_reinit Sebastian Reichel
2026-07-14 19:58 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 19/35] phy: rockchip: usbdp: Re-init the PHY on orientation change Sebastian Reichel
2026-07-14 20:09 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 20/35] phy: rockchip: usbdp: Factor out lane_mux_sel setup Sebastian Reichel
2026-07-14 20:03 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 21/35] phy: rockchip: usbdp: Properly handle TYPEC_STATE_SAFE and TYPEC_STATE_USB Sebastian Reichel
2026-07-14 20:22 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 22/35] phy: rockchip: usbdp: Use guard functions for mutex Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 23/35] phy: rockchip: usbdp: Hold mutex in DP PHY configure Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 24/35] phy: rockchip: usbdp: Add some extra debug messages Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 25/35] phy: rockchip: usbdp: Avoid xHCI SErrors Sebastian Reichel
2026-07-14 20:11 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 26/35] phy: rockchip: usbdp: Handle rk_udphy_reset_deassert errors Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 27/35] phy: rockchip: usbdp: Only enable USB3 when not in high-speed mode Sebastian Reichel
2026-07-14 20:15 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 28/35] phy: core: add notifier infrastructure Sebastian Reichel
2026-07-14 20:10 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 29/35] usb: dwc3: core: support PHY reset notifications Sebastian Reichel
2026-07-14 20:15 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 30/35] phy: rockchip: usbdp: Add phy reset notification support Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 31/35] phy: rockchip: usbdp: Drop -EPROBE_DEFER hack Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 32/35] phy: rockchip: usbdp: Rename mode to hw_mode Sebastian Reichel
2026-07-14 20:18 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 33/35] phy: rockchip: usbdp: Fix power state handling Sebastian Reichel
2026-07-14 19:26 ` [PATCH v13 34/35] phy: rockchip: usbdp: Re-init PHY on mux change Sebastian Reichel
2026-07-14 20:39 ` sashiko-bot
2026-07-14 19:26 ` [PATCH v13 35/35] phy: rockchip: usbdp: Add USB-C state without DP enabled 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=20260714194910.13B941F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--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