Linux Power Management development
 help / color / mirror / Atom feed
From: "Niklas Söderlund" <niklas.soderlund@ragnatech.se>
To: zhang san <shunsheng1218@gmail.com>
Cc: rafael@kernel.org, daniel.lezcano@kernel.org,
	rui.zhang@intel.com, lukasz.luba@arm.com, magnus.damm@gmail.com,
	linux-renesas-soc@vger.kernel.org, linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 2/3] thermal: rcar_gen3: release the interrupt handlers from ->remove()
Date: Wed, 25 Nov 2026 12:31:06 +0100	[thread overview]
Message-ID: <20261125113106.GM3898744@ragnatech.se> (raw)
In-Reply-To: <nh-17d10cf4-3201-426c-b9a7-95bcba2df381@google.com>

Hi Yaohan,

On 2026-11-25 05:18:20 -0600, zhang san wrote:
> Hi Niklas,
> 
> Fair enough, and sorry for wasting your review time. Dropping
> RCAR_GEN3_THERMAL_MAX_IRQ and your earlier style feedback across revisions
> was my fault.

I'm happy to keep reviewing your work. And I think the issue you are 
working on is valid and worth fixing. I don't see it as wasted as at the 
very least patch 1/3 is good code and more or less ready to go and fixes 
a real issue.

I was just, a bit blunt, asking for you to work thru the changes 
yourself a bit more. From my side it reads as a copy-past from LLM and 
having to point out the same thing in multiple iterations is what's 
tedious as an LLM can't learn, but you can! And I'm happy to support you 
if you want to.

> 
> I'm dropping patches 2/3 and 3/3 and won't send any further IRQ lifetime
> changes here unless I've worked through the driver properly on my own.
> I'll look at patch 1/3 separately on its own using your feedback.

Thanks for breaking out 1/3 it is good and fixes a real issue. As stated 
above if you want to keep working on 2/3 and 3/3 with more human power* 
then LLM, I'm happy to keep reviewing it.

* I don't care if you use an LLM or not, but you need to workthru the
  LLM suggestions some more before posting it IMHO.

