drivers/acpi/apei/ghes.c
Source file repositories/reference/linux-study-clean/drivers/acpi/apei/ghes.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/acpi/apei/ghes.c- Extension
.c- Size
- 52073 bytes
- Lines
- 1954
- Domain
- Driver Families
- Bucket
- drivers/acpi
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/arm_sdei.hlinux/kernel.hlinux/moduleparam.hlinux/init.hlinux/acpi.hlinux/bitfield.hlinux/io.hlinux/interrupt.hlinux/timer.hlinux/cper.hlinux/cleanup.hlinux/platform_device.hlinux/minmax.hlinux/mutex.hlinux/ratelimit.hlinux/vmalloc.hlinux/irq_work.hlinux/llist.hlinux/genalloc.hlinux/kfifo.hlinux/pci.hlinux/pfn.hlinux/aer.hlinux/nmi.hlinux/sched/clock.hlinux/uuid.hlinux/ras.hlinux/task_work.hlinux/vmcore_info.hacpi/actbl1.hacpi/ghes.hacpi/apei.h
Detected Declarations
struct ghes_vendor_record_entrystruct ghes_task_workfunction is_hest_type_generic_v2function errorsfunction ghes_unmapfunction ghes_estatus_pool_initfunction ghes_estatus_pool_region_freefunction map_gen_v2function unmap_gen_v2function ghes_ack_errorfunction ghes_finifunction ghes_severityfunction ghes_copy_tofrom_physfunction __ghes_check_estatusfunction __ghes_peek_estatusfunction __ghes_read_estatusfunction ghes_read_estatusfunction ghes_clear_estatusfunction memory_failure_cbfunction ghes_do_memory_failurefunction ghes_handle_memory_failurefunction ghes_handle_arm_hw_errorfunction fieldfunction ghes_handle_aerfunction ghes_register_vendor_record_notifierfunction ghes_unregister_vendor_record_notifierfunction ghes_vendor_record_notifier_destroyfunction devm_ghes_register_vendor_record_notifierfunction ghes_vendor_record_work_funcfunction ghes_defer_non_standard_eventfunction cxl_cper_post_prot_errfunction cxl_cper_register_prot_err_workfunction cxl_cper_unregister_prot_err_workfunction cxl_cper_prot_err_kfifo_getfunction cxl_cper_post_eventfunction cxl_cper_register_workfunction cxl_cper_unregister_workfunction cxl_cper_kfifo_getfunction ghes_log_hwerrfunction ghes_do_procfunction __ghes_print_estatusfunction ghes_print_estatusfunction ghes_estatus_cachedfunction ghes_estatus_cache_rcu_freefunction ghes_estatus_cache_addfunction __ghes_panicfunction ghes_procfunction ghes_add_timer
Annotated Snippet
struct ghes_vendor_record_entry {
struct work_struct work;
int error_severity;
char vendor_record[];
};
static struct gen_pool *ghes_estatus_pool;
static struct ghes_estatus_cache __rcu *ghes_estatus_caches[GHES_ESTATUS_CACHES_SIZE];
static atomic_t ghes_estatus_cache_alloced;
static void __iomem *ghes_map(u64 pfn, enum fixed_addresses fixmap_idx)
{
phys_addr_t paddr;
pgprot_t prot;
paddr = PFN_PHYS(pfn);
prot = arch_apei_get_mem_attribute(paddr);
__set_fixmap(fixmap_idx, paddr, prot);
return (void __iomem *) __fix_to_virt(fixmap_idx);
}
static void ghes_unmap(void __iomem *vaddr, enum fixed_addresses fixmap_idx)
{
int _idx = virt_to_fix((unsigned long)vaddr);
WARN_ON_ONCE(fixmap_idx != _idx);
clear_fixmap(fixmap_idx);
}
int ghes_estatus_pool_init(unsigned int num_ghes)
{
unsigned long addr, len;
int rc;
ghes_estatus_pool = gen_pool_create(GHES_ESTATUS_POOL_MIN_ALLOC_ORDER, -1);
if (!ghes_estatus_pool)
return -ENOMEM;
len = GHES_ESTATUS_CACHE_AVG_SIZE * GHES_ESTATUS_CACHE_ALLOCED_MAX;
len += (num_ghes * GHES_ESOURCE_PREALLOC_MAX_SIZE);
addr = (unsigned long)vmalloc(PAGE_ALIGN(len));
if (!addr)
goto err_pool_alloc;
rc = gen_pool_add(ghes_estatus_pool, addr, PAGE_ALIGN(len), -1);
if (rc)
goto err_pool_add;
return 0;
err_pool_add:
vfree((void *)addr);
err_pool_alloc:
gen_pool_destroy(ghes_estatus_pool);
return -ENOMEM;
}
/**
* ghes_estatus_pool_region_free - free previously allocated memory
* from the ghes_estatus_pool.
* @addr: address of memory to free.
* @size: size of memory to free.
*
* Returns none.
*/
void ghes_estatus_pool_region_free(unsigned long addr, u32 size)
{
gen_pool_free(ghes_estatus_pool, addr, size);
}
EXPORT_SYMBOL_GPL(ghes_estatus_pool_region_free);
static int map_gen_v2(struct ghes *ghes)
{
return apei_map_generic_address(&ghes->generic_v2->read_ack_register);
}
static void unmap_gen_v2(struct ghes *ghes)
{
apei_unmap_generic_address(&ghes->generic_v2->read_ack_register);
}
static void ghes_ack_error(struct acpi_hest_generic_v2 *gv2)
{
int rc;
u64 val = 0;
Annotation
- Immediate include surface: `linux/arm_sdei.h`, `linux/kernel.h`, `linux/moduleparam.h`, `linux/init.h`, `linux/acpi.h`, `linux/bitfield.h`, `linux/io.h`, `linux/interrupt.h`.
- Detected declarations: `struct ghes_vendor_record_entry`, `struct ghes_task_work`, `function is_hest_type_generic_v2`, `function errors`, `function ghes_unmap`, `function ghes_estatus_pool_init`, `function ghes_estatus_pool_region_free`, `function map_gen_v2`, `function unmap_gen_v2`, `function ghes_ack_error`.
- Atlas domain: Driver Families / drivers/acpi.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.