[PATCH v11 10/36] phy: rockchip: usbdp: Add missing mode_change update
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Thu Jul 9 12:19:08 PDT 2026
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The newly introduced rk_udphy_mode_set() helper incorrectly returns early if the logical mode matches, failing to trigger PHY hardware reinitialization on Type-C cable orientation flips.
--
--- Patch [10]: [PATCH v11 10/36] phy: rockchip: usbdp: Add missing mode_change update ---
commit 3a5a910ac8d7d8bee622a7fda0b441c254a882fe
Author: Sebastian Reichel <sebastian.reichel at collabora.com>
phy: rockchip: usbdp: Add missing mode_change update
This commit introduces a new helper rk_udphy_mode_set() to update available
modes and set the mode_change flag. It aims to fix an issue where missing
re-initialization caused DisplayPort to stop working.
> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index 982315535caf7..7540c897dde13 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
[ ... ]
> @@ -617,6 +617,15 @@ static void rk_udphy_dp_hpd_event_trigger(struct rk_udphy *udphy, bool hpd)
> rk_udphy_grfreg_write(udphy->vogrf, &cfg->vogrfcfg[udphy->id].hpd_trigger, hpd);
> }
>
> +static void rk_udphy_mode_set(struct rk_udphy *udphy, u8 mode)
> +{
> + if (udphy->mode == mode)
> + return;
> +
> + udphy->mode_change = true;
> + udphy->mode = mode;
> +}
> +
> static void rk_udphy_set_typec_default_mapping(struct rk_udphy *udphy)
> {
> if (udphy->flip) {
> @@ -647,7 +656,7 @@ static void rk_udphy_set_typec_default_mapping(struct rk_udphy *udphy)
> gpiod_set_value_cansleep(udphy->sbu2_dc_gpio, 1);
> }
>
> - udphy->mode = UDPHY_MODE_DP_USB;
> + rk_udphy_mode_set(udphy, UDPHY_MODE_DP_USB);
[Severity: High]
Will this early return in rk_udphy_mode_set() prevent PHY re-initialization
during a Type-C cable orientation flip?
When the cable is rapidly flipped and replugged, the USB driver might keep the
PHY powered on temporarily due to runtime PM autosuspend, meaning udphy->status
can remain UDPHY_MODE_USB.
In this scenario, rk_udphy_set_typec_default_mapping() recalculates the new
reversed physical lane mappings and calls the new helper:
rk_udphy_orien_sw_set() ->
rk_udphy_set_typec_default_mapping() ->
// physical lane mappings are updated here
rk_udphy_mode_set(udphy, UDPHY_MODE_DP_USB);
Since udphy->mode is already UDPHY_MODE_DP_USB, the helper returns early
without setting mode_change to true.
Consequently, when DP power-on occurs in rk_udphy_power_on(), the hardware
initialization step is skipped because mode_change is false. The hardware's
lane mux registers are never updated with the new reversed mappings, which
causes DisplayPort to fail.
Does the mode_change flag need to be set during an orientation change even if
the logical mode remains the same?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260709-rockchip-usbdp-cleanup-v11-0-a149ac60f76c@collabora.com?part=10
More information about the linux-phy
mailing list