drivers/firmware/arm_sdei.c
Source file repositories/reference/linux-study-clean/drivers/firmware/arm_sdei.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/arm_sdei.c- Extension
.c- Size
- 24455 bytes
- Lines
- 1122
- Domain
- Driver Families
- Bucket
- drivers/firmware
- Inferred role
- Driver Families: implementation source
- Status
- source 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.
- 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
acpi/ghes.hlinux/acpi.hlinux/arm_sdei.hlinux/arm-smccc.hlinux/atomic.hlinux/bitops.hlinux/compiler.hlinux/cpuhotplug.hlinux/cpu.hlinux/cpu_pm.hlinux/errno.hlinux/hardirq.hlinux/kernel.hlinux/kprobes.hlinux/kvm_host.hlinux/list.hlinux/mutex.hlinux/notifier.hlinux/of.hlinux/of_platform.hlinux/percpu.hlinux/platform_device.hlinux/pm.hlinux/ptrace.hlinux/preempt.hlinux/reboot.hlinux/slab.hlinux/smp.hlinux/spinlock.h
Detected Declarations
struct sdei_eventstruct sdei_crosscall_argsfunction sdei_do_local_callfunction sdei_do_cross_callfunction sdei_cross_call_returnfunction sdei_to_linux_errnofunction invoke_sdei_fnfunction sdei_api_event_contextfunction sdei_api_event_get_infofunction for_each_possible_cpufunction sdei_event_destroy_llockedfunction sdei_event_destroyfunction sdei_api_get_versionfunction sdei_mask_local_cpufunction _ipi_mask_cpufunction sdei_unmask_local_cpufunction _ipi_unmask_cpufunction _ipi_private_resetfunction sdei_api_shared_resetfunction sdei_mark_interface_brokenfunction sdei_platform_resetfunction sdei_api_event_enablefunction _local_event_enablefunction sdei_event_enablefunction sdei_api_event_disablefunction _ipi_event_disablefunction sdei_event_disablefunction sdei_api_event_unregisterfunction _local_event_unregisterfunction sdei_event_unregisterfunction sdei_reregister_sharedfunction sdei_api_event_registerfunction _local_event_registerfunction sdei_event_registerfunction sdei_reregister_sharedfunction sdei_cpuhp_downfunction sdei_cpuhp_upfunction sdei_pm_notifierfunction sdei_device_suspendfunction sdei_device_resumefunction sdei_device_freezefunction sdei_device_thawfunction sdei_device_restorefunction sdei_reboot_notifierfunction sdei_smccc_smcfunction sdei_smccc_hvcfunction sdei_register_ghesfunction sdei_unregister_ghes
Annotated Snippet
struct sdei_event {
/* These three are protected by the sdei_list_lock */
struct list_head list;
bool reregister;
bool reenable;
u32 event_num;
u8 type;
u8 priority;
/* This pointer is handed to firmware as the event argument. */
union {
/* Shared events */
struct sdei_registered_event *registered;
/* CPU private events */
struct sdei_registered_event __percpu *private_registered;
};
};
/* Take the mutex for any API call or modification. Take the mutex first. */
static DEFINE_MUTEX(sdei_events_lock);
/* and then hold this when modifying the list */
static DEFINE_SPINLOCK(sdei_list_lock);
static LIST_HEAD(sdei_list);
/* Private events are registered/enabled via IPI passing one of these */
struct sdei_crosscall_args {
struct sdei_event *event;
atomic_t errors;
int first_error;
};
#define CROSSCALL_INIT(arg, event) \
do { \
arg.event = event; \
arg.first_error = 0; \
atomic_set(&arg.errors, 0); \
} while (0)
static inline int sdei_do_local_call(smp_call_func_t fn,
struct sdei_event *event)
{
struct sdei_crosscall_args arg;
CROSSCALL_INIT(arg, event);
fn(&arg);
return arg.first_error;
}
static inline int sdei_do_cross_call(smp_call_func_t fn,
struct sdei_event *event)
{
struct sdei_crosscall_args arg;
CROSSCALL_INIT(arg, event);
on_each_cpu(fn, &arg, true);
return arg.first_error;
}
static inline void
sdei_cross_call_return(struct sdei_crosscall_args *arg, int err)
{
if (err && (atomic_inc_return(&arg->errors) == 1))
arg->first_error = err;
}
static int sdei_to_linux_errno(unsigned long sdei_err)
{
switch (sdei_err) {
case SDEI_NOT_SUPPORTED:
return -EOPNOTSUPP;
case SDEI_INVALID_PARAMETERS:
return -EINVAL;
case SDEI_DENIED:
return -EPERM;
case SDEI_PENDING:
return -EINPROGRESS;
case SDEI_OUT_OF_RESOURCE:
return -ENOMEM;
}
return 0;
}
static int invoke_sdei_fn(unsigned long function_id, unsigned long arg0,
unsigned long arg1, unsigned long arg2,
Annotation
- Immediate include surface: `acpi/ghes.h`, `linux/acpi.h`, `linux/arm_sdei.h`, `linux/arm-smccc.h`, `linux/atomic.h`, `linux/bitops.h`, `linux/compiler.h`, `linux/cpuhotplug.h`.
- Detected declarations: `struct sdei_event`, `struct sdei_crosscall_args`, `function sdei_do_local_call`, `function sdei_do_cross_call`, `function sdei_cross_call_return`, `function sdei_to_linux_errno`, `function invoke_sdei_fn`, `function sdei_api_event_context`, `function sdei_api_event_get_info`, `function for_each_possible_cpu`.
- Atlas domain: Driver Families / drivers/firmware.
- 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.