From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: linux-phy@lists.infradead.org, olteanv@gmail.com,
devicetree@vger.kernel.org, conor+dt@kernel.org,
neil.armstrong@linaro.org, robh@kernel.org, vkoul@kernel.org
Subject: Re: [PATCH v6 21/23] phy: rockchip: usbdp: Support going from DP-only mode to USB mode
Date: Fri, 19 Jun 2026 15:57:57 +0000 [thread overview]
Message-ID: <20260619155757.AE6371F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260619-rockchip-usbdp-cleanup-v6-21-3bb1f54b3f35@collabora.com>
Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] The `usb_in_use` flag is bypassed if `phy_init` is called while the PHY is in a DP-only mode, permanently breaking USB functionality for subsequent adapter swaps.
- [High] The fix fails to restore USB functionality when transitioning from a DP-only adapter to a pure USB Type-C device.
- [High] The `!(old_mode & UDPHY_MODE_USB)` check in `rk_udphy_typec_mux_set()` erroneously fails because `rk_udphy_orien_sw_set()` preemptively modifies the mode during unplug/replug.
- [Medium] If `rk_udphy_power_on()` fails during a type-C mux transition, `udphy->mode` remains permanently updated, preventing future retries from restoring USB power.
--
commit fe9deaf95e7e3b871d382c46e07c07e56534ca4d
Author: Sebastian Reichel <sebastian.reichel@collabora.com>
phy: rockchip: usbdp: Support going from DP-only mode to USB mode
This patch adds support for restoring USB functionality when a DP-only
adapter is unplugged and replaced with an adapter supporting USB, working
around the USB controller keeping the PHY enabled.
> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index 81aae3bc57476..7f26b74cb5151 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
[ ... ]
> @@ -1287,7 +1293,13 @@ static int rk_udphy_usb3_phy_init(struct phy *phy)
> return 0;
> }
>
> - return rk_udphy_power_on(udphy, UDPHY_MODE_USB);
> + ret = rk_udphy_power_on(udphy, UDPHY_MODE_USB);
> + if (ret)
> + return ret;
> +
> + udphy->usb_in_use = true;
[Severity: High]
Does this early return logic introduce a regression that prevents the flag
from being set if the system boots with a DP-only adapter?
If phy_init is called when the current mode lacks USB, it takes the early
return visible in the context above and skips executing
udphy->usb_in_use = true.
When a DP+USB adapter is later plugged in, udphy->usb_in_use will be false,
and the newly added restoration logic in rk_udphy_typec_mux_set() will
silently skip powering on the USB PHY.
> +
> + return 0;
> }
[ ... ]
> @@ -1315,6 +1329,7 @@ static int rk_udphy_typec_mux_set(struct typec_mux_dev *mux,
> struct typec_mux_state *state)
> {
> struct rk_udphy *udphy = typec_mux_get_drvdata(mux);
> + u8 old_mode;
>
> /*
> * Ignore mux events not involving DP AltMode, because
[Severity: High]
Is there a regression here where pure USB adapters bypass this restoration
logic entirely?
The code just below this in rk_udphy_typec_mux_set() aborts for non-DP
events:
if (!state->alt || state->alt->svid != USB_TYPEC_DP_SID)
return 0;
If a pure USB Type-C device is connected after a DP-only adapter,
rk_udphy_orien_sw_set() updates the default mapping to UDPHY_MODE_DP_USB,
but rk_udphy_typec_mux_set() is never triggered. Since the USB controller
keeps the PHY logically enabled without calling phy_init again, the USB PHY
would remain powered off.
> @@ -1326,8 +1341,20 @@ static int rk_udphy_typec_mux_set(struct typec_mux_dev *mux,
>
> guard(mutex)(&udphy->mutex);
>
> + old_mode = udphy->mode;
> +
> rk_udphy_set_typec_state(udphy, state->mode);
>
> + /*
> + * If the new mode includes USB but the old one didn't (e.g. leaving
> + * DP-only), and the USB PHY was already initialized by the USB
> + * controller, we need to power on the USB side now since no
> + * subsequent phy_init call will come from the controller.
> + */
> + if ((udphy->mode & UDPHY_MODE_USB) && !(old_mode & UDPHY_MODE_USB) &&
[Severity: High]
Does this introduce a regression where old_mode already includes
UDPHY_MODE_USB during an unplug/replug sequence?
When unplugging a DP-only adapter and plugging in a DP+USB adapter,
rk_udphy_orien_sw_set() is called first and unconditionally sets
udphy->mode to UDPHY_MODE_DP_USB.
When rk_udphy_typec_mux_set() is called moments later, old_mode = udphy->mode
will capture UDPHY_MODE_DP_USB. The check !(old_mode & UDPHY_MODE_USB)
would then evaluate to false, causing the USB PHY restoration to be skipped.
> + udphy->usb_in_use && !udphy->hs)
> + return rk_udphy_power_on(udphy, UDPHY_MODE_USB);
[Severity: Medium]
If rk_udphy_power_on() fails here, does it leave udphy->mode permanently
updated without a rollback?
rk_udphy_set_typec_state() modifies udphy->mode before this power-on
attempt. If rk_udphy_power_on() returns an error, the mode retains the USB
bit. If the Type-C subsystem retries the switch later, old_mode will now
include the USB bit, which would permanently prevent future retries from
passing the restoration check.
> +
> return 0;
> }
>
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260619-rockchip-usbdp-cleanup-v6-0-3bb1f54b3f35@collabora.com?part=21
next prev parent reply other threads:[~2026-06-19 15:57 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-19 15:28 [PATCH v6 00/23] phy: rockchip: usbdp: Fixes, DP 1-lane support and cleanups Sebastian Reichel
2026-06-19 15:28 ` [PATCH v6 01/23] dt-bindings: phy: rockchip-usbdp: add improved ports scheme Sebastian Reichel
2026-06-19 15:28 ` [PATCH v6 02/23] phy: rockchip: usbdp: Update mode_change after error handling Sebastian Reichel
2026-06-19 15:49 ` sashiko-bot
2026-06-19 15:28 ` [PATCH v6 03/23] phy: rockchip: usbdp: Do not lose USB3 PHY status Sebastian Reichel
2026-06-19 15:28 ` [PATCH v6 04/23] phy: rockchip: usbdp: Fix devm_clk_bulk_get_all check Sebastian Reichel
2026-06-19 15:43 ` sashiko-bot
2026-06-19 15:28 ` [PATCH v6 05/23] phy: rockchip: usbdp: Drop seamless DP takeover Sebastian Reichel
2026-06-19 15:47 ` sashiko-bot
2026-06-19 15:28 ` [PATCH v6 06/23] phy: rockchip: usbdp: Limit DP lane count to muxed lanes Sebastian Reichel
2026-06-19 15:28 ` [PATCH v6 07/23] phy: rockchip: usbdp: Keep clocks running on PHY re-init Sebastian Reichel
2026-06-19 15:50 ` sashiko-bot
2026-06-19 15:28 ` [PATCH v6 08/23] phy: rockchip: usbdp: Amend SSC modulation deviation Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 09/23] phy: rockchip: usbdp: Fix LFPS detect threshold control Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 10/23] phy: rockchip: usbdp: Add missing mode_change update Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 11/23] phy: rockchip: usbdp: Support single-lane DP Sebastian Reichel
2026-06-19 15:48 ` sashiko-bot
2026-06-19 15:29 ` [PATCH v6 12/23] phy: rockchip: usbdp: Rename DP lane functions Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 13/23] phy: rockchip: usbdp: Use FIELD_PREP_WM16_CONST Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 14/23] phy: rockchip: usbdp: Cleanup DP lane selection function Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 15/23] phy: rockchip: usbdp: Register DP aux bridge Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 16/23] phy: rockchip: usbdp: Drop DP HPD handling Sebastian Reichel
2026-06-19 16:00 ` sashiko-bot
2026-06-19 15:29 ` [PATCH v6 17/23] phy: rockchip: usbdp: Rename mode_change to phy_needs_reinit Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 18/23] phy: rockchip: usbdp: Re-init the PHY on orientation change Sebastian Reichel
2026-06-19 15:53 ` sashiko-bot
2026-06-19 15:29 ` [PATCH v6 19/23] phy: rockchip: usbdp: Factor out lane_mux_sel setup Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 20/23] phy: rockchip: usbdp: Use guard functions for mutex Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 21/23] phy: rockchip: usbdp: Support going from DP-only mode to USB mode Sebastian Reichel
2026-06-19 15:57 ` sashiko-bot [this message]
2026-06-19 15:29 ` [PATCH v6 22/23] phy: rockchip: usbdp: Hold mutex in DP PHY configure Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 23/23] phy: rockchip: usbdp: Add some extra debug messages 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=20260619155757.AE6371F000E9@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