Re: [PATCH v1 2/2] iommu: add Unisoc iommu basic driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Chunyan,

I love your patch! Perhaps something to improve:

[auto build test WARNING on robh/for-next]
[also build test WARNING on v5.11-rc4 next-20210121]
[cannot apply to iommu/next]
[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/Chunyan-Zhang/Add-Unisoc-iommu-basic-driver/20210121-194023
base:   https://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git for-next
config: arc-allyesconfig (attached as .config)
compiler: arceb-elf-gcc (GCC) 9.3.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/891db11d7229149235a02e5bc31a61188243a5d7
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Chunyan-Zhang/Add-Unisoc-iommu-basic-driver/20210121-194023
        git checkout 891db11d7229149235a02e5bc31a61188243a5d7
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc 

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/iommu/sprd-iommu.c: In function 'sprd_iommu_attach_device':
   drivers/iommu/sprd-iommu.c:248:16: error: implicit declaration of function 'dma_alloc_coherent' [-Werror=implicit-function-declaration]
     248 |  dom->pgt_va = dma_alloc_coherent(sdev->dev, pgt_size, &dom->pgt_pa, GFP_KERNEL);
         |                ^~~~~~~~~~~~~~~~~~
>> drivers/iommu/sprd-iommu.c:248:14: warning: assignment to 'u32 *' {aka 'unsigned int *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     248 |  dom->pgt_va = dma_alloc_coherent(sdev->dev, pgt_size, &dom->pgt_pa, GFP_KERNEL);
         |              ^
   drivers/iommu/sprd-iommu.c: In function 'sprd_iommu_detach_device':
   drivers/iommu/sprd-iommu.c:270:2: error: implicit declaration of function 'dma_free_coherent' [-Werror=implicit-function-declaration]
     270 |  dma_free_coherent(sdev->dev, pgt_size, dom->pgt_va, dom->pgt_pa);
         |  ^~~~~~~~~~~~~~~~~
   In file included from include/linux/device.h:15,
                    from drivers/iommu/sprd-iommu.c:10:
   drivers/iommu/sprd-iommu.c: In function 'sprd_iommu_map':
>> drivers/iommu/sprd-iommu.c:296:27: warning: format '%lx' expects argument of type 'long unsigned int', but argument 4 has type 'size_t' {aka 'unsigned int'} [-Wformat=]
     296 |   dev_err(dom->sdev->dev, "(iova(0x%lx) + sixe(0x%lx)) are not in the range!\n",
         |                           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/dev_printk.h:19:22: note: in definition of macro 'dev_fmt'
      19 | #define dev_fmt(fmt) fmt
         |                      ^~~
   drivers/iommu/sprd-iommu.c:296:3: note: in expansion of macro 'dev_err'
     296 |   dev_err(dom->sdev->dev, "(iova(0x%lx) + sixe(0x%lx)) are not in the range!\n",
         |   ^~~~~~~
   drivers/iommu/sprd-iommu.c:296:52: note: format string is defined here
     296 |   dev_err(dom->sdev->dev, "(iova(0x%lx) + sixe(0x%lx)) are not in the range!\n",
         |                                                  ~~^
         |                                                    |
         |                                                    long unsigned int
         |                                                  %x
>> drivers/iommu/sprd-iommu.c:279:38: warning: variable 'mdata' set but not used [-Wunused-but-set-variable]
     279 |  const struct sprd_iommu_match_data *mdata;
         |                                      ^~~~~
   drivers/iommu/sprd-iommu.c: In function 'sprd_iommu_probe':
   drivers/iommu/sprd-iommu.c:483:21: warning: assignment to 'u32 *' {aka 'unsigned int *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
     483 |  sdev->prot_page_va = dma_alloc_coherent(dev, SPRD_IOMMU_PAGE_SIZE,
         |                     ^
   cc1: some warnings being treated as errors


vim +248 drivers/iommu/sprd-iommu.c

   240	
   241	static int sprd_iommu_attach_device(struct iommu_domain *domain,
   242					    struct device *dev)
   243	{
   244		struct sprd_iommu_device *sdev = dev_iommu_priv_get(dev);
   245		struct sprd_iommu_domain *dom = to_sprd_domain(domain);
   246		size_t pgt_size = sprd_iommu_pgt_size(domain);
   247	
 > 248		dom->pgt_va = dma_alloc_coherent(sdev->dev, pgt_size, &dom->pgt_pa, GFP_KERNEL);
   249		if (!dom->pgt_va)
   250			return -ENOMEM;
   251	
   252		dom->sdev = sdev;
   253	
   254		sprd_iommu_first_ppn(dom);
   255		sprd_iommu_first_vpn(dom);
   256		sprd_iommu_vpn_range(dom);
   257		sprd_iommu_default_ppn(sdev);
   258		sprd_iommu_hw_en(sdev, true);
   259	
   260		return 0;
   261	}
   262	
   263	static void sprd_iommu_detach_device(struct iommu_domain *domain,
   264						     struct device *dev)
   265	{
   266		struct sprd_iommu_domain *dom = to_sprd_domain(domain);
   267		struct sprd_iommu_device *sdev = dom->sdev;
   268		size_t pgt_size = sprd_iommu_pgt_size(domain);
   269	
   270		dma_free_coherent(sdev->dev, pgt_size, dom->pgt_va, dom->pgt_pa);
   271		sprd_iommu_hw_en(sdev, false);
   272		dom->sdev = NULL;
   273	}
   274	
   275	static int sprd_iommu_map(struct iommu_domain *domain, unsigned long iova,
   276				  phys_addr_t paddr, size_t size, int prot, gfp_t gfp)
   277	{
   278		struct sprd_iommu_domain *dom = to_sprd_domain(domain);
 > 279		const struct sprd_iommu_match_data *mdata;
   280		unsigned int page_num = size >> SPRD_IOMMU_PAGE_SHIFT;
   281		unsigned long flags;
   282		unsigned int i;
   283		u32 *pgt_base_iova;
   284		u32 pabase = (u32)paddr;
   285		int map_size = 0;
   286		unsigned long start = domain->geometry.aperture_start;
   287		unsigned long end = domain->geometry.aperture_end;
   288	
   289		if (!dom->sdev) {
   290			pr_err("No sprd_iommu_device attached to the domain\n");
   291			return -EINVAL;
   292		}
   293	
   294		mdata = dom->sdev->mdata;
   295		if (iova < start || (iova + size) > (end + 1)) {
 > 296			dev_err(dom->sdev->dev, "(iova(0x%lx) + sixe(0x%lx)) are not in the range!\n",
   297				iova, size);
   298			return -EINVAL;
   299		}
   300	
   301		pgt_base_iova = dom->pgt_va + ((iova - start) >> SPRD_IOMMU_PAGE_SHIFT);
   302	
   303		spin_lock_irqsave(&dom->pgtlock, flags);
   304		for (i = 0; i < page_num; i++) {
   305			pgt_base_iova[i] = pabase >> SPRD_IOMMU_PAGE_SHIFT;
   306			pabase += SPRD_IOMMU_PAGE_SIZE;
   307			map_size += SPRD_IOMMU_PAGE_SIZE;
   308		}
   309		spin_unlock_irqrestore(&dom->pgtlock, flags);
   310	
   311		return map_size == size ? 0 : -EEXIST;
   312	}
   313	

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

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux