genirq/devres: Simplify API devm_free_irq() implementation
PATCH v2 1/1 genirq/devres: Simplify API devm_free_irq() implementation
From: Zijun Hu <[email protected]>
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.
---
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/[email protected]
--- kernel/irq/devres.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/irq/devres.c +1 -2
@@ -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,
Signature · 1 line
Zijun Hu <[email protected]>
[tip: irq/core] genirq/devres: Don't free interrupt which is not managed by devres
The following commit has been merged into the irq/core branch of tip:
The following commit has been merged into the irq/core branch of tip:
Commit-ID: 2396eefa075a31884d3336e1e94db47a0bd2a456 Gitweb: https://git.kernel.org/tip/2396eefa075a31884d3336e1e94db47a0bd2a456 Author: Zijun Hu <[email protected]> AuthorDate: Fri, 18 Oct 2024 20:08:25 +08:00 Committer: Thomas Gleixner <[email protected]> CommitterDate: Thu, 24 Oct 2024 11:20:06 +02:00
genirq/devres: Don't free interrupt which is not managed by devres
If devres_destroy() does not find a matching devres entry, then devm_free_irq() emits a warning and tries to free the interrupt.
That's wrong as devm_free_irq() should only undo what devm_request_irq() set up.
Replace devres_destroy() with a call to devres_release() which only invokes the release function (free_irq()) in case that a matching devres entry was found.
[ tglx: Massaged change log ]
--- kernel/irq/devres.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
kernel/irq/devres.c +1 -2
@@ -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);