mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: "Zhipeng Wang (OSS)" <zhipeng.wang_1@oss.nxp.com>
Cc: Thomas Gleixner <tglx@kernel.org>, Marc Zyngier <maz@kernel.org>,
	Frank Li <frank.li@nxp.com>, Radu Rendec <radu@rendec.net>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@gmail.com>,
	Jindong Yue <jindong.yue@nxp.com>,
	Xuegang Liu <xuegang.liu@nxp.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"imx@lists.linux.dev" <imx@lists.linux.dev>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH v6 4/9] irqchip/imx-irqsteer: Convert to devm_pm_runtime_set_active_enabled()
Date: Mon, 12 Oct 2026 14:25:40 -0500	[thread overview]
Message-ID: <as00NCc7ISmSlpIp@SMW015318> (raw)
In-Reply-To: <VI0PR04MB12350BD5EF98B9EC922D797F0EB912@VI0PR04MB12350.eurprd04.prod.outlook.com>

On Sat, Oct 10, 2026 at 08:26:44AM +0000, Zhipeng Wang (OSS) wrote:
> > Subject: Re: [PATCH v6 4/9] irqchip/imx-irqsteer: Convert to
> > devm_pm_runtime_set_active_enabled()
> >
>
> NXP Confidential
> > On Thu, Oct 08, 2026 at 06:02:26PM +0900, Zhipeng.wang_1@oss.nxp.com
> > wrote:
> > > From: Zhipeng Wang <zhipeng.wang_1@nxp.com>
> > >
> > > imx_irqsteer_probe() enables runtime PM with pm_runtime_enable(), but
> > > imx_irqsteer_remove() never disables it. Runtime PM therefore stays
> > > enabled after the device is unbound, and rebinding it triggers:
> > >
> > >   Unbalanced pm_runtime_enable!
> > >
> > > Use devm_pm_runtime_set_active_enabled() so the driver core marks the
> > > device active (matching the enabled clock) and disables runtime PM
> > > again on unbind, keeping the enable balanced across unbind/rebind.
> > >
> > > This becomes reachable once the driver can be unbound and reloaded,
> > > but the imbalance already exists today on unbind, so fix it separately
> > > with a Fixes tag for stable.
> > >
> > > Fixes: 4730d2233311 ("irqchip/imx-irqsteer: Add runtime PM support")
> > > Suggested-by: Fabio Estevam <festevam@nabladev.com>
> > > Signed-off-by: Zhipeng Wang <zhipeng.wang_1@nxp.com>
> > > ---
> > >  drivers/irqchip/irq-imx-irqsteer.c | 10 ++++++----
> > >  1 file changed, 6 insertions(+), 4 deletions(-)
> > >
> > > diff --git a/drivers/irqchip/irq-imx-irqsteer.c
> > > b/drivers/irqchip/irq-imx-irqsteer.c
> > > index d05de3d26fb2..5acc04504e52 100644
> > > --- a/drivers/irqchip/irq-imx-irqsteer.c
> > > +++ b/drivers/irqchip/irq-imx-irqsteer.c
> > > @@ -239,6 +239,10 @@ static int imx_irqsteer_probe(struct
> > platform_device *pdev)
> > >     if (irqsteer_has_chanctrl(data->devtype_data))
> > >             writel_relaxed(BIT(data->channel), data->regs + CHANCTRL);
> > >
> > > +   ret = devm_pm_runtime_set_active_enabled(&pdev->dev);
> > > +   if (ret)
> > > +           goto out;
> > > +
> > >     data->domain = irq_domain_create_linear(dev_fwnode(&pdev->dev),
> > data->reg_num * 32,
> > >                                             &imx_irqsteer_domain_ops, data);
> > >     if (!data->domain) {
> > > @@ -260,9 +264,6 @@ static int imx_irqsteer_probe(struct
> > > platform_device *pdev)
> > >
> > >     platform_set_drvdata(pdev, data);
> > >
> > > -   pm_runtime_set_active(&pdev->dev);
> > > -   pm_runtime_enable(&pdev->dev);
> > > -
> > >     return 0;
> > >  out:
> > >     clk_disable_unprepare(data->ipg_clk);
> > > @@ -285,7 +286,8 @@ static void imx_irqsteer_remove(struct
> > > platform_device *pdev)
> > >
> > >     irq_domain_remove(irqsteer_data->domain);
> > >
> > > -   clk_disable_unprepare(irqsteer_data->ipg_clk);
> > > +   if (!pm_runtime_status_suspended(&pdev->dev))
> > > +           clk_disable_unprepare(irqsteer_data->ipg_clk);
> >
> > Are you sure need do this? suppose runtime_pm tear down call runtime pm
> > susped to disable clock.
> >
> > Frank
> >
> Hi Frank,
>
> I don't think the devres teardown disables the clock here.
>
> devm_pm_runtime_set_active_enabled() registers two devres actions that
> run on unbind: pm_runtime_disable() and pm_runtime_set_suspended().
> pm_runtime_set_suspended() only sets the status to RPM_SUSPENDED via
> __pm_runtime_set_status(); it does not invoke the ->runtime_suspend
> callback. So imx_irqsteer_suspend() is not called at teardown and the
> clock is not disabled by runtime PM.
>
> At this patch the clock is still managed by hand (devm_clk_get() plus
> clk_prepare_enable() in probe()), so remove() has to clk_disable_unprepare()
> to balance it. The pm_runtime_status_suspended() guard is there for the
> case where the device is already runtime-suspended at unbind: the runtime
> suspend callback has then already dropped the clock, so remove() must not
> disable it a second time, otherwise the enable count underflows.
>
> The later patch "Let devres own the clock" switches to
> devm_clk_get_enabled(), and at that point this manual clk_disable_unprepare()
> (and the guard) is removed, replaced by a pm_runtime_resume_and_get() /
> pm_runtime_put_noidle() pair.

Okay

Reviewed-by: Frank Li <Frank.Li@nxp.com>

>
> Thanks,
> Zhipeng
>
> > >  }
> > >
> > >  #ifdef CONFIG_PM
> > > --
> > > 2.34.1
> > >
> > >

  reply	other threads:[~2026-10-12 19:25 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08  9:02 [PATCH v6 0/9] irqchip/imx-irqsteer: Allow building as module Zhipeng.wang_1
2026-10-08  9:02 ` [PATCH v6 1/9] irqchip/imx-irqsteer: Call chained_irq_exit() on the handler error path Zhipeng.wang_1
2026-10-08  9:02 ` [PATCH v6 2/9] irqchip/imx-irqsteer: Validate IRQ count before creating domain Zhipeng.wang_1
2026-10-08 20:36   ` Frank Li
2026-10-08  9:02 ` [PATCH v6 3/9] irqchip/imx-irqsteer: Dispose of parent IRQ mappings in remove() Zhipeng.wang_1
2026-10-08  9:02 ` [PATCH v6 4/9] irqchip/imx-irqsteer: Convert to devm_pm_runtime_set_active_enabled() Zhipeng.wang_1
2026-10-08 20:41   ` Frank Li
2026-10-10  8:26     ` Zhipeng Wang (OSS)
2026-10-12 19:25       ` Frank Li [this message]
2026-10-08  9:02 ` [PATCH v6 5/9] irqchip/imx-irqsteer: Mask all interrupts in probe() Zhipeng.wang_1
2026-10-08  9:02 ` [PATCH v6 6/9] irqchip/imx-irqsteer: Let devres own the clock Zhipeng.wang_1
2026-10-08 20:54   ` Frank Li
2026-10-08  9:02 ` [PATCH v6 7/9] irqchip/imx-irqsteer: Allow building as module Zhipeng.wang_1
2026-10-08  9:02 ` [PATCH v6 8/9] genirq/irqdomain: Add devm_irq_domain_create_linear() Zhipeng.wang_1
2026-10-08  9:02 ` [PATCH v6 9/9] irqchip/imx-irqsteer: Use devm_irq_domain_create_linear() Zhipeng.wang_1
2026-10-08 21:01   ` Frank Li
2026-10-10  9:06     ` Zhipeng Wang (OSS)

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=as00NCc7ISmSlpIp@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=festevam@gmail.com \
    --cc=frank.li@nxp.com \
    --cc=imx@lists.linux.dev \
    --cc=jindong.yue@nxp.com \
    --cc=kernel@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maz@kernel.org \
    --cc=radu@rendec.net \
    --cc=s.hauer@pengutronix.de \
    --cc=tglx@kernel.org \
    --cc=xuegang.liu@nxp.com \
    --cc=zhipeng.wang_1@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®