drivers/crypto/ccp/tee-dev.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ccp/tee-dev.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ccp/tee-dev.c- Extension
.c- Size
- 8847 bytes
- Lines
- 400
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/bitfield.hlinux/types.hlinux/mutex.hlinux/delay.hlinux/slab.hlinux/gfp.hlinux/psp.hlinux/psp-tee.hpsp-dev.htee-dev.h
Detected Declarations
function tee_alloc_ringfunction tee_free_ringfunction tee_free_cmd_bufferfunction tee_send_destroy_cmdfunction tee_init_ringfunction tee_destroy_ringfunction tee_dev_initfunction tee_dev_destroyfunction tee_submit_cmdfunction tee_wait_cmd_completionfunction psp_tee_process_cmdfunction psp_check_tee_statusfunction tee_restoreexport psp_tee_process_cmdexport psp_check_tee_status
Annotated Snippet
if (!retry && FIELD_GET(PSP_CMDRESP_STS, reg) == PSP_TEE_STS_RING_BUSY) {
dev_info(tee->dev, "tee: ring init command failed with busy status, retrying\n");
if (tee_send_destroy_cmd(tee)) {
retry = true;
goto retry_init;
}
}
dev_err(tee->dev, "tee: ring init command failed (%#010lx)\n",
FIELD_GET(PSP_CMDRESP_STS, reg));
tee_free_ring(tee);
psp_dead = true;
ret = -EIO;
}
free_buf:
tee_free_cmd_buffer(cmd);
return ret;
}
static void tee_destroy_ring(struct psp_tee_device *tee)
{
if (!tee->rb_mgr.ring_start)
return;
if (psp_dead)
goto free_ring;
tee_send_destroy_cmd(tee);
free_ring:
tee_free_ring(tee);
}
int tee_dev_init(struct psp_device *psp)
{
struct device *dev = psp->dev;
struct psp_tee_device *tee;
int ret;
ret = -ENOMEM;
tee = devm_kzalloc(dev, sizeof(*tee), GFP_KERNEL);
if (!tee)
goto e_err;
psp->tee_data = tee;
tee->dev = dev;
tee->psp = psp;
tee->io_regs = psp->io_regs;
tee->vdata = (struct tee_vdata *)psp->vdata->tee;
if (!tee->vdata) {
ret = -ENODEV;
dev_err(dev, "tee: missing driver data\n");
goto e_err;
}
ret = tee_init_ring(tee);
if (ret) {
dev_err(dev, "tee: failed to init ring buffer\n");
goto e_err;
}
dev_notice(dev, "tee enabled\n");
return 0;
e_err:
psp->tee_data = NULL;
dev_notice(dev, "tee initialization failed\n");
return ret;
}
void tee_dev_destroy(struct psp_device *psp)
{
struct psp_tee_device *tee = psp->tee_data;
if (!tee)
return;
tee_destroy_ring(tee);
}
static int tee_submit_cmd(struct psp_tee_device *tee, enum tee_cmd_id cmd_id,
void *buf, size_t len, struct tee_ring_cmd **resp)
{
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/types.h`, `linux/mutex.h`, `linux/delay.h`, `linux/slab.h`, `linux/gfp.h`, `linux/psp.h`, `linux/psp-tee.h`.
- Detected declarations: `function tee_alloc_ring`, `function tee_free_ring`, `function tee_free_cmd_buffer`, `function tee_send_destroy_cmd`, `function tee_init_ring`, `function tee_destroy_ring`, `function tee_dev_init`, `function tee_dev_destroy`, `function tee_submit_cmd`, `function tee_wait_cmd_completion`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: integration 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.