drivers/crypto/ccp/dbc.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ccp/dbc.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ccp/dbc.c- Extension
.c- Size
- 6529 bytes
- Lines
- 260
- Domain
- Driver Families
- Bucket
- drivers/crypto
- Inferred role
- Driver Families: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/mutex.hdbc.h
Detected Declarations
struct error_mapfunction send_dbc_cmd_thru_extfunction send_dbc_cmd_thru_pafunction send_dbc_cmdfunction send_dbc_noncefunction send_dbc_parameterfunction dbc_dev_destroyfunction dbc_ioctlfunction dbc_dev_init
Annotated Snippet
static const struct file_operations dbc_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = dbc_ioctl,
};
int dbc_dev_init(struct psp_device *psp)
{
struct device *dev = psp->dev;
struct psp_dbc_device *dbc_dev;
int ret;
dbc_dev = devm_kzalloc(dev, sizeof(*dbc_dev), GFP_KERNEL);
if (!dbc_dev)
return -ENOMEM;
BUILD_BUG_ON(sizeof(union dbc_buffer) > PAGE_SIZE);
dbc_dev->mbox = (void *)devm_get_free_pages(dev, GFP_KERNEL | __GFP_ZERO, 0);
if (!dbc_dev->mbox) {
ret = -ENOMEM;
goto cleanup_dev;
}
psp->dbc_data = dbc_dev;
dbc_dev->dev = dev;
dbc_dev->psp = psp;
if (psp->capability.dbc_thru_ext) {
dbc_dev->use_ext = true;
dbc_dev->payload_size = &dbc_dev->mbox->ext_req.header.payload_size;
dbc_dev->result = &dbc_dev->mbox->ext_req.header.status;
dbc_dev->payload = &dbc_dev->mbox->ext_req.buf;
dbc_dev->header_size = sizeof(struct psp_ext_req_buffer_hdr);
} else {
dbc_dev->payload_size = &dbc_dev->mbox->pa_req.header.payload_size;
dbc_dev->result = &dbc_dev->mbox->pa_req.header.status;
dbc_dev->payload = &dbc_dev->mbox->pa_req.buf;
dbc_dev->header_size = sizeof(struct psp_req_buffer_hdr);
}
ret = send_dbc_nonce(dbc_dev);
if (ret == -EACCES) {
dev_dbg(dbc_dev->dev,
"dynamic boost control was previously authenticated\n");
ret = 0;
}
dev_dbg(dbc_dev->dev, "dynamic boost control is %savailable\n",
ret ? "un" : "");
if (ret) {
ret = 0;
goto cleanup_mbox;
}
dbc_dev->char_dev.minor = MISC_DYNAMIC_MINOR;
dbc_dev->char_dev.name = "dbc";
dbc_dev->char_dev.fops = &dbc_fops;
dbc_dev->char_dev.mode = 0600;
ret = misc_register(&dbc_dev->char_dev);
if (ret)
goto cleanup_mbox;
mutex_init(&dbc_dev->ioctl_mutex);
return 0;
cleanup_mbox:
devm_free_pages(dev, (unsigned long)dbc_dev->mbox);
cleanup_dev:
psp->dbc_data = NULL;
devm_kfree(dev, dbc_dev);
return ret;
}
Annotation
- Immediate include surface: `linux/mutex.h`, `dbc.h`.
- Detected declarations: `struct error_map`, `function send_dbc_cmd_thru_ext`, `function send_dbc_cmd_thru_pa`, `function send_dbc_cmd`, `function send_dbc_nonce`, `function send_dbc_parameter`, `function dbc_dev_destroy`, `function dbc_ioctl`, `function dbc_dev_init`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
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.