// SPDX-License-Identifier: GPL-2.0
/*
* System Control and Management Interface (SCMI) Notification support
*
* Copyright (C) 2020 ARM Ltd.
*/
/**
* DOC: Theory of operation
*
* SCMI Protocol specification allows the platform to signal events to
* interested agents via notification messages: this is an implementation
* of the dispatch and delivery of such notifications to the interested users
* inside the Linux kernel.
*
* An SCMI Notification core instance is initialized for each active platform
* instance identified by the means of the usual &struct scmi_handle.
*
* Each SCMI Protocol implementation, during its initialization, registers with
* this core its set of supported events using scmi_register_protocol_events():
* all the needed descriptors are stored in the &struct registered_protocols and
* &struct registered_events arrays.
*
* Kernel users interested in some specific event can register their callbacks
* providing the usual notifier_block descriptor, since this core implements
* events' delivery using the standard Kernel notification chains machinery.
*
* Given the number of possible events defined by SCMI and the extensibility
* of the SCMI Protocol itself, the underlying notification chains are created
* and destroyed dynamically on demand depending on the number of users
* effectively registered for an event, so that no support structures or chains
* are allocated until at least one user has registered a notifier_block for
* such event. Similarly, events' generation itself is enabled at the platform
* level only after at least one user has registered, and it is shutdown after
* the last user for that event has gone.
*
* All users provided callbacks and allocated notification-chains are stored in
* the @registered_events_handlers hashtable. Callbacks' registration requests
* for still to be registered events are instead kept in the dedicated common
* hashtable @pending_events_handlers.
*
* An event is identified univocally by the tuple (proto_id, evt_id, src_id)
* and is served by its own dedicated notification chain; information con