kernel/irq/resend.c
Source file repositories/reference/linux-study-clean/kernel/irq/resend.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/irq/resend.c- Extension
.c- Size
- 4937 bytes
- Lines
- 195
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/irq.hlinux/module.hlinux/random.hlinux/interrupt.hinternals.h
Detected Declarations
function resend_irqsfunction irq_sw_resendfunction clear_irq_resendfunction irq_resend_initfunction clear_irq_resendfunction try_retriggerfunction check_irq_resendfunction irq_inject_interruptexport irq_inject_interrupt
Annotated Snippet
void clear_irq_resend(struct irq_desc *desc) {}
void irq_resend_init(struct irq_desc *desc) {}
static int irq_sw_resend(struct irq_desc *desc)
{
return -EINVAL;
}
#endif
static int try_retrigger(struct irq_desc *desc)
{
if (desc->irq_data.chip->irq_retrigger)
return desc->irq_data.chip->irq_retrigger(&desc->irq_data);
#ifdef CONFIG_IRQ_DOMAIN_HIERARCHY
return irq_chip_retrigger_hierarchy(&desc->irq_data);
#else
return 0;
#endif
}
/*
* IRQ resend
*
* Is called with interrupts disabled and desc->lock held.
*/
int check_irq_resend(struct irq_desc *desc, bool inject)
{
int err = 0;
/*
* We do not resend level type interrupts. Level type interrupts
* are resent by hardware when they are still active. Clear the
* pending bit so suspend/resume does not get confused.
*/
if (irq_settings_is_level(desc)) {
desc->istate &= ~IRQS_PENDING;
return -EINVAL;
}
if (desc->istate & IRQS_REPLAY)
return -EBUSY;
if (!(desc->istate & IRQS_PENDING) && !inject)
return 0;
desc->istate &= ~IRQS_PENDING;
if (!try_retrigger(desc))
err = irq_sw_resend(desc);
/* If the retrigger was successful, mark it with the REPLAY bit */
if (!err)
desc->istate |= IRQS_REPLAY;
return err;
}
#ifdef CONFIG_GENERIC_IRQ_INJECTION
/**
* irq_inject_interrupt - Inject an interrupt for testing/error injection
* @irq: The interrupt number
*
* This function must only be used for debug and testing purposes!
*
* Especially on x86 this can cause a premature completion of an interrupt
* affinity change causing the interrupt line to become stale. Very
* unlikely, but possible.
*
* The injection can fail for various reasons:
* - Interrupt is not activated
* - Interrupt is NMI type or currently replaying
* - Interrupt is level type
* - Interrupt does not support hardware retrigger and software resend is
* either not enabled or not possible for the interrupt.
*/
int irq_inject_interrupt(unsigned int irq)
{
int err = -EINVAL;
/* Try the state injection hardware interface first */
if (!irq_set_irqchip_state(irq, IRQCHIP_STATE_PENDING, true))
return 0;
/* That failed, try via the resend mechanism */
scoped_irqdesc_get_and_buslock(irq, 0) {
struct irq_desc *desc = scoped_irqdesc;
/*
* Only try to inject when the interrupt is:
* - not NMI type
Annotation
- Immediate include surface: `linux/irq.h`, `linux/module.h`, `linux/random.h`, `linux/interrupt.h`, `internals.h`.
- Detected declarations: `function resend_irqs`, `function irq_sw_resend`, `function clear_irq_resend`, `function irq_resend_init`, `function clear_irq_resend`, `function try_retrigger`, `function check_irq_resend`, `function irq_inject_interrupt`, `export irq_inject_interrupt`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.