drivers/crypto/aspeed/aspeed-acry.c
Source file repositories/reference/linux-study-clean/drivers/crypto/aspeed/aspeed-acry.c
File Facts
- System
- Linux kernel
- Corpus path
drivers/crypto/aspeed/aspeed-acry.c- Extension
.c- Size
- 20904 bytes
- Lines
- 819
- 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.
- 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
crypto/engine.hcrypto/internal/akcipher.hcrypto/internal/rsa.hcrypto/scatterwalk.hlinux/clk.hlinux/count_zeros.hlinux/dma-mapping.hlinux/err.hlinux/interrupt.hlinux/kernel.hlinux/mfd/syscon.hlinux/module.hlinux/of.hlinux/platform_device.hlinux/regmap.hlinux/slab.hlinux/string.h
Detected Declarations
struct aspeed_acry_devstruct aspeed_acry_devstruct aspeed_acry_ctxstruct aspeed_acry_algenum aspeed_rsa_key_modefunction akcipher_request_castfunction aspeed_acry_do_fallbackfunction aspeed_acry_need_fallbackfunction aspeed_acry_handle_queuefunction aspeed_acry_do_requestfunction aspeed_acry_completefunction aspeed_acry_rsa_sg_copy_to_bufferfunction aspeed_acry_rsa_ctx_copyfunction aspeed_acry_rsa_transferfunction aspeed_acry_rsa_triggerfunction aspeed_acry_rsa_encfunction aspeed_acry_rsa_decfunction aspeed_rsa_set_nfunction aspeed_rsa_set_efunction aspeed_rsa_set_dfunction aspeed_rsa_key_freefunction aspeed_acry_rsa_setkeyfunction aspeed_acry_rsa_set_pub_keyfunction aspeed_acry_rsa_set_priv_keyfunction aspeed_acry_rsa_max_sizefunction aspeed_acry_rsa_init_tfmfunction aspeed_acry_rsa_exit_tfmfunction aspeed_acry_registerfunction aspeed_acry_unregisterfunction aspeed_acry_irqfunction aspeed_acry_sram_mappingfunction aspeed_acry_done_taskfunction aspeed_acry_probefunction aspeed_acry_remove
Annotated Snippet
struct aspeed_acry_dev {
void __iomem *regs;
struct device *dev;
int irq;
struct clk *clk;
struct regmap *ahbc;
struct akcipher_request *req;
struct tasklet_struct done_task;
aspeed_acry_fn_t resume;
unsigned long flags;
/* ACRY output SRAM buffer */
void __iomem *acry_sram;
/* ACRY input DMA buffer */
void *buf_addr;
dma_addr_t buf_dma_addr;
struct crypto_engine *crypt_engine_rsa;
/* ACRY SRAM memory mapped */
int exp_dw_mapping[ASPEED_ACRY_RSA_MAX_KEY_LEN];
int mod_dw_mapping[ASPEED_ACRY_RSA_MAX_KEY_LEN];
int data_byte_mapping[ASPEED_ACRY_SRAM_MAX_LEN];
};
struct aspeed_acry_ctx {
struct aspeed_acry_dev *acry_dev;
struct rsa_key key;
int enc;
u8 *n;
u8 *e;
u8 *d;
size_t n_sz;
size_t e_sz;
size_t d_sz;
aspeed_acry_fn_t trigger;
struct crypto_akcipher *fallback_tfm;
};
struct aspeed_acry_alg {
struct aspeed_acry_dev *acry_dev;
struct akcipher_engine_alg akcipher;
};
enum aspeed_rsa_key_mode {
ASPEED_RSA_EXP_MODE = 0,
ASPEED_RSA_MOD_MODE,
ASPEED_RSA_DATA_MODE,
};
static inline struct akcipher_request *
akcipher_request_cast(struct crypto_async_request *req)
{
return container_of(req, struct akcipher_request, base);
}
static int aspeed_acry_do_fallback(struct akcipher_request *req)
{
struct crypto_akcipher *cipher = crypto_akcipher_reqtfm(req);
struct aspeed_acry_ctx *ctx = akcipher_tfm_ctx(cipher);
int err;
akcipher_request_set_tfm(req, ctx->fallback_tfm);
if (ctx->enc)
err = crypto_akcipher_encrypt(req);
else
err = crypto_akcipher_decrypt(req);
akcipher_request_set_tfm(req, cipher);
return err;
}
static bool aspeed_acry_need_fallback(struct akcipher_request *req)
{
struct crypto_akcipher *cipher = crypto_akcipher_reqtfm(req);
struct aspeed_acry_ctx *ctx = akcipher_tfm_ctx(cipher);
return ctx->key.n_sz > ASPEED_ACRY_RSA_MAX_KEY_LEN;
}
static int aspeed_acry_handle_queue(struct aspeed_acry_dev *acry_dev,
struct akcipher_request *req)
{
Annotation
- Immediate include surface: `crypto/engine.h`, `crypto/internal/akcipher.h`, `crypto/internal/rsa.h`, `crypto/scatterwalk.h`, `linux/clk.h`, `linux/count_zeros.h`, `linux/dma-mapping.h`, `linux/err.h`.
- Detected declarations: `struct aspeed_acry_dev`, `struct aspeed_acry_dev`, `struct aspeed_acry_ctx`, `struct aspeed_acry_alg`, `enum aspeed_rsa_key_mode`, `function akcipher_request_cast`, `function aspeed_acry_do_fallback`, `function aspeed_acry_need_fallback`, `function aspeed_acry_handle_queue`, `function aspeed_acry_do_request`.
- Atlas domain: Driver Families / drivers/crypto.
- Implementation status: source implementation candidate.
- 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.