> 
> Thanks,
> Yaohan
> 
> On Wed, 25 Nov 2026 08:33:42 +0100, "Niklas Söderlund"
> <niklas.soderlund@ragnatech.se> wrote:
> > Hi Yaohan,
> >
> > Thanks for your work.
> >
> > On 2026-11-25 11:03:26 +0800, Yaohan Li wrote:
> > > The interrupt handlers are requested before the thermal zones, and
> > > devres releases the managed resources in the reverse order, so the
> > > handlers outlive the zones they report to. The handler walks every
> > > sensor and calls thermal_zone_device_update() through tsc->zone, which
> > > is not cleared when the zone is unregistered. Masking the interrupt
> > > sources neither waits for a threaded handler that is already running
> > > nor removes the action.
> > >
> > > Release the handlers from ->remove(), which runs before the runtime PM
> > > reference is dropped and before devres unregisters the zones.
> > > free_irq() also waits for a running handler, and after it returns the
> > > handler cannot be invoked again.
> > >
> > > Record the interrupt numbers as they are requested, so that a partial
> > > request is undone as well: if the second handler cannot be registered,
> > > the first one is released and the driver falls back to polling, as
> > > before.
> > >
> > > Signed-off-by: Yaohan Li <shunsheng1218@gmail.com>
> > >
> > > ---
> > > Prepared against v7.4-rc1-1969-g666539eecdf4.
> > >
> > > Compile tested only: arm64, aarch64-linux-gnu-gcc 11.4,
> > > CONFIG_ARCH_RENESAS and CONFIG_RCAR_GEN3_THERMAL.
> > >
> > > AI assistance: prepared with Claude (Anthropic) as a coding assistant; the
> > > author reviewed the reasoning and takes responsibility for the content.
> > > ---
> > > drivers/thermal/renesas/rcar_gen3_thermal.c | 38 ++++++++++++++++++---
> > > 1 file changed, 33 insertions(+), 5 deletions(-)
> > >
> > > diff --git a/drivers/thermal/renesas/rcar_gen3_thermal.c b/drivers/thermal/renesas/rcar_gen3_thermal.c
> > > index a96f02d4a8ad..37348f4413b6 100644
> > > --- a/drivers/thermal/renesas/rcar_gen3_thermal.c
> > > +++ b/drivers/thermal/renesas/rcar_gen3_thermal.c
> > > @@ -107,6 +107,8 @@ struct rcar_gen3_thermal_priv {
> > > struct rcar_gen3_thermal_tsc *tscs[TSC_MAX_NUM];
> > > struct thermal_zone_device_ops ops;
> > > unsigned int num_tscs;
> > > + int irqs[2];
> >
> > What happened to RCAR_GEN3_THERMAL_MAX_IRQ ?
> >
> > Please stop thorowing this code at an LLM it comes up with new code
> > ignore past ideas.
> >
> > > + unsigned int num_irqs;
> > > int ptat[3];
> > > int tj_t;
> > > const struct rcar_thermal_info *info;
> > > @@ -466,9 +468,25 @@ static const struct of_device_id rcar_gen3_thermal_dt_ids[] = {
> > > };
> > > MODULE_DEVICE_TABLE(of, rcar_gen3_thermal_dt_ids);
> > >
> > > +static void rcar_gen3_thermal_free_irqs(struct device *dev,
> > > + struct rcar_gen3_thermal_priv *priv)
> > > +{
> > > + while (priv->num_irqs)
> >
> > Please use a for loop not modifyig priv->num_irqs, this looks dangerous.
> >
> > > + devm_free_irq(dev, priv->irqs[--priv->num_irqs], priv);
> > > +}
> > > +
> > > static void rcar_gen3_thermal_remove(struct platform_device *pdev)
> > > {
> > > + struct rcar_gen3_thermal_priv *priv = platform_get_drvdata(pdev);
> > > struct device *dev = &pdev->dev;
> > > + unsigned int i;
> > > +
> > > + for (i = 0; i < priv->num_tscs; i++) {
> >
> > Declare loop variable in for loop, where possible.
> >
> > > + rcar_gen3_thermal_write(priv->tscs[i], REG_GEN3_IRQEN, 0);
> > > + rcar_gen3_thermal_write(priv->tscs[i], REG_GEN3_IRQMSK, 0);
> > > + }
> > > +
> > > + rcar_gen3_thermal_free_irqs(dev, priv);
> > >
> > > pm_runtime_put(dev);
> > > pm_runtime_disable(dev);
> > > @@ -491,22 +509,32 @@ static int rcar_gen3_thermal_request_irqs(struct rcar_gen3_thermal_priv *priv,
> > >
> > > for (i = 0; i < 2; i++) {
> > > irq = platform_get_irq_optional(pdev, i);
> > > - if (irq < 0)
> > > - return irq;
> > > + if (irq < 0) {
> > > + ret = irq;
> > > + goto release;
> > > + }
> >
> > This changes the behavior of the driver...
> >
> > Please stop using an LLM to code this. As you don't have hardware to
> > test with throwing LLM spaghetti over the wall and see if it sticks is
> > getting tedious. Please read, understand and write the code yourself as
> > coding for gear you can't test is hard.
> >
> > I will not review another set of LLM slop, especially as the good parts
> > like RCAR_GEN3_THERMAL_MAX_IRQ are dropped between revisions.
> >
> > Nacked-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
> >
> > >
> > > irqname = devm_kasprintf(dev, GFP_KERNEL, "%s:ch%d",
> > > dev_name(dev), i);
> > > - if (!irqname)
> > > - return -ENOMEM;
> > > + if (!irqname) {
> > > + ret = -ENOMEM;
> > > + goto release;
> > > + }
> > >
> > > ret = devm_request_threaded_irq(dev, irq, NULL,
> > > rcar_gen3_thermal_irq,
> > > IRQF_ONESHOT, irqname, priv);
> > > if (ret)
> > > - return ret;
> > > + goto release;
> > > +
> > > + priv->irqs[priv->num_irqs++] = irq;
> > > }
> > >
> > > return 0;
> > > +
> > > +release:
> > > + rcar_gen3_thermal_free_irqs(dev, priv);
> > > + return ret;
> > > }
> > >
> > > static int rcar_gen3_thermal_probe(struct platform_device *pdev)
> > > --
> > > 2.34.1
> > >
> >
> > --
> > Kind Regards,
> > Niklas Söderlund

-- 
Kind Regards,
Niklas Söderlund

  reply	other threads:[~2026-11-25 11:31 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17 14:53 [PATCH] thermal: rcar_gen3: quiesce the interrupt source before releasing it Yaohan Li
2026-11-18  9:31 ` Niklas Söderlund
2026-11-19  2:29 ` [PATCH v2] thermal: rcar_gen3: release the IRQ handlers before the zones are freed Yaohan Li
2026-11-22 14:48   ` Niklas Söderlund
2026-11-23  2:21     ` Yaohan Li
2026-11-23  6:47       ` Niklas Söderlund
2026-11-24  2:22         ` Yaohan Li
2026-11-24  6:40           ` Niklas Söderlund
2026-11-24  9:51   ` [PATCH v3] thermal: rcar_gen3: register the interrupt handlers after the zones Yaohan Li
2026-11-24 13:15     ` Niklas Söderlund
2026-11-25  3:03     ` [PATCH v4 0/3] thermal: rcar_gen3: fix the interrupt handler lifetimes Yaohan Li
2026-11-25  3:03       ` [PATCH v4 1/3] thermal: rcar_gen3: check for sensors before reading the fuses Yaohan Li
2026-11-25  6:04         ` Niklas Söderlund
2026-11-25  3:03       ` [PATCH v4 2/3] thermal: rcar_gen3: release the interrupt handlers from ->remove() Yaohan Li
2026-11-25  7:33         ` Niklas Söderlund
2026-11-25 11:18           ` zhang san
2026-11-25 11:31             ` Niklas Söderlund [this message]
2026-11-25  3:03       ` [PATCH v4 3/3] thermal: rcar_gen3: do not enable the interrupts before the zones exist Yaohan Li

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=20261125113106.GM3898744@ragnatech.se \
    --to=niklas.soderlund@ragnatech.se \
    --cc=daniel.lezcano@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=lukasz.luba@arm.com \
    --cc=magnus.damm@gmail.com \
    --cc=rafael@kernel.org \
    --cc=rui.zhang@intel.com \
    --cc=shunsheng1218@gmail.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