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 v5 2/2] phy: cix: add Sky1 USB/DP combo PHY driver
Date: Tue, 01 Dec 2026 02:02:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-242354@kernel.org> (raw)
In-Reply-To: <20261201014059.3811728-3-gary.yang@cixtech.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] phy: cix: stale dp_lanes, bus_width, and cur_mode on deferred
DP reinit
- [Medium] phy: cix: udphy_dp_phy_power_on() drops DP power state in
USB-only mode
--
commit 4655d6dad04c97aef72f0068945521b5e297a7ae
Author: Gary Yang <gary.yang@cixtech.com>
phy: cix: add Sky1 USB/DP combo PHY driver
This commit adds a generic PHY driver for the CIX Sky1 USB3/DisplayPort
combo PHY, with Type-C orientation switch and mode mux integration.
> diff --git a/drivers/phy/cix/phy-cix-usbdp.c b/drivers/phy/cix/phy-cix-usbdp.c
> new file mode 100644
> index 0000000000000..046ded908adc4
> --- /dev/null
> +++ b/drivers/phy/cix/phy-cix-usbdp.c
> @@ -0,0 +1,1570 @@
[ ... ]
> +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;
> + int ret;
> +
> + /* 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;
> + }
> +
> + if (state->mode < TYPEC_STATE_MODAL) {
> + /*
> + * The DP altmode driver signals the safe and USB states
> + * around a mode switch. The USB and the USB+DP modes share
> + * one register table, so keep the DP lanes available for
> + * those notifications.
> + */
> + if (state->alt && state->alt->svid == USB_TYPEC_DP_SID)
> + mode = UDPHY_MODE_DP_USB;
> + else
> + mode = UDPHY_MODE_USB;
> + } else {
[ ... ]
> +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;
[Severity: Medium]
Can udphy_dp_phy_power_on() leave DisplayPort unpowered for the session if
it runs while udphy->next_mode is UDPHY_MODE_USB?
Port-level typec_set_mode() calls for TYPEC_STATE_SAFE or TYPEC_STATE_USB
pass state->alt == NULL, which sets udphy->next_mode to UDPHY_MODE_USB in
usbdp_typec_mux_set(). If the DP controller calls phy_power_on() before
the modal DP mux notification arrives, udphy_dp_phy_power_on() returns 0
without setting UDPHY_MODE_DP in udphy->cur_mode or recording that the DP
consumer requested power, while the PHY core increments dp_phy->power_count
to 1. When the mux later switches to UDPHY_MODE_DP or UDPHY_MODE_DP_USB,
UDPHY_MODE_DP is still never set in udphy->cur_mode, so every
udphy_dp_phy_configure() call sees !(udphy->cur_mode & UDPHY_MODE_DP) and
silently drops link training writes.
> + udphy->dp_lanes = udphy_dplane_get(udphy);
> +
> + ret = cix_usbdp_phy_power_on(udphy);
> + if (ret)
> + return ret;
> +
> + /*
> + * With 4-lane DisplayPort the DP PHY owns the PMA lanes, so the USB3
> + * function cannot be active anymore even if its consumer still holds
> + * phy_init(). Drop the USB bit here so that the combo PHY can really
> + * be powered off once the DP PHY releases the lanes.
> + */
> + if (udphy->next_mode == UDPHY_MODE_DP)
> + udphy->cur_mode &= ~UDPHY_MODE_USB;
> +
> + phy_set_bus_width(phy, udphy->dp_lanes);
> + udphy->cur_mode |= UDPHY_MODE_DP;
> +
> + /*
> + * In the USB+DP modes the USB3 controller keeps using its lanes, so
> + * keep the USB mode accounted for while its consumer is initialized.
> + */
> + if ((udphy->next_mode & UDPHY_MODE_USB) && udphy->u3_initialized)
> + udphy->cur_mode |= UDPHY_MODE_USB;
> +
> + return 0;
> +}
[ ... ]
> +static int udphy_dp_phy_configure(struct phy *phy,
> + union phy_configure_opts *opts)
> +{
[ ... ]
> + if (dp->set_rate && udphy->needs_reinit) {
> + ret = udphy->cfg->udphy_reinit(udphy);
> + if (ret) {
> + dev_err(udphy->dev, "failed to reconfigure udphy\n");
> + return ret;
> + }
> +
> + udphy->needs_reinit = false;
> +
> + if (udphy->next_mode == UDPHY_MODE_DP)
> + udphy->cur_mode &= ~UDPHY_MODE_USB;
> + }
> +
> + /* All of the options are valid, so they can be applied now. */
> + if (dp->set_lanes)
> + udphy->dp_lanes = dp->lanes;
> +
> + if (dp->set_rate) {
> + ret = udphy_dp_phy_set_rate(udphy, dp);
> + if (ret) {
> + dev_err(udphy->dev, "failed to set DP link rate\n");
> + return ret;
> + }
> + }
[Severity: Medium]
When a deferred udphy_reinit() runs here after a mux mode change, does it
leave udphy->dp_lanes, the PHY bus_width, and udphy->cur_mode out of sync
with udphy->next_mode?
Unlike udphy_dp_phy_power_on(), this path does not update udphy->dp_lanes
from udphy_dplane_get(udphy) when dp->set_lanes is not set in the same
call, nor does it call phy_set_bus_width(phy, udphy_dplane_get(udphy)).
If a DP controller configures link rate before lane count in separate
phy_configure() calls, udphy_dp_phy_set_rate() iterates over the previous
mode's udphy->dp_lanes, either leaving XCVR_DIAG_HSCLK_DIV unprogrammed on
lanes 2 and 3 after a 2-to-4 lane switch or overwriting the 2 active USB3
PMA lanes after a 4-to-2 lane switch.
In addition, this path does not check that udphy->next_mode still includes
UDPHY_MODE_DP, and does not restore UDPHY_MODE_USB in udphy->cur_mode when
switching from UDPHY_MODE_DP back to UDPHY_MODE_DP_USB while
udphy->u3_initialized is true.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201014059.3811728-2-gary.yang@cixtech.com?part=2
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
WARNING: multiple messages have this Message-ID (diff)
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 v5 2/2] phy: cix: add Sky1 USB/DP combo PHY driver
Date: Tue, 01 Dec 2026 02:02:21 +0000 [thread overview]
Message-ID: <sashiko-outbox-242354@kernel.org> (raw)
In-Reply-To: <20261201014059.3811728-3-gary.yang@cixtech.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] phy: cix: stale dp_lanes, bus_width, and cur_mode on deferred
DP reinit
- [Medium] phy: cix: udphy_dp_phy_power_on() drops DP power state in
USB-only mode
--
commit 4655d6dad04c97aef72f0068945521b5e297a7ae
Author: Gary Yang <gary.yang@cixtech.com>
phy: cix: add Sky1 USB/DP combo PHY driver
This commit adds a generic PHY driver for the CIX Sky1 USB3/DisplayPort
combo PHY, with Type-C orientation switch and mode mux integration.
> diff --git a/drivers/phy/cix/phy-cix-usbdp.c b/drivers/phy/cix/phy-cix-usbdp.c
> new file mode 100644
> index 0000000000000..046ded908adc4
> --- /dev/null
> +++ b/drivers/phy/cix/phy-cix-usbdp.c
> @@ -0,0 +1,1570 @@
[ ... ]
> +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;
> + int ret;
> +
> + /* 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;
> + }
> +
> + if (state->mode < TYPEC_STATE_MODAL) {
> + /*
> + * The DP altmode driver signals the safe and USB states
> + * around a mode switch. The USB and the USB+DP modes share
> + * one register table, so keep the DP lanes available for
> + * those notifications.
> + */
> + if (state->alt && state->alt->svid == USB_TYPEC_DP_SID)
> + mode = UDPHY_MODE_DP_USB;
> + else
> + mode = UDPHY_MODE_USB;
> + } else {
[ ... ]
> +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;
[Severity: Medium]
Can udphy_dp_phy_power_on() leave DisplayPort unpowered for the session if
it runs while udphy->next_mode is UDPHY_MODE_USB?
Port-level typec_set_mode() calls for TYPEC_STATE_SAFE or TYPEC_STATE_USB
pass state->alt == NULL, which sets udphy->next_mode to UDPHY_MODE_USB in
usbdp_typec_mux_set(). If the DP controller calls phy_power_on() before
the modal DP mux notification arrives, udphy_dp_phy_power_on() returns 0
without setting UDPHY_MODE_DP in udphy->cur_mode or recording that the DP
consumer requested power, while the PHY core increments dp_phy->power_count
to 1. When the mux later switches to UDPHY_MODE_DP or UDPHY_MODE_DP_USB,
UDPHY_MODE_DP is still never set in udphy->cur_mode, so every
udphy_dp_phy_configure() call sees !(udphy->cur_mode & UDPHY_MODE_DP) and
silently drops link training writes.
> + udphy->dp_lanes = udphy_dplane_get(udphy);
> +
> + ret = cix_usbdp_phy_power_on(udphy);
> + if (ret)
> + return ret;
> +
> + /*
> + * With 4-lane DisplayPort the DP PHY owns the PMA lanes, so the USB3
> + * function cannot be active anymore even if its consumer still holds
> + * phy_init(). Drop the USB bit here so that the combo PHY can really
> + * be powered off once the DP PHY releases the lanes.
> + */
> + if (udphy->next_mode == UDPHY_MODE_DP)
> + udphy->cur_mode &= ~UDPHY_MODE_USB;
> +
> + phy_set_bus_width(phy, udphy->dp_lanes);
> + udphy->cur_mode |= UDPHY_MODE_DP;
> +
> + /*
> + * In the USB+DP modes the USB3 controller keeps using its lanes, so
> + * keep the USB mode accounted for while its consumer is initialized.
> + */
> + if ((udphy->next_mode & UDPHY_MODE_USB) && udphy->u3_initialized)
> + udphy->cur_mode |= UDPHY_MODE_USB;
> +
> + return 0;
> +}
[ ... ]
> +static int udphy_dp_phy_configure(struct phy *phy,
> + union phy_configure_opts *opts)
> +{
[ ... ]
> + if (dp->set_rate && udphy->needs_reinit) {
> + ret = udphy->cfg->udphy_reinit(udphy);
> + if (ret) {
> + dev_err(udphy->dev, "failed to reconfigure udphy\n");
> + return ret;
> + }
> +
> + udphy->needs_reinit = false;
> +
> + if (udphy->next_mode == UDPHY_MODE_DP)
> + udphy->cur_mode &= ~UDPHY_MODE_USB;
> + }
> +
> + /* All of the options are valid, so they can be applied now. */
> + if (dp->set_lanes)
> + udphy->dp_lanes = dp->lanes;
> +
> + if (dp->set_rate) {
> + ret = udphy_dp_phy_set_rate(udphy, dp);
> + if (ret) {
> + dev_err(udphy->dev, "failed to set DP link rate\n");
> + return ret;
> + }
> + }
[Severity: Medium]
When a deferred udphy_reinit() runs here after a mux mode change, does it
leave udphy->dp_lanes, the PHY bus_width, and udphy->cur_mode out of sync
with udphy->next_mode?
Unlike udphy_dp_phy_power_on(), this path does not update udphy->dp_lanes
from udphy_dplane_get(udphy) when dp->set_lanes is not set in the same
call, nor does it call phy_set_bus_width(phy, udphy_dplane_get(udphy)).
If a DP controller configures link rate before lane count in separate
phy_configure() calls, udphy_dp_phy_set_rate() iterates over the previous
mode's udphy->dp_lanes, either leaving XCVR_DIAG_HSCLK_DIV unprogrammed on
lanes 2 and 3 after a 2-to-4 lane switch or overwriting the 2 active USB3
PMA lanes after a 4-to-2 lane switch.
In addition, this path does not check that udphy->next_mode still includes
UDPHY_MODE_DP, and does not restore UDPHY_MODE_USB in udphy->cur_mode when
switching from UDPHY_MODE_DP back to UDPHY_MODE_DP_USB while
udphy->u3_initialized is true.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261201014059.3811728-2-gary.yang@cixtech.com?part=2
next prev parent reply other threads:[~2026-12-01 2:02 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-01 1:40 [PATCH v5 0/2] phy: cix: add Sky1 USB/DP combo PHY support Gary Yang
2026-12-01 1:40 ` Gary Yang
2026-12-01 1:40 ` [PATCH v5 1/2] dt-bindings: phy: add CIX Sky1 USB/DP combo PHY Gary Yang
2026-12-01 1:40 ` Gary Yang
2026-12-01 1:40 ` [PATCH v5 2/2] phy: cix: add Sky1 USB/DP combo PHY driver Gary Yang
2026-12-01 1:40 ` Gary Yang
2026-12-01 2:02 ` sashiko-bot [this message]
2026-12-01 2:02 ` sashiko-bot
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-242354@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 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.