Hi Hui, Thank you for the patch! Perhaps something to improve: [auto build test WARNING on cryptodev/master] [also build test WARNING on crypto/master v5.12-rc1 next-20210301] [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/Hui-Tang/crypto-qat-fix-use-of-dma_map_single/20210301-114717 base: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master config: x86_64-randconfig-a001-20210301 (attached as .config) compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project 5de09ef02e24d234d9fc0cd1c6dfe18a1bb784b0) 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 # install x86_64 cross compiling tool for clang build # apt-get install binutils-x86-64-linux-gnu # https://github.com/0day-ci/linux/commit/54bc41cf4d0517cc36b01680dd2394a48f62da09 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Hui-Tang/crypto-qat-fix-use-of-dma_map_single/20210301-114717 git checkout 54bc41cf4d0517cc36b01680dd2394a48f62da09 # save the attached .config to linux build tree COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=x86_64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@xxxxxxxxx> All warnings (new ones prefixed by >>): >> drivers/crypto/qat/qat_common/qat_algs.c:744:7: warning: variable 'blp' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized] if (unlikely(dma_mapping_error(dev, bufl->bufers[y].addr))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/compiler.h:78:22: note: expanded from macro 'unlikely' # define unlikely(x) __builtin_expect(!!(x), 0) ^~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/crypto/qat/qat_common/qat_algs.c:809:30: note: uninitialized use occurs here if (!dma_mapping_error(dev, blp)) ^~~ drivers/crypto/qat/qat_common/qat_algs.c:744:3: note: remove the 'if' if its condition is always false if (unlikely(dma_mapping_error(dev, bufl->bufers[y].addr))) ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/crypto/qat/qat_common/qat_algs.c:721:16: note: initialize the variable 'blp' to silence this warning dma_addr_t blp; ^ = 0 1 warning generated. vim +744 drivers/crypto/qat/qat_common/qat_algs.c d370cec3219490 Tadeusz Struk 2014-06-05 710 d370cec3219490 Tadeusz Struk 2014-06-05 711 static int qat_alg_sgl_to_bufl(struct qat_crypto_instance *inst, d370cec3219490 Tadeusz Struk 2014-06-05 712 struct scatterlist *sgl, e19ab1211d2848 Herbert Xu 2015-07-30 713 struct scatterlist *sglout, d370cec3219490 Tadeusz Struk 2014-06-05 714 struct qat_crypto_request *qat_req) d370cec3219490 Tadeusz Struk 2014-06-05 715 { d370cec3219490 Tadeusz Struk 2014-06-05 716 struct device *dev = &GET_DEV(inst->accel_dev); e19ab1211d2848 Herbert Xu 2015-07-30 717 int i, sg_nctr = 0; e19ab1211d2848 Herbert Xu 2015-07-30 718 int n = sg_nents(sgl); d370cec3219490 Tadeusz Struk 2014-06-05 719 struct qat_alg_buf_list *bufl; d370cec3219490 Tadeusz Struk 2014-06-05 720 struct qat_alg_buf_list *buflout = NULL; d370cec3219490 Tadeusz Struk 2014-06-05 721 dma_addr_t blp; d370cec3219490 Tadeusz Struk 2014-06-05 722 dma_addr_t bloutp = 0; d370cec3219490 Tadeusz Struk 2014-06-05 723 struct scatterlist *sg; 1793d1aba19415 Gustavo A. R. Silva 2019-06-06 724 size_t sz_out, sz = struct_size(bufl, bufers, n + 1); d370cec3219490 Tadeusz Struk 2014-06-05 725 d370cec3219490 Tadeusz Struk 2014-06-05 726 if (unlikely(!n)) d370cec3219490 Tadeusz Struk 2014-06-05 727 return -EINVAL; d370cec3219490 Tadeusz Struk 2014-06-05 728 82f82504b8f5f1 Tadeusz Struk 2014-12-08 729 bufl = kzalloc_node(sz, GFP_ATOMIC, 09adc8789c4e89 Tadeusz Struk 2014-10-13 730 dev_to_node(&GET_DEV(inst->accel_dev))); d370cec3219490 Tadeusz Struk 2014-06-05 731 if (unlikely(!bufl)) d370cec3219490 Tadeusz Struk 2014-06-05 732 return -ENOMEM; d370cec3219490 Tadeusz Struk 2014-06-05 733 d370cec3219490 Tadeusz Struk 2014-06-05 734 for_each_sg(sgl, sg, n, i) { e19ab1211d2848 Herbert Xu 2015-07-30 735 int y = sg_nctr; 82f82504b8f5f1 Tadeusz Struk 2014-12-08 736 82f82504b8f5f1 Tadeusz Struk 2014-12-08 737 if (!sg->length) 82f82504b8f5f1 Tadeusz Struk 2014-12-08 738 continue; d65071ecde1ed1 Tadeusz Struk 2014-06-24 739 d370cec3219490 Tadeusz Struk 2014-06-05 740 bufl->bufers[y].addr = dma_map_single(dev, sg_virt(sg), d370cec3219490 Tadeusz Struk 2014-06-05 741 sg->length, d370cec3219490 Tadeusz Struk 2014-06-05 742 DMA_BIDIRECTIONAL); d370cec3219490 Tadeusz Struk 2014-06-05 743 bufl->bufers[y].len = sg->length; d370cec3219490 Tadeusz Struk 2014-06-05 @744 if (unlikely(dma_mapping_error(dev, bufl->bufers[y].addr))) 72eed063767e13 Arnd Bergmann 2017-06-22 745 goto err_in; 82f82504b8f5f1 Tadeusz Struk 2014-12-08 746 sg_nctr++; d370cec3219490 Tadeusz Struk 2014-06-05 747 } e19ab1211d2848 Herbert Xu 2015-07-30 748 bufl->num_bufs = sg_nctr; 54bc41cf4d0517 Hui Tang 2021-03-01 749 blp = dma_map_single(dev, bufl, sz, DMA_TO_DEVICE); 54bc41cf4d0517 Hui Tang 2021-03-01 750 if (unlikely(dma_mapping_error(dev, blp))) 54bc41cf4d0517 Hui Tang 2021-03-01 751 goto err_in; d370cec3219490 Tadeusz Struk 2014-06-05 752 qat_req->buf.bl = bufl; d370cec3219490 Tadeusz Struk 2014-06-05 753 qat_req->buf.blp = blp; d370cec3219490 Tadeusz Struk 2014-06-05 754 qat_req->buf.sz = sz; d370cec3219490 Tadeusz Struk 2014-06-05 755 /* Handle out of place operation */ d370cec3219490 Tadeusz Struk 2014-06-05 756 if (sgl != sglout) { d370cec3219490 Tadeusz Struk 2014-06-05 757 struct qat_alg_buf *bufers; d370cec3219490 Tadeusz Struk 2014-06-05 758 82f82504b8f5f1 Tadeusz Struk 2014-12-08 759 n = sg_nents(sglout); 1793d1aba19415 Gustavo A. R. Silva 2019-06-06 760 sz_out = struct_size(buflout, bufers, n + 1); 82f82504b8f5f1 Tadeusz Struk 2014-12-08 761 sg_nctr = 0; 82f82504b8f5f1 Tadeusz Struk 2014-12-08 762 buflout = kzalloc_node(sz_out, GFP_ATOMIC, 09adc8789c4e89 Tadeusz Struk 2014-10-13 763 dev_to_node(&GET_DEV(inst->accel_dev))); d370cec3219490 Tadeusz Struk 2014-06-05 764 if (unlikely(!buflout)) 72eed063767e13 Arnd Bergmann 2017-06-22 765 goto err_in; d370cec3219490 Tadeusz Struk 2014-06-05 766 bufers = buflout->bufers; d370cec3219490 Tadeusz Struk 2014-06-05 767 for_each_sg(sglout, sg, n, i) { e19ab1211d2848 Herbert Xu 2015-07-30 768 int y = sg_nctr; 82f82504b8f5f1 Tadeusz Struk 2014-12-08 769 82f82504b8f5f1 Tadeusz Struk 2014-12-08 770 if (!sg->length) 82f82504b8f5f1 Tadeusz Struk 2014-12-08 771 continue; d65071ecde1ed1 Tadeusz Struk 2014-06-24 772 d370cec3219490 Tadeusz Struk 2014-06-05 773 bufers[y].addr = dma_map_single(dev, sg_virt(sg), d370cec3219490 Tadeusz Struk 2014-06-05 774 sg->length, d370cec3219490 Tadeusz Struk 2014-06-05 775 DMA_BIDIRECTIONAL); d370cec3219490 Tadeusz Struk 2014-06-05 776 if (unlikely(dma_mapping_error(dev, bufers[y].addr))) 72eed063767e13 Arnd Bergmann 2017-06-22 777 goto err_out; 82f82504b8f5f1 Tadeusz Struk 2014-12-08 778 bufers[y].len = sg->length; 82f82504b8f5f1 Tadeusz Struk 2014-12-08 779 sg_nctr++; d370cec3219490 Tadeusz Struk 2014-06-05 780 } e19ab1211d2848 Herbert Xu 2015-07-30 781 buflout->num_bufs = sg_nctr; 82f82504b8f5f1 Tadeusz Struk 2014-12-08 782 buflout->num_mapped_bufs = sg_nctr; 54bc41cf4d0517 Hui Tang 2021-03-01 783 bloutp = dma_map_single(dev, buflout, sz_out, DMA_TO_DEVICE); 54bc41cf4d0517 Hui Tang 2021-03-01 784 if (unlikely(dma_mapping_error(dev, bloutp))) 54bc41cf4d0517 Hui Tang 2021-03-01 785 goto err_out; d370cec3219490 Tadeusz Struk 2014-06-05 786 qat_req->buf.blout = buflout; d370cec3219490 Tadeusz Struk 2014-06-05 787 qat_req->buf.bloutp = bloutp; 82f82504b8f5f1 Tadeusz Struk 2014-12-08 788 qat_req->buf.sz_out = sz_out; d370cec3219490 Tadeusz Struk 2014-06-05 789 } else { d370cec3219490 Tadeusz Struk 2014-06-05 790 /* Otherwise set the src and dst to the same address */ d370cec3219490 Tadeusz Struk 2014-06-05 791 qat_req->buf.bloutp = qat_req->buf.blp; 82f82504b8f5f1 Tadeusz Struk 2014-12-08 792 qat_req->buf.sz_out = 0; d370cec3219490 Tadeusz Struk 2014-06-05 793 } d370cec3219490 Tadeusz Struk 2014-06-05 794 return 0; 82f82504b8f5f1 Tadeusz Struk 2014-12-08 795 72eed063767e13 Arnd Bergmann 2017-06-22 796 err_out: 54bc41cf4d0517 Hui Tang 2021-03-01 797 if (!dma_mapping_error(dev, bloutp)) 54bc41cf4d0517 Hui Tang 2021-03-01 798 dma_unmap_single(dev, bloutp, sz_out, DMA_TO_DEVICE); 54bc41cf4d0517 Hui Tang 2021-03-01 799 82f82504b8f5f1 Tadeusz Struk 2014-12-08 800 n = sg_nents(sglout); e19ab1211d2848 Herbert Xu 2015-07-30 801 for (i = 0; i < n; i++) 82f82504b8f5f1 Tadeusz Struk 2014-12-08 802 if (!dma_mapping_error(dev, buflout->bufers[i].addr)) 82f82504b8f5f1 Tadeusz Struk 2014-12-08 803 dma_unmap_single(dev, buflout->bufers[i].addr, 82f82504b8f5f1 Tadeusz Struk 2014-12-08 804 buflout->bufers[i].len, d370cec3219490 Tadeusz Struk 2014-06-05 805 DMA_BIDIRECTIONAL); d370cec3219490 Tadeusz Struk 2014-06-05 806 kfree(buflout); 72eed063767e13 Arnd Bergmann 2017-06-22 807 72eed063767e13 Arnd Bergmann 2017-06-22 808 err_in: 54bc41cf4d0517 Hui Tang 2021-03-01 809 if (!dma_mapping_error(dev, blp)) 54bc41cf4d0517 Hui Tang 2021-03-01 810 dma_unmap_single(dev, blp, sz, DMA_TO_DEVICE); 54bc41cf4d0517 Hui Tang 2021-03-01 811 72eed063767e13 Arnd Bergmann 2017-06-22 812 n = sg_nents(sgl); 72eed063767e13 Arnd Bergmann 2017-06-22 813 for (i = 0; i < n; i++) 72eed063767e13 Arnd Bergmann 2017-06-22 814 if (!dma_mapping_error(dev, bufl->bufers[i].addr)) 72eed063767e13 Arnd Bergmann 2017-06-22 815 dma_unmap_single(dev, bufl->bufers[i].addr, 72eed063767e13 Arnd Bergmann 2017-06-22 816 bufl->bufers[i].len, 72eed063767e13 Arnd Bergmann 2017-06-22 817 DMA_BIDIRECTIONAL); 72eed063767e13 Arnd Bergmann 2017-06-22 818 72eed063767e13 Arnd Bergmann 2017-06-22 819 kfree(bufl); 72eed063767e13 Arnd Bergmann 2017-06-22 820 72eed063767e13 Arnd Bergmann 2017-06-22 821 dev_err(dev, "Failed to map buf for dma\n"); d370cec3219490 Tadeusz Struk 2014-06-05 822 return -ENOMEM; d370cec3219490 Tadeusz Struk 2014-06-05 823 } d370cec3219490 Tadeusz Struk 2014-06-05 824 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip