Commit 05976c5f authored by Cristian Marussi's avatar Cristian Marussi Committed by Sudeep Holla

firmware: arm_scmi: Support optional system wide atomic-threshold-us

An SCMI agent can be configured system-wide with a well-defined atomic
threshold: only SCMI synchronous command whose latency has been advertised
by the SCMI platform to be lower or equal to this configured threshold will
be considered for atomic operations, when requested and if supported by the
underlying transport at all.

Link: https://lore.kernel.org/r/20220217131234.50328-6-cristian.marussi@arm.comSigned-off-by: default avatarCristian Marussi <cristian.marussi@arm.com>
Signed-off-by: default avatarSudeep Holla <sudeep.holla@arm.com>
parent 0539884c
......@@ -131,6 +131,12 @@ struct scmi_protocol_instance {
* MAX_PROTOCOLS_IMP elements allocated by the base protocol
* @active_protocols: IDR storing device_nodes for protocols actually defined
* in the DT and confirmed as implemented by fw.
* @atomic_threshold: Optional system wide DT-configured threshold, expressed
* in microseconds, for atomic operations.
* Only SCMI synchronous commands reported by the platform
* to have an execution latency lesser-equal to the threshold
* should be considered for atomic mode operation: such
* decision is finally left up to the SCMI drivers.
* @notify_priv: Pointer to private data structure specific to notifications.
* @node: List head
* @users: Number of users of this instance
......@@ -149,6 +155,7 @@ struct scmi_info {
struct mutex protocols_mtx;
u8 *protocols_imp;
struct idr active_protocols;
unsigned int atomic_threshold;
void *notify_priv;
struct list_head node;
int users;
......@@ -1406,15 +1413,22 @@ static void scmi_devm_protocol_put(struct scmi_device *sdev, u8 protocol_id)
* SCMI instance is configured as atomic.
*
* @handle: A reference to the SCMI platform instance.
* @atomic_threshold: An optional return value for the system wide currently
* configured threshold for atomic operations.
*
* Return: True if transport is configured as atomic
*/
static bool scmi_is_transport_atomic(const struct scmi_handle *handle)
static bool scmi_is_transport_atomic(const struct scmi_handle *handle,
unsigned int *atomic_threshold)
{
bool ret;
struct scmi_info *info = handle_to_scmi_info(handle);
return info->desc->atomic_enabled &&
is_transport_polling_capable(info);
ret = info->desc->atomic_enabled && is_transport_polling_capable(info);
if (ret && atomic_threshold)
*atomic_threshold = info->atomic_threshold;
return ret;
}
static inline
......@@ -1954,6 +1968,13 @@ static int scmi_probe(struct platform_device *pdev)
handle->version = &info->version;
handle->devm_protocol_get = scmi_devm_protocol_get;
handle->devm_protocol_put = scmi_devm_protocol_put;
/* System wide atomic threshold for atomic ops .. if any */
if (!of_property_read_u32(np, "atomic-threshold-us",
&info->atomic_threshold))
dev_info(dev,
"SCMI System wide atomic threshold set to %d us\n",
info->atomic_threshold);
handle->is_transport_atomic = scmi_is_transport_atomic;
if (desc->ops->link_supplier) {
......
......@@ -619,6 +619,8 @@ struct scmi_notify_ops {
* be interested to know if they can assume SCMI
* command transactions associated to this handle will
* never sleep and act accordingly.
* An optional atomic threshold value could be returned
* where configured.
* @notify_ops: pointer to set of notifications related operations
*/
struct scmi_handle {
......@@ -629,7 +631,8 @@ struct scmi_handle {
(*devm_protocol_get)(struct scmi_device *sdev, u8 proto,
struct scmi_protocol_handle **ph);
void (*devm_protocol_put)(struct scmi_device *sdev, u8 proto);
bool (*is_transport_atomic)(const struct scmi_handle *handle);
bool (*is_transport_atomic)(const struct scmi_handle *handle,
unsigned int *atomic_threshold);
const struct scmi_notify_ops *notify_ops;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment