[PATCH 10/16] crypto: rockchip: rework by using crypto_engine
kernel test robot
lkp at intel.com
Mon Feb 28 17:26:09 PST 2022
Hi Corentin,
I love your patch! Perhaps something to improve:
[auto build test WARNING on rockchip/for-next]
[also build test WARNING on herbert-cryptodev-2.6/master herbert-crypto-2.6/master v5.17-rc6 next-20220228]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Corentin-Labbe/crypto-rockchip-permit-to-pass-self-tests/20220301-035430
base: https://git.kernel.org/pub/scm/linux/kernel/git/mmind/linux-rockchip.git for-next
config: arm-defconfig (https://download.01.org/0day-ci/archive/20220301/202203010927.TpnG5TzB-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/7e5f8e4a5f09473643937e0ecff342bf336793fb
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Corentin-Labbe/crypto-rockchip-permit-to-pass-self-tests/20220301-035430
git checkout 7e5f8e4a5f09473643937e0ecff342bf336793fb
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=arm SHELL=/bin/bash drivers/crypto/rockchip/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp at intel.com>
All warnings (new ones prefixed by >>):
In file included from include/linux/device.h:15,
from drivers/crypto/rockchip/rk3288_crypto_skcipher.c:11:
drivers/crypto/rockchip/rk3288_crypto_skcipher.c: In function 'rk_cipher_run':
>> drivers/crypto/rockchip/rk3288_crypto_skcipher.c:383:40: warning: format '%x' expects argument of type 'unsigned int', but argument 12 has type 'long unsigned int' [-Wformat=]
383 | dev_dbg(ctx->dev->dev, "LEN=%d/%d/%u ivsize=%d mode=%x n=%d BI=%d todo=%u way=%x\n",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/dev_printk.h:129:41: note: in definition of macro 'dev_printk'
129 | _dev_printk(level, dev, fmt, ##__VA_ARGS__); \
| ^~~
include/linux/dev_printk.h:163:45: note: in expansion of macro 'dev_fmt'
163 | dev_printk(KERN_DEBUG, dev, dev_fmt(fmt), ##__VA_ARGS__); \
| ^~~~~~~
drivers/crypto/rockchip/rk3288_crypto_skcipher.c:383:17: note: in expansion of macro 'dev_dbg'
383 | dev_dbg(ctx->dev->dev, "LEN=%d/%d/%u ivsize=%d mode=%x n=%d BI=%d todo=%u way=%x\n",
| ^~~~~~~
drivers/crypto/rockchip/rk3288_crypto_skcipher.c:383:96: note: format string is defined here
383 | dev_dbg(ctx->dev->dev, "LEN=%d/%d/%u ivsize=%d mode=%x n=%d BI=%d todo=%u way=%x\n",
| ~^
| |
| unsigned int
| %lx
drivers/crypto/rockchip/rk3288_crypto_skcipher.c: In function 'rk_ablk_exit_tfm':
drivers/crypto/rockchip/rk3288_crypto_skcipher.c:474:31: warning: unused variable 'ctx' [-Wunused-variable]
474 | struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
| ^~~
vim +383 drivers/crypto/rockchip/rk3288_crypto_skcipher.c
311
312 static int rk_cipher_run(struct crypto_engine *engine, void *async_req)
313 {
314 struct skcipher_request *areq = container_of(async_req, struct skcipher_request, base);
315 struct crypto_skcipher *tfm = crypto_skcipher_reqtfm(areq);
316 struct rk_cipher_ctx *ctx = crypto_skcipher_ctx(tfm);
317 struct rk_cipher_rctx *rctx = skcipher_request_ctx(areq);
318 struct scatterlist *sgs, *sgd;
319 int err = 0;
320 int n = 0;
321 int ivsize = crypto_skcipher_ivsize(tfm);
322 int offset;
323 u8 iv[AES_BLOCK_SIZE];
324 u8 biv[AES_BLOCK_SIZE];
325 u8 *ivtouse = areq->iv;
326 unsigned int len = areq->cryptlen;
327 unsigned int todo;
328
329 ivsize = crypto_skcipher_ivsize(tfm);
330 if (areq->iv && crypto_skcipher_ivsize(tfm) > 0) {
331 if (rctx->mode & RK_CRYPTO_DEC) {
332 offset = areq->cryptlen - ivsize;
333 scatterwalk_map_and_copy(rctx->backup_iv, areq->src,
334 offset, ivsize, 0);
335 }
336 }
337
338 sgs = areq->src;
339 sgd = areq->dst;
340
341 while (sgs && sgd && len) {
342 if (!sgs->length) {
343 sgs = sg_next(sgs);
344 sgd = sg_next(sgd);
345 continue;
346 }
347 if (rctx->mode & RK_CRYPTO_DEC) {
348 /* we backup last block of source to be used as IV at next step */
349 offset = sgs->length - ivsize;
350 scatterwalk_map_and_copy(biv, sgs, offset, ivsize, 0);
351 }
352 if (sgs == sgd) {
353 err = dma_map_sg(ctx->dev->dev, sgs, 1, DMA_BIDIRECTIONAL);
354 if (err <= 0) {
355 err = -EINVAL;
356 goto theend_iv;
357 }
358 } else {
359 err = dma_map_sg(ctx->dev->dev, sgs, 1, DMA_TO_DEVICE);
360 if (err <= 0) {
361 err = -EINVAL;
362 goto theend_iv;
363 }
364 err = dma_map_sg(ctx->dev->dev, sgd, 1, DMA_FROM_DEVICE);
365 if (err <= 0) {
366 err = -EINVAL;
367 goto theend_sgs;
368 }
369 }
370 err = 0;
371 rk_ablk_hw_init(ctx->dev, areq);
372 if (ivsize) {
373 if (ivsize == DES_BLOCK_SIZE)
374 memcpy_toio(ctx->dev->reg + RK_CRYPTO_TDES_IV_0, ivtouse, ivsize);
375 else
376 memcpy_toio(ctx->dev->reg + RK_CRYPTO_AES_IV_0, ivtouse, ivsize);
377 }
378 reinit_completion(&ctx->dev->complete);
379 ctx->dev->status = 0;
380
381 todo = min(sg_dma_len(sgs), len);
382 len -= todo;
> 383 dev_dbg(ctx->dev->dev, "LEN=%d/%d/%u ivsize=%d mode=%x n=%d BI=%d todo=%u way=%x\n",
384 sg_dma_len(sgs), sg_dma_len(sgd), areq->cryptlen,
385 ivsize, rctx->mode, n, sgs == sgd,
386 todo, rctx->mode & RK_CRYPTO_DEC);
387 crypto_dma_start(ctx->dev, sgs, sgd, todo / 4);
388 wait_for_completion_interruptible_timeout(&ctx->dev->complete,
389 msecs_to_jiffies(2000));
390 if (!ctx->dev->status) {
391 dev_err(ctx->dev->dev, "DMA timeout\n");
392 err = -EFAULT;
393 goto theend;
394 }
395 if (sgs == sgd) {
396 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_BIDIRECTIONAL);
397 } else {
398 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_TO_DEVICE);
399 dma_unmap_sg(ctx->dev->dev, sgd, 1, DMA_FROM_DEVICE);
400 }
401 if (rctx->mode & RK_CRYPTO_DEC) {
402 memcpy(iv, biv, ivsize);
403 ivtouse = iv;
404 } else {
405 offset = sgd->length - ivsize;
406 scatterwalk_map_and_copy(iv, sgd, offset, ivsize, 0);
407 ivtouse = iv;
408 }
409 sgs = sg_next(sgs);
410 sgd = sg_next(sgd);
411 n++;
412 }
413
414 if (areq->iv && ivsize > 0) {
415 offset = areq->cryptlen - ivsize;
416 if (rctx->mode & RK_CRYPTO_DEC) {
417 memcpy(areq->iv, rctx->backup_iv, ivsize);
418 memzero_explicit(rctx->backup_iv, ivsize);
419 } else {
420 scatterwalk_map_and_copy(areq->iv, areq->dst, offset,
421 ivsize, 0);
422 }
423 }
424
425 theend:
426 local_bh_disable();
427 crypto_finalize_skcipher_request(engine, areq, err);
428 local_bh_enable();
429 return 0;
430
431 theend_sgs:
432 if (sgs == sgd) {
433 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_BIDIRECTIONAL);
434 } else {
435 dma_unmap_sg(ctx->dev->dev, sgs, 1, DMA_TO_DEVICE);
436 dma_unmap_sg(ctx->dev->dev, sgd, 1, DMA_FROM_DEVICE);
437 }
438 theend_iv:
439 return err;
440 }
441
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
More information about the linux-arm-kernel
mailing list