Lines Matching +full:protocol +full:- +full:id
1 // SPDX-License-Identifier: GPL-2.0
3 * System Control and Management Interface (SCMI) Message Protocol driver
5 * SCMI Message Protocol is used between the System Control Processor(SCP)
7 * provides a mechanism for inter-processor communication between SCP's
14 * Copyright (C) 2018-2024 ARM Ltd.
25 #include <linux/io-64-nonatomic-hi-lo.h>
47 #define SCMI_VENDOR_MODULE_ALIAS_FMT "scmi-protocol-0x%02x-%s"
57 /* Track the unique id for the transfers for debug & profiling purpose */
63 * struct scmi_xfers_info - Structure to manage transfer information
71 * a number of xfers equal to the maximum allowed in-flight
74 * currently in-flight messages.
85 * struct scmi_protocol_instance - Describe an initialized protocol instance.
86 * @handle: Reference to the SCMI handle associated to this protocol instance.
87 * @proto: A reference to the protocol descriptor.
88 * @gid: A reference for per-protocol devres management.
89 * @users: A refcount to track effective users of this protocol.
90 * @priv: Reference for optional protocol private data.
91 * @version: Protocol version supported by the platform as detected at runtime.
92 * @negotiated_version: When the platform supports a newer protocol version,
96 * This field is NON-zero when a successful negotiation
98 * @ph: An embedded protocol handle that will be passed down to protocol
101 * Each protocol is initialized independently once for each SCMI platform in
118 * struct scmi_debug_info - Debug common info
134 * struct scmi_info - Structure representing a SCMI instance
136 * @id: A sequence number starting from zero identifying this instance
139 * @version: SCMI revision information containing protocol version,
140 * implementation version and (sub-)vendor identification.
144 * @tx_idr: IDR object to map protocol id to Tx channel info pointer
145 * @rx_idr: IDR object to map protocol id to Rx channel info pointer
147 * this SCMI instance: populated on protocol's first attempted
152 * base protocol
166 int id; member
286 proto = scmi_vendor_protocol_lookup(protocol_id, version->vendor_id, in scmi_vendor_protocol_get()
287 version->sub_vendor_id, in scmi_vendor_protocol_get()
288 version->impl_ver); in scmi_vendor_protocol_get()
293 protocol_id, version->vendor_id); in scmi_vendor_protocol_get()
297 protocol_id, version->vendor_id); in scmi_vendor_protocol_get()
299 pr_warn("Problem loading module for protocol 0x%x\n", in scmi_vendor_protocol_get()
306 version->vendor_id, in scmi_vendor_protocol_get()
307 version->sub_vendor_id, in scmi_vendor_protocol_get()
308 version->impl_ver); in scmi_vendor_protocol_get()
312 pr_info("Loaded SCMI Vendor Protocol 0x%x - %s %s %X\n", in scmi_vendor_protocol_get()
313 protocol_id, proto->vendor_id ?: "", in scmi_vendor_protocol_get()
314 proto->sub_vendor_id ?: "", proto->impl_ver); in scmi_vendor_protocol_get()
329 if (!proto || !try_module_get(proto->owner)) { in scmi_protocol_get()
330 pr_warn("SCMI Protocol 0x%x not found!\n", protocol_id); in scmi_protocol_get()
334 pr_debug("Found SCMI Protocol 0x%x\n", protocol_id); in scmi_protocol_get()
342 module_put(proto->owner); in scmi_protocol_put()
347 if (!proto->vendor_id) { in scmi_vendor_protocol_check()
348 pr_err("missing vendor_id for protocol 0x%x\n", proto->id); in scmi_vendor_protocol_check()
349 return -EINVAL; in scmi_vendor_protocol_check()
352 if (strlen(proto->vendor_id) >= SCMI_SHORT_NAME_MAX_SIZE) { in scmi_vendor_protocol_check()
353 pr_err("malformed vendor_id for protocol 0x%x\n", proto->id); in scmi_vendor_protocol_check()
354 return -EINVAL; in scmi_vendor_protocol_check()
357 if (proto->sub_vendor_id && in scmi_vendor_protocol_check()
358 strlen(proto->sub_vendor_id) >= SCMI_SHORT_NAME_MAX_SIZE) { in scmi_vendor_protocol_check()
359 pr_err("malformed sub_vendor_id for protocol 0x%x\n", in scmi_vendor_protocol_check()
360 proto->id); in scmi_vendor_protocol_check()
361 return -EINVAL; in scmi_vendor_protocol_check()
373 pr_err("invalid protocol\n"); in scmi_protocol_register()
374 return -EINVAL; in scmi_protocol_register()
377 if (!proto->instance_init) { in scmi_protocol_register()
378 pr_err("missing init for protocol 0x%x\n", proto->id); in scmi_protocol_register()
379 return -EINVAL; in scmi_protocol_register()
382 if (proto->id >= SCMI_PROTOCOL_VENDOR_BASE && in scmi_protocol_register()
384 return -EINVAL; in scmi_protocol_register()
387 * Calculate a protocol key to register this protocol with the core; in scmi_protocol_register()
390 key = scmi_protocol_key_calculate(proto->id, proto->vendor_id, in scmi_protocol_register()
391 proto->sub_vendor_id, in scmi_protocol_register()
392 proto->impl_ver); in scmi_protocol_register()
394 return -EINVAL; in scmi_protocol_register()
398 pr_err("unable to allocate SCMI protocol slot for 0x%x - err %d\n", in scmi_protocol_register()
399 proto->id, ret); in scmi_protocol_register()
403 pr_debug("Registered SCMI Protocol 0x%x - %s %s 0x%08X\n", in scmi_protocol_register()
404 proto->id, proto->vendor_id, proto->sub_vendor_id, in scmi_protocol_register()
405 proto->impl_ver); in scmi_protocol_register()
415 key = scmi_protocol_key_calculate(proto->id, proto->vendor_id, in scmi_protocol_unregister()
416 proto->sub_vendor_id, in scmi_protocol_unregister()
417 proto->impl_ver); in scmi_protocol_unregister()
423 pr_debug("Unregistered SCMI Protocol 0x%x\n", proto->id); in scmi_protocol_unregister()
428 * scmi_create_protocol_devices - Create devices for all pending requests for
431 * @np: The device node describing the protocol
433 * @prot_id: The protocol ID
436 * for the specified protocol.
444 mutex_lock(&info->devreq_mtx); in scmi_create_protocol_devices()
445 sdev = scmi_device_create(np, info->dev, prot_id, name); in scmi_create_protocol_devices()
447 dev_err(info->dev, in scmi_create_protocol_devices()
448 "failed to create device for protocol 0x%X (%s)\n", in scmi_create_protocol_devices()
450 mutex_unlock(&info->devreq_mtx); in scmi_create_protocol_devices()
456 mutex_lock(&info->devreq_mtx); in scmi_destroy_protocol_devices()
457 scmi_device_destroy(info->dev, prot_id, name); in scmi_destroy_protocol_devices()
458 mutex_unlock(&info->devreq_mtx); in scmi_destroy_protocol_devices()
466 info->notify_priv = priv; in scmi_notification_instance_data_set()
467 /* Ensure updated protocol private date are visible */ in scmi_notification_instance_data_set()
477 return info->notify_priv; in scmi_notification_instance_data_get()
481 * scmi_xfer_token_set - Reserve and set new token for the xfer at hand
487 * xfer->hdr.seq: picking a monotonically increasing value avoids immediate
488 * reuse of freshly completed or timed-out xfers, thus mitigating the risk
489 * of incorrect association of a late and expired xfer with a live in-flight
490 * transaction, both happening to re-use the same token identifier.
492 * Since platform is NOT required to answer our request in-order we should
495 * - exactly 'next_token' may be NOT available so pick xfer_id >= next_token
498 * - all tokens ahead upto (MSG_TOKEN_ID_MASK - 1) are used in-flight but we
502 * X = used in-flight
505 * ------
507 * |- xfer_id picked
508 * -----------+----------------------------------------------------------
510 * ----------------------------------------------------------------------
512 * |- next_token
514 * Out-of-order pending at start
515 * -----------------------------
517 * |- xfer_id picked, last_token fixed
518 * -----+----------------------------------------------------------------
520 * ----------------------------------------------------------------------
522 * |- next_token
525 * Out-of-order pending at end
526 * ---------------------------
528 * |- xfer_id picked, last_token fixed
529 * -----+----------------------------------------------------------------
531 * ----------------------------------------------------------------------
533 * |- next_token
545 * Pick a candidate monotonic token in range [0, MSG_TOKEN_MAX - 1] in scmi_xfer_token_set()
546 * using the pre-allocated transfer_id as a base. in scmi_xfer_token_set()
552 next_token = (xfer->transfer_id & (MSG_TOKEN_MAX - 1)); in scmi_xfer_token_set()
555 xfer_id = find_next_zero_bit(minfo->xfer_alloc_table, in scmi_xfer_token_set()
559 * After heavily out-of-order responses, there are no free in scmi_xfer_token_set()
563 xfer_id = find_next_zero_bit(minfo->xfer_alloc_table, in scmi_xfer_token_set()
567 * maximum number of (MSG_TOKEN_MAX - 1) in-flight messages in scmi_xfer_token_set()
568 * but we have not found any free token [0, MSG_TOKEN_MAX - 1]. in scmi_xfer_token_set()
571 return -ENOMEM; in scmi_xfer_token_set()
574 /* Update +/- last_token accordingly if we skipped some hole */ in scmi_xfer_token_set()
576 atomic_add((int)(xfer_id - next_token), &transfer_last_id); in scmi_xfer_token_set()
578 xfer->hdr.seq = (u16)xfer_id; in scmi_xfer_token_set()
584 * scmi_xfer_token_clear - Release the token
592 clear_bit(xfer->hdr.seq, minfo->xfer_alloc_table); in scmi_xfer_token_clear()
596 * scmi_xfer_inflight_register_unlocked - Register the xfer as in-flight
601 * Note that this helper assumes that the xfer to be registered as in-flight
611 /* Set in-flight */ in scmi_xfer_inflight_register_unlocked()
612 set_bit(xfer->hdr.seq, minfo->xfer_alloc_table); in scmi_xfer_inflight_register_unlocked()
613 hash_add(minfo->pending_xfers, &xfer->node, xfer->hdr.seq); in scmi_xfer_inflight_register_unlocked()
614 xfer->pending = true; in scmi_xfer_inflight_register_unlocked()
618 * scmi_xfer_inflight_register - Try to register an xfer as in-flight
626 * same sequence number is currently still registered as in-flight.
628 * Return: 0 on Success or -EBUSY if sequence number embedded in the xfer
637 spin_lock_irqsave(&minfo->xfer_lock, flags); in scmi_xfer_inflight_register()
638 if (!test_bit(xfer->hdr.seq, minfo->xfer_alloc_table)) in scmi_xfer_inflight_register()
641 ret = -EBUSY; in scmi_xfer_inflight_register()
642 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_inflight_register()
648 * scmi_xfer_raw_inflight_register - An helper to register the given xfer as in
661 return scmi_xfer_inflight_register(xfer, &info->tx_minfo); in scmi_xfer_raw_inflight_register()
665 * scmi_xfer_pending_set - Pick a proper sequence number and mark the xfer
666 * as pending in-flight
679 spin_lock_irqsave(&minfo->xfer_lock, flags); in scmi_xfer_pending_set()
684 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_pending_set()
690 * scmi_xfer_get() - Allocate one message
716 spin_lock_irqsave(&minfo->xfer_lock, flags); in scmi_xfer_get()
717 if (hlist_empty(&minfo->free_xfers)) { in scmi_xfer_get()
718 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_get()
719 return ERR_PTR(-ENOMEM); in scmi_xfer_get()
723 xfer = hlist_entry(minfo->free_xfers.first, struct scmi_xfer, node); in scmi_xfer_get()
724 hlist_del_init(&xfer->node); in scmi_xfer_get()
730 xfer->transfer_id = atomic_inc_return(&transfer_last_id); in scmi_xfer_get()
732 refcount_set(&xfer->users, 1); in scmi_xfer_get()
733 atomic_set(&xfer->busy, SCMI_XFER_FREE); in scmi_xfer_get()
734 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_get()
740 * scmi_xfer_raw_get - Helper to get a bare free xfer from the TX channel
746 * Return: A valid xfer on Success, or an error-pointer otherwise
753 xfer = scmi_xfer_get(handle, &info->tx_minfo); in scmi_xfer_raw_get()
755 xfer->flags |= SCMI_XFER_FLAG_IS_RAW; in scmi_xfer_raw_get()
761 * scmi_xfer_raw_channel_get - Helper to get a reference to the proper channel
765 * @protocol_id: Identifier of the protocol
767 * Note that in a regular SCMI stack, usually, a protocol has to be defined in
769 * protocol in range is allowed, re-using the Base channel, so as to enable
770 * fuzzing on any protocol without the need of a fully compiled DT.
780 cinfo = idr_find(&info->tx_idr, protocol_id); in scmi_xfer_raw_channel_get()
783 return ERR_PTR(-EINVAL); in scmi_xfer_raw_channel_get()
785 cinfo = idr_find(&info->tx_idr, SCMI_PROTOCOL_BASE); in scmi_xfer_raw_channel_get()
787 return ERR_PTR(-EINVAL); in scmi_xfer_raw_channel_get()
788 dev_warn_once(handle->dev, in scmi_xfer_raw_channel_get()
789 "Using Base channel for protocol 0x%X\n", in scmi_xfer_raw_channel_get()
797 * __scmi_xfer_put() - Release a message
812 spin_lock_irqsave(&minfo->xfer_lock, flags); in __scmi_xfer_put()
813 if (refcount_dec_and_test(&xfer->users)) { in __scmi_xfer_put()
814 if (xfer->pending) { in __scmi_xfer_put()
816 hash_del(&xfer->node); in __scmi_xfer_put()
817 xfer->pending = false; in __scmi_xfer_put()
819 hlist_add_head(&xfer->node, &minfo->free_xfers); in __scmi_xfer_put()
821 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in __scmi_xfer_put()
825 * scmi_xfer_raw_put - Release an xfer that was taken by @scmi_xfer_raw_get
837 xfer->flags &= ~SCMI_XFER_FLAG_IS_RAW; in scmi_xfer_raw_put()
838 xfer->flags &= ~SCMI_XFER_FLAG_CHAN_SET; in scmi_xfer_raw_put()
839 return __scmi_xfer_put(&info->tx_minfo, xfer); in scmi_xfer_raw_put()
843 * scmi_xfer_lookup_unlocked - Helper to lookup an xfer_id
846 * @xfer_id: Token ID to lookup in @pending_xfers
859 if (test_bit(xfer_id, minfo->xfer_alloc_table)) in scmi_xfer_lookup_unlocked()
860 xfer = XFER_FIND(minfo->pending_xfers, xfer_id); in scmi_xfer_lookup_unlocked()
862 return xfer ?: ERR_PTR(-EINVAL); in scmi_xfer_lookup_unlocked()
866 * scmi_bad_message_trace - A helper to trace weird messages
874 * timed-out message that arrives and as such, can be traced only referring to
881 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_bad_message_trace()
898 trace_scmi_msg_dump(info->id, cinfo->id, in scmi_bad_message_trace()
905 * scmi_msg_response_validate - Validate message type against state of related
914 * related synchronous response (Out-of-Order Delayed Response) the missing
917 * SCMI transport can deliver such out-of-order responses.
919 * Context: Assumes to be called with xfer->lock already acquired.
930 * delayed response we're not prepared to handle: bail-out safely in scmi_msg_response_validate()
933 if (msg_type == MSG_TYPE_DELAYED_RESP && !xfer->async_done) { in scmi_msg_response_validate()
934 dev_err(cinfo->dev, in scmi_msg_response_validate()
936 xfer->hdr.seq); in scmi_msg_response_validate()
937 return -EINVAL; in scmi_msg_response_validate()
940 switch (xfer->state) { in scmi_msg_response_validate()
947 xfer->hdr.status = SCMI_SUCCESS; in scmi_msg_response_validate()
948 xfer->state = SCMI_XFER_RESP_OK; in scmi_msg_response_validate()
949 complete(&xfer->done); in scmi_msg_response_validate()
950 dev_warn(cinfo->dev, in scmi_msg_response_validate()
952 xfer->hdr.seq); in scmi_msg_response_validate()
957 return -EINVAL; in scmi_msg_response_validate()
961 return -EINVAL; in scmi_msg_response_validate()
968 * scmi_xfer_state_update - Update xfer state
981 xfer->hdr.type = msg_type; in scmi_xfer_state_update()
984 if (xfer->hdr.type == MSG_TYPE_COMMAND) in scmi_xfer_state_update()
985 xfer->state = SCMI_XFER_RESP_OK; in scmi_xfer_state_update()
987 xfer->state = SCMI_XFER_DRESP_OK; in scmi_xfer_state_update()
994 ret = atomic_cmpxchg(&xfer->busy, SCMI_XFER_FREE, SCMI_XFER_BUSY); in scmi_xfer_acquired()
1000 * scmi_xfer_command_acquire - Helper to lookup and acquire a command xfer
1017 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_xfer_command_acquire()
1018 struct scmi_xfers_info *minfo = &info->tx_minfo; in scmi_xfer_command_acquire()
1023 spin_lock_irqsave(&minfo->xfer_lock, flags); in scmi_xfer_command_acquire()
1026 dev_err(cinfo->dev, in scmi_xfer_command_acquire()
1029 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_command_acquire()
1032 scmi_inc_count(info->dbg->counters, ERR_MSG_UNEXPECTED); in scmi_xfer_command_acquire()
1036 refcount_inc(&xfer->users); in scmi_xfer_command_acquire()
1037 spin_unlock_irqrestore(&minfo->xfer_lock, flags); in scmi_xfer_command_acquire()
1039 spin_lock_irqsave(&xfer->lock, flags); in scmi_xfer_command_acquire()
1052 spin_unlock_irqrestore(&xfer->lock, flags); in scmi_xfer_command_acquire()
1055 dev_err(cinfo->dev, in scmi_xfer_command_acquire()
1056 "Invalid message type:%d for %d - HDR:0x%X state:%d\n", in scmi_xfer_command_acquire()
1057 msg_type, xfer_id, msg_hdr, xfer->state); in scmi_xfer_command_acquire()
1060 scmi_inc_count(info->dbg->counters, ERR_MSG_INVALID); in scmi_xfer_command_acquire()
1064 xfer = ERR_PTR(-EINVAL); in scmi_xfer_command_acquire()
1073 atomic_set(&xfer->busy, SCMI_XFER_FREE); in scmi_xfer_command_release()
1074 __scmi_xfer_put(&info->tx_minfo, xfer); in scmi_xfer_command_release()
1080 if (!cinfo->is_p2a) { in scmi_clear_channel()
1081 dev_warn(cinfo->dev, "Invalid clear on A2P channel !\n"); in scmi_clear_channel()
1085 if (info->desc->ops->clear_channel) in scmi_clear_channel()
1086 info->desc->ops->clear_channel(cinfo); in scmi_clear_channel()
1093 struct device *dev = cinfo->dev; in scmi_handle_notification()
1094 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_handle_notification()
1095 struct scmi_xfers_info *minfo = &info->rx_minfo; in scmi_handle_notification()
1099 xfer = scmi_xfer_get(cinfo->handle, minfo); in scmi_handle_notification()
1105 scmi_inc_count(info->dbg->counters, ERR_MSG_NOMEM); in scmi_handle_notification()
1111 unpack_scmi_header(msg_hdr, &xfer->hdr); in scmi_handle_notification()
1113 /* Ensure order between xfer->priv store and following ops */ in scmi_handle_notification()
1114 smp_store_mb(xfer->priv, priv); in scmi_handle_notification()
1115 info->desc->ops->fetch_notification(cinfo, info->desc->max_msg_size, in scmi_handle_notification()
1118 trace_scmi_msg_dump(info->id, cinfo->id, xfer->hdr.protocol_id, in scmi_handle_notification()
1119 xfer->hdr.id, "NOTI", xfer->hdr.seq, in scmi_handle_notification()
1120 xfer->hdr.status, xfer->rx.buf, xfer->rx.len); in scmi_handle_notification()
1121 scmi_inc_count(info->dbg->counters, NOTIFICATION_OK); in scmi_handle_notification()
1123 scmi_notify(cinfo->handle, xfer->hdr.protocol_id, in scmi_handle_notification()
1124 xfer->hdr.id, xfer->rx.buf, xfer->rx.len, ts); in scmi_handle_notification()
1126 trace_scmi_rx_done(xfer->transfer_id, xfer->hdr.id, in scmi_handle_notification()
1127 xfer->hdr.protocol_id, xfer->hdr.seq, in scmi_handle_notification()
1131 xfer->hdr.seq = MSG_XTRACT_TOKEN(msg_hdr); in scmi_handle_notification()
1132 scmi_raw_message_report(info->raw, xfer, SCMI_RAW_NOTIF_QUEUE, in scmi_handle_notification()
1133 cinfo->id); in scmi_handle_notification()
1145 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_handle_response()
1150 scmi_raw_error_report(info->raw, cinfo, msg_hdr, priv); in scmi_handle_response()
1158 if (xfer->hdr.type == MSG_TYPE_DELAYED_RESP) in scmi_handle_response()
1159 xfer->rx.len = info->desc->max_msg_size; in scmi_handle_response()
1162 /* Ensure order between xfer->priv store and following ops */ in scmi_handle_response()
1163 smp_store_mb(xfer->priv, priv); in scmi_handle_response()
1164 info->desc->ops->fetch_response(cinfo, xfer); in scmi_handle_response()
1166 trace_scmi_msg_dump(info->id, cinfo->id, xfer->hdr.protocol_id, in scmi_handle_response()
1167 xfer->hdr.id, in scmi_handle_response()
1168 xfer->hdr.type == MSG_TYPE_DELAYED_RESP ? in scmi_handle_response()
1171 xfer->hdr.seq, xfer->hdr.status, in scmi_handle_response()
1172 xfer->rx.buf, xfer->rx.len); in scmi_handle_response()
1174 trace_scmi_rx_done(xfer->transfer_id, xfer->hdr.id, in scmi_handle_response()
1175 xfer->hdr.protocol_id, xfer->hdr.seq, in scmi_handle_response()
1176 xfer->hdr.type); in scmi_handle_response()
1178 if (xfer->hdr.type == MSG_TYPE_DELAYED_RESP) { in scmi_handle_response()
1180 complete(xfer->async_done); in scmi_handle_response()
1181 scmi_inc_count(info->dbg->counters, DELAYED_RESPONSE_OK); in scmi_handle_response()
1183 complete(&xfer->done); in scmi_handle_response()
1184 scmi_inc_count(info->dbg->counters, RESPONSE_OK); in scmi_handle_response()
1193 if (!xfer->hdr.poll_completion) in scmi_handle_response()
1194 scmi_raw_message_report(info->raw, xfer, in scmi_handle_response()
1196 cinfo->id); in scmi_handle_response()
1203 * scmi_rx_callback() - callback for receiving messages
1236 * xfer_put() - Release a transmit message
1238 * @ph: Pointer to SCMI protocol handle
1245 struct scmi_info *info = handle_to_scmi_info(pi->handle); in xfer_put()
1247 __scmi_xfer_put(&info->tx_minfo, xfer); in xfer_put()
1254 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_xfer_done_no_timeout()
1257 * Poll also on xfer->done so that polling can be forcibly terminated in scmi_xfer_done_no_timeout()
1258 * in case of out-of-order receptions of delayed responses in scmi_xfer_done_no_timeout()
1260 return info->desc->ops->poll_done(cinfo, xfer) || in scmi_xfer_done_no_timeout()
1261 (*ooo = try_wait_for_completion(&xfer->done)) || in scmi_xfer_done_no_timeout()
1270 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_wait_for_reply()
1272 if (xfer->hdr.poll_completion) { in scmi_wait_for_reply()
1277 if (!desc->sync_cmds_completed_on_ret) { in scmi_wait_for_reply()
1288 if (!ooo && !info->desc->ops->poll_done(cinfo, xfer)) { in scmi_wait_for_reply()
1290 "timed out in resp(caller: %pS) - polling\n", in scmi_wait_for_reply()
1292 ret = -ETIMEDOUT; in scmi_wait_for_reply()
1293 scmi_inc_count(info->dbg->counters, XFERS_RESPONSE_POLLED_TIMEOUT); in scmi_wait_for_reply()
1301 * Do not fetch_response if an out-of-order delayed in scmi_wait_for_reply()
1304 spin_lock_irqsave(&xfer->lock, flags); in scmi_wait_for_reply()
1305 if (xfer->state == SCMI_XFER_SENT_OK) { in scmi_wait_for_reply()
1306 desc->ops->fetch_response(cinfo, xfer); in scmi_wait_for_reply()
1307 xfer->state = SCMI_XFER_RESP_OK; in scmi_wait_for_reply()
1309 spin_unlock_irqrestore(&xfer->lock, flags); in scmi_wait_for_reply()
1312 trace_scmi_msg_dump(info->id, cinfo->id, in scmi_wait_for_reply()
1313 xfer->hdr.protocol_id, xfer->hdr.id, in scmi_wait_for_reply()
1316 xfer->hdr.seq, xfer->hdr.status, in scmi_wait_for_reply()
1317 xfer->rx.buf, xfer->rx.len); in scmi_wait_for_reply()
1318 scmi_inc_count(info->dbg->counters, RESPONSE_POLLED_OK); in scmi_wait_for_reply()
1321 scmi_raw_message_report(info->raw, xfer, in scmi_wait_for_reply()
1323 cinfo->id); in scmi_wait_for_reply()
1328 if (!wait_for_completion_timeout(&xfer->done, in scmi_wait_for_reply()
1332 ret = -ETIMEDOUT; in scmi_wait_for_reply()
1333 scmi_inc_count(info->dbg->counters, XFERS_RESPONSE_TIMEOUT); in scmi_wait_for_reply()
1341 * scmi_wait_for_message_response - An helper to group all the possible ways of
1347 * Chooses waiting strategy (sleep-waiting vs busy-waiting) depending on
1348 * configuration flags like xfer->hdr.poll_completion.
1355 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_wait_for_message_response()
1356 struct device *dev = info->dev; in scmi_wait_for_message_response()
1358 trace_scmi_xfer_response_wait(xfer->transfer_id, xfer->hdr.id, in scmi_wait_for_message_response()
1359 xfer->hdr.protocol_id, xfer->hdr.seq, in scmi_wait_for_message_response()
1360 info->desc->max_rx_timeout_ms, in scmi_wait_for_message_response()
1361 xfer->hdr.poll_completion); in scmi_wait_for_message_response()
1363 return scmi_wait_for_reply(dev, info->desc, cinfo, xfer, in scmi_wait_for_message_response()
1364 info->desc->max_rx_timeout_ms); in scmi_wait_for_message_response()
1368 * scmi_xfer_raw_wait_for_message_response - An helper to wait for a message
1382 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_xfer_raw_wait_for_message_response()
1383 struct device *dev = info->dev; in scmi_xfer_raw_wait_for_message_response()
1385 ret = scmi_wait_for_reply(dev, info->desc, cinfo, xfer, timeout_ms); in scmi_xfer_raw_wait_for_message_response()
1387 dev_dbg(dev, "timed out in RAW response - HDR:%08X\n", in scmi_xfer_raw_wait_for_message_response()
1388 pack_scmi_header(&xfer->hdr)); in scmi_xfer_raw_wait_for_message_response()
1394 * do_xfer() - Do one transfer
1396 * @ph: Pointer to SCMI protocol handle
1399 * Return: -ETIMEDOUT in case of no response, if transmit error,
1408 struct scmi_info *info = handle_to_scmi_info(pi->handle); in do_xfer()
1409 struct device *dev = info->dev; in do_xfer()
1413 if (xfer->hdr.poll_completion && in do_xfer()
1414 !is_transport_polling_capable(info->desc)) { in do_xfer()
1417 scmi_inc_count(info->dbg->counters, SENT_FAIL_POLLING_UNSUPPORTED); in do_xfer()
1418 return -EINVAL; in do_xfer()
1421 cinfo = idr_find(&info->tx_idr, pi->proto->id); in do_xfer()
1423 scmi_inc_count(info->dbg->counters, SENT_FAIL_CHANNEL_NOT_FOUND); in do_xfer()
1424 return -EINVAL; in do_xfer()
1427 if (is_polling_enabled(cinfo, info->desc)) in do_xfer()
1428 xfer->hdr.poll_completion = true; in do_xfer()
1431 * Initialise protocol id now from protocol handle to avoid it being in do_xfer()
1432 * overridden by mistake (or malice) by the protocol code mangling with in do_xfer()
1435 xfer->hdr.protocol_id = pi->proto->id; in do_xfer()
1436 reinit_completion(&xfer->done); in do_xfer()
1438 trace_scmi_xfer_begin(xfer->transfer_id, xfer->hdr.id, in do_xfer()
1439 xfer->hdr.protocol_id, xfer->hdr.seq, in do_xfer()
1440 xfer->hdr.poll_completion); in do_xfer()
1443 xfer->hdr.status = SCMI_SUCCESS; in do_xfer()
1444 xfer->state = SCMI_XFER_SENT_OK; in do_xfer()
1447 * on xfer->state due to the monotonically increasing tokens allocation, in do_xfer()
1448 * we must anyway ensure xfer->state initialization is not re-ordered in do_xfer()
1450 * ISR calling scmi_rx_callback() cannot see an old stale xfer->state. in do_xfer()
1454 ret = info->desc->ops->send_message(cinfo, xfer); in do_xfer()
1457 scmi_inc_count(info->dbg->counters, SENT_FAIL); in do_xfer()
1461 trace_scmi_msg_dump(info->id, cinfo->id, xfer->hdr.protocol_id, in do_xfer()
1462 xfer->hdr.id, "CMND", xfer->hdr.seq, in do_xfer()
1463 xfer->hdr.status, xfer->tx.buf, xfer->tx.len); in do_xfer()
1464 scmi_inc_count(info->dbg->counters, SENT_OK); in do_xfer()
1467 if (!ret && xfer->hdr.status) { in do_xfer()
1468 ret = scmi_to_linux_errno(xfer->hdr.status); in do_xfer()
1469 scmi_inc_count(info->dbg->counters, ERR_PROTOCOL); in do_xfer()
1472 if (info->desc->ops->mark_txdone) in do_xfer()
1473 info->desc->ops->mark_txdone(cinfo, ret, xfer); in do_xfer()
1475 trace_scmi_xfer_end(xfer->transfer_id, xfer->hdr.id, in do_xfer()
1476 xfer->hdr.protocol_id, xfer->hdr.seq, ret); in do_xfer()
1485 struct scmi_info *info = handle_to_scmi_info(pi->handle); in reset_rx_to_maxsz()
1487 xfer->rx.len = info->desc->max_msg_size; in reset_rx_to_maxsz()
1491 * do_xfer_with_response() - Do one transfer and wait until the delayed
1494 * @ph: Pointer to SCMI protocol handle
1498 * it could cause long busy-waiting here, so ignore polling for the delayed
1505 * attained at the protocol layer), but this would also have led to longer
1511 * Return: -ETIMEDOUT in case of no delayed response, if transmit error,
1520 xfer->async_done = &async_response; in do_xfer_with_response()
1528 WARN_ON_ONCE(xfer->hdr.poll_completion); in do_xfer_with_response()
1532 if (!wait_for_completion_timeout(xfer->async_done, timeout)) { in do_xfer_with_response()
1533 dev_err(ph->dev, in do_xfer_with_response()
1536 ret = -ETIMEDOUT; in do_xfer_with_response()
1537 } else if (xfer->hdr.status) { in do_xfer_with_response()
1538 ret = scmi_to_linux_errno(xfer->hdr.status); in do_xfer_with_response()
1542 xfer->async_done = NULL; in do_xfer_with_response()
1547 * xfer_get_init() - Allocate and initialise one message for transmit
1549 * @ph: Pointer to SCMI protocol handle
1568 struct scmi_info *info = handle_to_scmi_info(pi->handle); in xfer_get_init()
1569 struct scmi_xfers_info *minfo = &info->tx_minfo; in xfer_get_init()
1570 struct device *dev = info->dev; in xfer_get_init()
1573 if (rx_size > info->desc->max_msg_size || in xfer_get_init()
1574 tx_size > info->desc->max_msg_size) in xfer_get_init()
1575 return -ERANGE; in xfer_get_init()
1577 xfer = scmi_xfer_get(pi->handle, minfo); in xfer_get_init()
1584 /* Pick a sequence number and register this xfer as in-flight */ in xfer_get_init()
1587 dev_err(pi->handle->dev, in xfer_get_init()
1593 xfer->tx.len = tx_size; in xfer_get_init()
1594 xfer->rx.len = rx_size ? : info->desc->max_msg_size; in xfer_get_init()
1595 xfer->hdr.type = MSG_TYPE_COMMAND; in xfer_get_init()
1596 xfer->hdr.id = msg_id; in xfer_get_init()
1597 xfer->hdr.poll_completion = false; in xfer_get_init()
1605 * version_get() - command to get the revision of the SCMI entity
1607 * @ph: Pointer to SCMI protocol handle
1608 * @version: Holds returned version of protocol.
1626 rev_info = t->rx.buf; in version_get()
1635 * scmi_set_protocol_priv - Set protocol specific data at init time
1637 * @ph: A reference to the protocol handle.
1639 * @version: The detected protocol version for the core to register.
1648 pi->priv = priv; in scmi_set_protocol_priv()
1649 pi->version = version; in scmi_set_protocol_priv()
1655 * scmi_get_protocol_priv - Set protocol specific data at init time
1657 * @ph: A reference to the protocol handle.
1659 * Return: Protocol private data if any was set.
1665 return pi->priv; in scmi_get_protocol_priv()
1683 * scmi_common_extended_name_get - Common helper to get extended resources name
1684 * @ph: A protocol handle reference.
1685 * @cmd_id: The specific command ID to use.
1686 * @res_id: The specific resource ID to use.
1704 ret = ph->xops->xfer_get_init(ph, cmd_id, txlen, sizeof(*resp), &t); in scmi_common_extended_name_get()
1708 put_unaligned_le32(res_id, t->tx.buf); in scmi_common_extended_name_get()
1710 put_unaligned_le32(*flags, t->tx.buf + sizeof(res_id)); in scmi_common_extended_name_get()
1711 resp = t->rx.buf; in scmi_common_extended_name_get()
1713 ret = ph->xops->do_xfer(ph, t); in scmi_common_extended_name_get()
1715 strscpy(name, resp->name, len); in scmi_common_extended_name_get()
1717 ph->xops->xfer_put(ph, t); in scmi_common_extended_name_get()
1720 dev_warn(ph->dev, in scmi_common_extended_name_get()
1721 "Failed to get extended name - id:%u (ret:%d). Using %s\n", in scmi_common_extended_name_get()
1727 * scmi_common_get_max_msg_size - Get maximum message size
1728 * @ph: A protocol handle reference.
1730 * Return: Maximum message size for the current protocol.
1735 struct scmi_info *info = handle_to_scmi_info(pi->handle); in scmi_common_get_max_msg_size()
1737 return info->desc->max_msg_size; in scmi_common_get_max_msg_size()
1741 * struct scmi_iterator - Iterator descriptor
1743 * a proper custom command payload for each multi-part command request.
1745 * @process_response to parse the multi-part replies.
1748 * @ph: A reference to the associated protocol handle to be used.
1751 * internal routines and by the caller-provided @scmi_iterator_ops.
1773 i = devm_kzalloc(ph->dev, sizeof(*i), GFP_KERNEL); in scmi_iterator_init()
1775 return ERR_PTR(-ENOMEM); in scmi_iterator_init()
1777 i->ph = ph; in scmi_iterator_init()
1778 i->ops = ops; in scmi_iterator_init()
1779 i->priv = priv; in scmi_iterator_init()
1781 ret = ph->xops->xfer_get_init(ph, msg_id, tx_size, 0, &i->t); in scmi_iterator_init()
1783 devm_kfree(ph->dev, i); in scmi_iterator_init()
1787 i->state.max_resources = max_resources; in scmi_iterator_init()
1788 i->msg = i->t->tx.buf; in scmi_iterator_init()
1789 i->resp = i->t->rx.buf; in scmi_iterator_init()
1796 int ret = -EINVAL; in scmi_iterator_run()
1802 if (!i || !i->ops || !i->ph) in scmi_iterator_run()
1805 iops = i->ops; in scmi_iterator_run()
1806 ph = i->ph; in scmi_iterator_run()
1807 st = &i->state; in scmi_iterator_run()
1810 iops->prepare_message(i->msg, st->desc_index, i->priv); in scmi_iterator_run()
1811 ret = ph->xops->do_xfer(ph, i->t); in scmi_iterator_run()
1815 st->rx_len = i->t->rx.len; in scmi_iterator_run()
1816 ret = iops->update_state(st, i->resp, i->priv); in scmi_iterator_run()
1820 if (st->num_returned > st->max_resources - st->desc_index) { in scmi_iterator_run()
1821 dev_err(ph->dev, in scmi_iterator_run()
1823 st->max_resources); in scmi_iterator_run()
1824 ret = -EINVAL; in scmi_iterator_run()
1828 for (st->loop_idx = 0; st->loop_idx < st->num_returned; in scmi_iterator_run()
1829 st->loop_idx++) { in scmi_iterator_run()
1830 ret = iops->process_response(ph, i->resp, st, i->priv); in scmi_iterator_run()
1835 st->desc_index += st->num_returned; in scmi_iterator_run()
1836 ph->xops->reset_rx_to_maxsz(ph, i->t); in scmi_iterator_run()
1841 } while (st->num_returned && st->num_remaining); in scmi_iterator_run()
1845 ph->xops->xfer_put(ph, i->t); in scmi_iterator_run()
1846 devm_kfree(ph->dev, i); in scmi_iterator_run()
1890 ret = -EINVAL; in scmi_common_fastchannel_init()
1894 ret = ph->xops->xfer_get_init(ph, describe_id, in scmi_common_fastchannel_init()
1899 info = t->tx.buf; in scmi_common_fastchannel_init()
1900 info->domain = cpu_to_le32(domain); in scmi_common_fastchannel_init()
1901 info->message_id = cpu_to_le32(message_id); in scmi_common_fastchannel_init()
1908 ret = ph->xops->do_xfer(ph, t); in scmi_common_fastchannel_init()
1912 resp = t->rx.buf; in scmi_common_fastchannel_init()
1913 flags = le32_to_cpu(resp->attr); in scmi_common_fastchannel_init()
1914 size = le32_to_cpu(resp->chan_size); in scmi_common_fastchannel_init()
1916 ret = -EINVAL; in scmi_common_fastchannel_init()
1921 *rate_limit = le32_to_cpu(resp->rate_limit) & GENMASK(19, 0); in scmi_common_fastchannel_init()
1923 phys_addr = le32_to_cpu(resp->chan_addr_low); in scmi_common_fastchannel_init()
1924 phys_addr |= (u64)le32_to_cpu(resp->chan_addr_high) << 32; in scmi_common_fastchannel_init()
1925 addr = devm_ioremap(ph->dev, phys_addr, size); in scmi_common_fastchannel_init()
1927 ret = -EADDRNOTAVAIL; in scmi_common_fastchannel_init()
1934 db = devm_kzalloc(ph->dev, sizeof(*db), GFP_KERNEL); in scmi_common_fastchannel_init()
1936 ret = -ENOMEM; in scmi_common_fastchannel_init()
1941 phys_addr = le32_to_cpu(resp->db_addr_low); in scmi_common_fastchannel_init()
1942 phys_addr |= (u64)le32_to_cpu(resp->db_addr_high) << 32; in scmi_common_fastchannel_init()
1943 addr = devm_ioremap(ph->dev, phys_addr, size); in scmi_common_fastchannel_init()
1945 ret = -EADDRNOTAVAIL; in scmi_common_fastchannel_init()
1949 db->addr = addr; in scmi_common_fastchannel_init()
1950 db->width = size; in scmi_common_fastchannel_init()
1951 db->set = le32_to_cpu(resp->db_set_lmask); in scmi_common_fastchannel_init()
1952 db->set |= (u64)le32_to_cpu(resp->db_set_hmask) << 32; in scmi_common_fastchannel_init()
1953 db->mask = le32_to_cpu(resp->db_preserve_lmask); in scmi_common_fastchannel_init()
1954 db->mask |= (u64)le32_to_cpu(resp->db_preserve_hmask) << 32; in scmi_common_fastchannel_init()
1959 ph->xops->xfer_put(ph, t); in scmi_common_fastchannel_init()
1961 dev_dbg(ph->dev, in scmi_common_fastchannel_init()
1962 "Using valid FC for protocol %X [MSG_ID:%u / RES_ID:%u]\n", in scmi_common_fastchannel_init()
1963 pi->proto->id, message_id, domain); in scmi_common_fastchannel_init()
1968 devm_kfree(ph->dev, db); in scmi_common_fastchannel_init()
1974 ph->xops->xfer_put(ph, t); in scmi_common_fastchannel_init()
1977 dev_warn(ph->dev, in scmi_common_fastchannel_init()
1978 "Failed to get FC for protocol %X [MSG_ID:%u / RES_ID:%u] - ret:%d. Using regular messaging.\n", in scmi_common_fastchannel_init()
1979 pi->proto->id, message_id, domain, ret); in scmi_common_fastchannel_init()
1986 if (db->mask) \
1987 val = ioread##w(db->addr) & db->mask; \
1988 iowrite##w((u##w)db->set | val, db->addr); \
1993 if (!db || !db->addr) in scmi_common_fastchannel_db_ring()
1996 if (db->width == 1) in scmi_common_fastchannel_db_ring()
1998 else if (db->width == 2) in scmi_common_fastchannel_db_ring()
2000 else if (db->width == 4) in scmi_common_fastchannel_db_ring()
2002 else /* db->width == 8 */ in scmi_common_fastchannel_db_ring()
2007 * scmi_protocol_msg_check - Check protocol message attributes
2009 * @ph: A reference to the protocol handle.
2010 * @message_id: The ID of the message to check.
2014 * An helper to check protocol message attributes for a specific protocol
2030 put_unaligned_le32(message_id, t->tx.buf); in scmi_protocol_msg_check()
2033 *attributes = get_unaligned_le32(t->rx.buf); in scmi_protocol_msg_check()
2050 * scmi_revision_area_get - Retrieve version memory area.
2052 * @ph: A reference to the protocol handle.
2054 * A helper to grab the version memory area reference during SCMI Base protocol
2058 * instance underlying this protocol handle.
2065 return pi->handle->version; in scmi_revision_area_get()
2069 * scmi_protocol_version_negotiate - Negotiate protocol version
2071 * @ph: A reference to the protocol handle.
2073 * An helper to negotiate a protocol version different from the latest
2090 /* ... then attempt protocol version negotiation */ in scmi_protocol_version_negotiate()
2096 put_unaligned_le32(pi->proto->supported_version, t->tx.buf); in scmi_protocol_version_negotiate()
2099 pi->negotiated_version = pi->proto->supported_version; in scmi_protocol_version_negotiate()
2107 * scmi_alloc_init_protocol_instance - Allocate and initialize a protocol
2110 * @proto: The protocol descriptor.
2112 * Allocate a new protocol instance descriptor, using the provided @proto
2114 * all resources management is handled via a dedicated per-protocol devres
2118 * Return: A reference to a freshly allocated and initialized protocol instance
2126 int ret = -ENOMEM; in scmi_alloc_init_protocol_instance()
2129 const struct scmi_handle *handle = &info->handle; in scmi_alloc_init_protocol_instance()
2131 /* Protocol specific devres group */ in scmi_alloc_init_protocol_instance()
2132 gid = devres_open_group(handle->dev, NULL, GFP_KERNEL); in scmi_alloc_init_protocol_instance()
2138 pi = devm_kzalloc(handle->dev, sizeof(*pi), GFP_KERNEL); in scmi_alloc_init_protocol_instance()
2142 pi->gid = gid; in scmi_alloc_init_protocol_instance()
2143 pi->proto = proto; in scmi_alloc_init_protocol_instance()
2144 pi->handle = handle; in scmi_alloc_init_protocol_instance()
2145 pi->ph.dev = handle->dev; in scmi_alloc_init_protocol_instance()
2146 pi->ph.xops = &xfer_ops; in scmi_alloc_init_protocol_instance()
2147 pi->ph.hops = &helpers_ops; in scmi_alloc_init_protocol_instance()
2148 pi->ph.set_priv = scmi_set_protocol_priv; in scmi_alloc_init_protocol_instance()
2149 pi->ph.get_priv = scmi_get_protocol_priv; in scmi_alloc_init_protocol_instance()
2150 refcount_set(&pi->users, 1); in scmi_alloc_init_protocol_instance()
2151 /* proto->init is assured NON NULL by scmi_protocol_register */ in scmi_alloc_init_protocol_instance()
2152 ret = pi->proto->instance_init(&pi->ph); in scmi_alloc_init_protocol_instance()
2156 ret = idr_alloc(&info->protocols, pi, proto->id, proto->id + 1, in scmi_alloc_init_protocol_instance()
2158 if (ret != proto->id) in scmi_alloc_init_protocol_instance()
2165 if (pi->proto->events) { in scmi_alloc_init_protocol_instance()
2166 ret = scmi_register_protocol_events(handle, pi->proto->id, in scmi_alloc_init_protocol_instance()
2167 &pi->ph, in scmi_alloc_init_protocol_instance()
2168 pi->proto->events); in scmi_alloc_init_protocol_instance()
2170 dev_warn(handle->dev, in scmi_alloc_init_protocol_instance()
2171 "Protocol:%X - Events Registration Failed - err:%d\n", in scmi_alloc_init_protocol_instance()
2172 pi->proto->id, ret); in scmi_alloc_init_protocol_instance()
2175 devres_close_group(handle->dev, pi->gid); in scmi_alloc_init_protocol_instance()
2176 dev_dbg(handle->dev, "Initialized protocol: 0x%X\n", pi->proto->id); in scmi_alloc_init_protocol_instance()
2178 if (pi->version > proto->supported_version) { in scmi_alloc_init_protocol_instance()
2179 ret = scmi_protocol_version_negotiate(&pi->ph); in scmi_alloc_init_protocol_instance()
2181 dev_info(handle->dev, in scmi_alloc_init_protocol_instance()
2182 "Protocol 0x%X successfully negotiated version 0x%X\n", in scmi_alloc_init_protocol_instance()
2183 proto->id, pi->negotiated_version); in scmi_alloc_init_protocol_instance()
2185 dev_warn(handle->dev, in scmi_alloc_init_protocol_instance()
2186 "Detected UNSUPPORTED higher version 0x%X for protocol 0x%X.\n", in scmi_alloc_init_protocol_instance()
2187 pi->version, pi->proto->id); in scmi_alloc_init_protocol_instance()
2188 dev_warn(handle->dev, in scmi_alloc_init_protocol_instance()
2190 pi->proto->supported_version); in scmi_alloc_init_protocol_instance()
2197 /* Take care to put the protocol module's owner before releasing all */ in scmi_alloc_init_protocol_instance()
2199 devres_release_group(handle->dev, gid); in scmi_alloc_init_protocol_instance()
2205 * scmi_get_protocol_instance - Protocol initialization helper.
2207 * @protocol_id: The protocol being requested.
2209 * In case the required protocol has never been requested before for this
2211 * resource allocation with a dedicated per-protocol devres subgroup.
2213 * Return: A reference to an initialized protocol instance or error on failure:
2214 * in particular returns -EPROBE_DEFER when the desired protocol could
2223 mutex_lock(&info->protocols_mtx); in scmi_get_protocol_instance()
2224 pi = idr_find(&info->protocols, protocol_id); in scmi_get_protocol_instance()
2227 refcount_inc(&pi->users); in scmi_get_protocol_instance()
2231 /* Fails if protocol not registered on bus */ in scmi_get_protocol_instance()
2232 proto = scmi_protocol_get(protocol_id, &info->version); in scmi_get_protocol_instance()
2236 pi = ERR_PTR(-EPROBE_DEFER); in scmi_get_protocol_instance()
2238 mutex_unlock(&info->protocols_mtx); in scmi_get_protocol_instance()
2244 * scmi_protocol_acquire - Protocol acquire
2246 * @protocol_id: The protocol being requested.
2248 * Register a new user for the requested protocol on the specified SCMI
2251 * Return: 0 if protocol was acquired successfully.
2259 * scmi_protocol_release - Protocol de-initialization helper.
2261 * @protocol_id: The protocol being requested.
2263 * Remove one user for the specified protocol and triggers de-initialization
2264 * and resources de-allocation once the last user has gone.
2271 mutex_lock(&info->protocols_mtx); in scmi_protocol_release()
2272 pi = idr_find(&info->protocols, protocol_id); in scmi_protocol_release()
2276 if (refcount_dec_and_test(&pi->users)) { in scmi_protocol_release()
2277 void *gid = pi->gid; in scmi_protocol_release()
2279 if (pi->proto->events) in scmi_protocol_release()
2282 if (pi->proto->instance_deinit) in scmi_protocol_release()
2283 pi->proto->instance_deinit(&pi->ph); in scmi_protocol_release()
2285 idr_remove(&info->protocols, protocol_id); in scmi_protocol_release()
2287 scmi_protocol_put(pi->proto); in scmi_protocol_release()
2289 devres_release_group(handle->dev, gid); in scmi_protocol_release()
2290 dev_dbg(handle->dev, "De-Initialized protocol: 0x%X\n", in scmi_protocol_release()
2295 mutex_unlock(&info->protocols_mtx); in scmi_protocol_release()
2302 struct scmi_info *info = handle_to_scmi_info(pi->handle); in scmi_setup_protocol_implemented()
2304 info->protocols_imp = prot_imp; in scmi_setup_protocol_implemented()
2312 struct scmi_revision_info *rev = handle->version; in scmi_is_protocol_implemented()
2314 if (!info->protocols_imp) in scmi_is_protocol_implemented()
2317 for (i = 0; i < rev->num_protocols; i++) in scmi_is_protocol_implemented()
2318 if (info->protocols_imp[i] == prot_id) in scmi_is_protocol_implemented()
2332 scmi_protocol_release(dres->handle, dres->protocol_id); in scmi_devm_release_protocol()
2344 return ERR_PTR(-ENOMEM); in scmi_devres_protocol_instance_get()
2346 pi = scmi_get_protocol_instance(sdev->handle, protocol_id); in scmi_devres_protocol_instance_get()
2352 dres->handle = sdev->handle; in scmi_devres_protocol_instance_get()
2353 dres->protocol_id = protocol_id; in scmi_devres_protocol_instance_get()
2354 devres_add(&sdev->dev, dres); in scmi_devres_protocol_instance_get()
2360 * scmi_devm_protocol_get - Devres managed get protocol operations and handle
2363 * @protocol_id: The protocol being requested.
2364 * @ph: A pointer reference used to pass back the associated protocol handle.
2366 * Get hold of a protocol accounting for its usage, eventually triggering its
2367 * initialization, and returning the protocol specific operations and related
2368 * protocol handle which will be used as first argument in most of the
2370 * Being a devres based managed method, protocol hold will be automatically
2371 * released, and possibly de-initialized on last user, once the SCMI driver
2374 * Return: A reference to the requested protocol operations or error.
2384 return ERR_PTR(-EINVAL); in scmi_devm_protocol_get()
2390 *ph = &pi->ph; in scmi_devm_protocol_get()
2392 return pi->proto->ops; in scmi_devm_protocol_get()
2396 * scmi_devm_protocol_acquire - Devres managed helper to get hold of a protocol
2399 * @protocol_id: The protocol being requested.
2401 * Get hold of a protocol accounting for its usage, possibly triggering its
2402 * initialization but without getting access to its protocol specific operations
2405 * Being a devres based managed method, protocol hold will be automatically
2406 * released, and possibly de-initialized on last user, once the SCMI driver
2430 return dres->protocol_id == *((u8 *)data); in scmi_devm_protocol_match()
2434 * scmi_devm_protocol_put - Devres managed put protocol operations and handle
2437 * @protocol_id: The protocol being requested.
2439 * Explicitly release a protocol hold previously obtained calling the above
2446 ret = devres_release(&sdev->dev, scmi_devm_release_protocol, in scmi_devm_protocol_put()
2452 * scmi_is_transport_atomic - Method to check if underlying transport for an
2467 ret = info->desc->atomic_enabled && in scmi_is_transport_atomic()
2468 is_transport_polling_capable(info->desc); in scmi_is_transport_atomic()
2470 *atomic_threshold = info->desc->atomic_threshold; in scmi_is_transport_atomic()
2476 * scmi_handle_get() - Get the SCMI handle for a device
2481 * and is expected to be maintained by caller of SCMI protocol library.
2495 if (dev->parent == info->dev) { in scmi_handle_get()
2496 info->users++; in scmi_handle_get()
2497 handle = &info->handle; in scmi_handle_get()
2507 * scmi_handle_put() - Release the handle acquired by scmi_handle_get
2512 * and is expected to be maintained by caller of SCMI protocol library.
2516 * if null was passed, it returns -EINVAL;
2523 return -EINVAL; in scmi_handle_put()
2527 if (!WARN_ON(!info->users)) in scmi_handle_put()
2528 info->users--; in scmi_handle_put()
2546 scmi_dev->handle = scmi_handle_get(&scmi_dev->dev); in scmi_set_handle()
2547 if (scmi_dev->handle) in scmi_set_handle()
2548 scmi_device_link_add(&scmi_dev->dev, scmi_dev->handle->dev); in scmi_set_handle()
2556 struct device *dev = sinfo->dev; in __scmi_xfer_info_init()
2557 const struct scmi_desc *desc = sinfo->desc; in __scmi_xfer_info_init()
2559 /* Pre-allocated messages, no more than what hdr.seq can support */ in __scmi_xfer_info_init()
2560 if (WARN_ON(!info->max_msg || info->max_msg > MSG_TOKEN_MAX)) { in __scmi_xfer_info_init()
2562 "Invalid maximum messages %d, not in range [1 - %lu]\n", in __scmi_xfer_info_init()
2563 info->max_msg, MSG_TOKEN_MAX); in __scmi_xfer_info_init()
2564 return -EINVAL; in __scmi_xfer_info_init()
2567 hash_init(info->pending_xfers); in __scmi_xfer_info_init()
2570 info->xfer_alloc_table = devm_bitmap_zalloc(dev, MSG_TOKEN_MAX, in __scmi_xfer_info_init()
2572 if (!info->xfer_alloc_table) in __scmi_xfer_info_init()
2573 return -ENOMEM; in __scmi_xfer_info_init()
2577 * pre-initialize the buffer pointer to pre-allocated buffers and in __scmi_xfer_info_init()
2580 INIT_HLIST_HEAD(&info->free_xfers); in __scmi_xfer_info_init()
2581 for (i = 0; i < info->max_msg; i++) { in __scmi_xfer_info_init()
2584 return -ENOMEM; in __scmi_xfer_info_init()
2586 xfer->rx.buf = devm_kcalloc(dev, sizeof(u8), desc->max_msg_size, in __scmi_xfer_info_init()
2588 if (!xfer->rx.buf) in __scmi_xfer_info_init()
2589 return -ENOMEM; in __scmi_xfer_info_init()
2591 xfer->tx.buf = xfer->rx.buf; in __scmi_xfer_info_init()
2592 init_completion(&xfer->done); in __scmi_xfer_info_init()
2593 spin_lock_init(&xfer->lock); in __scmi_xfer_info_init()
2596 hlist_add_head(&xfer->node, &info->free_xfers); in __scmi_xfer_info_init()
2599 spin_lock_init(&info->xfer_lock); in __scmi_xfer_info_init()
2606 const struct scmi_desc *desc = sinfo->desc; in scmi_channels_max_msg_configure()
2608 if (!desc->ops->get_max_msg) { in scmi_channels_max_msg_configure()
2609 sinfo->tx_minfo.max_msg = desc->max_msg; in scmi_channels_max_msg_configure()
2610 sinfo->rx_minfo.max_msg = desc->max_msg; in scmi_channels_max_msg_configure()
2614 base_cinfo = idr_find(&sinfo->tx_idr, SCMI_PROTOCOL_BASE); in scmi_channels_max_msg_configure()
2616 return -EINVAL; in scmi_channels_max_msg_configure()
2617 sinfo->tx_minfo.max_msg = desc->ops->get_max_msg(base_cinfo); in scmi_channels_max_msg_configure()
2620 base_cinfo = idr_find(&sinfo->rx_idr, SCMI_PROTOCOL_BASE); in scmi_channels_max_msg_configure()
2622 sinfo->rx_minfo.max_msg = in scmi_channels_max_msg_configure()
2623 desc->ops->get_max_msg(base_cinfo); in scmi_channels_max_msg_configure()
2637 ret = __scmi_xfer_info_init(sinfo, &sinfo->tx_minfo); in scmi_xfer_info_init()
2638 if (!ret && !idr_is_empty(&sinfo->rx_idr)) in scmi_xfer_info_init()
2639 ret = __scmi_xfer_info_init(sinfo, &sinfo->rx_minfo); in scmi_xfer_info_init()
2655 idr = tx ? &info->tx_idr : &info->rx_idr; in scmi_chan_setup()
2657 if (!info->desc->ops->chan_available(of_node, idx)) { in scmi_chan_setup()
2660 return -EINVAL; in scmi_chan_setup()
2664 cinfo = devm_kzalloc(info->dev, sizeof(*cinfo), GFP_KERNEL); in scmi_chan_setup()
2666 return -ENOMEM; in scmi_chan_setup()
2668 cinfo->is_p2a = !tx; in scmi_chan_setup()
2669 cinfo->rx_timeout_ms = info->desc->max_rx_timeout_ms; in scmi_chan_setup()
2670 cinfo->max_msg_size = info->desc->max_msg_size; in scmi_chan_setup()
2676 tdev = scmi_device_create(of_node, info->dev, prot_id, name); in scmi_chan_setup()
2678 dev_err(info->dev, in scmi_chan_setup()
2680 devm_kfree(info->dev, cinfo); in scmi_chan_setup()
2681 return -EINVAL; in scmi_chan_setup()
2685 cinfo->id = prot_id; in scmi_chan_setup()
2686 cinfo->dev = &tdev->dev; in scmi_chan_setup()
2687 ret = info->desc->ops->chan_setup(cinfo, info->dev, tx); in scmi_chan_setup()
2690 scmi_device_destroy(info->dev, prot_id, name); in scmi_chan_setup()
2691 devm_kfree(info->dev, cinfo); in scmi_chan_setup()
2695 if (tx && is_polling_required(cinfo, info->desc)) { in scmi_chan_setup()
2696 if (is_transport_polling_capable(info->desc)) in scmi_chan_setup()
2697 dev_info(&tdev->dev, in scmi_chan_setup()
2698 "Enabled polling mode TX channel - prot_id:%d\n", in scmi_chan_setup()
2701 dev_warn(&tdev->dev, in scmi_chan_setup()
2708 dev_err(info->dev, in scmi_chan_setup()
2713 scmi_device_destroy(info->dev, prot_id, name); in scmi_chan_setup()
2714 devm_kfree(info->dev, cinfo); in scmi_chan_setup()
2719 cinfo->handle = &info->handle; in scmi_chan_setup()
2732 if (ret && ret != -ENOMEM) in scmi_txrx_setup()
2737 dev_err(info->dev, in scmi_txrx_setup()
2738 "failed to setup channel for protocol:0x%X\n", prot_id); in scmi_txrx_setup()
2744 * scmi_channels_setup - Helper to initialize all required channels
2755 * protocol defined in the DT, a distinct freshly initialized channel is
2756 * created only if the DT node for the protocol at hand describes a dedicated
2757 * channel: in all the other cases the common BASE protocol channel is reused.
2764 struct device_node *top_np = info->dev->of_node; in scmi_channels_setup()
2778 dev_err(info->dev, in scmi_channels_setup()
2779 "Out of range protocol %d\n", prot_id); in scmi_channels_setup()
2789 static int scmi_chan_destroy(int id, void *p, void *idr) in scmi_chan_destroy() argument
2793 if (cinfo->dev) { in scmi_chan_destroy()
2794 struct scmi_info *info = handle_to_scmi_info(cinfo->handle); in scmi_chan_destroy()
2795 struct scmi_device *sdev = to_scmi_dev(cinfo->dev); in scmi_chan_destroy()
2797 of_node_put(cinfo->dev->of_node); in scmi_chan_destroy()
2798 scmi_device_destroy(info->dev, id, sdev->name); in scmi_chan_destroy()
2799 cinfo->dev = NULL; in scmi_chan_destroy()
2802 idr_remove(idr, id); in scmi_chan_destroy()
2810 idr_for_each(idr, info->desc->ops->chan_free, idr); in scmi_cleanup_channels()
2820 scmi_cleanup_channels(info, &info->tx_idr); in scmi_cleanup_txrx_channels()
2822 scmi_cleanup_channels(info, &info->rx_idr); in scmi_cleanup_txrx_channels()
2832 if (!strncmp(sdev->name, "__scmi_transport_device", 23) || in scmi_bus_notifier()
2833 sdev->dev.parent != info->dev) in scmi_bus_notifier()
2842 scmi_handle_put(sdev->handle); in scmi_bus_notifier()
2843 sdev->handle = NULL; in scmi_bus_notifier()
2849 dev_dbg(info->dev, "Device %s (%s) is now %s\n", dev_name(&sdev->dev), in scmi_bus_notifier()
2850 sdev->name, action == BUS_NOTIFY_BIND_DRIVER ? in scmi_bus_notifier()
2863 np = idr_find(&info->active_protocols, id_table->protocol_id); in scmi_device_request_notifier()
2867 dev_dbg(info->dev, "%sRequested device (%s) for protocol 0x%x\n", in scmi_device_request_notifier()
2868 action == SCMI_BUS_NOTIFY_DEVICE_REQUEST ? "" : "UN-", in scmi_device_request_notifier()
2869 id_table->name, id_table->protocol_id); in scmi_device_request_notifier()
2873 scmi_create_protocol_devices(np, info, id_table->protocol_id, in scmi_device_request_notifier()
2874 id_table->name); in scmi_device_request_notifier()
2877 scmi_destroy_protocol_devices(info, id_table->protocol_id, in scmi_device_request_notifier()
2878 id_table->name); in scmi_device_request_notifier()
2907 struct scmi_debug_info *dbg = filp->private_data; in reset_all_on_write()
2910 atomic_set(&dbg->counters[i], 0); in reset_all_on_write()
2931 &dbg->counters[idx]); in scmi_debugfs_counters_setup()
2943 debugfs_remove_recursive(dbg->top_dentry); in scmi_debugfs_common_cleanup()
2944 kfree(dbg->name); in scmi_debugfs_common_cleanup()
2945 kfree(dbg->type); in scmi_debugfs_common_cleanup()
2955 dbg = devm_kzalloc(info->dev, sizeof(*dbg), GFP_KERNEL); in scmi_debugfs_common_setup()
2959 dbg->name = kstrdup(of_node_full_name(info->dev->of_node), GFP_KERNEL); in scmi_debugfs_common_setup()
2960 if (!dbg->name) { in scmi_debugfs_common_setup()
2961 devm_kfree(info->dev, dbg); in scmi_debugfs_common_setup()
2965 of_property_read_string(info->dev->of_node, "compatible", &c_ptr); in scmi_debugfs_common_setup()
2966 dbg->type = kstrdup(c_ptr, GFP_KERNEL); in scmi_debugfs_common_setup()
2967 if (!dbg->type) { in scmi_debugfs_common_setup()
2968 kfree(dbg->name); in scmi_debugfs_common_setup()
2969 devm_kfree(info->dev, dbg); in scmi_debugfs_common_setup()
2973 snprintf(top_dir, 16, "%d", info->id); in scmi_debugfs_common_setup()
2977 dbg->is_atomic = info->desc->atomic_enabled && in scmi_debugfs_common_setup()
2978 is_transport_polling_capable(info->desc); in scmi_debugfs_common_setup()
2981 (char **)&dbg->name); in scmi_debugfs_common_setup()
2984 (u32 *)&info->desc->atomic_threshold); in scmi_debugfs_common_setup()
2986 debugfs_create_str("type", 0400, trans, (char **)&dbg->type); in scmi_debugfs_common_setup()
2988 debugfs_create_bool("is_atomic", 0400, trans, &dbg->is_atomic); in scmi_debugfs_common_setup()
2991 (u32 *)&info->desc->max_rx_timeout_ms); in scmi_debugfs_common_setup()
2994 (u32 *)&info->desc->max_msg_size); in scmi_debugfs_common_setup()
2997 (u32 *)&info->tx_minfo.max_msg); in scmi_debugfs_common_setup()
3000 (u32 *)&info->rx_minfo.max_msg); in scmi_debugfs_common_setup()
3005 dbg->top_dentry = top_dentry; in scmi_debugfs_common_setup()
3007 if (devm_add_action_or_reset(info->dev, in scmi_debugfs_common_setup()
3016 int id, num_chans = 0, ret = 0; in scmi_debugfs_raw_mode_setup() local
3021 if (!info->dbg) in scmi_debugfs_raw_mode_setup()
3022 return -EINVAL; in scmi_debugfs_raw_mode_setup()
3025 idr_for_each_entry(&info->tx_idr, cinfo, id) { in scmi_debugfs_raw_mode_setup()
3031 dev_warn(info->dev, in scmi_debugfs_raw_mode_setup()
3032 "SCMI RAW - Error enumerating channels\n"); in scmi_debugfs_raw_mode_setup()
3036 if (!test_bit(cinfo->id, protos)) { in scmi_debugfs_raw_mode_setup()
3037 channels[num_chans++] = cinfo->id; in scmi_debugfs_raw_mode_setup()
3038 set_bit(cinfo->id, protos); in scmi_debugfs_raw_mode_setup()
3042 info->raw = scmi_raw_mode_init(&info->handle, info->dbg->top_dentry, in scmi_debugfs_raw_mode_setup()
3043 info->id, channels, num_chans, in scmi_debugfs_raw_mode_setup()
3044 info->desc, info->tx_minfo.max_msg); in scmi_debugfs_raw_mode_setup()
3045 if (IS_ERR(info->raw)) { in scmi_debugfs_raw_mode_setup()
3046 dev_err(info->dev, "Failed to initialize SCMI RAW Mode !\n"); in scmi_debugfs_raw_mode_setup()
3047 ret = PTR_ERR(info->raw); in scmi_debugfs_raw_mode_setup()
3048 info->raw = NULL; in scmi_debugfs_raw_mode_setup()
3060 if (!trans || !trans->supplier || !trans->core_ops) in scmi_transport_setup()
3063 if (!device_link_add(dev, trans->supplier, DL_FLAG_AUTOREMOVE_CONSUMER)) { in scmi_transport_setup()
3070 *trans->core_ops = &scmi_trans_core_ops; in scmi_transport_setup()
3072 dev_info(dev, "Using %s\n", dev_driver_string(trans->supplier)); in scmi_transport_setup()
3074 ret = of_property_read_u32(dev->of_node, "arm,max-rx-timeout-ms", in scmi_transport_setup()
3075 &trans->desc.max_rx_timeout_ms); in scmi_transport_setup()
3076 if (ret && ret != -EINVAL) in scmi_transport_setup()
3077 dev_err(dev, "Malformed arm,max-rx-timeout-ms DT property.\n"); in scmi_transport_setup()
3079 ret = of_property_read_u32(dev->of_node, "arm,max-msg-size", in scmi_transport_setup()
3080 &trans->desc.max_msg_size); in scmi_transport_setup()
3081 if (ret && ret != -EINVAL) in scmi_transport_setup()
3082 dev_err(dev, "Malformed arm,max-msg-size DT property.\n"); in scmi_transport_setup()
3084 ret = of_property_read_u32(dev->of_node, "arm,max-msg", in scmi_transport_setup()
3085 &trans->desc.max_msg); in scmi_transport_setup()
3086 if (ret && ret != -EINVAL) in scmi_transport_setup()
3087 dev_err(dev, "Malformed arm,max-msg DT property.\n"); in scmi_transport_setup()
3090 "SCMI max-rx-timeout: %dms / max-msg-size: %dbytes / max-msg: %d\n", in scmi_transport_setup()
3091 trans->desc.max_rx_timeout_ms, trans->desc.max_msg_size, in scmi_transport_setup()
3092 trans->desc.max_msg); in scmi_transport_setup()
3095 if (!of_property_read_u32(dev->of_node, "atomic-threshold-us", in scmi_transport_setup()
3096 &trans->desc.atomic_threshold)) in scmi_transport_setup()
3099 trans->desc.atomic_threshold); in scmi_transport_setup()
3101 return &trans->desc; in scmi_transport_setup()
3112 struct device *dev = &pdev->dev; in scmi_probe()
3113 struct device_node *child, *np = dev->of_node; in scmi_probe()
3118 ret = -EINVAL; in scmi_probe()
3124 return -ENOMEM; in scmi_probe()
3126 info->id = ida_alloc_min(&scmi_id, 0, GFP_KERNEL); in scmi_probe()
3127 if (info->id < 0) in scmi_probe()
3128 return info->id; in scmi_probe()
3130 info->dev = dev; in scmi_probe()
3131 info->desc = desc; in scmi_probe()
3132 info->bus_nb.notifier_call = scmi_bus_notifier; in scmi_probe()
3133 info->dev_req_nb.notifier_call = scmi_device_request_notifier; in scmi_probe()
3134 INIT_LIST_HEAD(&info->node); in scmi_probe()
3135 idr_init(&info->protocols); in scmi_probe()
3136 mutex_init(&info->protocols_mtx); in scmi_probe()
3137 idr_init(&info->active_protocols); in scmi_probe()
3138 mutex_init(&info->devreq_mtx); in scmi_probe()
3141 idr_init(&info->tx_idr); in scmi_probe()
3142 idr_init(&info->rx_idr); in scmi_probe()
3144 handle = &info->handle; in scmi_probe()
3145 handle->dev = info->dev; in scmi_probe()
3146 handle->version = &info->version; in scmi_probe()
3147 handle->devm_protocol_acquire = scmi_devm_protocol_acquire; in scmi_probe()
3148 handle->devm_protocol_get = scmi_devm_protocol_get; in scmi_probe()
3149 handle->devm_protocol_put = scmi_devm_protocol_put; in scmi_probe()
3150 handle->is_transport_atomic = scmi_is_transport_atomic; in scmi_probe()
3159 ret = bus_register_notifier(&scmi_bus_type, &info->bus_nb); in scmi_probe()
3166 &info->dev_req_nb); in scmi_probe()
3179 info->dbg = scmi_debugfs_common_setup(info); in scmi_probe()
3180 if (!info->dbg) in scmi_probe()
3201 if (info->desc->atomic_enabled && in scmi_probe()
3202 !is_transport_polling_capable(info->desc)) in scmi_probe()
3207 * Trigger SCMI Base protocol initialization. in scmi_probe()
3222 list_add_tail(&info->node, &scmi_list); in scmi_probe()
3232 dev_err(dev, "Out of range protocol %d\n", prot_id); in scmi_probe()
3235 dev_err(dev, "SCMI protocol %d not implemented\n", in scmi_probe()
3241 * Save this valid DT protocol descriptor amongst in scmi_probe()
3244 ret = idr_alloc(&info->active_protocols, child, in scmi_probe()
3247 dev_err(dev, "SCMI protocol %d already activated. Skip\n", in scmi_probe()
3260 scmi_raw_mode_cleanup(info->raw); in scmi_probe()
3261 scmi_notification_exit(&info->handle); in scmi_probe()
3264 &info->dev_req_nb); in scmi_probe()
3266 bus_unregister_notifier(&scmi_bus_type, &info->bus_nb); in scmi_probe()
3270 ida_free(&scmi_id, info->id); in scmi_probe()
3278 int id; in scmi_remove() local
3283 scmi_raw_mode_cleanup(info->raw); in scmi_remove()
3286 if (info->users) in scmi_remove()
3287 dev_warn(&pdev->dev, in scmi_remove()
3289 list_del(&info->node); in scmi_remove()
3292 scmi_notification_exit(&info->handle); in scmi_remove()
3294 mutex_lock(&info->protocols_mtx); in scmi_remove()
3295 idr_destroy(&info->protocols); in scmi_remove()
3296 mutex_unlock(&info->protocols_mtx); in scmi_remove()
3298 idr_for_each_entry(&info->active_protocols, child, id) in scmi_remove()
3300 idr_destroy(&info->active_protocols); in scmi_remove()
3303 &info->dev_req_nb); in scmi_remove()
3304 bus_unregister_notifier(&scmi_bus_type, &info->bus_nb); in scmi_remove()
3309 ida_free(&scmi_id, info->id); in scmi_remove()
3317 return sprintf(buf, "%u.%u\n", info->version.major_ver, in protocol_version_show()
3318 info->version.minor_ver); in protocol_version_show()
3327 return sprintf(buf, "0x%x\n", info->version.impl_ver); in firmware_version_show()
3336 return sprintf(buf, "%s\n", info->version.vendor_id); in vendor_id_show()
3345 return sprintf(buf, "%s\n", info->version.sub_vendor_id); in sub_vendor_id_show()
3360 .name = "arm-scmi",
3385 return -EINVAL; in scmi_driver_init()
3432 MODULE_ALIAS("platform:arm-scmi");
3434 MODULE_DESCRIPTION("ARM SCMI protocol driver");