All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Xu Yang" <xu.yang_2@oss.nxp.com>
Cc: vkoul@kernel.org, linux-phy@lists.infradead.org,
	Frank.Li@kernel.org, imx@lists.linux.dev,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v7 3/6] phy: fsl-imx8mq-usb: add runtime PM support
Date: Wed, 29 Jul 2026 06:55:20 +0000	[thread overview]
Message-ID: <20260729065521.32C7E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260729-imx8mp-usb-phy-improvement-v7-3-c385ee40ade6@nxp.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Incorrect error checking of pm_runtime_get_sync() return value causes spurious warnings when the device is already active.
- [Low] Failure of pm_runtime_get_sync() in remove() leads to an unbalanced clock disable by devres, triggering a kernel WARN.
--

--- Patch [3]: [PATCH v7 3/6] phy: fsl-imx8mq-usb: add runtime PM support ---
commit f054765f7ebd59735a4592c4d68b74584abdbeeb
Author: Xu Yang <xu.yang_2@nxp.com>

phy: fsl-imx8mq-usb: add runtime PM support

Add runtime PM support to ensure the PHY clocks are properly gated
when the PHY is not in use, reducing power consumption. Clock
management is moved from power_on()/power_off() callbacks into the
runtime_resume()/runtime_suspend() callbacks.

> diff --git a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
> index 3a5788c609e1b..74e665525ec48 100644
> --- a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
> +++ b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
[ ... ]
> @@ -708,44 +696,101 @@ static int imx8mq_usb_phy_probe(struct platform_device *pdev)
[ ... ]
>  static void imx8mq_usb_phy_remove(struct platform_device *pdev)
>  {
> +	struct device *dev = &pdev->dev;
> +	int ret;
> +
> +	ret = pm_runtime_get_sync(dev);
> +	if (ret)
> +		dev_warn(dev, "failed to resume on remove: %d\n", ret);

[Severity: Medium]
Is it intended to warn when pm_runtime_get_sync() returns 1?

Since pm_runtime_get_sync() returns 1 when the device is already active
(or when CONFIG_PM is disabled), checking "if (ret)" instead of
"if (ret < 0)" will trigger this warning even on successful unbinds
where the device was already active.

> +
> +	pm_runtime_disable(dev);
> +	pm_runtime_put_noidle(dev);
>  }

[Severity: Low]
Could a failure in pm_runtime_get_sync() lead to a clock enable count
underflow?

The clocks are acquired using devm_clk_get_enabled() in probe(), which
registers a devres cleanup action to disable the clocks on teardown. If
the runtime resume fails here in remove(), the clocks will remain disabled
by the runtime PM framework. When devres subsequently attempts to disable
them again during cleanup, it will cause an unbalanced clock disable and
a kernel WARN.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260729-imx8mp-usb-phy-improvement-v7-0-c385ee40ade6@nxp.com?part=3

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Xu Yang" <xu.yang_2@oss.nxp.com>
Cc: vkoul@kernel.org, linux-phy@lists.infradead.org,
	Frank.Li@kernel.org, imx@lists.linux.dev,
	neil.armstrong@linaro.org, olteanv@gmail.com
Subject: Re: [PATCH v7 3/6] phy: fsl-imx8mq-usb: add runtime PM support
Date: Wed, 29 Jul 2026 06:55:20 +0000	[thread overview]
Message-ID: <20260729065521.32C7E1F00A3A@smtp.kernel.org> (raw)
In-Reply-To: <20260729-imx8mp-usb-phy-improvement-v7-3-c385ee40ade6@nxp.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Incorrect error checking of pm_runtime_get_sync() return value causes spurious warnings when the device is already active.
- [Low] Failure of pm_runtime_get_sync() in remove() leads to an unbalanced clock disable by devres, triggering a kernel WARN.
--

--- Patch [3]: [PATCH v7 3/6] phy: fsl-imx8mq-usb: add runtime PM support ---
commit f054765f7ebd59735a4592c4d68b74584abdbeeb
Author: Xu Yang <xu.yang_2@nxp.com>

