Skip to content

Commit e62291c

Browse files
committed
crypto: marvell/cesa - Fix sparse warnings
This patch fixes most sparse warnings in the cesa driver. The only ones remaining are to do with copying data between iomem pointers and SG lists. Most changes are trivial. The following are the noteworthy ones: - Removal of swab in mv_cesa_aes_setkey. This appears to be bogus as everything gets swabbed again later on so for BE this ends up being different from LE. The change takes the LE behaviour as the correct one. - next_dma in mv_cesa_tdma_chain was not swabbed. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au> Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent cbdad1f commit e62291c

File tree

4 files changed

+32
-25
lines changed

4 files changed

+32
-25
lines changed

drivers/crypto/marvell/cesa/cesa.h

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ struct mv_cesa_sec_accel_desc {
237237
* Context associated to a cipher operation.
238238
*/
239239
struct mv_cesa_skcipher_op_ctx {
240-
u32 key[8];
240+
__le32 key[8];
241241
u32 iv[4];
242242
};
243243

@@ -250,7 +250,7 @@ struct mv_cesa_skcipher_op_ctx {
250250
*/
251251
struct mv_cesa_hash_op_ctx {
252252
u32 iv[16];
253-
u32 hash[8];
253+
__le32 hash[8];
254254
};
255255

256256
/**
@@ -298,8 +298,14 @@ struct mv_cesa_op_ctx {
298298
*/
299299
struct mv_cesa_tdma_desc {
300300
__le32 byte_cnt;
301-
__le32 src;
302-
__le32 dst;
301+
union {
302+
__le32 src;
303+
dma_addr_t src_dma;
304+
};
305+
union {
306+
__le32 dst;
307+
dma_addr_t dst_dma;
308+
};
303309
__le32 next_dma;
304310

305311
/* Software state */
@@ -504,7 +510,7 @@ struct mv_cesa_hash_ctx {
504510
*/
505511
struct mv_cesa_hmac_ctx {
506512
struct mv_cesa_ctx base;
507-
u32 iv[16];
513+
__be32 iv[16];
508514
};
509515

510516
/**

drivers/crypto/marvell/cesa/cipher.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,8 +264,7 @@ static int mv_cesa_aes_setkey(struct crypto_skcipher *cipher, const u8 *key,
264264
remaining = (ctx->aes.key_length - 16) / 4;
265265
offset = ctx->aes.key_length + 24 - remaining;
266266
for (i = 0; i < remaining; i++)
267-
ctx->aes.key_dec[4 + i] =
268-
cpu_to_le32(ctx->aes.key_enc[offset + i]);
267+
ctx->aes.key_dec[4 + i] = ctx->aes.key_enc[offset + i];
269268

270269
return 0;
271270
}

drivers/crypto/marvell/cesa/hash.c

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,11 @@ static void mv_cesa_ahash_std_step(struct ahash_request *req)
224224
CESA_SA_DATA_SRAM_OFFSET + len,
225225
new_cache_ptr);
226226
} else {
227-
len += mv_cesa_ahash_pad_req(creq,
228-
engine->sram + len +
229-
CESA_SA_DATA_SRAM_OFFSET);
227+
i = mv_cesa_ahash_pad_req(creq, creq->cache);
228+
len += i;
229+
memcpy_toio(engine->sram + len +
230+
CESA_SA_DATA_SRAM_OFFSET,
231+
creq->cache, i);
230232
}
231233

232234
if (frag_mode == CESA_SA_DESC_CFG_LAST_FRAG)
@@ -344,7 +346,7 @@ static void mv_cesa_ahash_complete(struct crypto_async_request *req)
344346
*/
345347
data = creq->base.chain.last->op->ctx.hash.hash;
346348
for (i = 0; i < digsize / 4; i++)
347-
creq->state[i] = cpu_to_le32(data[i]);
349+
creq->state[i] = le32_to_cpu(data[i]);
348350

349351
memcpy(ahashreq->result, data, digsize);
350352
} else {
@@ -1267,10 +1269,10 @@ static int mv_cesa_ahmac_md5_setkey(struct crypto_ahash *tfm, const u8 *key,
12671269
return ret;
12681270

12691271
for (i = 0; i < ARRAY_SIZE(istate.hash); i++)
1270-
ctx->iv[i] = be32_to_cpu(istate.hash[i]);
1272+
ctx->iv[i] = cpu_to_be32(istate.hash[i]);
12711273

12721274
for (i = 0; i < ARRAY_SIZE(ostate.hash); i++)
1273-
ctx->iv[i + 8] = be32_to_cpu(ostate.hash[i]);
1275+
ctx->iv[i + 8] = cpu_to_be32(ostate.hash[i]);
12741276

12751277
return 0;
12761278
}
@@ -1338,10 +1340,10 @@ static int mv_cesa_ahmac_sha1_setkey(struct crypto_ahash *tfm, const u8 *key,
13381340
return ret;
13391341

13401342
for (i = 0; i < ARRAY_SIZE(istate.state); i++)
1341-
ctx->iv[i] = be32_to_cpu(istate.state[i]);
1343+
ctx->iv[i] = cpu_to_be32(istate.state[i]);
13421344

13431345
for (i = 0; i < ARRAY_SIZE(ostate.state); i++)
1344-
ctx->iv[i + 8] = be32_to_cpu(ostate.state[i]);
1346+
ctx->iv[i + 8] = cpu_to_be32(ostate.state[i]);
13451347

13461348
return 0;
13471349
}
@@ -1396,10 +1398,10 @@ static int mv_cesa_ahmac_sha256_setkey(struct crypto_ahash *tfm, const u8 *key,
13961398
return ret;
13971399

13981400
for (i = 0; i < ARRAY_SIZE(istate.state); i++)
1399-
ctx->iv[i] = be32_to_cpu(istate.state[i]);
1401+
ctx->iv[i] = cpu_to_be32(istate.state[i]);
14001402

14011403
for (i = 0; i < ARRAY_SIZE(ostate.state); i++)
1402-
ctx->iv[i + 8] = be32_to_cpu(ostate.state[i]);
1404+
ctx->iv[i + 8] = cpu_to_be32(ostate.state[i]);
14031405

14041406
return 0;
14051407
}

drivers/crypto/marvell/cesa/tdma.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,10 @@ void mv_cesa_dma_prepare(struct mv_cesa_req *dreq,
8383

8484
for (tdma = dreq->chain.first; tdma; tdma = tdma->next) {
8585
if (tdma->flags & CESA_TDMA_DST_IN_SRAM)
86-
tdma->dst = cpu_to_le32(tdma->dst + engine->sram_dma);
86+
tdma->dst = cpu_to_le32(tdma->dst_dma + engine->sram_dma);
8787

8888
if (tdma->flags & CESA_TDMA_SRC_IN_SRAM)
89-
tdma->src = cpu_to_le32(tdma->src + engine->sram_dma);
89+
tdma->src = cpu_to_le32(tdma->src_dma + engine->sram_dma);
9090

9191
if ((tdma->flags & CESA_TDMA_TYPE_MSK) == CESA_TDMA_OP)
9292
mv_cesa_adjust_op(engine, tdma->op);
@@ -114,7 +114,7 @@ void mv_cesa_tdma_chain(struct mv_cesa_engine *engine,
114114
*/
115115
if (!(last->flags & CESA_TDMA_BREAK_CHAIN) &&
116116
!(dreq->chain.first->flags & CESA_TDMA_SET_STATE))
117-
last->next_dma = dreq->chain.first->cur_dma;
117+
last->next_dma = cpu_to_le32(dreq->chain.first->cur_dma);
118118
}
119119
}
120120

@@ -237,8 +237,8 @@ int mv_cesa_dma_add_result_op(struct mv_cesa_tdma_chain *chain, dma_addr_t src,
237237
return -EIO;
238238

239239
tdma->byte_cnt = cpu_to_le32(size | BIT(31));
240-
tdma->src = src;
241-
tdma->dst = op_desc->src;
240+
tdma->src_dma = src;
241+
tdma->dst_dma = op_desc->src_dma;
242242
tdma->op = op_desc->op;
243243

244244
flags &= (CESA_TDMA_DST_IN_SRAM | CESA_TDMA_SRC_IN_SRAM);
@@ -272,7 +272,7 @@ struct mv_cesa_op_ctx *mv_cesa_dma_add_op(struct mv_cesa_tdma_chain *chain,
272272
tdma->op = op;
273273
tdma->byte_cnt = cpu_to_le32(size | BIT(31));
274274
tdma->src = cpu_to_le32(dma_handle);
275-
tdma->dst = CESA_SA_CFG_SRAM_OFFSET;
275+
tdma->dst_dma = CESA_SA_CFG_SRAM_OFFSET;
276276
tdma->flags = CESA_TDMA_DST_IN_SRAM | CESA_TDMA_OP;
277277

278278
return op;
@@ -289,8 +289,8 @@ int mv_cesa_dma_add_data_transfer(struct mv_cesa_tdma_chain *chain,
289289
return PTR_ERR(tdma);
290290

291291
tdma->byte_cnt = cpu_to_le32(size | BIT(31));
292-
tdma->src = src;
293-
tdma->dst = dst;
292+
tdma->src_dma = src;
293+
tdma->dst_dma = dst;
294294

295295
flags &= (CESA_TDMA_DST_IN_SRAM | CESA_TDMA_SRC_IN_SRAM);
296296
tdma->flags = flags | CESA_TDMA_DATA;

0 commit comments

Comments
 (0)