drivers/crypto/ti/dthev2-common.c
Source file repositories/reference/linux-study-clean/drivers/crypto/ti/dthev2-common.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/ti/dthev2-common.c- Extension
.c- Size
- 5664 bytes
- Lines
- 237
- Domain
- Driver Families
- Bucket
- drivers/crypto
- 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
crypto/aes.hcrypto/algapi.hcrypto/engine.hcrypto/internal/aead.hcrypto/internal/skcipher.hdthev2-common.hlinux/delay.hlinux/dmaengine.hlinux/dmapool.hlinux/dma-mapping.hlinux/io.hlinux/kernel.hlinux/module.hlinux/mod_devicetable.hlinux/platform_device.hlinux/scatterlist.h
Detected Declarations
function dthe_dma_initfunction dthe_register_algsfunction dthe_unregister_algsfunction dthe_probefunction dthe_remove
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0-only
/*
* K3 DTHE V2 crypto accelerator driver
*
* Copyright (C) Texas Instruments 2025 - https://www.ti.com
* Author: T Pratham <t-pratham@ti.com>
*/
#include <crypto/aes.h>
#include <crypto/algapi.h>
#include <crypto/engine.h>
#include <crypto/internal/aead.h>
#include <crypto/internal/skcipher.h>
#include "dthev2-common.h"
#include <linux/delay.h>
#include <linux/dmaengine.h>
#include <linux/dmapool.h>
#include <linux/dma-mapping.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/mod_devicetable.h>
#include <linux/platform_device.h>
#include <linux/scatterlist.h>
#define DRIVER_NAME "dthev2"
static struct dthe_list dthe_dev_list = {
.dev_list = LIST_HEAD_INIT(dthe_dev_list.dev_list),
.lock = __SPIN_LOCK_UNLOCKED(dthe_dev_list.lock),
};
struct dthe_data *dthe_get_dev(struct dthe_tfm_ctx *ctx)
{
struct dthe_data *dev_data;
if (ctx->dev_data)
return ctx->dev_data;
spin_lock_bh(&dthe_dev_list.lock);
dev_data = list_first_entry(&dthe_dev_list.dev_list, struct dthe_data, list);
if (dev_data)
list_move_tail(&dev_data->list, &dthe_dev_list.dev_list);
spin_unlock_bh(&dthe_dev_list.lock);
return dev_data;
}
struct scatterlist *dthe_copy_sg(struct scatterlist *dst,
struct scatterlist *src,
int buflen)
{
struct scatterlist *from_sg, *to_sg;
int sglen;
for (to_sg = dst, from_sg = src; buflen && from_sg; buflen -= sglen) {
sglen = from_sg->length;
if (sglen > buflen)
sglen = buflen;
sg_set_buf(to_sg, sg_virt(from_sg), sglen);
from_sg = sg_next(from_sg);
to_sg = sg_next(to_sg);
}
return to_sg;
}
static int dthe_dma_init(struct dthe_data *dev_data)
{
int ret;
struct dma_slave_config cfg;
dev_data->dma_aes_rx = NULL;
dev_data->dma_aes_tx = NULL;
dev_data->dma_sha_tx = NULL;
dev_data->dma_aes_rx = dma_request_chan(dev_data->dev, "rx");
if (IS_ERR(dev_data->dma_aes_rx)) {
return dev_err_probe(dev_data->dev, PTR_ERR(dev_data->dma_aes_rx),
"Unable to request rx DMA channel\n");
}
dev_data->dma_aes_tx = dma_request_chan(dev_data->dev, "tx1");
if (IS_ERR(dev_data->dma_aes_tx)) {
ret = dev_err_probe(dev_data->dev, PTR_ERR(dev_data->dma_aes_tx),
"Unable to request tx1 DMA channel\n");
goto err_dma_aes_tx;
}
Annotation
- Immediate include surface: `crypto/aes.h`, `crypto/algapi.h`, `crypto/engine.h`, `crypto/internal/aead.h`, `crypto/internal/skcipher.h`, `dthev2-common.h`, `linux/delay.h`, `linux/dmaengine.h`.
- Detected declarations: `function dthe_dma_init`, `function dthe_register_algs`, `function dthe_unregister_algs`, `function dthe_probe`, `function dthe_remove`.
- Atlas domain: Driver Families / drivers/crypto.
- 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.