drivers/tee/optee/ffa_abi.c
Source file repositories/reference/linux-study-clean/drivers/tee/optee/ffa_abi.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tee/optee/ffa_abi.c- Extension
.c- Size
- 31154 bytes
- Lines
- 1223
- Domain
- Driver Families
- Bucket
- drivers/tee
- 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/arm_ffa.hlinux/errno.hlinux/rpmb.hlinux/scatterlist.hlinux/sched.hlinux/slab.hlinux/string.hlinux/tee_core.hlinux/types.hoptee_private.hoptee_ffa.hoptee_rpc_cmd.h
Detected Declarations
struct shm_rhashfunction rh_free_fnfunction optee_shm_add_ffa_handlefunction optee_shm_rem_ffa_handlefunction optee_ffa_from_msg_paramfunction optee_ffa_from_msg_paramfunction to_msg_param_ffa_memfunction optee_ffa_to_msg_paramfunction optee_ffa_shm_registerfunction optee_ffa_shm_unregisterfunction optee_ffa_shm_unregister_suppfunction optee_ffa_shm_pool_alloc_pagesfunction pool_ffa_op_freefunction pool_ffa_op_destroy_poolfunction optee_ffa_shm_pool_alloc_pagesfunction optee_ffa_do_call_with_argfunction handle_ffa_rpc_func_cmd_shm_freefunction handle_ffa_rpc_func_cmdfunction optee_handle_ffa_rpcfunction optee_ffa_yielding_callfunction optee_ffa_do_call_with_argfunction do_call_lend_protmemfunction optee_ffa_lend_protmemfunction optee_ffa_reclaim_protmemfunction optee_ffa_get_os_revisionfunction optee_ffa_api_is_compatiblefunction optee_ffa_exchange_capsfunction notif_work_fnfunction notif_callbackfunction enable_async_notiffunction optee_ffa_get_versionfunction optee_ffa_openfunction optee_ffa_removefunction optee_ffa_async_notif_initfunction optee_ffa_protmem_pool_initfunction optee_ffa_probefunction optee_ffa_abi_registerfunction optee_ffa_abi_unregister
Annotated Snippet
struct shm_rhash {
struct tee_shm *shm;
u64 global_id;
struct rhash_head linkage;
};
static void rh_free_fn(void *ptr, void *arg)
{
kfree(ptr);
}
static const struct rhashtable_params shm_rhash_params = {
.head_offset = offsetof(struct shm_rhash, linkage),
.key_len = sizeof(u64),
.key_offset = offsetof(struct shm_rhash, global_id),
.automatic_shrinking = true,
};
static struct tee_shm *optee_shm_from_ffa_handle(struct optee *optee,
u64 global_id)
{
struct tee_shm *shm = NULL;
struct shm_rhash *r;
mutex_lock(&optee->ffa.mutex);
r = rhashtable_lookup_fast(&optee->ffa.global_ids, &global_id,
shm_rhash_params);
if (r)
shm = r->shm;
mutex_unlock(&optee->ffa.mutex);
return shm;
}
static int optee_shm_add_ffa_handle(struct optee *optee, struct tee_shm *shm,
u64 global_id)
{
struct shm_rhash *r;
int rc;
r = kmalloc_obj(*r);
if (!r)
return -ENOMEM;
r->shm = shm;
r->global_id = global_id;
mutex_lock(&optee->ffa.mutex);
rc = rhashtable_lookup_insert_fast(&optee->ffa.global_ids, &r->linkage,
shm_rhash_params);
mutex_unlock(&optee->ffa.mutex);
if (rc)
kfree(r);
return rc;
}
static int optee_shm_rem_ffa_handle(struct optee *optee, u64 global_id)
{
struct shm_rhash *r;
int rc = -ENOENT;
mutex_lock(&optee->ffa.mutex);
r = rhashtable_lookup_fast(&optee->ffa.global_ids, &global_id,
shm_rhash_params);
if (r)
rc = rhashtable_remove_fast(&optee->ffa.global_ids,
&r->linkage, shm_rhash_params);
mutex_unlock(&optee->ffa.mutex);
if (!rc)
kfree(r);
return rc;
}
/*
* 2. Convert between struct tee_param and struct optee_msg_param
*
* optee_ffa_from_msg_param() and optee_ffa_to_msg_param() are the main
* functions.
*/
static void from_msg_param_ffa_mem(struct optee *optee, struct tee_param *p,
u32 attr, const struct optee_msg_param *mp)
{
struct tee_shm *shm = NULL;
u64 offs_high = 0;
u64 offs_low = 0;
Annotation
- Immediate include surface: `linux/arm_ffa.h`, `linux/errno.h`, `linux/rpmb.h`, `linux/scatterlist.h`, `linux/sched.h`, `linux/slab.h`, `linux/string.h`, `linux/tee_core.h`.
- Detected declarations: `struct shm_rhash`, `function rh_free_fn`, `function optee_shm_add_ffa_handle`, `function optee_shm_rem_ffa_handle`, `function optee_ffa_from_msg_param`, `function optee_ffa_from_msg_param`, `function to_msg_param_ffa_mem`, `function optee_ffa_to_msg_param`, `function optee_ffa_shm_register`, `function optee_ffa_shm_unregister`.
- Atlas domain: Driver Families / drivers/tee.
- 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.