Skip to content

Commit e055bff

Browse files
committed
crypto: chelsio - Set DMA alignment explicitly
This driver has been implicitly relying on kmalloc alignment to be sufficient for DMA. This may no longer be the case with upcoming arm64 changes. This patch changes it to explicitly request DMA alignment from the Crypto API. Signed-off-by: Herbert Xu <[email protected]>
1 parent 07547fa commit e055bff

File tree

1 file changed

+22
-21
lines changed

1 file changed

+22
-21
lines changed

drivers/crypto/chelsio/chcr_algo.c

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ static inline int chcr_handle_aead_resp(struct aead_request *req,
210210
unsigned char *input,
211211
int err)
212212
{
213-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
213+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
214214
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
215215
struct chcr_dev *dev = a_ctx(tfm)->dev;
216216

@@ -718,7 +718,7 @@ static inline int get_qidxs(struct crypto_async_request *req,
718718
{
719719
struct aead_request *aead_req =
720720
container_of(req, struct aead_request, base);
721-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(aead_req);
721+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(aead_req);
722722
*txqidx = reqctx->txqidx;
723723
*rxqidx = reqctx->rxqidx;
724724
break;
@@ -2362,7 +2362,7 @@ static void chcr_hmac_cra_exit(struct crypto_tfm *tfm)
23622362

23632363
inline void chcr_aead_common_exit(struct aead_request *req)
23642364
{
2365-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
2365+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
23662366
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
23672367
struct uld_ctx *u_ctx = ULD_CTX(a_ctx(tfm));
23682368

@@ -2373,7 +2373,7 @@ static int chcr_aead_common_init(struct aead_request *req)
23732373
{
23742374
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
23752375
struct chcr_aead_ctx *aeadctx = AEAD_CTX(a_ctx(tfm));
2376-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
2376+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
23772377
unsigned int authsize = crypto_aead_authsize(tfm);
23782378
int error = -EINVAL;
23792379

@@ -2417,7 +2417,7 @@ static int chcr_aead_fallback(struct aead_request *req, unsigned short op_type)
24172417
{
24182418
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
24192419
struct chcr_aead_ctx *aeadctx = AEAD_CTX(a_ctx(tfm));
2420-
struct aead_request *subreq = aead_request_ctx(req);
2420+
struct aead_request *subreq = aead_request_ctx_dma(req);
24212421

24222422
aead_request_set_tfm(subreq, aeadctx->sw_cipher);
24232423
aead_request_set_callback(subreq, req->base.flags,
@@ -2438,7 +2438,7 @@ static struct sk_buff *create_authenc_wr(struct aead_request *req,
24382438
struct uld_ctx *u_ctx = ULD_CTX(ctx);
24392439
struct chcr_aead_ctx *aeadctx = AEAD_CTX(ctx);
24402440
struct chcr_authenc_ctx *actx = AUTHENC_CTX(aeadctx);
2441-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
2441+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
24422442
struct sk_buff *skb = NULL;
24432443
struct chcr_wr *chcr_req;
24442444
struct cpl_rx_phys_dsgl *phys_cpl;
@@ -2576,7 +2576,7 @@ int chcr_aead_dma_map(struct device *dev,
25762576
unsigned short op_type)
25772577
{
25782578
int error;
2579-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
2579+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
25802580
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
25812581
unsigned int authsize = crypto_aead_authsize(tfm);
25822582
int src_len, dst_len;
@@ -2637,7 +2637,7 @@ void chcr_aead_dma_unmap(struct device *dev,
26372637
struct aead_request *req,
26382638
unsigned short op_type)
26392639
{
2640-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
2640+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
26412641
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
26422642
unsigned int authsize = crypto_aead_authsize(tfm);
26432643
int src_len, dst_len;
@@ -2678,7 +2678,7 @@ void chcr_add_aead_src_ent(struct aead_request *req,
26782678
struct ulptx_sgl *ulptx)
26792679
{
26802680
struct ulptx_walk ulp_walk;
2681-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
2681+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
26822682

26832683
if (reqctx->imm) {
26842684
u8 *buf = (u8 *)ulptx;
@@ -2704,7 +2704,7 @@ void chcr_add_aead_dst_ent(struct aead_request *req,
27042704
struct cpl_rx_phys_dsgl *phys_cpl,
27052705
unsigned short qid)
27062706
{
2707-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
2707+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
27082708
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
27092709
struct dsgl_walk dsgl_walk;
27102710
unsigned int authsize = crypto_aead_authsize(tfm);
@@ -2894,7 +2894,7 @@ static int generate_b0(struct aead_request *req, u8 *ivptr,
28942894
unsigned int l, lp, m;
28952895
int rc;
28962896
struct crypto_aead *aead = crypto_aead_reqtfm(req);
2897-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
2897+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
28982898
u8 *b0 = reqctx->scratch_pad;
28992899

29002900
m = crypto_aead_authsize(aead);
@@ -2932,7 +2932,7 @@ static int ccm_format_packet(struct aead_request *req,
29322932
unsigned short op_type,
29332933
unsigned int assoclen)
29342934
{
2935-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
2935+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
29362936
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
29372937
struct chcr_aead_ctx *aeadctx = AEAD_CTX(a_ctx(tfm));
29382938
int rc = 0;
@@ -2963,7 +2963,7 @@ static void fill_sec_cpl_for_aead(struct cpl_tx_sec_pdu *sec_cpl,
29632963
struct chcr_context *ctx = a_ctx(tfm);
29642964
struct uld_ctx *u_ctx = ULD_CTX(ctx);
29652965
struct chcr_aead_ctx *aeadctx = AEAD_CTX(ctx);
2966-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
2966+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
29672967
unsigned int cipher_mode = CHCR_SCMD_CIPHER_MODE_AES_CCM;
29682968
unsigned int mac_mode = CHCR_SCMD_AUTH_MODE_CBCMAC;
29692969
unsigned int rx_channel_id = reqctx->rxqidx / ctx->rxq_perchan;
@@ -3036,7 +3036,7 @@ static struct sk_buff *create_aead_ccm_wr(struct aead_request *req,
30363036
{
30373037
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
30383038
struct chcr_aead_ctx *aeadctx = AEAD_CTX(a_ctx(tfm));
3039-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
3039+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
30403040
struct sk_buff *skb = NULL;
30413041
struct chcr_wr *chcr_req;
30423042
struct cpl_rx_phys_dsgl *phys_cpl;
@@ -3135,7 +3135,7 @@ static struct sk_buff *create_gcm_wr(struct aead_request *req,
31353135
struct chcr_context *ctx = a_ctx(tfm);
31363136
struct uld_ctx *u_ctx = ULD_CTX(ctx);
31373137
struct chcr_aead_ctx *aeadctx = AEAD_CTX(ctx);
3138-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
3138+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
31393139
struct sk_buff *skb = NULL;
31403140
struct chcr_wr *chcr_req;
31413141
struct cpl_rx_phys_dsgl *phys_cpl;
@@ -3255,9 +3255,10 @@ static int chcr_aead_cra_init(struct crypto_aead *tfm)
32553255
CRYPTO_ALG_ASYNC);
32563256
if (IS_ERR(aeadctx->sw_cipher))
32573257
return PTR_ERR(aeadctx->sw_cipher);
3258-
crypto_aead_set_reqsize(tfm, max(sizeof(struct chcr_aead_reqctx),
3259-
sizeof(struct aead_request) +
3260-
crypto_aead_reqsize(aeadctx->sw_cipher)));
3258+
crypto_aead_set_reqsize_dma(
3259+
tfm, max(sizeof(struct chcr_aead_reqctx),
3260+
sizeof(struct aead_request) +
3261+
crypto_aead_reqsize(aeadctx->sw_cipher)));
32613262
return chcr_device_init(a_ctx(tfm));
32623263
}
32633264

@@ -3735,7 +3736,7 @@ static int chcr_aead_op(struct aead_request *req,
37353736
create_wr_t create_wr_fn)
37363737
{
37373738
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
3738-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
3739+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
37393740
struct chcr_context *ctx = a_ctx(tfm);
37403741
struct uld_ctx *u_ctx = ULD_CTX(ctx);
37413742
struct sk_buff *skb;
@@ -3785,7 +3786,7 @@ static int chcr_aead_op(struct aead_request *req,
37853786
static int chcr_aead_encrypt(struct aead_request *req)
37863787
{
37873788
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
3788-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
3789+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
37893790
struct chcr_context *ctx = a_ctx(tfm);
37903791
unsigned int cpu;
37913792

@@ -3816,7 +3817,7 @@ static int chcr_aead_decrypt(struct aead_request *req)
38163817
struct crypto_aead *tfm = crypto_aead_reqtfm(req);
38173818
struct chcr_context *ctx = a_ctx(tfm);
38183819
struct chcr_aead_ctx *aeadctx = AEAD_CTX(ctx);
3819-
struct chcr_aead_reqctx *reqctx = aead_request_ctx(req);
3820+
struct chcr_aead_reqctx *reqctx = aead_request_ctx_dma(req);
38203821
int size;
38213822
unsigned int cpu;
38223823

0 commit comments

Comments
 (0)