From: sashiko-bot@kernel.org
To: "Gary Yang" <gary.yang@cixtech.com>
Cc: linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org,
neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v3 2/2] phy: cix: add Sky1 USB/DP combo PHY driver
Date: Mon, 30 Nov 2026 06:44:35 +0000 [thread overview]
Message-ID: <sashiko-outbox-240522@kernel.org> (raw)
In-Reply-To: <20261130062028.3366748-3-gary.yang@cixtech.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [High] phy: cix: stale cur_mode and deferred reinit in
cix_usbdp_phy_power_on()
- [High] phy: cix: usbdp_typec_mux_set() drops UDPHY_MODE_DP in default
branch
--
commit 65650ff2bab980862db4f825d7173df1ccff3e28
Author: Gary Yang <gary.yang@cixtech.com>
phy: cix: add Sky1 USB/DP combo PHY driver
This commit adds a driver for the CIX Sky1 USB/DP combo PHY, exposing USB3
and DisplayPort PHYs and registering a Type-C orientation switch and mode
mux.
> diff --git a/drivers/phy/cix/phy-cix-usbdp.c b/drivers/phy/cix/phy-cix-usbdp.c
> new file mode 100644
> index 0000000000000..9a2c8b827ff8c
> --- /dev/null
> +++ b/drivers/phy/cix/phy-cix-usbdp.c
[ ... ]
> +static int usbdp_typec_mux_set(struct typec_mux_dev *mux,
> + struct typec_mux_state *state)
> +{
> + struct cix_udphy *udphy = typec_mux_get_drvdata(mux);
> + u8 mode;
> +
> + /* Ignore mux events not involving USB or DisplayPort */
> + if (!usbdp_typec_is_supported_mode(state)) {
> + dev_dbg(udphy->dev, "ignore mux event with mode=%lu\n",
> + state->mode);
> + return 0;
> + }
> +
> + switch (state->mode) {
> + case TYPEC_DP_STATE_C:
> + fallthrough;
> + case TYPEC_DP_STATE_E:
> + mode = UDPHY_MODE_DP;
> + break;
> + case TYPEC_DP_STATE_D:
> + fallthrough;
> + case TYPEC_DP_STATE_F:
> + mode = UDPHY_MODE_DP_USB;
> + break;
> + default:
> + /* usb only handle as usb+dp mode */
> + mode = UDPHY_MODE_USB;
> + break;
> + }
[Severity: High]
Should the default case set mode to UDPHY_MODE_DP_USB instead of
UDPHY_MODE_USB, matching the comment and udphy_set_default_mode()?
When dp_altmode_configure_vdm() places the mux in TYPEC_STATE_SAFE before
sending DP_CMD_CONFIGURE, setting udphy->next_mode to UDPHY_MODE_USB drops
UDPHY_MODE_DP. If HPD then triggers phy_power_on(udphy->dp_phy) before the
DisplayPort alt mode state notification arrives (as in
dp_altmode_configured()), udphy_dp_phy_power_on() sees
!(udphy->next_mode & UDPHY_MODE_DP) and returns 0 without powering on the
PHY or setting UDPHY_MODE_DP in udphy->cur_mode, causing
udphy_dp_phy_configure() to silently drop all subsequent link training
writes.
[ ... ]
> +static int cix_usbdp_phy_power_on(struct cix_udphy *udphy)
> +{
> + int ret;
> +
> + if (udphy->cur_mode == udphy->next_mode && !udphy->needs_reinit)
> + return 0;
> +
> + if (udphy->cur_mode == UDPHY_MODE_NONE)
> + ret = udphy->cfg->udphy_init(udphy);
> + else if (udphy->needs_reinit)
> + ret = udphy->cfg->udphy_reinit(udphy);
> + else
> + return 0;
> +
> + if (ret) {
> + dev_err(udphy->dev, "failed to bring up udphy\n");
> + return ret;
> + }
> +
> + udphy->needs_reinit = false;
> +
> + return 0;
> +}
> +
> +static int cix_usbdp_phy_power_off(struct cix_udphy *udphy)
> +{
> + int ret;
> +
> + ret = udphy->cfg->udphy_exit(udphy);
> + if (ret) {
> + dev_err(udphy->dev, "failed to exit udphy\n");
> + return ret;
> + }
> +
> + udphy->cur_mode = UDPHY_MODE_NONE;
> +
> + return 0;
> +}
> +
> +static int udphy_dp_phy_power_on(struct phy *phy)
> +{
> + struct cix_udphy *udphy = phy_get_drvdata(phy);
> + int ret;
> +
> + guard(mutex)(&udphy->mutex);
> +
> + if (!(udphy->next_mode & UDPHY_MODE_DP))
> + return 0;
> +
> + udphy->dp_lanes = udphy_dplane_get(udphy);
> +
> + ret = cix_usbdp_phy_power_on(udphy);
> + if (ret)
> + return ret;
> +
> + phy_set_bus_width(phy, udphy->dp_lanes);
> + udphy->cur_mode |= UDPHY_MODE_DP;
> +
> + return 0;
> +}
> +
> +static int udphy_dp_phy_power_off(struct phy *phy)
> +{
> + struct cix_udphy *udphy = phy_get_drvdata(phy);
> +
> + guard(mutex)(&udphy->mutex);
> +
> + if (!(udphy->cur_mode & UDPHY_MODE_DP))
> + return 0;
> +
> + udphy->cur_mode &= ~UDPHY_MODE_DP;
> + phy_set_bus_width(phy, 0);
> +
> + if (udphy->cur_mode == UDPHY_MODE_NONE)
> + return cix_usbdp_phy_power_off(udphy);
> +
> + return 0;
> +}
[ ... ]
> +static int cix_u3phy_init(struct phy *phy)
> +{
> + struct cix_udphy *udphy = phy_get_drvdata(phy);
> + int ret;
> +
> + guard(mutex)(&udphy->mutex);
> +
> + if (!(udphy->next_mode & UDPHY_MODE_USB))
> + return 0;
> +
> + ret = cix_usbdp_phy_power_on(udphy);
> + if (ret)
> + return ret;
> +
> + udphy->cur_mode |= UDPHY_MODE_USB;
> +
> + return 0;
> +}
[Severity: High]
Does transitioning into 4-lane DisplayPort mode (UDPHY_MODE_DP) while
u3_phy is already initialized leave UDPHY_MODE_USB stuck in
udphy->cur_mode?
When u3_phy is initialized at probe or on initial Type-C attach,
cix_u3phy_init() sets UDPHY_MODE_USB in udphy->cur_mode. Entering 4-lane
DP alt mode sets udphy->next_mode = UDPHY_MODE_DP and udphy->needs_reinit =
true without tearing down u3_phy (and even if cix_u3phy_set_mode() runs,
cix_u3phy_init() returns 0 early when !(udphy->next_mode & UDPHY_MODE_USB)
without clearing UDPHY_MODE_USB). udphy_dp_phy_power_on() then calls
sky1_udphy_reinit() to reprogram the whole PHY into 4-lane DP-only mode and
ORs UDPHY_MODE_DP into udphy->cur_mode. When udphy_dp_phy_power_off()
later clears UDPHY_MODE_DP, udphy->cur_mode is still UDPHY_MODE_USB rather
than UDPHY_MODE_NONE, so cix_usbdp_phy_power_off() is skipped and the PHY
and apb_clk stay enabled.
Also, because udphy_orien_sw_set() and usbdp_typec_mux_set() only set
udphy->needs_reinit = true and defer sky1_udphy_reinit() to the next
cix_usbdp_phy_power_on(), any orientation change or exit from 4-lane DP
back to USB while u3_phy is already active will never trigger
sky1_udphy_reinit(), leaving the hardware programmed with the stale
orientation or 4-lane DP-only register table.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261130062028.3366748-1-gary.yang@cixtech.com?part=2
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
prev parent reply other threads:[~2026-11-30 6:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-30 6:20 [PATCH v3 0/2] phy: cix: add Sky1 USB/DP combo PHY support Gary Yang
2026-11-30 6:20 ` [PATCH v3 1/2] dt-bindings: phy: add CIX Sky1 USB/DP combo PHY Gary Yang
2026-11-30 6:20 ` [PATCH v3 2/2] phy: cix: add Sky1 USB/DP combo PHY driver Gary Yang
2026-11-30 6:44 ` sashiko-bot [this message]
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=sashiko-outbox-240522@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=gary.yang@cixtech.com \
--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=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