All of lore.kernel.org
 help / color / mirror / Atom feed
* [lpieralisi-pci:pci/endpoint 18/19] drivers/misc/pci_endpoint_test.c:347:39: sparse: sparse: incorrect type in argument 2 (different address spaces)
@ 2020-03-11 19:50 kbuild test robot
  0 siblings, 0 replies; only message in thread
From: kbuild test robot @ 2020-03-11 19:50 UTC (permalink / raw)
  To: kbuild-all

[-- Attachment #1: Type: text/plain, Size: 6692 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/lpieralisi/pci.git pci/endpoint
head:   386ea4d311f756d9053d103873d54892b61fbebb
commit: a4e8103481a0fa227ad6d1bf8022a2fa41f0259b [18/19] misc: pci_endpoint_test: Add support to get DMA option from userspace
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-174-g094d5a94-dirty
        git checkout a4e8103481a0fa227ad6d1bf8022a2fa41f0259b
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

>> drivers/misc/pci_endpoint_test.c:347:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@    expected void const [noderef] <asn:1> *from @@    got n:1> *from @@
   drivers/misc/pci_endpoint_test.c:347:39: sparse:    expected void const [noderef] <asn:1> *from
   drivers/misc/pci_endpoint_test.c:347:39: sparse:    got void *
   drivers/misc/pci_endpoint_test.c:480:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@    expected void const [noderef] <asn:1> *from @@    got n:1> *from @@
   drivers/misc/pci_endpoint_test.c:480:39: sparse:    expected void const [noderef] <asn:1> *from
   drivers/misc/pci_endpoint_test.c:480:39: sparse:    got void *
   drivers/misc/pci_endpoint_test.c:577:39: sparse: sparse: incorrect type in argument 2 (different address spaces) @@    expected void const [noderef] <asn:1> *from @@    got n:1> *from @@
   drivers/misc/pci_endpoint_test.c:577:39: sparse:    expected void const [noderef] <asn:1> *from
   drivers/misc/pci_endpoint_test.c:577:39: sparse:    got void *

vim +347 drivers/misc/pci_endpoint_test.c

   322	
   323	static bool pci_endpoint_test_copy(struct pci_endpoint_test *test,
   324					   unsigned long arg)
   325	{
   326		struct pci_endpoint_test_xfer_param param;
   327		bool ret = false;
   328		void *src_addr;
   329		void *dst_addr;
   330		u32 flags = 0;
   331		bool use_dma;
   332		size_t size;
   333		dma_addr_t src_phys_addr;
   334		dma_addr_t dst_phys_addr;
   335		struct pci_dev *pdev = test->pdev;
   336		struct device *dev = &pdev->dev;
   337		void *orig_src_addr;
   338		dma_addr_t orig_src_phys_addr;
   339		void *orig_dst_addr;
   340		dma_addr_t orig_dst_phys_addr;
   341		size_t offset;
   342		size_t alignment = test->alignment;
   343		u32 src_crc32;
   344		u32 dst_crc32;
   345		int err;
   346	
 > 347		err = copy_from_user(&param, (void *)arg, sizeof(param));
   348		if (err) {
   349			dev_err(dev, "Failed to get transfer param\n");
   350			return false;
   351		}
   352	
   353		size = param.size;
   354		if (size > SIZE_MAX - alignment)
   355			goto err;
   356	
   357		use_dma = param.use_dma;
   358		if (use_dma)
   359			flags |= FLAG_USE_DMA;
   360	
   361		if (irq_type < IRQ_TYPE_LEGACY || irq_type > IRQ_TYPE_MSIX) {
   362			dev_err(dev, "Invalid IRQ type option\n");
   363			goto err;
   364		}
   365	
   366		orig_src_addr = kzalloc(size + alignment, GFP_KERNEL);
   367		if (!orig_src_addr) {
   368			dev_err(dev, "Failed to allocate source buffer\n");
   369			ret = false;
   370			goto err;
   371		}
   372	
   373		get_random_bytes(orig_src_addr, size + alignment);
   374		orig_src_phys_addr = dma_map_single(dev, orig_src_addr,
   375						    size + alignment, DMA_TO_DEVICE);
   376		if (dma_mapping_error(dev, orig_src_phys_addr)) {
   377			dev_err(dev, "failed to map source buffer address\n");
   378			ret = false;
   379			goto err_src_phys_addr;
   380		}
   381	
   382		if (alignment && !IS_ALIGNED(orig_src_phys_addr, alignment)) {
   383			src_phys_addr = PTR_ALIGN(orig_src_phys_addr, alignment);
   384			offset = src_phys_addr - orig_src_phys_addr;
   385			src_addr = orig_src_addr + offset;
   386		} else {
   387			src_phys_addr = orig_src_phys_addr;
   388			src_addr = orig_src_addr;
   389		}
   390	
   391		pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_LOWER_SRC_ADDR,
   392					 lower_32_bits(src_phys_addr));
   393	
   394		pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_UPPER_SRC_ADDR,
   395					 upper_32_bits(src_phys_addr));
   396	
   397		src_crc32 = crc32_le(~0, src_addr, size);
   398	
   399		orig_dst_addr = kzalloc(size + alignment, GFP_KERNEL);
   400		if (!orig_dst_addr) {
   401			dev_err(dev, "Failed to allocate destination address\n");
   402			ret = false;
   403			goto err_dst_addr;
   404		}
   405	
   406		orig_dst_phys_addr = dma_map_single(dev, orig_dst_addr,
   407						    size + alignment, DMA_FROM_DEVICE);
   408		if (dma_mapping_error(dev, orig_dst_phys_addr)) {
   409			dev_err(dev, "failed to map destination buffer address\n");
   410			ret = false;
   411			goto err_dst_phys_addr;
   412		}
   413	
   414		if (alignment && !IS_ALIGNED(orig_dst_phys_addr, alignment)) {
   415			dst_phys_addr = PTR_ALIGN(orig_dst_phys_addr, alignment);
   416			offset = dst_phys_addr - orig_dst_phys_addr;
   417			dst_addr = orig_dst_addr + offset;
   418		} else {
   419			dst_phys_addr = orig_dst_phys_addr;
   420			dst_addr = orig_dst_addr;
   421		}
   422	
   423		pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_LOWER_DST_ADDR,
   424					 lower_32_bits(dst_phys_addr));
   425		pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_UPPER_DST_ADDR,
   426					 upper_32_bits(dst_phys_addr));
   427	
   428		pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_SIZE,
   429					 size);
   430	
   431		pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_FLAGS, flags);
   432		pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type);
   433		pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1);
   434		pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_COMMAND,
   435					 COMMAND_COPY);
   436	
   437		wait_for_completion(&test->irq_raised);
   438	
   439		dma_unmap_single(dev, orig_dst_phys_addr, size + alignment,
   440				 DMA_FROM_DEVICE);
   441	
   442		dst_crc32 = crc32_le(~0, dst_addr, size);
   443		if (dst_crc32 == src_crc32)
   444			ret = true;
   445	
   446	err_dst_phys_addr:
   447		kfree(orig_dst_addr);
   448	
   449	err_dst_addr:
   450		dma_unmap_single(dev, orig_src_phys_addr, size + alignment,
   451				 DMA_TO_DEVICE);
   452	
   453	err_src_phys_addr:
   454		kfree(orig_src_addr);
   455	
   456	err:
   457		return ret;
   458	}
   459	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-11 19:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-11 19:50 [lpieralisi-pci:pci/endpoint 18/19] drivers/misc/pci_endpoint_test.c:347:39: sparse: sparse: incorrect type in argument 2 (different address spaces) kbuild test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.