[PATCH v10 19/36] phy: rockchip: usbdp: Re-init the PHY on orientation change

sashiko-bot at kernel.org sashiko-bot at kernel.org
Fri Jul 3 16:51:31 PDT 2026


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The patch defers PHY hardware re-initialization during Type-C orientation changes by setting a `phy_needs_reinit` flag, assuming a subsequent call to `rk_udphy_update_power_state()` will apply the change. However, for USB3-only connections, this subsequent call is often never made, resulting in broken USB3 functionality.
--

commit af712ecc489de5c647a8e305c7beca4b1c6dd5cb
Author: Sebastian Reichel <sebastian.reichel at collabora.com>

phy: rockchip: usbdp: Re-init the PHY on orientation change

This patch updates the rockchip usbdp PHY driver to track orientation
changes by checking if the cable orientation is reversed. If the orientation
changes, it flags the PHY as needing re-initialization so that the lane 
muxing can be reconfigured.

> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index e44d19c9d1193..4b454798c4ed4 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> @@ -620,6 +620,7 @@ static int rk_udphy_orien_sw_set(struct typec_switch_dev *sw,
>  				 enum typec_orientation orien)
>  {
>  	struct rk_udphy *udphy = typec_switch_get_drvdata(sw);
> +	bool flipped = orien == TYPEC_ORIENTATION_REVERSE;
>  
>  	mutex_lock(&udphy->mutex);
>  
> @@ -631,7 +632,10 @@ static int rk_udphy_orien_sw_set(struct typec_switch_dev *sw,
>  		goto unlock_ret;
>  	}
>  
> -	udphy->flip = orien == TYPEC_ORIENTATION_REVERSE;
> +	if (udphy->flip != flipped)
> +		udphy->phy_needs_reinit = true;
> +

[Severity: High]
Does this deferral of PHY initialization break USB3-only connections?

By only setting the phy_needs_reinit flag here, the actual hardware update
appears to be deferred until rk_udphy_update_power_state() is called to 
consume it.

For USB3-only connections (especially on fixed-role ports or boards without a
mode-switch property), is rk_udphy_update_power_state() guaranteed to be
called after this orientation change? 

If it isn't called, it seems a reverse-plugged USB3 device might fail to
connect because the reverse lane routing is never written to the hardware. 
Additionally, if a DisplayPort device (which does trigger a power state 
update) is plugged in reverse and then replaced with a normal USB3 device, 
could the software state reset to normal while the hardware remains stuck 
in reverse?

> +	udphy->flip = flipped;
>  	rk_udphy_set_typec_default_mapping(udphy);
>  	rk_udphy_usb_bvalid_enable(udphy, true);
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260703-rockchip-usbdp-cleanup-v10-0-a392711ca8a9@collabora.com?part=19



More information about the linux-phy mailing list