From: sashiko-bot@kernel.org
To: "Benjamin Robin" <benjamin.robin@bootlin.com>
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 20/22] phy: cadence-torrent: rework suspend/resume to restore link config
Date: Wed, 02 Dec 2026 15:34:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-246111@kernel.org> (raw)
In-Reply-To: <20261202-phy-cadence-torrent-ng-v2-20-0b493387347b@bootlin.com>
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 <benjamin.robin@bootlin.com>
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/cadence/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)
>
> static int tp_suspend_noirq(struct device *dev)
> {
> + int ret = 0;
> struct tp_data *tp_data = dev_get_drvdata(dev);
> - int i;
>
> tp_refclk_driver_suspend(tp_data);
>
> - reset_control_assert(tp_data->phy_rst);
> - reset_control_assert(tp_data->apb_rst);
> - for (i = 0; i < tp_data->nb_links; i++)
> - reset_control_assert(tp_data->links[i].lnk_rst);
> -
> tp_data->already_configured = false;
> - tp_ref_clks_uninit(tp_data);
> + if (!tp_data->nb_phy_on) {
> + tp_ref_clks_uninit(tp_data);
> + ret = reset_control_assert(tp_data->apb_rst);
> + }
>
> - return 0;
> + return ret;
> }
>
> static int tp_resume_noirq(struct device *dev)
> {
> + int ret;
> + bool config_needed = false;
> + bool restore_resets = false;
> struct tp_data *tp_data = dev_get_drvdata(dev);
> - int node = tp_data->nb_links;
> - int ret, i;
>
> - ret = tp_refclk_driver_resume(tp_data);
> + /* Enable APB unconditionally */
> + ret = reset_control_deassert(tp_data->apb_rst);
> if (ret)
> return ret;
>
> + ret = tp_refclk_driver_resume(tp_data);
> + if (ret)
> + goto failed;
> +
> ret = tp_ref_clks_init(tp_data);
> if (ret)
> - return ret;
> + goto failed;
>
> - /* 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 = true;
>
> - ret = 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 = 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 = true;
> + restore_resets = true;
> + }
> +
> + if (config_needed) {
> + ret = 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 = 0; i < tp_data->nb_links; ++i) {
> + struct tp_link *link = &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 == true) and nb_phy_on == 0 at suspend,
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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-phy-cadence-torrent-ng-v2-0-0b493387347b@bootlin.com?part=20
WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Benjamin Robin" <benjamin.robin@bootlin.com>
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 20/22] phy: cadence-torrent: rework suspend/resume to restore link config
Date: Wed, 02 Dec 2026 15:34:34 +0000 [thread overview]
Message-ID: <sashiko-outbox-246111@kernel.org> (raw)
In-Reply-To: <20261202-phy-cadence-torrent-ng-v2-20-0b493387347b@bootlin.com>
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 <benjamin.robin@bootlin.com>
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/cadence/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)
>
> static int tp_suspend_noirq(struct device *dev)
> {
> + int ret = 0;
> struct tp_data *tp_data = dev_get_drvdata(dev);
> - int i;
>
> tp_refclk_driver_suspend(tp_data);
>
> - reset_control_assert(tp_data->phy_rst);
> - reset_control_assert(tp_data->apb_rst);
> - for (i = 0; i < tp_data->nb_links; i++)
> - reset_control_assert(tp_data->links[i].lnk_rst);
> -
> tp_data->already_configured = false;
> - tp_ref_clks_uninit(tp_data);
> + if (!tp_data->nb_phy_on) {
> + tp_ref_clks_uninit(tp_data);
> + ret = reset_control_assert(tp_data->apb_rst);
> + }
>
> - return 0;
> + return ret;
> }
>
> static int tp_resume_noirq(struct device *dev)
> {
> + int ret;
> + bool config_needed = false;
> + bool restore_resets = false;
> struct tp_data *tp_data = dev_get_drvdata(dev);
> - int node = tp_data->nb_links;
> - int ret, i;
>
> - ret = tp_refclk_driver_resume(tp_data);
> + /* Enable APB unconditionally */
> + ret = reset_control_deassert(tp_data->apb_rst);
> if (ret)
> return ret;
>
> + ret = tp_refclk_driver_resume(tp_data);
> + if (ret)
> + goto failed;
> +
> ret = tp_ref_clks_init(tp_data);
> if (ret)
> - return ret;
> + goto failed;
>
> - /* 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 = true;
>
> - ret = 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 = 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 = true;
> + restore_resets = true;
> + }
> +
> + if (config_needed) {
> + ret = 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 = 0; i < tp_data->nb_links; ++i) {
> + struct tp_link *link = &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 == true) and nb_phy_on == 0 at suspend,
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.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261202-phy-cadence-torrent-ng-v2-0-0b493387347b@bootlin.com?part=20
--
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy
next prev parent reply other threads:[~2026-12-02 15:34 UTC|newest]
Thread overview: 52+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 15:08 [PATCH v2 00/22] phy: cadence-torrent: rewrite Torrent PHY driver Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 01/22] arm64: dts: ti: k3-j7200: Fix QSGMII overlay by adding SERDES PHY Benjamin Robin
2026-12-02 15:08 ` Benjamin Robin
2026-12-02 15:24 ` sashiko-bot
2026-12-02 15:24 ` sashiko-bot
2026-12-02 15:08 ` [PATCH v2 02/22] drm/bridge: cdns-mhdp8546: Power on/off the PHY in probe/remove Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 03/22] dt-bindings: phy: cadence-torrent: make cdns,num-lanes optional again Benjamin Robin
2026-12-02 15:08 ` Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 04/22] dt-bindings: phy: cadence-torrent: add phy-mode constants Benjamin Robin
2026-12-02 15:08 ` Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 05/22] phy: cadence-torrent: make cdns,num-lanes optional again Benjamin Robin
2026-12-02 15:08 ` Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 06/22] phy: torrent: fix `RX_DIAG_NQST_CTRL` register address Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 07/22] phy: cadence-torrent: rename symbols to prepare for rewrite Benjamin Robin
2026-12-02 15:08 ` Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 08/22] phy: cadence-torrent: replace regmap with readw/writew Benjamin Robin
2026-12-02 15:08 ` Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 09/22] phy: cadence-torrent: move refclk clk_init_data to the stack Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 10/22] phy: cadence-torrent: drop diag_tx_drv from DP voltage coeff Benjamin Robin
2026-12-02 15:08 ` Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 11/22] phy: cadence-torrent: use link lane count and mlane for DP config Benjamin Robin
2026-12-02 15:08 ` Benjamin Robin
2026-12-02 15:28 ` sashiko-bot
2026-12-02 15:28 ` sashiko-bot
2026-12-02 15:08 ` [PATCH v2 12/22] phy: cadence-torrent: use devm_of_clk_add_hw_provider() Benjamin Robin
2026-12-02 15:08 ` Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 13/22] phy: cadence-torrent: rework subnode parsing and lane validation Benjamin Robin
2026-12-02 15:08 ` [PATCH v2 14/22] phy: cadence-torrent: rework ref clock init and probe cleanup Benjamin Robin
2026-12-02 15:08 ` Benjamin Robin
2026-12-02 15:24 ` sashiko-bot
2026-12-02 15:24 ` sashiko-bot
2026-12-02 15:09 ` [PATCH v2 15/22] phy: cadence-torrent: factor out DP PLL frequency update Benjamin Robin
2026-12-02 15:09 ` [PATCH v2 16/22] phy: cadence-torrent: store clock and reset handles only on success Benjamin Robin
2026-12-02 15:09 ` Benjamin Robin
2026-12-02 15:09 ` [PATCH v2 17/22] phy: cadence-torrent: unify link configuration in the probe Benjamin Robin
2026-12-02 15:09 ` Benjamin Robin
2026-12-02 15:37 ` sashiko-bot
2026-12-02 15:37 ` sashiko-bot
2026-12-02 15:09 ` [PATCH v2 18/22] phy: cadence-torrent: allow config on an already-configured DP link Benjamin Robin
2026-12-02 15:09 ` Benjamin Robin
2026-12-02 15:31 ` sashiko-bot
2026-12-02 15:31 ` sashiko-bot
2026-12-02 15:09 ` [PATCH v2 19/22] phy: cadence-torrent: track current DP link bit rate Benjamin Robin
2026-12-02 15:09 ` [PATCH v2 20/22] phy: cadence-torrent: rework suspend/resume to restore link config Benjamin Robin
2026-12-02 15:34 ` sashiko-bot [this message]
2026-12-02 15:34 ` sashiko-bot
2026-12-02 15:09 ` [PATCH v2 21/22] phy: cadence-torrent: rewrite Torrent PHY driver Benjamin Robin
2026-12-02 15:38 ` sashiko-bot
2026-12-02 15:38 ` sashiko-bot
2026-12-02 15:09 ` [PATCH v2 22/22] phy: cadence-torrent: support 8 lanes on the sd0801 PHY Benjamin Robin
2026-12-02 15:30 ` sashiko-bot
2026-12-02 15:30 ` sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=sashiko-outbox-246111@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=benjamin.robin@bootlin.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-phy@lists.infradead.org \
--cc=neil.armstrong@linaro.org \
--cc=olteanv@gmail.com \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.