From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
vkoul@kernel.org, neil.armstrong@linaro.org, olteanv@gmail.com,
linux-phy@lists.infradead.org
Subject: Re: [PATCH v13 02/35] phy: rockchip: usbdp: Update mode_change after error handling
Date: Tue, 14 Jul 2026 19:54:16 +0000 [thread overview]
Message-ID: <20260714195417.0C8C91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714-rockchip-usbdp-cleanup-v13-2-6cb3e769d4c5@collabora.com>
Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
Pre-existing issues:
- [High] State tracking corruption in `rk_udphy_power_on` drops active consumer modes.
- [High] USB3 port remains disabled in system controller when switching from DP-only to DP+USB mode.
- [High] Dynamically disabling PHY clocks without USB controller coordination causes SErrors.
- [High] Type-C disconnects (TYPEC_STATE_SAFE) or USB-only transitions are ignored, stranding PHY state.
- [High] Missing mutex protection in `rk_udphy_dp_phy_configure` allows concurrent access to shared PHY state.
- [Medium] Probe error paths and driver unbind leak clock references.
- [Medium] U3 port remains enabled in system controller when initializing into DP-only mode.
--
--- Patch [2]: [PATCH v13 02/35] phy: rockchip: usbdp: Update mode_change after error handling ---
commit 5e684d6b433ae738bd5f378d7294d9e76a2199d9
Author: Sebastian Reichel <sebastian.reichel@collabora.com>
phy: rockchip: usbdp: Update mode_change after error handling
This commit delays resetting the mode_change flag in rk_udphy_power_on()
until after all potential errors are handled. This ensures that if
rk_udphy_setup() fails, the reinitialization attempt won't be silently
skipped on subsequent tries.
Closes: https://lore.kernel.org/linux-phy/20260612163835.8D5471F000E9@smtp.kernel.org/
> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> @@ -1000,15 +1000,14 @@ static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode)
[ ... ]
> if (udphy->status == UDPHY_MODE_NONE) {
> - udphy->mode_change = false;
> ret = rk_udphy_setup(udphy);
> if (ret)
> return ret;
>
> if (udphy->mode & UDPHY_MODE_USB)
> rk_udphy_u3_port_disable(udphy, false);
> - } else if (udphy->mode_change) {
> udphy->mode_change = false;
> + } else if (udphy->mode_change) {
[Severity: Medium]
This is a pre-existing issue, but does this block leave the U3 port enabled
when initializing into DP-only mode?
If the PHY is completely powered off and the Type-C mux selects DP-only mode,
the DP consumer calls rk_udphy_power_on().
While this block handles initialization, it lacks the logic to call
rk_udphy_u3_port_disable(udphy, true). If the USB consumer is not bound or
initialized yet, does the GRF register for the U3 port retain its previous
state, potentially causing unexpected behavior or minor power drain?
> udphy->status = UDPHY_MODE_NONE;
[Severity: High]
This is a pre-existing issue, but does this aggressively clear the state and
drop active consumer modes?
If both DP and USB consumers are active, and a Type-C event triggers a mode
change, the first consumer to call rk_udphy_power_on() executes this block.
By forcefully overwriting udphy->status = UDPHY_MODE_NONE before
re-initializing, and only appending the caller's mode at the end
(udphy->status |= mode), isn't the other active consumer's state flag
permanently lost?
If that first consumer later calls rk_udphy_power_off(), wouldn't the status
evaluate to 0 and completely disable the PHY, crashing the other consumer
which is still running?
> if (udphy->mode == UDPHY_MODE_DP)
> rk_udphy_u3_port_disable(udphy, true);
[ ... ]
> rk_udphy_disable(udphy);
[Severity: High]
This isn't a bug introduced by this patch, but can dynamically disabling PHY
clocks without coordinating with the USB controller cause SErrors?
When a Type-C mode change occurs while the USB controller (DWC3) is active,
this block calls rk_udphy_disable(), which immediately cuts the PHY clocks.
Because there is no coordination (like phy_notify_reset) to quiesce DWC3 or
reroute its clock via rk_udphy_u3_port_disable(udphy, true) before the
disable call, will any active DWC3 register access instantly cause an SError
kernel panic?
> ret = rk_udphy_setup(udphy);
> if (ret)
> return ret;
> + udphy->mode_change = false;
> }
[Severity: High]
This is a pre-existing issue, but does this branch leave the USB 3.0 port
disabled?
When the Type-C port switches from DP-only to DP+USB mode, the USB3 port was
previously disabled via GRF registers. This branch resets the PHY and clears
mode_change, but it never explicitly calls rk_udphy_u3_port_disable(udphy,
false) to re-enable it.
Since the USB consumer's initialization relies on rk_udphy_power_on() to
handle this, will any dynamic transition from DP-only to DP+USB via cable
flip or replug leave the USB3 port broken?
[Severity: High]
This isn't a bug introduced by this patch, but are Type-C disconnects being
ignored in rk_udphy_typec_mux_set()?
Looking at rk_udphy_typec_mux_set(), the mode update is improperly gated
behind an alt-mode check:
drivers/phy/rockchip/phy-rockchip-usbdp.c:rk_udphy_typec_mux_set() {
...
if (state->alt && state->alt->svid == USB_TYPEC_DP_SID) {
struct typec_displayport_data *data = state->data;
if (!data) {
...
}
On Type-C cable unplug or a transition to USB-only mode, state->mode is
TYPEC_STATE_SAFE or TYPEC_STATE_USB, so state->alt is NULL. Since the mode
update logic is strictly guarded by the SVID check, it gets completely
bypassed.
Does this leave udphy->mode indefinitely retaining the old DP state, breaking
subsequent USB connections and preventing proper PHY power down?
[Severity: High]
This is a pre-existing issue, but is there missing mutex protection in
rk_udphy_dp_phy_configure()?
This function accesses and mutates shared state without acquiring
udphy->mutex:
drivers/phy/rockchip/phy-rockchip-usbdp.c:rk_udphy_dp_phy_configure() {
...
if (dp->set_rate) {
udphy->link_rate = dp->link_rate;
...
}
Since rk_udphy_dp_phy_configure() is invoked by the DP subsystem during link
training, it reads shared state like udphy->lane_mux_sel and modifies
udphy->bw and udphy->link_rate.
Meanwhile, an asynchronous Type-C event running rk_udphy_typec_mux_set()
modifies these exact arrays while holding the mutex. Can this race condition
lead to reading torn lane mappings and programming incorrect hardware
registers?
[Severity: Medium]
This isn't a bug introduced by this patch, but do the probe error paths and
driver unbind leak clock references?
In rk_udphy_probe(), clocks can be enabled if the bootloader left the PHY
active:
drivers/phy/rockchip/phy-rockchip-usbdp.c:rk_udphy_probe() {
...
ret = rk_udphy_get_initial_status(udphy);
if (ret)
return ret;
mutex_init(&udphy->mutex);
platform_set_drvdata(pdev, udphy);
...
}
If a subsequent step in the probe fails (such as devm_phy_create), or if the
driver is unbound, there appears to be no corresponding
clk_bulk_disable_unprepare() execution or .remove callback to release these
clocks. Does this cause a clock reference count leak?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260714-rockchip-usbdp-cleanup-v13-0-6cb3e769d4c5@collabora.com?part=2
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-07-14 19:54 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 [this message]
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
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=20260714195417.0C8C91F000E9@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