From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=202.12.124.159 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795606271; b=I0JXDvE4lhI9Szo3Ft+izXSl10SE0FwVR7A5x00J+1thoPJVQjZo15ljOygYhOhVQ+nf RqX3yc0Z66xJhnLRinxLvfRMHSOIHlBThroq1CJzbkrX52Fzkz4QqRNGH+iPNNp6DBP5G orFYOryca/gPw0PYuPvqlvxM5Iuw3Ezu1ecwr1LF0HU61Q3ThcjtNS/mebV70O7vPuVpi LZyLNp4Vqtsj7e7cTlGY0XNgq2PwMIBo3eLJ6sglqqxHWWD8Gcf6OYZcy02F+8yOA2Tjg rf6moKijNYeGV9T/cmVZlfbnP/NNFINYaK+kdpVSrGVDEUHyCj+XvwVy9s1nK9MigYw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795606271; h=DMARC-Filter:Received:Received:DKIM-Signature:DKIM-Signature: X-DKIM2-Info:DKIM2-Signature:X-DKIM2-Info:Message-Instance: X-ME-Sender:X-ME-Received:X-ME-Proxy-Cause:X-ME-Proxy:Feedback-ID: Received:Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:Content-Transfer-Encoding: In-Reply-To; bh=07CB2JdpTLRGg0uhkULyfmQ+l69QiH2n18DqTWiKyng=; b=iBDh/p8EAj1k8lHwpm4gU590dKjzHwSl0Cn/c4gX5fIL+6Ufm7REPlGX2hoNhjgcGiVd ctPPdxIsMZDdM0VnqKiTGJQCz3lB7aCjy6EQ/0y+5P4FLhfTMUOkMjQttjZ7iNtXWFSi7 nuwDBaIhfInvRM/09R9i/gwzwhgSL1gHlFWvvSESc9JMwWAeswhuLkyU4QOw0Ewy+6v4l 5XhSRDlM2IAzYRM9pyfXu8FQ/610FetE6mFmDpi1AVH+yancjpIb0GM0x2guuZGige0b/ kWhMr0JVaUva9By0KLkljv0YOWTelppzpEg/g3zkONYlkDaDUp46Qkr+A9icy4dqZqw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=ragnatech.se; spf=pass smtp.mailfrom=ragnatech.se; dkim=pass header.d=ragnatech.se header.i=@ragnatech.se header.a=rsa-sha256 header.s=fm2 header.b=bGC6fXPG; dkim=pass header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=1kerWhiN; arc=none smtp.remote-ip=202.12.124.159 Received: from fhigh-b8-smtp.messagingengine.com (fhigh-b8-smtp.messagingengine.com [202.12.124.159]) (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 2E9EB606A327 for ; Wed, 25 Nov 2026 11:31:11 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2E9EB606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ragnatech.se Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=ragnatech.se header.i=@ragnatech.se header.a=rsa-sha256 header.s=fm2 header.b=bGC6fXPG; dkim=pass (2048-bit key, unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.a=rsa-sha256 header.s=fm3 header.b=1kerWhiN Received: from phl-compute-02.internal (phl-compute-02.internal [10.202.2.42]) by mailfhigh.stl.internal (Postfix) with ESMTP id A687E7A0608 for ; Wed, 25 Nov 2026 06:31:10 -0500 (EST) Received: from phl-frontend-04 ([10.202.2.163]) by phl-compute-02.internal (MEProxy); Wed, 25 Nov 2026 06:31:10 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech.se; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm2; t=1795606269; x=1795692669; bh=07CB2JdpTLRGg0uhkULyfmQ+l69QiH2n18DqTWiKyng=; b= bGC6fXPGGbWnx/h7ckOm/Wf+GcGt1SuAMHdukor6aie33500Bgi3QizxNBVmSJIU oNfJIHupIRItGgvFsnZrIYKR1o7cc3Zr92Svae/OiyQVcwk8tNtzp/X4UhhZbJtI lLE6SC2mdsqWF9gTNCDGmAOU9458vm0so6O1UAoEC6Ar04tDPvrpXkletAn6+hqK a4tsRpmToqXejrGdEEpEowjtxIUWnpJwaLChC3mzGhKoCM9czInvBAgA/OSQyVvL Ey9PdhxqSMaWQ5z3QR5H2o6i1xwqhTi/A42liKL58Fr5lVp4vH8txAKr5ZQfDyfM QeYjjn2uuFITL1q0RxcpMw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1795606269; x= 1795692669; bh=07CB2JdpTLRGg0uhkULyfmQ+l69QiH2n18DqTWiKyng=; b=1 kerWhiNzkdfetpxL3Ulhe4ZcqAPeAH0VZLT/sstGDX14w0a+vd3IpSawawqYs9cN Xj708kZwg9EOt8CUF8x6aXj1Vm7SVH7HY+MGkCX6qm5kuC09jHVTokyq/000yyzw Z4vAWrB/Y3XDsbDFwfiPHREaZkBkYQXlHArv0Wk4gqGOkkZs+SaljdUZlGbYB7FI EVwYn4dUUU5uJwzbRWk2HfafZJ4V8mz9Hao2k6c3WHB/VKFRzm6p5+sUW33FnmgN SAaD8SY1vxle7ZdjVWCtzanx7qFQ2TJ+qP0bxm+DotIYdz2damf6JapJLO5R/a9D uSwoIPftpUWuxjcW4i1Cw== X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=sign d=ragnatech.se a=rsa-sha256; DKIM2-Signature: i=1; m=1; t=1795606269; d=ragnatech.se; mf=PG5pa2xhcy5zb2Rlcmx1bmRAcmFnbmF0ZWNoLnNlPg==; rt=PGxpbnV4LWtlcm5lbEB2Z2VyLmtlcm5lbC5vcmc+; s=fm2:rsa-sha256:X6IiZOsog6BaC2NkNXzuRdIcPYWeyclswLgdhbDPZYuVY3o FgSFilSD8HKPPQTAUVpMtJ3/OzP9XmDnfG596qbCO6SjpPOGMooopwb7a+Mu+EQr BPXEsJr10bjVVgIVEJ5DIkRyK/SduW+yOkwhgXsEuIcu2ecelfvOhiX5XNWx1hz8 GcAJWZDK0rfPM5JwsODDug3nSID+qaiOM5YbjWYY8rzxy1iCmJ495Z21F1ZJiDU3 iNpmd+V1U9tvO+e3/CwLjelzdjEVIB7guwhaLqbnwmY31y6bXOWgkVtgmfTnZDCO 6FeSHoY5gwh4PCHsg0xhTLEwblFADtAH3A0Oe4g==; X-DKIM2-Info: draft=ietf-dkim-dkim2-spec-09; repo=github.com/dkim2wg/interop; date=2026-11-03; sw=lmtpprox; action=mi-m=1; hc=13; hn=cc,content-disposition,content-transfer-encoding, content-type,date,feedback-id,from,in-reply-to,message-id, mime-version,references,subject,to; Message-Instance: m=1; h=sha256:ufM61RjvuqR1r5BUEPLZlryjW+cmxFM2FV1LvtCK5eI=:4WYlrs6VcY1qrwdfudkrtiUKHwcTjuWD3mfHDU/7I7I=; X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: dmFkZTFYIO1k+miz4jJ9B4TClE7SkH/GEU7+sz0HR7Lfzb+pMfdQPHogWYQRlB3X/KzKna VGGt6bpybPog+30OxfnKZETDRcplBcv7Abac6MjdMtHXwc3n1DHt7Q8jUMqw7swYGLVb2R VN8R5oRGRfjeZyi8LGnINAb1Hr3zsWrAb/4q/NcyX3K9EQy2GQ8CIgpJVplv2awK9HSoYJ V1P8Ht0tPLOG+PcIyAImchcVgsSV2fuaYLAkVx5wysyHiy6sG8gMXk9CsovaTD0LSO71CI 7MIX2OamBJ/tcs0oHyy5WdoUTWf9coDW5lFrPFSFF8vnsyIOUEwg6vBpGpryr5N5lTCbZf dUOjGml6OdRzzzkbxXSNbElpC8F7E1TuI5qTjU0+0KaFjv0RB+1Ijn9mfLiAmRALgWkcS/ 6LbE5DRXuripm/yq1b9myEYptWUBFlTsAC/dga6kwGlNkM352mzoO/15iyiFaao6Zl8cU4 lNgEi7CyrrbKVnUExy4ymLpPRB/aLe10Zz+dIjj73wmHvCmXJNwp1DGkzeBJLr598yKHzL tradNAmxlPvxou/ggdzJiy4rAWN58QbVHDb0MK+oY6z7YY3RKxLhjlpmzfcd6q5mdsYt0d Jk3qgTdLObXJ9UaxdK2WVsmPf7aeJsxEdr4xhUQSUU+fvyPGp6oB6Z0mD5EQ X-ME-Proxy: Feedback-ID: i80c9496c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 Nov 2026 06:31:08 -0500 (EST) Date: Wed, 25 Nov 2026 12:31:06 +0100 From: Niklas =?utf-8?Q?S=C3=B6derlund?= To: zhang san 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() Message-ID: <20261125113106.GM3898744@ragnatech.se> References: <20261124095110.131258-1-shunsheng1218@gmail.com> <20261125030327.953450-1-shunsheng1218@gmail.com> <20261125030327.953450-3-shunsheng1218@gmail.com> <20261125073342.GL3898744@ragnatech.se> X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: 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" > 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 > > > > > > --- > > > 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 > > > > > > > > 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