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=1796296347; b=fV1Eipr0fyJuFbPLS4J/VzHse5rML4aBPGBbCxP83QeqmrzywgoeovU0ljOQfzRT6BIc GVsikOdgtfmfF0agLvxaRcW61HxTX6KOiKaOmgS757cHZIZGkXxhhZoJ9XgQwo3XPcTlz lC/8SXTYfMFLFl4MWG1EBbCsMkDfPegSoG6TifKMyIaIAMNFEfd20bzAdSDsSUU4SIcA0 U1yMImMmzCdGksLF6I+pjIWMb4ANzMZns0XgkKEIatfSVjdtKuFHqeCL748hrucFjS3of OJAkO1+hIJ0XfPYNnDU97yjbEs/IqVPWxWYoPeKJo4HcIKVBfLr5IU6KRyzI6BVMX9g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796296347; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=7s6fectsMyw3RtoD0Q098QwqOFLcfbY8b4UkoIosGMk=; b=CFu5RfUt2UEUrgC615KBJRXmzMZ+s7Luuy9RkmW/6MhgX08Lh7ek8DAQTWF+R6gB3YBA HsM19WFMXwQgwLGUuSl0TmFasLg6+rmfPVmZ13EjdP1Ejk3W0+ZU7YGlfQdradFQ7iC99 Qv43NE2FZiL+q6JnxUjwZ6/dmdjtN3bgroMORkdFnUt2CKsttuxgn0eGeYE68SRLP34U2 CSIflYAwolhaDgYww9/rsvFlDprZYACgIke7fDuaTydFFZfc2juhriMW7HfrYfbBe0MCn YXmSWZo3Teyu9xYTvJojKxwQaKwAnbpdJGe0WAAUllQ6HSC3dzoan8Sit5WngCBLTTw== 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=IdDz5bL4; 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 E2F14606A322 for ; Thu, 3 Dec 2026 11:12:26 +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=IdDz5bL4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6F0F11F000C1; Thu, 3 Dec 2026 11:12:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796296346; bh=7s6fectsMyw3RtoD0Q098QwqOFLcfbY8b4UkoIosGMk=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=IdDz5bL4fAJPzncev/ta7qlf02qvkw2rWjUhC6lmB4itfUCLe3ZFkVYzydMEgmPoJ AxE1MXFSWDxJerX7hA98tdV8PBEWfig+4oIcLXRMOsC6uMkON+pgNvwVVJKBghE1Wx SRNuJR1/NNBvmxjaQ+G2WUfMa2blSR6Hf9v6UP7qvMnoWkTJdtdhEMPAEc/ucUb5Bj 8bRWqZr627BUMzzDH+PLp2kFDpeQOvV73gcFZy7uWCWKZj0qjEpvFA+FiJQcV6hu9P Z05rYb4zpjxNJd0T9nKjVAbBNlWjX0ydKTFrLgilqqOdW1gVRoKfAL0Nd5bOvVSQRE rqYtQoXCf6rzA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v8 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: <20261203104915.231202-3-gary.yang@cixtech.com> References: <20261203104915.231202-1-gary.yang@cixtech.com> <20261203104915.231202-3-gary.yang@cixtech.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Thu, 03 Dec 2026 11:12:26 +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: udphy_dp_phy_set_rate() ignores dp->ssc leaving SSC always enabled - [Medium] phy: cix: premature PHY provider registration in cix_udphy_probe() - [Medium] phy: cix: udphy_dp_phy_set_rate() under-waits PLL1 lock and PMA ready -- commit 29c5fede3844afcbadc8c1146b5c8f3d0bf0f9e2 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 separate 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..6d655cc0ac076 > --- /dev/null > +++ b/drivers/phy/cix/phy-cix-usbdp.c [ ... ] > +static int udphy_dp_phy_set_rate(struct cix_udphy *udphy, > + struct phy_configure_opts_dp *dp) > +{ [ ... ] > + udphy_update_bits(udphy, PHY_PMA_PLL_CTRL, BIT(1), 0x0); > + usleep_range(10, 20); > + > + udphy_write_table(udphy, conf->seq, conf->num_seq); > + > + /* > + * Program the divider of every lane assigned to DisplayPort, not just > + * the lanes of the previous configuration: the caller may raise the > + * lane count in a separate phy_configure() call, without repeating the > + * rate update. > + */ > + for (i =3D 0; i < udphy_dplane_get(udphy); 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); > + } > + > + writel(conf->pll_intdiv, udphy->base + CMN_PLL1_INTDIV_M0 * 4); > + writel(conf->pll_fracdivl, udphy->base + CMN_PLL1_FRACDIVL_M0 * 4); > + writel(conf->pll_high_thr, udphy->base + CMN_PLL1_HIGH_THR_M0 * 4); > + writel(conf->clk_sel, udphy->base + CMN_PDIAG_PLL1_CLK_SEL_M0 * 4); [Severity: Medium] Should udphy_dp_phy_set_rate() also program CMN_PLL1_SS_CTRL1_M0 according to dp->ssc? All three mode tables unconditionally write 0x0001 to CMN_PLL1_SS_CTRL1_M0, so SSC stays enabled on PLL1 even when a DisplayPort sink does not support downspread (dp->ssc =3D=3D 0). struct phy_configure_opts_dp expects set_rate to apply both link_rate and ssc, and driving SSC on a non-SSC sink can break link training. The sibling driver in drivers/phy/cix/phy-cix-dp.c toggles the same offset (0x00d8) between 0x0001 and 0x0000 in cix_dp_phy_set_ssc(). > + > + udphy_update_bits(udphy, PHY_PMA_PLL_CTRL, BIT(1), BIT(1)); > + usleep_range(10, 20); > + > + return 0; > +} [Severity: Medium] Is usleep_range(10, 20) long enough here, instead of polling the PMA status registers for PLL1 disable and lock? At the 24 MHz reference clock implied by link_cfg[], the PLL1 startup, VCO calibration, and lock timers programmed in the mode tables sum to at least 61 us for a single calibration iteration. Reprogramming PLL1 before it disables or returning before it locks can break DP link training. Similarly, after a deferred sky1_udphy_reinit() in udphy_dp_phy_configure(), udphy_dp_phy_set_rate() runs right after deasserting udphy->reset without waiting for PMA common readiness. Both drivers/phy/cix/phy-cix-dp.c (cix_dp_pll_raw_ctrl_ack()) and drivers/phy/cadence/phy-cadence-torrent.c poll PHY_PMA_CMN_CTRL2 (0xe001) for PLL disable/ready and wait for PMA common readiness after reset. [ ... ] > + phy_provider =3D devm_of_phy_provider_register(dev, cix_udphy_phy_xlate= ); > + if (IS_ERR(phy_provider)) > + return dev_err_probe(dev, PTR_ERR(phy_provider), > + "failed to register PHY provider\n"); > + > + /* > + * Register with the Type-C class only once the PHYs and the provider > + * are in place, so that the switch and mux callbacks cannot run before > + * the driver is fully set up. > + */ > + if (device_property_present(dev, "orientation-switch")) { > + ret =3D udphy_setup_orien_switch(udphy); > + if (ret) > + return ret; > + > + ret =3D devm_add_action_or_reset(dev, > + udphy_orien_switch_unregister, > + udphy); > + if (ret) > + return ret; > + } > + > + if (device_property_present(dev, "mode-switch")) { > + ret =3D udphy_setup_typec_mux(udphy); > + if (ret) > + return ret; > + > + ret =3D devm_add_action_or_reset(dev, udphy_typec_mux_unregister, > + udphy); > + if (ret) > + return ret; > + } [Severity: Medium] Can registering the PHY provider before the Type-C orientation switch and mux cause a use-after-free if one of those registrations fails? Because the OF graph ports between this PHY and its USB3/DP consumers form a cycle with the phys links, fw_devlink relaxes them and a consumer can probe as soon as devm_of_phy_provider_register() publishes the provider: CPU0 CPU1 cix_udphy_probe() devm_of_phy_provider_register() consumer probe phy_get() -> u3_phy phy_init(u3_phy) udphy_setup_typec_mux() fails devres_release_all() phy_destroy(u3_phy) devm_kfree(udphy) phy_exit(u3_phy) cix_u3phy_exit() &udphy->mutex <-- use-after-free phy_destroy() calls device_unregister() without revoking active consumer references, so devres frees struct cix_udphy (and puts apb_clk while still enabled) while the consumer still holds u3_phy. Moving devm_of_phy_provider_register() to the end of cix_udphy_probe(), after the Type-C switch and mux registrations, closes this window since their callbacks only need u3_phy and dp_phy from devm_phy_create(). --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261203104915.2312= 02-1-gary.yang@cixtech.com?part=3D2