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=1796225091; b=SqfUL27o/g1ml6+3TjpBJJeeaXGw23xkpKR65r+0P+VMV5fxY+SD8nWhodSxaXGnSxpB tHAA5cG89mlkU/vtIsgY6QluLsh1hmrYprfEz7nOn3cePZL8vYg8YlRvz1YxhkTbWmZXA 8ZQUXRyAc/6Wk3rvrtbgDBTEK5nEqiwFePftZ0xrgI833Dn6PCQIEtQBdMfEZhiPTrgPi cQd143kfrQmSqjuOzqnceOpQCmdNWjI9xkT86AEKIlsYqYYp70fg9vMDtMgBOb9KFxCKd hENCgCR6fZHPhfbqB4cD8IEnBRykeuqy5s4fMwIBwpmJsDOmP0YKckRfAQORyjW3f6A== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796225091; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=MtLusZq4SQHOp+iN0ZO4L8VdzqA+7PH7/uk59T7prU0=; b=gHs1s2rsQseDakQg5NLn/BKp/eqKkzq8hcwGfHSejlJ72H/p/h6BsMLRdzDPmgxVJ1d/ xCkTyoroa16AWbwoUiXPyYS9UmgCPpO+fPazFPgFabLyv/2cAqpt4OoQkhQ7PD62Xvtxk ErjI8OXyv5wdrbsz++ZtG2Cc0+EjmLGe3AlbPmgh+dubOqhTnemnfuFxuJ3nZ7YIYCRKv 1dcnJP9xVs8gKIhrAMa4p2mUg0YylDAhe+YiE0xsp1qwFD0lqZaUQ7P7U85UtN0w42A+r mpnKX5sqK2Iq3xv6Nt7lOu/FQAuIP5M+AlP8AY5R46NUZ2BP91wedsF5YGdfJgBw6zQ== 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=kiNqiyU4; 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 DFB4A606A31A for ; Wed, 2 Dec 2026 15:24:50 +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=kiNqiyU4 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9E7E41F00897; Wed, 2 Dec 2026 15:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796225090; bh=MtLusZq4SQHOp+iN0ZO4L8VdzqA+7PH7/uk59T7prU0=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=kiNqiyU4sFiaUoFEsV6jVtRu1Rln2KlPNY0d7UhRnSmRzZH9DeHtjvklvLEbSv/G/ 5ewYDuwHFsT5fl78P3Ij27MwE/Uj1z3K3N84B+QJDMtFq5TnQX9N19BMcfYfp9VBWy ofXZyBhVxNFKJsCcIW4k0+LfRxlN4M4iFAzXGkQ8XU2PKZl8YVdn+SXO1Li8DmfSYX Kh2qrwiVTnKbHeyTmuQfzzkUBq2oExfmJPLIz7ixZpQ//Fs972Js/lKtpLMvuDQMbu AkrcGMwQaJzraAhLpnVOa7DWHznSKFi94qOxrn+KEyfyJW65qAHpI96aaELkRe6cBp 3Ycr6v+T4yQGA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 14/22] phy: cadence-torrent: rework ref clock init and probe cleanup Reply-To: sashiko-reviews@lists.linux.dev 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-14-0b493387347b@bootlin.com> References: <20261202-phy-cadence-torrent-ng-v2-0-0b493387347b@bootlin.com> <20261202-phy-cadence-torrent-ng-v2-14-0b493387347b@bootlin.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 15:24:49 +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 1 potential issue to consider: - [Medium] phy: cadence-torrent: invalid reset_control_assert() calls on probe error -- commit d8ca83553938e7b813b4701d8d1a0be332d25133 Author: Benjamin Robin phy: cadence-torrent: rework ref clock init and probe cleanup This commit refactors reference clock initialization into helper functions and consolidates probe error handling and driver removal into a shared tp_cleanup_remove() helper. > diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cade= nce/phy-cadence-torrent.c > index 69e5323b1d689..de4ff3a133ffa 100644 > --- a/drivers/phy/cadence/phy-cadence-torrent.c > +++ b/drivers/phy/cadence/phy-cadence-torrent.c [ ... ] > @@ -2672,6 +2671,18 @@ static int tp_dp_reg_base_init(struct platform_dev= ice *pdev, struct tp_data *tp_ > return 0; > } > =20 > +static void tp_cleanup_remove(struct tp_data *tp_data) > +{ > + for (u8 i =3D 0; i < tp_data->nb_links; ++i) { > + reset_control_assert(tp_data->links[i].lnk_rst); > + reset_control_put(tp_data->links[i].lnk_rst); > + } > + > + reset_control_assert(tp_data->phy_rst); > + reset_control_assert(tp_data->apb_rst); > + tp_ref_clks_uninit(tp_data); > +} > + > static bool tp_is_already_configured(const struct tp_data *tp_data) > { > u16 val =3D tp_reg_read(&tp_data->reg_phy_pma_common_cdb, PHY_PMA_CMN_C= TRL1); > @@ -2721,21 +2732,11 @@ static int cdns_torrent_phy_probe(struct platform= _device *pdev) > =20 > ret =3D tp_of_get_reset(tp_data); > if (ret) > - return ret; > + goto cleanup; > =20 > ret =3D tp_of_get_clk(tp_data); > if (ret) > - return ret; > - > - tp_data->already_configured =3D tp_is_already_configured(tp_data); > - if (!tp_data->already_configured) { > - ret =3D cdns_torrent_clk(tp_data); > - if (ret) > - return ret; > - > - /* Enable APB */ > - reset_control_deassert(tp_data->apb_rst); > - } > + goto cleanup; > =20 > for_each_available_child_of_node(dev->of_node, child) { > /* PHY subnode name must be 'phy'. */ > @@ -2744,29 +2745,39 @@ static int cdns_torrent_phy_probe(struct platform= _device *pdev) > =20 > ret =3D tp_add_phy_from_of_subnode(tp_data, child); > if (ret) > - goto put_lnk_rst; > + goto cleanup; > } > child =3D NULL; > =20 > if (tp_data->nb_links =3D=3D 0) { > ret =3D -ENODEV; > - goto put_lnk_rst; > + goto cleanup; > + } > + > + /* Enable APB */ > + reset_control_deassert(tp_data->apb_rst); > + > + tp_data->already_configured =3D tp_is_already_configured(tp_data); > + if (!tp_data->already_configured) { > + ret =3D tp_ref_clks_init(tp_data); > + if (ret) > + goto cleanup; > } > =20 > ret =3D tp_dp_reg_base_init(pdev, tp_data); > if (ret) > - goto put_lnk_rst; > + goto cleanup; > =20 > if (tp_data->nb_links > 1 && !tp_data->already_configured) { > ret =3D cdns_torrent_phy_configure_multilink(tp_data); > if (ret) > - goto put_lnk_rst; > + goto cleanup; > } > =20 > phy_provider =3D devm_of_phy_provider_register(dev, of_phy_simple_xlate= ); > if (IS_ERR(phy_provider)) { > ret =3D PTR_ERR(phy_provider); > - goto put_lnk_rst; > + goto cleanup; > } > =20 > if (tp_data->nb_links > 1) > @@ -2781,33 +2792,19 @@ static int cdns_torrent_phy_probe(struct platform= _device *pdev) > =20 > return 0; > =20 > -put_lnk_rst: > +cleanup: > if (child) > of_node_put(child); > =20 > - for (u8 i =3D 0; i < tp_data->nb_links; i++) > - reset_control_put(tp_data->links[i].lnk_rst); > - > - reset_control_assert(tp_data->apb_rst); > - clk_disable_unprepare(tp_data->clk1); > - clk_disable_unprepare(tp_data->clk); > + tp_cleanup_remove(tp_data); > return ret; > } [Severity: Medium] Can jumping to cleanup from cdns_torrent_phy_probe() trigger a WARN_ON() in reset_control_assert() or reset a SERDES that was already configured by the bootloader? If tp_of_get_reset() fails (for example with -EPROBE_DEFER), tp_data->phy_rst or tp_data->apb_rst holds an ERR_PTR, which tp_cleanup_remove() passes to reset_control_assert(), hitting WARN_ON(IS_ERR(rstc)): drivers/phy/cadence/phy-cadence-torrent.c:tp_of_get_reset() { tp_data->phy_rst =3D devm_reset_control_get_exclusive_by_index(dev, 0); if (IS_ERR(tp_data->phy_rst)) { dev_err(dev, "%s: failed to get reset\n", dev->of_node->full_name); return PTR_ERR(tp_data->phy_rst); } ... } Although commit "phy: cadence-torrent: store clock and reset handles only on success" later in this series avoids storing the ERR_PTR, ordering that change before this one would avoid breaking bisection. In addition, calling tp_cleanup_remove() on probe failure after tp_of_get_reset() (such as -EPROBE_DEFER in tp_of_get_clk() or tp_add_phy_from_of_subnode(), or any failure when tp_data->already_configured is true) unconditionally asserts links[i].lnk_rst, phy_rst, and apb_rst. Previously, probe failure never asserted phy_rst or links[i].lnk_rst, and asserting these resets on probe deferral resets an already-configured SERDES and clears PHY_PMA_CMN_CTRL1, so subsequent probe retries no longer detect already_configured. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202-phy-cadenc= e-torrent-ng-v2-0-0b493387347b@bootlin.com?part=3D14