From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=185.246.84.56 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796308052; b=wvDYhYm8ESNgcOhY5GfwwayBI02XJr7Mo3HV5VucZHOmvZ2UA+zgbevb44lBuiEzb4vB 0gToMdM0fp6ZaTh2MZbPyBEMxkQxuhGWAOCzbKjCglkaHNUztkeKMnBKvYCVmmfiiyQ3+ NFCMUvDIW+VTvpCIUIz1QoRwP2UxGQb2SOp+JddE72qqAWLZ5+x40elzUMKAn4PsRZ7sQ doEXllzSvXly0OcsmVSzQsZKsRykcUK4/1TxyyaLDKYlLa9WZRl618w7zbfs0nyCEz15D xopQs0zwMXlb1jJerdNxiBCoT9pzRCTupeexbgGvlUNgiOZ9y7uMYKlTUTiZdGHCn6w== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796308052; h=DMARC-Filter:Received:Received:Received:DKIM-Signature:From:To:Cc: Subject:Date:Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:X-Last-TLS-Session-Version; bh=Z+K2Gm0HZkhxP5TNxY5JCU0jn4Yo6zBY4cgvBe3XIWE=; b=GQnpUaw5wUERn/zZqFHWWYTuwmYeX4ejYjbw2t++rBar7zp5p+vPcwTLS4SEL3Q6Wn1K pN39qdu7KolvlA24XQ4gudNFzbRaQ9gWwRT4I1K8XwM2NywA9WCBqCtmrhrXq9YEyBId5 cOsUAJLUNOoMs9lMjDawW2hZcmonyRHRDSAukiuG0yGUMLkQKQdnVJu+yKiLPV2adnSko TJyWXMFueV50j1CwOMsfDOtyEwSIRCRn/Nnt3BDFHqnQ1u2cg1K5ttKncQR+sc0HSpK4S OForuwKTl1NbX05wWOKFdaXRBIVEZcTW6oE2UbYpqC/yFAKpHr+Cy/N2ytt5cs60K9g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=xCUS8+Iu; arc=none smtp.remote-ip=185.246.84.56 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 DB4B5606A332 for ; Thu, 3 Dec 2026 14:27:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org DB4B5606A332 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.a=rsa-sha256 header.s=dkim header.b=xCUS8+Iu Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 8EA961A190F; Thu, 3 Dec 2026 14:27:22 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5C62D604ED; Thu, 3 Dec 2026 14:27:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 5E79C11EA1688; Thu, 03 Dec 2026 15:27:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1796308037; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=Z+K2Gm0HZkhxP5TNxY5JCU0jn4Yo6zBY4cgvBe3XIWE=; b=xCUS8+IuBfbBO3YAVnORJLqN/ZNBoxuy8RwQsXIcmjaimqiMYnS9ghGYP/jKDWPo8ZjjUp UyQnm4Zk3QhNvRGA9B6v2FqedEudk9BBXD/vfzdrCo9gaMz0wu2Pcev+FzgfbeysyRiN31 wkLGq8Hw9vs2W/L/qNHjh6o61G1hNGKJOwuVxmQUWdfCRHaqNJeLKF7R+hYYwsOi9edGW5 Ge/CLRkobraudW6EAEp7O6Qzx7s+1rtdP1SdJ9jsi8lHxXvBDYoAZeZmFce2WG0SX4g/0i SHD70mzP8zt9HuxPZ0+3Vkge+Isdp3nmSyiGqN40+BD4ixool2y1HVxsSo/QTA== From: Benjamin Robin To: sashiko-reviews@lists.linux.dev 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 Subject: Re: [PATCH v2 14/22] phy: cadence-torrent: rework ref clock init and probe cleanup Date: Thu, 03 Dec 2026 15:27:14 +0100 Message-ID: In-Reply-To: References: <20261202-phy-cadence-torrent-ng-v2-0-0b493387347b@bootlin.com> <20261202-phy-cadence-torrent-ng-v2-14-0b493387347b@bootlin.com> X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" X-Last-TLS-Session-Version: TLSv1.3 On Wednesday, December 2, 2026 at 4:24=E2=80=AFPM, sashiko-bot@kernel.org w= rote: > 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 > -- >=20 > commit d8ca83553938e7b813b4701d8d1a0be332d25133 > Author: Benjamin Robin >=20 > phy: cadence-torrent: rework ref clock init and probe cleanup >=20 > This commit refactors reference clock initialization into helper functions > and consolidates probe error handling and driver removal into a shared > tp_cleanup_remove() helper. >=20 > > diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/ca= dence/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_d= evice *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= _CTRL1); > > @@ -2721,21 +2732,11 @@ static int cdns_torrent_phy_probe(struct platfo= rm_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 platfo= rm_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_xla= te); > > 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 platfo= rm_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; > > } >=20 > [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)): >=20 > 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); > } > ... > } >=20 > 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. This indeed could be an issue. In v3 the commit "store clock and reset handles only on success" will be put before this one. > 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. I guess there is no reason to put the PHY in resets in case of probe failur= e. We should keep the reset in their default state. However when configuring the torrent PHY, everything should be in reset. This will be changed in v3. =2D-=20 Benjamin Robin, Bootlin Embedded Linux and Kernel engineering https://bootlin.com