drivers/firmware/arm_scmi/notify.c
Source file repositories/reference/linux-study-clean/drivers/firmware/arm_scmi/notify.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/firmware/arm_scmi/notify.c- Extension
.c- Size
- 54698 bytes
- Lines
- 1727
- 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
linux/bitfield.hlinux/bug.hlinux/compiler.hlinux/device.hlinux/err.hlinux/hashtable.hlinux/kernel.hlinux/ktime.hlinux/kfifo.hlinux/list.hlinux/mutex.hlinux/notifier.hlinux/refcount.hlinux/scmi_protocol.hlinux/slab.hlinux/types.hlinux/workqueue.hcommon.hnotify.h
Detected Declarations
struct scmi_registered_events_descstruct scmi_notify_instancestruct events_queuestruct scmi_event_headerstruct scmi_registered_eventstruct scmi_registered_events_descstruct scmi_registered_eventstruct scmi_event_handlerstruct scmi_notifier_devresfunction scmi_lookup_and_call_event_chainfunction ERR_PTRfunction scmi_process_event_payloadfunction scmi_events_dispatcherfunction scmi_notifyfunction scmi_kfifo_freefunction scmi_initialize_events_queuefunction scmi_allocate_registered_events_descfunction scmi_register_protocol_eventsfunction scmi_deregister_protocol_eventsfunction scmi_allocate_event_handlerfunction scmi_free_event_handlerfunction scmi_bind_event_handlerfunction eventfunction scmi_register_event_handlerfunction alwaysfunction scmi_get_handlerfunction scmi_get_or_create_handlerfunction scmi_get_active_handlerfunction __scmi_enable_evtfunction scmi_enable_eventsfunction scmi_disable_eventsfunction scmi_put_handler_unlockedfunction scmi_put_handlerfunction scmi_put_active_handlerfunction scmi_event_handler_enable_eventsfunction scmi_notifier_registerfunction scmi_notifier_unregisterfunction scmi_devm_release_notifierfunction scmi_devm_notifier_registerfunction scmi_devm_notifier_matchfunction scmi_devm_notifier_unregisterfunction scmi_protocols_late_initfunction scmi_protocols_late_initfunction scmi_notification_exit
Annotated Snippet
struct scmi_notify_instance {
void *gid;
struct scmi_handle *handle;
struct work_struct init_work;
struct workqueue_struct *notify_wq;
/* lock to protect pending_events_handlers */
struct mutex pending_mtx;
struct scmi_registered_events_desc **registered_protocols;
DECLARE_HASHTABLE(pending_events_handlers, SCMI_PENDING_HASH_SZ);
};
/**
* struct events_queue - Describes a queue and its associated worker
* @sz: Size in bytes of the related kfifo
* @kfifo: A dedicated Kernel kfifo descriptor
* @notify_work: A custom work item bound to this queue
* @wq: A reference to the associated workqueue
*
* Each protocol has its own dedicated events_queue descriptor.
*/
struct events_queue {
size_t sz;
struct kfifo kfifo;
struct work_struct notify_work;
struct workqueue_struct *wq;
};
/**
* struct scmi_event_header - A utility header
* @timestamp: The timestamp, in nanoseconds (boottime), which was associated
* to this event as soon as it entered the SCMI RX ISR
* @payld_sz: Effective size of the embedded message payload which follows
* @evt_id: Event ID (corresponds to the Event MsgID for this Protocol)
* @payld: A reference to the embedded event payload
*
* This header is prepended to each received event message payload before
* queueing it on the related &struct events_queue.
*/
struct scmi_event_header {
ktime_t timestamp;
size_t payld_sz;
unsigned char evt_id;
unsigned char payld[];
};
struct scmi_registered_event;
/**
* struct scmi_registered_events_desc - Protocol Specific information
* @id: Protocol ID
* @ops: Protocol specific and event-related operations
* @equeue: The embedded per-protocol events_queue
* @ni: A reference to the initialized instance descriptor
* @eh: A reference to pre-allocated buffer to be used as a scratch area by the
* deferred worker when fetching data from the kfifo
* @eh_sz: Size of the pre-allocated buffer @eh
* @in_flight: A reference to an in flight &struct scmi_registered_event
* @num_events: Number of events in @registered_events
* @registered_events: A dynamically allocated array holding all the registered
* events' descriptors, whose fixed-size is determined at
* compile time.
* @registered_mtx: A mutex to protect @registered_events_handlers
* @ph: SCMI protocol handle reference
* @registered_events_handlers: An hashtable containing all events' handlers
* descriptors registered for this protocol
*
* All protocols that register at least one event have their protocol-specific
* information stored here, together with the embedded allocated events_queue.
* These descriptors are stored in the @registered_protocols array at protocol
* registration time.
*
* Once these descriptors are successfully registered, they are NEVER again
* removed or modified since protocols do not unregister ever, so that, once
* we safely grab a NON-NULL reference from the array we can keep it and use it.
*/
struct scmi_registered_events_desc {
u8 id;
const struct scmi_event_ops *ops;
struct events_queue equeue;
struct scmi_notify_instance *ni;
struct scmi_event_header *eh;
size_t eh_sz;
void *in_flight;
int num_events;
struct scmi_registered_event **registered_events;
/* mutex to protect registered_events_handlers */
struct mutex registered_mtx;
const struct scmi_protocol_handle *ph;
DECLARE_HASHTABLE(registered_events_handlers, SCMI_REGISTERED_HASH_SZ);
};
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/bug.h`, `linux/compiler.h`, `linux/device.h`, `linux/err.h`, `linux/hashtable.h`, `linux/kernel.h`, `linux/ktime.h`.
- Detected declarations: `struct scmi_registered_events_desc`, `struct scmi_notify_instance`, `struct events_queue`, `struct scmi_event_header`, `struct scmi_registered_event`, `struct scmi_registered_events_desc`, `struct scmi_registered_event`, `struct scmi_event_handler`, `struct scmi_notifier_devres`, `function scmi_lookup_and_call_event_chain`.
- 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.