From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796103295; b=M/m7kaWz8GMFRvLbDOsIwsVlA1K9R/eXJS7yPCscDBuGuGTCeqPyHNv/xSyGqnWulSxG Q47n8qCOjINOoVLLhHKFaxeE4Og20wNCj3RUtLkzJK3lmgc6WYRwtCOb7Izf3xjBmSHj1 pgORedbWelTHOe2fTT8mgjtV8aR0zjAiNZXfUqb3fX787MqihA4xweH4biK7cdzuvSbVO BT8C+iekUjZW+9IMIji0A8tzkdYX+hbTDzcAdaCv8oOq7lEMyfOawwex3QGn/Jjz/3mBe SLdBS7N77CMRPaDiWyMqD4t0t+HiJyQDLaqqsT9p/+2JYhT0skip9NiRlO2ARdxyGHQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796103295; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=kbRtcZsJpMCQ7Czs8oPTTyhdBF9YK8afZZ0YHmEuWnA=; b=weSvhD+fg7p3Ks3pt7B860ihm0tYnB/Vi5x9ABYXrBWG051vN2quCwYj8swWRrVAaAWC /EE1glyIV7BP9W0gVxxwA85/7AaUFq5Pmo0BxmPDoON3PFGH5D7p7G6SbeDGGFsOc4hyO uyNKz4mXGDtcV4B+/gEkKC5ce6WM1hXTM9fjf+RkbhTfjLfwXyh5NATeIVLX6gGayzn16 f2GpPAN238tlTPdEdbMerPzPVRFZNj3lR2cJfIGQjmMUAEjlmJYYAMjb+FdgAAmuf4mg3 8eIGAE1xySQdAIEGKnb+wA0JwTRE8XiIdLUqSCSrxjtMVq9QF2VudImgMtq9thnEoDg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OZk7GhUn; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CE3C5606A31A for ; Tue, 1 Dec 2026 05:34:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=OZk7GhUn Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4664D1F000C1; Tue, 1 Dec 2026 05:34:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796103295; bh=kbRtcZsJpMCQ7Czs8oPTTyhdBF9YK8afZZ0YHmEuWnA=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=OZk7GhUnJLAyxG2toxcEQhLXID2CtYqKmeBS1CxYzCDVWM5HIyn3fhqFGDUT8r51o 1TcxVro4gYzYkZb3Ngat2SXer807ysJEPYC82WZWQ9wUenLfzcMxNrllYkMt/A9R+v bnDEJQUikmkMEawFmXaMi913Tw019io/lQMHar21PgdkfV3CspX15vVLNAjUaqWtde CruB4ueVCz+AkDHBuOLCwcoRW8Jf4uXB+WWHoNP9S1HZJDMl6P/bk5ddFVct/+Doan tfdVL6971wJgurw9WG551Q+2MpD+T+g11hQ0B5796fI55CSbkCLIQGGr7glhU2G+Z6 Jh0t9Z0V4IjAg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v6 2/2] phy: cix: add Sky1 USB/DP combo PHY driver Reply-To: sashiko-reviews@lists.linux.dev To: "Gary Yang" 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 In-Reply-To: <20261201051629.3862739-3-gary.yang@cixtech.com> References: <20261201051629.3862739-1-gary.yang@cixtech.com> <20261201051629.3862739-3-gary.yang@cixtech.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Tue, 01 Dec 2026 05:34:53 +0000 X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [Medium] phy: cix-usbdp: stale DP bus_width in usbdp_typec_mux_set() when DP is powered - [Medium] phy: cix-usbdp: deferred reinit in udphy_dp_phy_configure() corrupts lanes - [Medium] phy: cix-usbdp: udphy_dp_phy_set_rate() skips HSCLK_DIV when lanes increase -- commit aaf1ea0adb7ea7807dcca74ff32ca474d68f46cb Author: Gary Yang 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-us= bdp.c > new file mode 100644 > index 0000000000000..ddca327694cf5 > --- /dev/null > +++ b/drivers/phy/cix/phy-cix-usbdp.c > @@ -1,1665 +1,1665 @@ [ ... ] > +static int udphy_orien_sw_set(struct typec_switch_dev *sw, > + enum typec_orientation orien) > +{ > + struct cix_udphy *udphy =3D typec_switch_get_drvdata(sw); > + bool flip; > + > + guard(mutex)(&udphy->mutex); > + > + if (orien =3D=3D TYPEC_ORIENTATION_NONE) > + return 0; > + > + flip =3D (orien =3D=3D TYPEC_ORIENTATION_REVERSE); > + if (udphy->flip !=3D flip) { > + dev_dbg(udphy->dev, "plug orientation changed, re-init required\n"); > + udphy->needs_reinit =3D true; > + } > + > + udphy->flip =3D flip; > + > + return udphy_sync_mode(udphy); > +} [ ... ] > +static int usbdp_typec_mux_set(struct typec_mux_dev *mux, > + struct typec_mux_state *state) > +{ > + struct cix_udphy *udphy =3D 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=3D%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 =3D=3D USB_TYPEC_DP_SID) > + mode =3D UDPHY_MODE_DP_USB; > + else > + mode =3D UDPHY_MODE_USB; > + } else { > + switch (state->mode) { > + case TYPEC_DP_STATE_A: > + case TYPEC_DP_STATE_C: > + case TYPEC_DP_STATE_E: > + mode =3D UDPHY_MODE_DP; > + break; > + case TYPEC_DP_STATE_B: > + case TYPEC_DP_STATE_D: > + case TYPEC_DP_STATE_F: > + mode =3D UDPHY_MODE_DP_USB; > + break; > + default: > + return 0; > + } > + } > + > + guard(mutex)(&udphy->mutex); > + > + if (udphy->next_mode !=3D mode) { > + dev_dbg(udphy->dev, "new mode: %u\n", mode); > + > + /* > + * The USB and the USB+DP modes share one register table, only > + * the DP-only mode needs a different one. > + */ > + if (mode =3D=3D UDPHY_MODE_DP || udphy->next_mode =3D=3D UDPHY_MODE_DP) > + udphy->needs_reinit =3D true; > + } > + > + udphy->next_mode =3D mode; > + > + /* > + * The DP controller may have powered the PHY on before the mux > + * notification selecting the DisplayPort mode arrived. Complete that > + * power-on now that the lanes are available. The PHY core already > + * holds the power reference, so keep dp_powered set when this fails > + * and retry on the next notification. > + */ > + if (udphy->dp_powered && (udphy->next_mode & UDPHY_MODE_DP) && > + !(udphy->cur_mode & UDPHY_MODE_DP)) { > + ret =3D udphy_dp_phy_power_on_locked(udphy); > + if (ret) > + return ret; > + } [Severity: Medium] Should usbdp_typec_mux_set() also update phy_set_bus_width(udphy->dp_phy, udphy_dplane_get(udphy)) when UDPHY_MODE_DP is already set in udphy->cur_mode? When the mux switches between 2-lane (UDPHY_MODE_DP_USB) and 4-lane (UDPHY_MODE_DP) DisplayPort modes while the DP PHY is already powered on, udphy->dp_phy->attrs.bus_width stays at the old lane count until udphy_dp_phy_configure() runs with set_rate set. DisplayPort controllers query phy_get_bus_width() before calling phy_configure() to determine the maximum lane count. On a 2-lane (or TYPEC_STATE_SAFE) to 4-lane switch, the controller reads a bus_width of 2 and caps link training to 2 lanes; on a 4-lane to 2-lane switch, it passes dp->lanes =3D 4 to phy_configure(), which udphy_dp_phy_verify_lanes() rejects with -EINVAL before the deferred reinit in udphy_dp_phy_configure() is reached. [ ... ] > +static int udphy_dp_phy_set_rate(struct cix_udphy *udphy, > + struct phy_configure_opts_dp *dp) > +{ > + const struct phy_link_cfg *conf; > + u32 i; > + > + switch (dp->link_rate) { > + case 1620: > + conf =3D &link_cfg[0]; > + break; > + case 2700: > + conf =3D &link_cfg[1]; > + break; > + case 5400: > + conf =3D &link_cfg[2]; > + break; > + case 8100: > + conf =3D &link_cfg[3]; > + break; > + default: > + return -EINVAL; > + } > + > + dev_dbg(udphy->dev, "lane %u, rate %u\n", udphy->dp_lanes, > + dp->link_rate); > + > + udphy_update_bits(udphy, PHY_PMA_PLL_CTRL, BIT(1), 0x0); > + usleep_range(10, 20); > + > + udphy_write_table(udphy, conf->seq, conf->num_seq); > + > + for (i =3D 0; i < udphy->dp_lanes; i++) { > + u32 lane =3D udphy_dp_lane_to_pma(udphy, i); > + u32 reg =3D XCVR_DIAG_HSCLK_DIV_LANE0 + lane * PHY_LANE_STRIDE; > + > + writel(conf->hsclk_div, udphy->base + reg * 4); > + } [Severity: Medium] Can this loop leave XCVR_DIAG_HSCLK_DIV unprogrammed on newly enabled lanes if a consumer configures the link rate and lane count in separate phy_configure() calls? If an earlier link training run reduced udphy->dp_lanes (for example to 1 or 2 lanes) and a later run calls phy_configure() with set_rate first and a second phy_configure() with set_lanes to increase the lane count, udphy_dp_phy_set_rate() only updates XCVR_DIAG_HSCLK_DIV for the old udphy->dp_lanes count, and the set_lanes call only updates udphy->dp_lanes in software. Programming XCVR_DIAG_HSCLK_DIV across udphy_dplane_get(udphy) lanes would keep all DP-assigned lanes at the new rate's divider. [ ... ] > +static int udphy_dp_phy_configure(struct phy *phy, > + union phy_configure_opts *opts) > +{ > + struct cix_udphy *udphy =3D phy_get_drvdata(phy); > + struct phy_configure_opts_dp *dp =3D &opts->dp; > + int ret; [ ... ] > + if (dp->set_rate && udphy->needs_reinit) { > + ret =3D udphy->cfg->udphy_reinit(udphy); > + if (ret) { > + dev_err(udphy->dev, "failed to reconfigure udphy\n"); > + return ret; > + } > + > + udphy->needs_reinit =3D false; > + > + /* > + * The mux may have taken lanes away from or given lanes back > + * to USB3. The DP controller does not necessarily report the > + * new lane count on the rate-setting call, so derive it from > + * the mode, and keep the bus width and the USB3 mode bit in > + * sync as udphy_dp_phy_power_on() does. > + */ > + if (!dp->set_lanes) > + udphy->dp_lanes =3D udphy_dplane_get(udphy); > + > + phy_set_bus_width(phy, udphy_dplane_get(udphy)); > + > + if (udphy->next_mode =3D=3D UDPHY_MODE_DP) > + udphy->cur_mode &=3D ~UDPHY_MODE_USB; > + else if (udphy->u3_initialized) > + udphy->cur_mode |=3D UDPHY_MODE_USB; > + } > + > + /* All of the options are valid, so they can be applied now. */ > + if (dp->set_lanes) > + udphy->dp_lanes =3D dp->lanes; [Severity: Medium] Can deferring udphy_reinit() until dp->set_rate cause udphy_dp_phy_set_voltages() to program the USB3 PMA lanes when udphy->flip changes? udphy_orien_sw_set() updates udphy->flip immediately while setting udphy->needs_reinit =3D true if DisplayPort is active. If a consumer calls phy_configure() with set_voltages =3D true and set_rate =3D false while needs_reinit is pending, udphy_reinit() is skipped so the hardware keeps the old orientation, but udphy_dp_phy_set_voltages() maps lanes with udphy_dp_lane_to_pma() using the new udphy->flip and writes DP TX swing registers onto the PMA lanes routed to USB3. In addition, if a consumer configures a reduced lane count (such as 1 or 2 lanes) in a separate phy_configure() call with set_lanes =3D true before calling phy_configure() with set_rate =3D true while needs_reinit is set, the !dp->set_lanes assignment overwrites the configured udphy->dp_lanes with udphy_dplane_get(udphy). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261201051629.3862= 739-1-gary.yang@cixtech.com?part=3D2