mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zijun Hu <zijun_hu@icloud.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Zijun Hu <zijun_hu@icloud.com>,
	linux-kernel@vger.kernel.org,  Zijun Hu <quic_zijuhu@quicinc.com>
Subject: [PATCH v2] genirq/devres: Simplify API devm_free_irq() implementation
Date: Fri, 18 Oct 2024 20:08:25 +0800	[thread overview]
Message-ID: <20241018-devres_kernel_fix-v2-1-08918ae84982@quicinc.com> (raw)

From: Zijun Hu <quic_zijuhu@quicinc.com>

Simplify devm_free_irq() implementation by dedicated API devres_release()
which have below advantages than current devres_destroy() + free_irq().

It is simpler if devm_free_irq() is freeing IRQ which was ever requested
by a devm_request_irq() variant, otherwise, it can avoid the wrong and
unnecessary free_irq() as explained below:

Currently, devm_free_irq() still tries to free the IRQ by free_irq()
even if it can not find a matching devres entry within devres_destroy()
for the IQR under the othewise condition mentioned above.

So that is wrong as devm_free_irq() should only free IRQ requested by
a devm_request_irq() variant.

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
---
linux-next tree has similar fixes as shown below:
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=0ee4dcafda9576910559f0471a3d6891daf9ab92
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=9bd133f05b1dca5ca4399a76d04d0f6f4d454e44
---
Changes in v2:
- Correct commit message and make it clearer base on Thomas's proposal
- Link to v1: https://lore.kernel.org/r/20241017-devres_kernel_fix-v1-1-4aa0d7c4fee4@quicinc.com
---
 kernel/irq/devres.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/kernel/irq/devres.c b/kernel/irq/devres.c
index b3e98668f4dd..eb16a58e0322 100644
--- a/kernel/irq/devres.c
+++ b/kernel/irq/devres.c
@@ -141,9 +141,8 @@ void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id)
 {
 	struct irq_devres match_data = { irq, dev_id };
 
-	WARN_ON(devres_destroy(dev, devm_irq_release, devm_irq_match,
+	WARN_ON(devres_release(dev, devm_irq_release, devm_irq_match,
 			       &match_data));
-	free_irq(irq, dev_id);
 }
 EXPORT_SYMBOL(devm_free_irq);
 

---
base-commit: 9bd133f05b1dca5ca4399a76d04d0f6f4d454e44
change-id: 20241017-devres_kernel_fix-4b29be51bded

Best regards,
-- 
Zijun Hu <quic_zijuhu@quicinc.com>


             reply	other threads:[~2024-10-18 12:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-18 12:08 Zijun Hu [this message]
2024-10-24  9:27 ` [tip: irq/core] genirq/devres: Don't free interrupt which is not managed by devres tip-bot2 for Zijun Hu

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=20241018-devres_kernel_fix-v2-1-08918ae84982@quicinc.com \
    --to=zijun_hu@icloud.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=quic_zijuhu@quicinc.com \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome