drivers/crypto/amlogic/amlogic-gxl-cipher.c
Source file repositories/reference/linux-study-clean/drivers/crypto/amlogic/amlogic-gxl-cipher.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/amlogic/amlogic-gxl-cipher.c- Extension
.c- Size
- 10226 bytes
- Lines
- 372
- 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.
- Touches IRQ or DMA behavior; this matters for the representative real-device path.
- 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/crypto.hlinux/delay.hlinux/io.hcrypto/scatterwalk.hlinux/scatterlist.hlinux/dma-mapping.hcrypto/internal/skcipher.hamlogic-gxl.h
Detected Declarations
function Copyrightfunction meson_cipher_need_fallbackfunction meson_cipher_do_fallbackfunction meson_cipherfunction meson_handle_cipher_requestfunction meson_skdecryptfunction meson_skencryptfunction meson_cipher_initfunction meson_cipher_exitfunction meson_aes_setkey
Annotated Snippet
if (ivsize > areq->cryptlen) {
dev_err(mc->dev, "invalid ivsize=%d vs len=%d\n", ivsize, areq->cryptlen);
err = -EINVAL;
goto theend;
}
memcpy(bkeyiv + 32, areq->iv, ivsize);
keyivlen = 48;
if (rctx->op_dir == MESON_DECRYPT) {
backup_iv = kzalloc(ivsize, GFP_KERNEL);
if (!backup_iv) {
err = -ENOMEM;
goto theend;
}
offset = areq->cryptlen - ivsize;
scatterwalk_map_and_copy(backup_iv, areq->src, offset,
ivsize, 0);
}
}
if (keyivlen == 24)
keyivlen = 32;
phykeyiv = dma_map_single(mc->dev, bkeyiv, keyivlen,
DMA_TO_DEVICE);
err = dma_mapping_error(mc->dev, phykeyiv);
if (err) {
dev_err(mc->dev, "Cannot DMA MAP KEY IV\n");
goto theend;
}
tloffset = 0;
eat = 0;
i = 0;
while (keyivlen > eat) {
desc = &mc->chanlist[flow].tl[tloffset];
memset(desc, 0, sizeof(struct meson_desc));
todo = min(keyivlen - eat, 16u);
desc->t_src = cpu_to_le32(phykeyiv + i * 16);
desc->t_dst = cpu_to_le32(i * 16);
v = (MODE_KEY << 20) | DESC_OWN | 16;
desc->t_status = cpu_to_le32(v);
eat += todo;
i++;
tloffset++;
}
if (areq->src == areq->dst) {
nr_sgs = dma_map_sg(mc->dev, areq->src, sg_nents(areq->src),
DMA_BIDIRECTIONAL);
if (!nr_sgs) {
dev_err(mc->dev, "Invalid SG count %d\n", nr_sgs);
err = -EINVAL;
goto theend;
}
nr_sgd = nr_sgs;
} else {
nr_sgs = dma_map_sg(mc->dev, areq->src, sg_nents(areq->src),
DMA_TO_DEVICE);
if (!nr_sgs || nr_sgs > MAXDESC - 3) {
dev_err(mc->dev, "Invalid SG count %d\n", nr_sgs);
err = -EINVAL;
goto theend;
}
nr_sgd = dma_map_sg(mc->dev, areq->dst, sg_nents(areq->dst),
DMA_FROM_DEVICE);
if (!nr_sgd || nr_sgd > MAXDESC - 3) {
dev_err(mc->dev, "Invalid SG count %d\n", nr_sgd);
err = -EINVAL;
goto theend;
}
}
src_sg = areq->src;
dst_sg = areq->dst;
len = areq->cryptlen;
while (src_sg) {
desc = &mc->chanlist[flow].tl[tloffset];
memset(desc, 0, sizeof(struct meson_desc));
desc->t_src = cpu_to_le32(sg_dma_address(src_sg));
desc->t_dst = cpu_to_le32(sg_dma_address(dst_sg));
todo = min(len, sg_dma_len(src_sg));
v = (op->keymode << 20) | DESC_OWN | todo | (algt->blockmode << 26);
if (rctx->op_dir)
v |= DESC_ENCRYPTION;
len -= todo;
if (!sg_next(src_sg))
v |= DESC_LAST;
desc->t_status = cpu_to_le32(v);
Annotation
- Immediate include surface: `linux/crypto.h`, `linux/delay.h`, `linux/io.h`, `crypto/scatterwalk.h`, `linux/scatterlist.h`, `linux/dma-mapping.h`, `crypto/internal/skcipher.h`, `amlogic-gxl.h`.
- Detected declarations: `function Copyright`, `function meson_cipher_need_fallback`, `function meson_cipher_do_fallback`, `function meson_cipher`, `function meson_handle_cipher_request`, `function meson_skdecrypt`, `function meson_skencrypt`, `function meson_cipher_init`, `function meson_cipher_exit`, `function meson_aes_setkey`.
- 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.
- IRQ or DMA behavior appears here, which is relevant to the selected PCIe/NVMe device path.
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.