Skip to content

Commit 9047a39

Browse files
Marc ZyngierKAGA-KOKO
authored andcommitted
genirq: Factor-in percpu irqaction creation
Move the code creating a per-cpu irqaction into its own helper, so that future changes to this code can be kept localised. At the same time, fix the documentation which appears to say the wrong thing when it comes to interrupts being automatically enabled (percpu_devid interrupts never are). Signed-off-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Tested-by: Will Deacon <will@kernel.org> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Link: https://patch.msgid.link/20251020122944.3074811-14-maz@kernel.org
1 parent 5c2b2cc commit 9047a39

1 file changed

Lines changed: 24 additions & 16 deletions

File tree

kernel/irq/manage.c

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,6 +2442,24 @@ int setup_percpu_irq(unsigned int irq, struct irqaction *act)
24422442
return retval;
24432443
}
24442444

2445+
static
2446+
struct irqaction *create_percpu_irqaction(irq_handler_t handler, unsigned long flags,
2447+
const char *devname, void __percpu *dev_id)
2448+
{
2449+
struct irqaction *action;
2450+
2451+
action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
2452+
if (!action)
2453+
return NULL;
2454+
2455+
action->handler = handler;
2456+
action->flags = flags | IRQF_PERCPU | IRQF_NO_SUSPEND;
2457+
action->name = devname;
2458+
action->percpu_dev_id = dev_id;
2459+
2460+
return action;
2461+
}
2462+
24452463
/**
24462464
* __request_percpu_irq - allocate a percpu interrupt line
24472465
* @irq: Interrupt line to allocate
@@ -2450,9 +2468,9 @@ int setup_percpu_irq(unsigned int irq, struct irqaction *act)
24502468
* @devname: An ascii name for the claiming device
24512469
* @dev_id: A percpu cookie passed back to the handler function
24522470
*
2453-
* This call allocates interrupt resources and enables the interrupt on the
2454-
* local CPU. If the interrupt is supposed to be enabled on other CPUs, it
2455-
* has to be done on each CPU using enable_percpu_irq().
2471+
* This call allocates interrupt resources, but doesn't enable the interrupt
2472+
* on any CPU, as all percpu-devid interrupts are flagged with IRQ_NOAUTOEN.
2473+
* It has to be done on each CPU using enable_percpu_irq().
24562474
*
24572475
* @dev_id must be globally unique. It is a per-cpu variable, and
24582476
* the handler gets called with the interrupted CPU's instance of
@@ -2477,15 +2495,10 @@ int __request_percpu_irq(unsigned int irq, irq_handler_t handler,
24772495
if (flags && flags != IRQF_TIMER)
24782496
return -EINVAL;
24792497

2480-
action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
2498+
action = create_percpu_irqaction(handler, flags, devname, dev_id);
24812499
if (!action)
24822500
return -ENOMEM;
24832501

2484-
action->handler = handler;
2485-
action->flags = flags | IRQF_PERCPU | IRQF_NO_SUSPEND;
2486-
action->name = devname;
2487-
action->percpu_dev_id = dev_id;
2488-
24892502
retval = irq_chip_pm_get(&desc->irq_data);
24902503
if (retval < 0) {
24912504
kfree(action);
@@ -2546,16 +2559,11 @@ int request_percpu_nmi(unsigned int irq, irq_handler_t handler,
25462559
if (irq_is_nmi(desc))
25472560
return -EINVAL;
25482561

2549-
action = kzalloc(sizeof(struct irqaction), GFP_KERNEL);
2562+
action = create_percpu_irqaction(handler, IRQF_NO_THREAD | IRQF_NOBALANCING,
2563+
name, dev_id);
25502564
if (!action)
25512565
return -ENOMEM;
25522566

2553-
action->handler = handler;
2554-
action->flags = IRQF_PERCPU | IRQF_NO_SUSPEND | IRQF_NO_THREAD
2555-
| IRQF_NOBALANCING;
2556-
action->name = name;
2557-
action->percpu_dev_id = dev_id;
2558-
25592567
retval = irq_chip_pm_get(&desc->irq_data);
25602568
if (retval < 0)
25612569
goto err_out;

0 commit comments

Comments
 (0)