[tip: irq/core] genirq/manage: Rework teardown_percpu_nmi()

tip-bot2 for Thomas Gleixner
2025-05-07T09:07:22Z

The following commit has been merged into the irq/core branch of tip:

Commit-ID: 5fec6d5cd24a35f5b03612dd02975e3be1b788b8
Gitweb: https://git.kernel.org/tip/5fec6d5cd24a35f5b03612dd02975e3be1b788b8
Author: Thomas Gleixner <tglx@linutronix.de>
AuthorDate: Tue, 29 Apr 2025 08:55:50 +02:00
Committer: Thomas Gleixner <tglx@linutronix.de>
CommitterDate: Wed, 07 May 2025 09:08:16 +02:00

genirq/manage: Rework teardown_percpu_nmi()

Use the new guards to get and lock the interrupt descriptor and tidy up the
code.

No functional change.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/all/20250429065422.552884529@linutronix.de

---
kernel/irq/manage.c | 19 +++++--------------
1 file changed, 5 insertions(+), 14 deletions(-)

diff --git a/kernel/irq/manage.c b/kernel/irq/manage.c
index c6472b1..fd5fcf3 100644
--- a/kernel/irq/manage.c
+++ b/kernel/irq/manage.c
@@ -2634,22 +2634,13 @@ int prepare_percpu_nmi(unsigned int irq)
*/
void teardown_percpu_nmi(unsigned int irq)
{
- unsigned long flags;
- struct irq_desc *desc;
-
WARN_ON(preemptible());

- desc = irq_get_desc_lock(irq, &flags,
- IRQ_GET_DESC_CHECK_PERCPU);
- if (!desc)
- return;
-
- if (WARN_ON(!irq_is_nmi(desc)))
- goto out;
-
- irq_nmi_teardown(desc);
-out:
- irq_put_desc_unlock(desc, flags);
+ scoped_irqdesc_get_and_lock(irq, IRQ_GET_DESC_CHECK_PERCPU) {
+ if (WARN_ON(!irq_is_nmi(scoped_irqdesc)))
+ return;
+ irq_nmi_teardown(scoped_irqdesc);
+ }
}

static int __irq_get_irqchip_state(struct irq_data *data, enum irqchip_irq_state which, bool *state)