From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 941F2606A322 for ; Wed, 2 Dec 2026 15:32:04 +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=bavdxuts Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0CFF510E57E; Wed, 2 Dec 2026 15:31:59 +0000 (UTC) Received: from sea.source.kernel.org (sea.source.kernel.org [172.234.252.31]) by gabe.freedesktop.org (Postfix) with ESMTPS id A439710E57E for ; Wed, 2 Dec 2026 15:31:52 +0000 (UTC) Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) by sea.source.kernel.org (Postfix) with ESMTP id 5896044157; Wed, 2 Dec 2026 15:31:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C4C2E1F0089F; Wed, 2 Dec 2026 15:31:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796225512; bh=VRiQZsCjuq5kLfp5Mf8CiWOSckjURqis8OsUlKhOXMI=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=bavdxutsaDtXWnWzbEzBk6ZNT1LHB6jaG6zN27n5cpneW8o/a5y84Yvxt+9jt/W2X ZVPF89goFNpEUBtI4JFIgSAFMmA2AE9fcYUCauQSKwEYnUG/KwivdihvLRMcft6BLq +Rc5W5otbmypjMQEVORIlWhDVK+hi99zpA29MuL2vbs5BKIZbBzAbSG8trujSR0VwY ZK86R8NhnQY+BoSM91lPG2rLJNjcA3PfapaeavtCenLS4kqwYGQkfr13mHlaOgSFRc 76QRnkPvPAZ5tRW84t0vhZazxXAUrkyCBMHpg3oS5CyoQCdadTyn0J/oGO0wmXnreL KtVps28frncOg== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 18/22] phy: cadence-torrent: allow config on an already-configured DP link To: "Benjamin Robin" Cc: devicetree@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-phy@lists.infradead.org, robh@kernel.org, conor+dt@kernel.org, vkoul@kernel.org, neil.armstrong@linaro.org, olteanv@gmail.com In-Reply-To: <20261202-phy-cadence-torrent-ng-v2-18-0b493387347b@bootlin.com> References: <20261202-phy-cadence-torrent-ng-v2-0-0b493387347b@bootlin.com> <20261202-phy-cadence-torrent-ng-v2-18-0b493387347b@bootlin.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 15:31:51 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sashiko-reviews@lists.linux.dev Sender: "dri-devel" X-Spam-Status: No, score=-10.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 X-Archived-By: Thank you for your contribution! Sashiko AI review found 3 potential issues to consider: - [High] phy: cadence-torrent: NULL pointer dereference in tp_dp_find_used_lanes() - [High] phy: cadence-torrent: uninitialized dp_pll and ref_clk in tp_phy_configure() - [Medium] phy: cadence-torrent: link->num_lanes set to 0 in tp_dp_find_used_lanes() -- commit 26b8eac666ec602cc77dee851e18adb2e17e76e7 Author: Benjamin Robin phy: cadence-torrent: allow config on an already-configured DP link This commit removes the early return for already-configured PHYs in tp_phy_configure() and reads the active DisplayPort lane count from the PHY_RESET register during probe when the PHY is already configured. > diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cade= nce/phy-cadence-torrent.c > index 3b4d52ee7a531..0cbbedeefd87a 100644 > --- a/drivers/phy/cadence/phy-cadence-torrent.c > +++ b/drivers/phy/cadence/phy-cadence-torrent.c > @@ -1310,6 +1310,27 @@ static int tp_dp_verify_config(const struct tp_lin= k *link, > return 0; > } > =20 > +static void tp_dp_find_used_lanes(const struct tp_data *tp_data, struct = tp_link *link) > +{ > + u32 mlane =3D link->mlane; > + u32 used_lanes_mask; > + u32 all_lane_mask; > + u32 value; > + > + all_lane_mask =3D ((1U << link->max_lanes) - 1) << mlane; > + value =3D tp_reg_dptx_read(tp_data, PHY_RESET); > + > + /* only keep the lanes not in reset */ > + used_lanes_mask =3D value & all_lane_mask; > + > + /* only keep the lanes with Tx differential output not into electrical = idle */ > + used_lanes_mask &=3D (~(value >> PMA_TX_ELEC_IDLE_SHIFT)) & all_lane_ma= sk; > + > + /* update the number of used lanes */ > + used_lanes_mask >>=3D mlane; > + link->num_lanes =3D __ffs(~used_lanes_mask); > +} [Severity: Medium] Can tp_dp_find_used_lanes() overwrite link->num_lanes with 0 when all DisplayPort lanes are held in reset or electrical idle at probe time? In a multi-link setup where the bootloader only configured the non-DP link, tp_is_already_configured() still returns true because the shared PHY_PMA_CMN_CTRL1 bit 0 is set, while the DP lanes in PHY_RESET have used_lanes_mask =3D=3D 0 and __ffs(~used_lanes_mask) =3D=3D 0. If the syst= em suspends and resumes before DP link training updates link->num_lanes, tp_resume_noirq() -> tp_configure_links() loops over 0 .. link->num_lanes -= 1 and skips programming the per-lane PMA TX/RX CDB registers for the DP link. > @@ -1433,9 +1454,6 @@ static int tp_phy_configure(struct phy *phy, union = phy_configure_opts *opts) > =20 > guard(mutex)(&tp_data->lock); > =20 > - if (tp_data->already_configured) > - return 0; > - > if (link->phy_type !=3D TYPE_DP) > return -EINVAL; [Severity: High] Will tp_phy_configure() fail with -ETIMEDOUT when opts->dp.set_rate is set on an already-configured PHY because tp_data->dp_pll and tp_data->ref_clk_rate were never initialized? When tp_data->already_configured is true, cdns_torrent_phy_probe() skips both tp_ref_clks_init() and tp_configure_links() (which calls cdns_torrent_dp_get_pll()), leaving tp_data->dp_pll and tp_data->ref_clk_rate at 0. When tp_phy_configure() calls tp_dp_set_rate() -> tp_dp_configure_rate(), pll_mask is 0 after the lanes have already been put into POWERSTATE_A3: drivers/phy/cadence/phy-cadence-torrent.c:tp_dp_configure_rate() { ... pll_mask =3D tp_data->dp_pll; ... tp_reg_clear_bits(reg_base, PHY_PMA_PLL_RAW_CTRL, pll_mask); ... ret =3D read_poll_timeout(tp_reg_read, val, (val & (pll_mask << 2)) !=3D 0= , 0, POLL_TIMEOUT_US, false, reg_base, PHY_PMA_CMN_CTRL2); ... } Because (val & (pll_mask << 2)) !=3D 0 is always false, tp_dp_configure_rat= e() times out and leaves the DisplayPort lanes powered down. Later in the series, commit "phy: cadence-torrent: rewrite Torrent PHY driver" replaces dp_pll with 1U << link->std_idx, but tp_ref_clks_init() and tp_init_plls_data() are still skipped when tp_data->already_configured is true, leaving pll->ref_clk_khz at 0 in tp_write_pll_regs(). [ ... ] > @@ -2750,6 +2778,8 @@ static int cdns_torrent_phy_probe(struct platform_d= evice *pdev) > ret =3D tp_ref_clks_init(tp_data); > if (ret) > goto cleanup; > + } else { > + tp_init_already_configured_links_opts(tp_data); > } > =20 > ret =3D tp_dp_reg_base_init(pdev, tp_data); [Severity: High] Does calling tp_init_already_configured_links_opts() before tp_dp_reg_base_init() cause a NULL pointer dereference on tp_data->base? When tp_data->already_configured is true and a TYPE_DP link is present, tp_init_already_configured_links_opts() -> tp_dp_find_used_lanes() -> tp_reg_dptx_read() reads from tp_data->base + PHY_RESET, but tp_data->base is only ioremapped in tp_dp_reg_base_init() immediately afterwards. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202-phy-cadenc= e-torrent-ng-v2-0-0b493387347b@bootlin.com?part=3D18