phy: fsl-imx8mq-usb: add runtime PM support

Add runtime PM support to ensure the PHY clocks are properly gated
when the PHY is not in use, reducing power consumption. Clock
management is moved from power_on()/power_off() callbacks into the
runtime_resume()/runtime_suspend() callbacks.

> diff --git a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
> index 3a5788c609e1b..74e665525ec48 100644
> --- a/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
> +++ b/drivers/phy/freescale/phy-fsl-imx8mq-usb.c
[ ... ]
> @@ -708,44 +696,101 @@ static int imx8mq_usb_phy_probe(struct platform_device *pdev)
[ ... ]
>  static void imx8mq_usb_phy_remove(struct platform_device *pdev)
>  {
> +	struct device *dev = &pdev->dev;
> +	int ret;
> +
> +	ret = pm_runtime_get_sync(dev);
> +	if (ret)
> +		dev_warn(dev, "failed to resume on remove: %d\n", ret);

[Severity: Medium]
Is it intended to warn when pm_runtime_get_sync() returns 1?

Since pm_runtime_get_sync() returns 1 when the device is already active
(or when CONFIG_PM is disabled), checking "if (ret)" instead of
"if (ret < 0)" will trigger this warning even on successful unbinds
where the device was already active.

> +
> +	pm_runtime_disable(dev);
> +	pm_runtime_put_noidle(dev);
>  }

[Severity: Low]
Could a failure in pm_runtime_get_sync() lead to a clock enable count
underflow?

The clocks are acquired using devm_clk_get_enabled() in probe(), which
registers a devres cleanup action to disable the clocks on teardown. If
the runtime resume fails here in remove(), the clocks will remain disabled
by the runtime PM framework. When devres subsequently attempts to disable
them again during cleanup, it will cause an unbalanced clock disable and
a kernel WARN.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260729-imx8mp-usb-phy-improvement-v7-0-c385ee40ade6@nxp.com?part=3

  reply	other threads:[~2026-07-29  6:55 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-29  6:38 [PATCH v7 0/6] phy: fsl-imx8mq-usb: few improvements Xu Yang
2026-07-29  6:38 ` Xu Yang
2026-07-29  6:38 ` [PATCH v7 1/6] phy: fsl-imx8mq-usb: fix typec switch leak on probe error path Xu Yang
2026-07-29  6:38   ` Xu Yang
2026-07-29  6:47   ` sashiko-bot
2026-07-29  6:47     ` sashiko-bot
2026-07-29  6:38 ` [PATCH v7 2/6] phy: fsl-imx8mq-usb: set usb phy to be wakeup capable Xu Yang
2026-07-29  6:38   ` Xu Yang
2026-07-29  6:38 ` [PATCH v7 3/6] phy: fsl-imx8mq-usb: add runtime PM support Xu Yang
2026-07-29  6:38   ` Xu Yang
2026-07-29  6:55   ` sashiko-bot [this message]
2026-07-29  6:55     ` sashiko-bot
2026-07-29  8:08     ` Xu Yang
2026-07-29  8:08       ` Xu Yang
2026-07-29  6:38 ` [PATCH v7 4/6] phy: fsl-imx8mq-usb: add control register regmap Xu Yang
2026-07-29  6:38   ` Xu Yang
2026-07-29  6:49   ` sashiko-bot
2026-07-29  6:49     ` sashiko-bot
2026-07-29  6:38 ` [PATCH v7 5/6] phy: fsl-imx8mq-usb: introduce per-variant driver data structure Xu Yang
2026-07-29  6:38   ` Xu Yang
2026-07-29  6:38 ` [PATCH v7 6/6] phy: fsl-imx8mq-usb: keep PHY power domain runtime always-on for i.MX8MP Xu Yang
2026-07-29  6:38   ` Xu Yang

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=20260729065521.32C7E1F00A3A@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=linux-phy@lists.infradead.org \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    --cc=xu.yang_2@oss.nxp.com \
    /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.