drivers/tee/amdtee/shm_pool.c
Source file repositories/reference/linux-study-clean/drivers/tee/amdtee/shm_pool.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/tee/amdtee/shm_pool.c- Extension
.c- Size
- 1456 bytes
- Lines
- 71
- 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.
- 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/slab.hlinux/tee_core.hlinux/psp.hamdtee_private.h
Detected Declarations
function pool_op_allocfunction pool_op_freefunction pool_op_destroy_pool
Annotated Snippet
// SPDX-License-Identifier: MIT
/*
* Copyright 2019 Advanced Micro Devices, Inc.
*/
#include <linux/slab.h>
#include <linux/tee_core.h>
#include <linux/psp.h>
#include "amdtee_private.h"
static int pool_op_alloc(struct tee_shm_pool *pool, struct tee_shm *shm,
size_t size, size_t align)
{
unsigned int order = get_order(size);
unsigned long va;
int rc;
/*
* Ignore alignment since this is already going to be page aligned
* and there's no need for any larger alignment.
*/
va = __get_free_pages(GFP_KERNEL | __GFP_ZERO, order);
if (!va)
return -ENOMEM;
shm->kaddr = (void *)va;
shm->paddr = __psp_pa((void *)va);
shm->size = PAGE_SIZE << order;
/* Map the allocated memory in to TEE */
rc = amdtee_map_shmem(shm);
if (rc) {
free_pages(va, order);
shm->kaddr = NULL;
return rc;
}
return 0;
}
static void pool_op_free(struct tee_shm_pool *pool, struct tee_shm *shm)
{
/* Unmap the shared memory from TEE */
amdtee_unmap_shmem(shm);
free_pages((unsigned long)shm->kaddr, get_order(shm->size));
shm->kaddr = NULL;
}
static void pool_op_destroy_pool(struct tee_shm_pool *pool)
{
kfree(pool);
}
static const struct tee_shm_pool_ops pool_ops = {
.alloc = pool_op_alloc,
.free = pool_op_free,
.destroy_pool = pool_op_destroy_pool,
};
struct tee_shm_pool *amdtee_config_shm(void)
{
struct tee_shm_pool *pool = kzalloc_obj(*pool);
if (!pool)
return ERR_PTR(-ENOMEM);
pool->ops = &pool_ops;
return pool;
}
Annotation
- Immediate include surface: `linux/slab.h`, `linux/tee_core.h`, `linux/psp.h`, `amdtee_private.h`.
- Detected declarations: `function pool_op_alloc`, `function pool_op_free`, `function pool_op_destroy_pool`.
- Atlas domain: Driver Families / drivers/tee.
- Implementation status: source implementation candidate.
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.