arch/powerpc/sysdev/xive/spapr.c
Source file repositories/reference/linux-study-clean/arch/powerpc/sysdev/xive/spapr.c
File Facts
- System
- Linux kernel
- Corpus path
arch/powerpc/sysdev/xive/spapr.c- Extension
.c- Size
- 20207 bytes
- Lines
- 885
- Domain
- Architecture Layer
- Bucket
- arch/powerpc
- Inferred role
- Architecture Layer: implementation source
- Status
- source implementation candidate
Why This File Exists
CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- CPU and platform-specific kernel glue: boot entry, traps, syscall entry, interrupts, page tables, context switch, and low-level barriers.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/types.hlinux/irq.hlinux/seq_file.hlinux/smp.hlinux/interrupt.hlinux/init.hlinux/of.hlinux/of_address.hlinux/of_fdt.hlinux/slab.hlinux/spinlock.hlinux/bitmap.hlinux/cpumask.hlinux/mm.hlinux/delay.hlinux/libfdt.hasm/machdep.hasm/prom.hasm/io.hasm/smp.hasm/irq.hasm/errno.hasm/xive.hasm/xive-regs.hasm/hvcall.hasm/svm.hasm/ultravisor.hxive-internal.h
Detected Declarations
struct xive_irq_bitmapfunction xive_irq_bitmap_addfunction xive_irq_bitmap_remove_allfunction list_for_each_entry_safefunction __xive_irq_bitmap_allocfunction xive_irq_bitmap_allocfunction list_for_each_entryfunction xive_irq_bitmap_freefunction list_for_each_entryfunction plpar_busy_delay_timefunction plpar_busy_delayfunction plpar_int_resetfunction plpar_int_get_source_infofunction plpar_int_set_source_configfunction plpar_int_get_source_configfunction plpar_int_get_queue_infofunction plpar_int_set_queue_configfunction plpar_int_syncfunction plpar_int_esbfunction xive_spapr_esb_rwfunction xive_spapr_populate_irq_datafunction xive_spapr_configure_irqfunction xive_spapr_get_irq_configfunction xive_spapr_configure_queuefunction xive_spapr_setup_queuefunction xive_spapr_cleanup_queuefunction xive_spapr_matchfunction xive_spapr_get_ipifunction xive_spapr_put_ipifunction xive_spapr_shutdownfunction xive_spapr_update_pendingfunction xive_spapr_setup_cpufunction xive_spapr_teardown_cpufunction xive_spapr_sync_sourcefunction xive_spapr_debug_showfunction xive_get_max_priofunction get_vec5_featurefunction xive_spapr_disabledfunction xive_spapr_init
Annotated Snippet
struct xive_irq_bitmap {
unsigned long *bitmap;
unsigned int base;
unsigned int count;
spinlock_t lock;
struct list_head list;
};
static LIST_HEAD(xive_irq_bitmaps);
static int __init xive_irq_bitmap_add(int base, int count)
{
struct xive_irq_bitmap *xibm;
xibm = kzalloc_obj(*xibm);
if (!xibm)
return -ENOMEM;
spin_lock_init(&xibm->lock);
xibm->base = base;
xibm->count = count;
xibm->bitmap = bitmap_zalloc(xibm->count, GFP_KERNEL);
if (!xibm->bitmap) {
kfree(xibm);
return -ENOMEM;
}
list_add(&xibm->list, &xive_irq_bitmaps);
pr_info("Using IRQ range [%x-%x]", xibm->base,
xibm->base + xibm->count - 1);
return 0;
}
static void xive_irq_bitmap_remove_all(void)
{
struct xive_irq_bitmap *xibm, *tmp;
list_for_each_entry_safe(xibm, tmp, &xive_irq_bitmaps, list) {
list_del(&xibm->list);
bitmap_free(xibm->bitmap);
kfree(xibm);
}
}
static int __xive_irq_bitmap_alloc(struct xive_irq_bitmap *xibm)
{
int irq;
irq = find_first_zero_bit(xibm->bitmap, xibm->count);
if (irq != xibm->count) {
set_bit(irq, xibm->bitmap);
irq += xibm->base;
} else {
irq = -ENOMEM;
}
return irq;
}
static int xive_irq_bitmap_alloc(void)
{
struct xive_irq_bitmap *xibm;
unsigned long flags;
int irq = -ENOENT;
list_for_each_entry(xibm, &xive_irq_bitmaps, list) {
spin_lock_irqsave(&xibm->lock, flags);
irq = __xive_irq_bitmap_alloc(xibm);
spin_unlock_irqrestore(&xibm->lock, flags);
if (irq >= 0)
break;
}
return irq;
}
static void xive_irq_bitmap_free(int irq)
{
unsigned long flags;
struct xive_irq_bitmap *xibm;
list_for_each_entry(xibm, &xive_irq_bitmaps, list) {
if ((irq >= xibm->base) && (irq < xibm->base + xibm->count)) {
spin_lock_irqsave(&xibm->lock, flags);
clear_bit(irq - xibm->base, xibm->bitmap);
spin_unlock_irqrestore(&xibm->lock, flags);
break;
}
}
}
Annotation
- Immediate include surface: `linux/types.h`, `linux/irq.h`, `linux/seq_file.h`, `linux/smp.h`, `linux/interrupt.h`, `linux/init.h`, `linux/of.h`, `linux/of_address.h`.
- Detected declarations: `struct xive_irq_bitmap`, `function xive_irq_bitmap_add`, `function xive_irq_bitmap_remove_all`, `function list_for_each_entry_safe`, `function __xive_irq_bitmap_alloc`, `function xive_irq_bitmap_alloc`, `function list_for_each_entry`, `function xive_irq_bitmap_free`, `function list_for_each_entry`, `function plpar_busy_delay_time`.
- Atlas domain: Architecture Layer / arch/powerpc.
- Implementation status: source 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.