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=1796225675; b=TE4GqNaOEpee1JmseCJbiiTZQ90iGO5MA+grMlTz67jsj2Yc9RQRifGT1ktZHsFwYNQP 1GD1CKOjSpwte2g3+CSC9VHpYZnEtmIRidX5VyTNSHMQa9gfyDKGohcgrh5/xe8ZphIDa U98DQKwVF1NLmqzS/XSZcdFmWUwMjlv4WGXTgrNsNnL+Qv//qBH2MEjzyo7G9j7t+mgXE vkaap9VQk02KUmDSDzvdz9vCF3qovD6sAqb//L8KcKLezXiJVLohZTRV6D9yNBiCQzpM/ NVQAWJpfbkTqZUudNHeEhbd9+zTRIZN0QMWbXX3D6M/gLJRHLZtaugohpaaxYNV+Iog== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796225675; h=Received:DKIM-Signature:Message-ID:From:Subject:Reply-To:To:Cc: In-Reply-To:References:Content-Type:Content-Transfer-Encoding:Date; bh=MZKisrc242ep2MFXohNtavYOc9botJZ1coX9Mss3eb8=; b=CVSjYAcgVOvPXDReHnzslpouHWw5JxGmMcPb4hqED9yehRGi+iiQqeg8cMnIZhGqbNs8 kGmwwUA81aQga5mO5o3730Ax0/bTZGwZF6zRCLHa9bsAvJVHRqg0Zjdx/T8umhoEyAdS4 XnWDqmL1vv8RFYmfAwNFdPdmBrn++e8FlFUDfpiDB0xFHpAzC9vWi4423hRxl5PvzZjuS U0EolplTNPNfSJMeAZFhHvsBRw3qStsfaeoe3CbEXD1i0hVL9cOBgscb86eMM/Kj1XR+8 0ztJcflY8QZ6JB+hVFkaLTbYtEsAwot6q8Qjy2F2kKN60gOly5tgWe0oUKkZakyy2oA== 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=ZIJOiLG1; 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 B6D4F606A31A for ; Wed, 2 Dec 2026 15:34:35 +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=ZIJOiLG1 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 36E6B1F0089F; Wed, 2 Dec 2026 15:34:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796225675; bh=MZKisrc242ep2MFXohNtavYOc9botJZ1coX9Mss3eb8=; h=From:Subject:Reply-To:To:Cc:In-Reply-To:References:Date; b=ZIJOiLG17KZgxLxU4PNJPt/78ro/XqVsWtTDl8lJP8AsiTk2G9ZSewKrdUJxW2ZAN GlXjHEv00P3VPj7V7+j7r9CWiqxWUKbLygZiHBE895wBqOtf6Taa42IWNZ7l6q4Wf0 hbVSPztRiZo4qv6wQHYs7Rl8P5bNlnH3fAV3UdqsDTejW2G6y40SdVkSMFdnzsndK6 /hHGz3P6Aa+NNsHRM/tkQgOnAQnYrJcxIqO7GzNTZ6Wqm+xBtYynujkqAmvqWi6D9Z TAdp45vitNppK5UEOxcxEBmL9n/YIBTmZu6KfEcdHjHUQzT7BIUHKLDRgPhAcHDGzm 0M47dLIykSVsA== Message-ID: From: sashiko-bot@kernel.org Subject: Re: [PATCH v2 20/22] phy: cadence-torrent: rework suspend/resume to restore link config 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-20-0b493387347b@bootlin.com> References: <20261202-phy-cadence-torrent-ng-v2-0-0b493387347b@bootlin.com> <20261202-phy-cadence-torrent-ng-v2-20-0b493387347b@bootlin.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Date: Wed, 02 Dec 2026 15:34:34 +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 2 potential issues to consider: - [Medium] phy: cadence-torrent: uninitialized rst_asserted breaks resume reset state - [Medium] phy: cadence-torrent: incomplete reset and link restoration in tp_resume_noirq() -- commit a2bcc09aba1dcb8fcf52a6ca3d4a6b96ba68afa6 Author: Benjamin Robin phy: cadence-torrent: rework suspend/resume to restore link config This commit reworks suspend and resume to track per-link reset state, keep reference clocks enabled across suspend when links remain powered on, and re-program the PHY on resume when its configuration was lost. > diff --git a/drivers/phy/cadence/phy-cadence-torrent.c b/drivers/phy/cade= nce/phy-cadence-torrent.c > index 02e3c91316d56..7c4c20b005a95 100644 > --- a/drivers/phy/cadence/phy-cadence-torrent.c > +++ b/drivers/phy/cadence/phy-cadence-torrent.c > @@ -348,6 +348,7 @@ struct tp_link { > u8 num_lanes; > u8 max_lanes; > u16 bit_rate; /* in Mb/s */ > + bool rst_asserted; > enum cdns_torrent_ssc_mode ssc_mode; > }; [Severity: Medium] Should link->rst_asserted be initialized when each link is set up at probe time? cdns_torrent_phy_probe() zero-allocates tp_data via devm_kzalloc_obj(), so link->rst_asserted starts as false for all links even though unpowered links remain in reset until tp_phy_on() is called. In a multi-link setup where one link is powered on (nb_phy_on > 0) and another link has never been powered on, a state-losing suspend and resume takes the restore_resets path in tp_resume_noirq() and sees !link->rst_asserted on the never-powered link, deasserting link->lnk_rst on an unpowered link. Also, if link->rst_asserted is initialized to true at probe time when !tp_data->already_configured, note that the tp_data->already_configured early return in tp_phy_on() increments nb_phy_on without calling tp_control_link_reset(link, false), so rst_asserted needs to reflect whether the link was already out of reset. [ ... ] > @@ -2994,51 +3010,80 @@ static int tp_refclk_driver_resume(struct tp_data= *tp_data) > =20 > static int tp_suspend_noirq(struct device *dev) > { > + int ret =3D 0; > struct tp_data *tp_data =3D dev_get_drvdata(dev); > - int i; > =20 > tp_refclk_driver_suspend(tp_data); > =20 > - reset_control_assert(tp_data->phy_rst); > - reset_control_assert(tp_data->apb_rst); > - for (i =3D 0; i < tp_data->nb_links; i++) > - reset_control_assert(tp_data->links[i].lnk_rst); > - > tp_data->already_configured =3D false; > - tp_ref_clks_uninit(tp_data); > + if (!tp_data->nb_phy_on) { > + tp_ref_clks_uninit(tp_data); > + ret =3D reset_control_assert(tp_data->apb_rst); > + } > =20 > - return 0; > + return ret; > } > =20 > static int tp_resume_noirq(struct device *dev) > { > + int ret; > + bool config_needed =3D false; > + bool restore_resets =3D false; > struct tp_data *tp_data =3D dev_get_drvdata(dev); > - int node =3D tp_data->nb_links; > - int ret, i; > =20 > - ret =3D tp_refclk_driver_resume(tp_data); > + /* Enable APB unconditionally */ > + ret =3D reset_control_deassert(tp_data->apb_rst); > if (ret) > return ret; > =20 > + ret =3D tp_refclk_driver_resume(tp_data); > + if (ret) > + goto failed; > + > ret =3D tp_ref_clks_init(tp_data); > if (ret) > - return ret; > + goto failed; > =20 > - /* Enable APB */ > - reset_control_deassert(tp_data->apb_rst); > + /* Check if we have lost the configuration */ > + if (!tp_data->nb_phy_on) { > + /* All the links are in reset, and the torrent PHY is in reset */ > + config_needed =3D true; > =20 > - ret =3D tp_configure_links(tp_data); > - if (ret) > - goto put_lnk_rst; > + } else if (!tp_is_already_configured(tp_data)) { > + /* First put all the links in reset, and the PHY in reset */ > + for (u8 i =3D 0; i < tp_data->nb_links; ++i) > + reset_control_assert(tp_data->links[i].lnk_rst); > + > + reset_control_assert(tp_data->phy_rst); > + config_needed =3D true; > + restore_resets =3D true; > + } > + > + if (config_needed) { > + ret =3D tp_configure_links(tp_data); > + if (ret) > + goto failed; > + } > + > + if (restore_resets) { > + /* Restore resets in previous state */ > + reset_control_deassert(tp_data->phy_rst); > + > + for (u8 i =3D 0; i < tp_data->nb_links; ++i) { > + struct tp_link *link =3D &tp_data->links[i]; > + > + if (!link->rst_asserted) > + reset_control_deassert(link->lnk_rst); > + } > + } [Severity: Medium] Does the restore_resets path in tp_resume_noirq() leave active links uninitialized after deasserting phy_rst and lnk_rst? When nb_phy_on > 0 and the PHY lost its configuration during suspend, restore_resets only deasserts phy_rst and link->lnk_rst. Unlike tp_phy_init() and tp_phy_on(), it does not wait for PHY_PMA_CMN_CTRL1[0] (CMN ready), re-run tp_dp_phy_init() and tp_dp_run() for active TYPE_DP links, or poll PHY_PCS_ISO_LINK_CTRL for active TYPE_PCIE and TYPE_USB links, leaving consumers that keep the PHY powered across suspend (such as cdns-mhdp8546) with an unstarted link. In addition, when the PHY was pre-configured by the bootloader at probe time (tp_data->already_configured =3D=3D true) and nb_phy_on =3D=3D 0 at su= spend, tp_suspend_noirq() clears already_configured without asserting phy_rst or lnk_rst. On resume, the !tp_data->nb_phy_on branch assumes all links and the PHY are already in reset and runs tp_configure_links() while the resets are still deasserted. --=20 Sashiko AI review =C2=B7 https://sashiko.dev/#/patchset/20261202-phy-cadenc= e-torrent-ng-v2-0-0b493387347b@bootlin.com?part=3D20