scmi_xfer_token_set(9)
π scmi_xfer_token_set β from the Kernel API Manual, bestie
okay so this is scmi_xfer_token_set, and it lives in the Kernel API Manual, and honestly? it's lowkey the bouncer at the club for transfer tokens. let's get into it π
β¨ NAME β¨
scmi_xfer_token_set β reserve and set a shiny new token for the xfer at hand π«Ά
πΈ SYNOPSIS πΈ
int scmi_xfer_token_set (struct scmi_xfers_info *minfo , struct
scmi_xfer *xfer );
π¦ ARGUMENTS π¦
minfoβ pointer to the Tx/Rx Message management info, based on channel type. the vibe-checked context, basically πxferβ the xfer we're acting upon. the main character of this function β¨
π DESCRIPTION π
okay so what it does: pick the next unused monotonically increasing token and set it into xfer->hdr.seq. and why monotonic, you ask? because picking a monotonically increasing value avoids immediate reuse of freshly completed or timed-out xfers β which mitigates the risk of incorrectly associating a late and expired xfer with a live in-flight transaction, when both happen to re-use the same token identifier. no cap, that's the whole safety rationale π₯
since the platform is NOT required to answer our request in-order, we should account for a few rare but possible scenarios:
- exactly
'next_token'may be NOT available, so pickxfer_id >= next_tokenusingfind_next_zero_bitstarting from the candidatenext_tokenbit π§ - all tokens ahead up to
(MSG_TOKEN_ID_MASK - 1)are used in-flight, but we are plenty of free tokens at start, so try a second pass usingfind_next_zero_bitand starting from0π
X = used in-flight
Normal β the chill one π
|- xfer_id picked
-----------+---------------------------------------------------------- |
| |X|X|X| | | | | | ... ... ... ... ... ... ... ... ... ... ...|X|X|
---------------------------------------------------------------------- ^
|- next_token
Out-of-order pending at start β the plot twist πͺοΈ
|- xfer_id picked, last_token fixed
-----+----------------------------------------------------------------
|X|X| | | | |X|X| ... ... ... ... ... ... ... ... ... ... ... ...|X| |
---------------------------------------------------------------------- ^
|- next_token
Out-of-order pending at end β the finale π¬
|- xfer_id picked, last_token fixed
-----+----------------------------------------------------------------
|X|X| | | | |X|X| ... ... ... ... ... ... ... ... ... ... |X|X|X||X|X|
---------------------------------------------------------------------- ^
|- next_token
π CONTEXT π
assumes to be called with xfer_lock already acquired. like, the lock is already in the group chat, don't re-add it π
β RETURN β
0 on success, or an error π
π SEE ALSO π
kernel file ./drivers/firmware/arm_scmi/driver.c and honestly the whole extended friend group:
struct scmi_xfers_info(9),struct scmi_protocol_instance(9),struct scmi_info(9)scmi_create_protocol_devices(9),scmi_xfer_token_clear(9),scmi_xfer_inflight_register_unlocked(9),scmi_xfer_inflight_register(9),scmi_xfer_raw_inflight_register(9),scmi_xfer_pending_set(9)scmi_xfer_get(9),scmi_xfer_raw_get(9),scmi_xfer_raw_channel_get(9),__scmi_xfer_put(9),scmi_xfer_raw_put(9),scmi_xfer_lookup_unlocked(9)scmi_bad_message_trace(9),scmi_msg_response_validate(9),scmi_xfer_state_update(9),scmi_xfer_command_acquire(9)scmi_rx_callback(9),xfer_put(9),scmi_wait_for_message_response(9),scmi_xfer_raw_wait_for_message_response(9)do_xfer(9),do_xfer_with_response(9),xfer_get_init(9),version_get(9)scmi_set_protocol_priv(9),scmi_get_protocol_priv(9),scmi_common_extended_name_get(9),scmi_common_get_max_msg_size(9),scmi_protocol_msg_check(9),struct scmi_iterator(9)scmi_revision_area_get(9),scmi_protocol_version_negotiate(9),scmi_protocol_version_initialize(9)scmi_alloc_init_protocol_instance(9),scmi_get_protocol_instance(9),scmi_protocol_acquire(9),scmi_protocol_release(9)scmi_devm_protocol_get(9),scmi_devm_protocol_acquire(9),scmi_devm_protocol_put(9)scmi_is_transport_atomic(9),scmi_handle_get(9),scmi_handle_put(9),scmi_channels_setup(9)
and that's the whole page, bestie π«Ά this one's straight out of ./drivers/firmware/arm_scmi, dated October 2026, and yeah β it's literally scmi_xfer_token_set(9) signing off πβ¨slayβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms