drivers/crypto/ccp/platform-access.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ccp/platform-access.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ccp/platform-access.c- Extension
.c- Size
- 5670 bytes
- Lines
- 228
- 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/errno.hlinux/iopoll.hlinux/mutex.hplatform-access.h
Detected Declarations
function Processorfunction wait_cmdfunction psp_check_platform_access_statusfunction psp_send_platform_access_msgfunction ioread32function psp_ring_platform_doorbellfunction platform_access_dev_destroyfunction platform_access_dev_initexport psp_check_platform_access_statusexport psp_send_platform_access_msgexport psp_ring_platform_doorbell
Annotated Snippet
ioread32(hi) != upper_32_bits(req_addr)) {
ret = -EBUSY;
goto unlock;
}
/*
* Read status from PSP. If status is non-zero, it indicates an error
* occurred during "processing" of the command.
* If status is zero, it indicates the command was "processed"
* successfully, but the result of the command is in the payload.
* Return both cases to the caller as -EIO to investigate.
*/
cmd_reg = ioread32(cmd);
if (FIELD_GET(PSP_CMDRESP_STS, cmd_reg))
req->header.status = FIELD_GET(PSP_CMDRESP_STS, cmd_reg);
if (req->header.status) {
ret = -EIO;
goto unlock;
}
print_hex_dump_debug("<-psp ", DUMP_PREFIX_OFFSET, 16, 2, req,
req->header.payload_size, false);
ret = 0;
unlock:
mutex_unlock(&pa_dev->mailbox_mutex);
return ret;
}
EXPORT_SYMBOL_GPL(psp_send_platform_access_msg);
int psp_ring_platform_doorbell(int msg, u32 *result)
{
struct psp_device *psp = psp_get_master_device();
struct psp_platform_access_device *pa_dev;
u32 __iomem *button, *cmd;
int ret, val;
if (!psp || !psp->platform_access_data)
return -ENODEV;
pa_dev = psp->platform_access_data;
button = psp->io_regs + pa_dev->vdata->doorbell_button_reg;
cmd = psp->io_regs + pa_dev->vdata->doorbell_cmd_reg;
mutex_lock(&pa_dev->doorbell_mutex);
if (wait_cmd(cmd)) {
dev_err(psp->dev, "doorbell command not done processing\n");
ret = -EBUSY;
goto unlock;
}
iowrite32(FIELD_PREP(DOORBELL_CMDRESP_STS, msg), cmd);
iowrite32(PSP_DRBL_RING, button);
if (wait_cmd(cmd)) {
ret = -ETIMEDOUT;
goto unlock;
}
val = FIELD_GET(DOORBELL_CMDRESP_STS, ioread32(cmd));
if (val) {
if (result)
*result = val;
ret = -EIO;
goto unlock;
}
ret = 0;
unlock:
mutex_unlock(&pa_dev->doorbell_mutex);
return ret;
}
EXPORT_SYMBOL_GPL(psp_ring_platform_doorbell);
void platform_access_dev_destroy(struct psp_device *psp)
{
struct psp_platform_access_device *pa_dev = psp->platform_access_data;
if (!pa_dev)
return;
mutex_destroy(&pa_dev->mailbox_mutex);
mutex_destroy(&pa_dev->doorbell_mutex);
psp->platform_access_data = NULL;
}
Annotation
- Immediate include surface: `linux/bitfield.h`, `linux/errno.h`, `linux/iopoll.h`, `linux/mutex.h`, `platform-access.h`.
- Detected declarations: `function Processor`, `function wait_cmd`, `function psp_check_platform_access_status`, `function psp_send_platform_access_msg`, `function ioread32`, `function psp_ring_platform_doorbell`, `function platform_access_dev_destroy`, `function platform_access_dev_init`, `export psp_check_platform_access_status`, `export psp_send_platform_access_msg`.
- 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.