[PATCH v12 22/36] phy: rockchip: usbdp: Use guard functions for mutex
sashiko-bot at kernel.org
sashiko-bot at kernel.org
Fri Jul 10 14:18:42 PDT 2026
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but `rk_udphy_dp_phy_configure` accesses shared PHY state without holding `udphy->mutex`.
--
--- Patch [22]: [PATCH v12 22/36] phy: rockchip: usbdp: Use guard functions for mutex ---
commit f4715c1e8ea1ff2794633378980dbaf55d276684
Author: Sebastian Reichel <sebastian.reichel at collabora.com>
phy: rockchip: usbdp: Use guard functions for mutex
Convert the driver to use guard functions for mutex handling as
a small cleanup. There is a small functional change in the DP PHY
power up function, which no longer sleeps if the internal powerup
code returns an error.
> diff --git a/drivers/phy/rockchip/phy-rockchip-usbdp.c b/drivers/phy/rockchip/phy-rockchip-usbdp.c
> index 0399cbf96e195..8c165bcab7968 100644
> --- a/drivers/phy/rockchip/phy-rockchip-usbdp.c
> +++ b/drivers/phy/rockchip/phy-rockchip-usbdp.c
[ ... ]
> @@ -1255,35 +1254,30 @@ static const struct phy_ops rk_udphy_dp_phy_ops = {
> static int rk_udphy_usb3_phy_init(struct phy *phy)
> {
[Severity: High]
This isn't a bug introduced by this patch, but rk_udphy_dp_phy_configure()
accesses shared PHY state without holding udphy->mutex.
Could this create a data race with Type-C orientation changes?
The function iterates over the udphy->dp_lane_sel array and writes to the
hardware PHY registers based on the mapped lanes:
for (i = 0; i < udphy->lanes; i++) {
lane = udphy->dp_lane_sel[i];
switch (udphy->link_rate) {
...
Because phy_configure is called by the DRM bridge without udphy->mutex held,
and concurrent Type-C orientation switch events handled in
rk_udphy_orien_sw_set() hold udphy->mutex while modifying udphy->dp_lane_sel
and udphy->lane_mux_sel, they might run at the same time.
If a cable is flipped exactly during a display bring-up, could this cause a
torn read that applies settings to the same lane twice while omitting others,
leaving the hardware incorrectly configured and DP alt mode output broken?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260710-rockchip-usbdp-cleanup-v12-0-8b41a9a9bef0@collabora.com?part=22
More information about the linux-phy
mailing list