From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: vkoul@kernel.org, robh@kernel.org, devicetree@vger.kernel.org,
neil.armstrong@linaro.org, linux-phy@lists.infradead.org,
conor+dt@kernel.org, olteanv@gmail.com
Subject: Re: [PATCH v6 02/23] phy: rockchip: usbdp: Update mode_change after error handling
Date: Fri, 19 Jun 2026 15:49:02 +0000 [thread overview]
Message-ID: <20260619154903.2225A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260619-rockchip-usbdp-cleanup-v6-2-3bb1f54b3f35@collabora.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] System crash due to concurrent MMIO access after PHY reinitialization failure.
- [High] State desync and resource leak in PHY mode tracking during Type-C role transitions.
--
commit e7082d92230eb75aff8a9e06c20d96b4d548e34c
Author: Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: phy: rockchip: usbdp: Update mode_change after error handling
If rk_udphy_init() or rk_udphy_setup() fails, the reinit will not be
tried again. Fix this by only updating the variable after all potential
errors have been handled.
Link: 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
> index fba35510d88ce..a5ffdf7a6e76b 100644
> --- 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) {
[Severity: High]
This isn't a bug introduced by this patch, but I have a question about how
PHY mode transitions are tracked when the Type-C mux switches from a state
with USB (like DP+USB) to a state without it (like DP-only).
In this scenario, the mode variable gets updated, but the USB flag is not
cleared from the status field. Later, when the USB subsystem calls
rk_udphy_usb3_phy_exit(), it sees that the current mode lacks the USB flag
and returns early. This bypasses rk_udphy_power_off().
Does this mean the USB flag is permanently leaked in the status field? If
the remaining DP consumer subsequently powers off, it seems the status would
still contain the USB flag, preventing the driver from properly shutting
down the hardware and leaving APB clocks active.
> 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) {
> udphy->status = UDPHY_MODE_NONE;
> if (udphy->mode == UDPHY_MODE_DP)
> rk_udphy_u3_port_disable(udphy, true);
> @@ -1017,6 +1016,7 @@ static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode)
> ret = rk_udphy_setup(udphy);
> if (ret)
> return ret;
[Severity: Critical]
This is a pre-existing issue, but what happens if the setup or init fails
here during a Type-C orientation change?
If rk_udphy_init() fails due to something like an LCPLL lock timeout, it
asserts all resets, including the APB resets, before returning the error.
This function then propagates that error, but it doesn't restore the prior
state of sibling PHYs (like DP) which might already be active.
Since the DP framework would still consider the PHY active, could it
subsequently invoke rk_udphy_dp_phy_configure()? If that happens and it
attempts MMIO access to the PMA regmap while the APB bus reset is still
asserted, would this trigger a bus hang and a kernel panic?
> + udphy->mode_change = false;
> }
>
> udphy->status |= mode;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260619-rockchip-usbdp-cleanup-v6-0-3bb1f54b3f35@collabora.com?part=2
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Sebastian Reichel" <sebastian.reichel@collabora.com>
Cc: vkoul@kernel.org, robh@kernel.org, devicetree@vger.kernel.org,
neil.armstrong@linaro.org, linux-phy@lists.infradead.org,
conor+dt@kernel.org, olteanv@gmail.com
Subject: Re: [PATCH v6 02/23] phy: rockchip: usbdp: Update mode_change after error handling
Date: Fri, 19 Jun 2026 15:49:02 +0000 [thread overview]
Message-ID: <20260619154903.2225A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260619-rockchip-usbdp-cleanup-v6-2-3bb1f54b3f35@collabora.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Pre-existing issues:
- [Critical] System crash due to concurrent MMIO access after PHY reinitialization failure.
- [High] State desync and resource leak in PHY mode tracking during Type-C role transitions.
--
commit e7082d92230eb75aff8a9e06c20d96b4d548e34c
Author: Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: phy: rockchip: usbdp: Update mode_change after error handling
If rk_udphy_init() or rk_udphy_setup() fails, the reinit will not be
tried again. Fix this by only updating the variable after all potential
errors have been handled.
Link: 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
> index fba35510d88ce..a5ffdf7a6e76b 100644
> --- 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) {
[Severity: High]
This isn't a bug introduced by this patch, but I have a question about how
PHY mode transitions are tracked when the Type-C mux switches from a state
with USB (like DP+USB) to a state without it (like DP-only).
In this scenario, the mode variable gets updated, but the USB flag is not
cleared from the status field. Later, when the USB subsystem calls
rk_udphy_usb3_phy_exit(), it sees that the current mode lacks the USB flag
and returns early. This bypasses rk_udphy_power_off().
Does this mean the USB flag is permanently leaked in the status field? If
the remaining DP consumer subsequently powers off, it seems the status would
still contain the USB flag, preventing the driver from properly shutting
down the hardware and leaving APB clocks active.
> 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) {
> udphy->status = UDPHY_MODE_NONE;
> if (udphy->mode == UDPHY_MODE_DP)
> rk_udphy_u3_port_disable(udphy, true);
> @@ -1017,6 +1016,7 @@ static int rk_udphy_power_on(struct rk_udphy *udphy, u8 mode)
> ret = rk_udphy_setup(udphy);
> if (ret)
> return ret;
[Severity: Critical]
This is a pre-existing issue, but what happens if the setup or init fails
here during a Type-C orientation change?
If rk_udphy_init() fails due to something like an LCPLL lock timeout, it
asserts all resets, including the APB resets, before returning the error.
This function then propagates that error, but it doesn't restore the prior
state of sibling PHYs (like DP) which might already be active.
Since the DP framework would still consider the PHY active, could it
subsequently invoke rk_udphy_dp_phy_configure()? If that happens and it
attempts MMIO access to the PMA regmap while the APB bus reset is still
asserted, would this trigger a bus hang and a kernel panic?
> + udphy->mode_change = false;
> }
>
> udphy->status |= mode;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260619-rockchip-usbdp-cleanup-v6-0-3bb1f54b3f35@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-06-19 15:49 UTC|newest]
Thread overview: 88+ 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 ` Sebastian Reichel
2026-06-19 15:28 ` 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 ` Sebastian Reichel
2026-06-19 15:28 ` 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:28 ` Sebastian Reichel
2026-06-19 15:28 ` Sebastian Reichel
2026-06-19 15:49 ` sashiko-bot [this message]
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 ` Sebastian Reichel
2026-06-19 15:28 ` 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:28 ` Sebastian Reichel
2026-06-19 15:28 ` Sebastian Reichel
2026-06-19 15:43 ` sashiko-bot
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:28 ` Sebastian Reichel
2026-06-19 15:28 ` Sebastian Reichel
2026-06-19 15:47 ` sashiko-bot
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 ` Sebastian Reichel
2026-06-19 15:28 ` 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:28 ` Sebastian Reichel
2026-06-19 15:28 ` Sebastian Reichel
2026-06-19 15:50 ` sashiko-bot
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:28 ` Sebastian Reichel
2026-06-19 15:28 ` 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 ` Sebastian Reichel
2026-06-19 15:29 ` 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 ` Sebastian Reichel
2026-06-19 15:29 ` Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 11/23] phy: rockchip: usbdp: Support single-lane DP Sebastian Reichel
2026-06-19 15:29 ` Sebastian Reichel
2026-06-19 15:29 ` Sebastian Reichel
2026-06-19 15:48 ` sashiko-bot
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 ` Sebastian Reichel
2026-06-19 15:29 ` 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 ` Sebastian Reichel
2026-06-19 15:29 ` 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 ` Sebastian Reichel
2026-06-19 15:29 ` 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 ` Sebastian Reichel
2026-06-19 15:29 ` Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 16/23] phy: rockchip: usbdp: Drop DP HPD handling Sebastian Reichel
2026-06-19 15:29 ` Sebastian Reichel
2026-06-19 15:29 ` Sebastian Reichel
2026-06-19 16:00 ` sashiko-bot
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 ` Sebastian Reichel
2026-06-19 15:29 ` 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:29 ` Sebastian Reichel
2026-06-19 15:29 ` Sebastian Reichel
2026-06-19 15:53 ` sashiko-bot
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 ` Sebastian Reichel
2026-06-19 15:29 ` 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 ` Sebastian Reichel
2026-06-19 15:29 ` 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:29 ` Sebastian Reichel
2026-06-19 15:29 ` Sebastian Reichel
2026-06-19 15:57 ` sashiko-bot
2026-06-19 15:57 ` sashiko-bot
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 ` Sebastian Reichel
2026-06-19 15:29 ` Sebastian Reichel
2026-06-19 15:29 ` [PATCH v6 23/23] phy: rockchip: usbdp: Add some extra debug messages Sebastian Reichel
2026-06-19 15:29 ` Sebastian Reichel
2026-06-19 15:29 ` 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=20260619154903.2225A1F000E9@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.