Skip to content

Commit

Permalink
genirq: Provide generic_handle_irq_safe()
Browse files Browse the repository at this point in the history
Provide generic_handle_irq_safe() which can used from any context.

Suggested-by: Thomas Gleixner <[email protected]>
Signed-off-by: Sebastian Andrzej Siewior <[email protected]>
Signed-off-by: Thomas Gleixner <[email protected]>
Reviewed-by: Hans de Goede <[email protected]>
Reviewed-by: Oleksandr Natalenko <[email protected]>
Reviewed-by: Wolfram Sang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[dereference23: Backport to 4.14]
Signed-off-by: Alexander Winkowski <[email protected]>
  • Loading branch information
Sebastian Andrzej Siewior authored and dereference23 committed Jun 18, 2023
1 parent 4d8fb46 commit 346c1c1
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/linux/irqdesc.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ static inline void generic_handle_irq_desc(struct irq_desc *desc)
}

int generic_handle_irq(unsigned int irq);
int generic_handle_irq_safe(unsigned int irq);

#ifdef CONFIG_HANDLE_DOMAIN_IRQ
/*
Expand Down
23 changes: 23 additions & 0 deletions kernel/irq/irqdesc.c
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,29 @@ int generic_handle_irq(unsigned int irq)
}
EXPORT_SYMBOL_GPL(generic_handle_irq);

/**
* generic_handle_irq_safe - Invoke the handler for a particular irq from any
* context.
* @irq: The irq number to handle
*
* Returns: 0 on success, a negative value on error.
*
* This function can be called from any context (IRQ or process context). It
* will report an error if not invoked from IRQ context and the irq has been
* marked to enforce IRQ-context only.
*/
int generic_handle_irq_safe(unsigned int irq)
{
unsigned long flags;
int ret;

local_irq_save(flags);
ret = generic_handle_irq(irq);
local_irq_restore(flags);
return ret;
}
EXPORT_SYMBOL_GPL(generic_handle_irq_safe);

#ifdef CONFIG_HANDLE_DOMAIN_IRQ
/**
* __handle_domain_irq - Invoke the handler for a HW irq belonging to a domain
Expand Down

0 comments on commit 346c1c1

Please sign in to comment.