Re: [PATCH 4/4] mic: vop: copy data to kernel space then write to io memory
From: kernel test robot
Date: Fri Sep 25 2020 - 07:05:24 EST
Hi Sherry,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on char-misc/char-misc-testing]
[also build test WARNING on soc/for-next linus/master v5.9-rc6 next-20200924]
[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/Sherry-Sun/Fix-some-bugs-of-the-vop-driver-and-mpssd-user-space-tool/20200925-152356
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git 9eb29f2ed95edda511ce28651b1d7cdef3614c12
config: ia64-randconfig-s032-20200925 (attached as .config)
compiler: ia64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.2-201-g24bdaac6-dirty
# https://github.com/0day-ci/linux/commit/5f4b5ded8447941d43166eba5d303cdca2e54f07
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Sherry-Sun/Fix-some-bugs-of-the-vop-driver-and-mpssd-user-space-tool/20200925-152356
git checkout 5f4b5ded8447941d43166eba5d303cdca2e54f07
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=ia64
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>
sparse warnings: (new ones prefixed by >>)
>> drivers/misc/mic/vop/vop_vringh.c:666:22: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void volatile [noderef] __iomem *dst @@ got void * @@
>> drivers/misc/mic/vop/vop_vringh.c:666:22: sparse: expected void volatile [noderef] __iomem *dst
drivers/misc/mic/vop/vop_vringh.c:666:22: sparse: got void *
vim +666 drivers/misc/mic/vop/vop_vringh.c
585
586 /*
587 * Initiates copies across the PCIe bus from a user space buffer to card
588 * memory. When transfers are done using DMA, source/destination addresses
589 * and transfer length must follow the alignment requirements of the MIC
590 * DMA engine.
591 */
592 static int vop_virtio_copy_from_user(struct vop_vdev *vdev, void __user *ubuf,
593 size_t len, u64 daddr, size_t dlen,
594 int vr_idx)
595 {
596 struct vop_device *vpdev = vdev->vpdev;
597 void __iomem *dbuf = vpdev->hw_ops->remap(vpdev, daddr, len);
598 struct vop_vringh *vvr = &vdev->vvr[vr_idx];
599 struct vop_info *vi = dev_get_drvdata(&vdev->vpdev->dev);
600 size_t dma_alignment;
601 bool x200;
602 size_t partlen;
603 bool dma = VOP_USE_DMA && vi->dma_ch;
604 int err = 0;
605 void *temp = NULL;
606
607 if (dma) {
608 dma_alignment = 1 << vi->dma_ch->device->copy_align;
609 x200 = is_dma_copy_aligned(vi->dma_ch->device, 1, 1, 1);
610
611 if (daddr & (dma_alignment - 1)) {
612 vdev->tx_dst_unaligned += len;
613 dma = false;
614 } else if (ALIGN(len, dma_alignment) > dlen) {
615 vdev->tx_len_unaligned += len;
616 dma = false;
617 }
618 }
619
620 if (!dma)
621 goto memcpy;
622
623 /*
624 * X100 uses DMA addresses as seen by the card so adding
625 * the aperture base is not required for DMA. However x200
626 * requires DMA addresses to be an offset into the bar so
627 * add the aperture base for x200.
628 */
629 if (x200)
630 daddr += vpdev->aper->pa;
631 while (len) {
632 partlen = min_t(size_t, len, VOP_INT_DMA_BUF_SIZE);
633
634 if (copy_from_user(vvr->buf, ubuf, partlen)) {
635 err = -EFAULT;
636 dev_err(vop_dev(vdev), "%s %d err %d\n",
637 __func__, __LINE__, err);
638 goto err;
639 }
640 err = vop_sync_dma(vdev, daddr, vvr->buf_da,
641 ALIGN(partlen, dma_alignment));
642 if (err) {
643 dev_err(vop_dev(vdev), "%s %d err %d\n",
644 __func__, __LINE__, err);
645 goto err;
646 }
647 daddr += partlen;
648 ubuf += partlen;
649 dbuf += partlen;
650 vdev->out_bytes_dma += partlen;
651 vdev->out_bytes += partlen;
652 len -= partlen;
653 }
654 memcpy:
655 /*
656 * We are copying to IO below and should ideally use something
657 * like copy_from_user_toio(..) if it existed.
658 */
659 temp = kmalloc(len, GFP_KERNEL);
660 if (copy_from_user(temp, ubuf, len)) {
661 err = -EFAULT;
662 dev_err(vop_dev(vdev), "%s %d err %d\n",
663 __func__, __LINE__, err);
664 goto err;
665 }
> 666 memcpy_toio((void __force *)dbuf, temp, len);
667 kfree(temp);
668 vdev->out_bytes += len;
669 err = 0;
670 err:
671 vpdev->hw_ops->unmap(vpdev, dbuf);
672 dev_dbg(vop_dev(vdev),
673 "%s: ubuf %p dbuf %p len 0x%zx vr_idx 0x%x\n",
674 __func__, ubuf, dbuf, len, vr_idx);
675 return err;
676 }
677
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip