[PATCH v4 14/23] iommufd: Add mmap interface

kernel test robot lkp at intel.com
Fri May 9 07:13:04 PDT 2025


Hi Nicolin,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 92a09c47464d040866cf2b4cd052bc60555185fb]

url:    https://github.com/intel-lab-lkp/linux/commits/Nicolin-Chen/iommufd-viommu-Add-driver-allocated-vDEVICE-support/20250509-110521
base:   92a09c47464d040866cf2b4cd052bc60555185fb
patch link:    https://lore.kernel.org/r/ee9ee287264fd75eb4fc64a63f20d03e9ba18161.1746757630.git.nicolinc%40nvidia.com
patch subject: [PATCH v4 14/23] iommufd: Add mmap interface
config: i386-buildonly-randconfig-003-20250509 (https://download.01.org/0day-ci/archive/20250509/202505092119.UALKhnIX-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250509/202505092119.UALKhnIX-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp at intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505092119.UALKhnIX-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/iommu/iommufd/driver.c:91:6: warning: variable 'num_pfns' set but not used [-Wunused-but-set-variable]
      91 |         int num_pfns, rc;
         |             ^
   1 warning generated.


vim +/num_pfns +91 drivers/iommu/iommufd/driver.c

    80	
    81	/*
    82	 * Allocate an @offset to return to user space to use for an mmap() syscall
    83	 *
    84	 * Driver should use a per-structure helper in include/linux/iommufd.h
    85	 */
    86	int _iommufd_alloc_mmap(struct iommufd_ctx *ictx, struct iommufd_object *owner,
    87				phys_addr_t base, size_t length, unsigned long *offset)
    88	{
    89		struct iommufd_mmap *immap;
    90		unsigned long startp;
  > 91		int num_pfns, rc;
    92	
    93		if (WARN_ON_ONCE(!offset))
    94			return -EINVAL;
    95		if (!PAGE_ALIGNED(base))
    96			return -EINVAL;
    97		if (!length || !PAGE_ALIGNED(length))
    98			return -EINVAL;
    99		num_pfns = length >> PAGE_SHIFT;
   100	
   101		immap = kzalloc(sizeof(*immap), GFP_KERNEL);
   102		if (!immap)
   103			return -ENOMEM;
   104		immap->owner = owner;
   105		immap->base_pfn = base >> PAGE_SHIFT;
   106		immap->num_pfns = length >> PAGE_SHIFT;
   107	
   108		rc = mtree_alloc_range(&ictx->mt_mmap, &startp, immap, immap->num_pfns,
   109				       0, U32_MAX >> PAGE_SHIFT, GFP_KERNEL);
   110		if (rc < 0) {
   111			kfree(immap);
   112			return rc;
   113		}
   114	
   115		/* mmap() syscall will right-shift the offset in vma->vm_pgoff */
   116		*offset = startp << PAGE_SHIFT;
   117		return 0;
   118	}
   119	EXPORT_SYMBOL_NS_GPL(_iommufd_alloc_mmap, "IOMMUFD");
   120	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki



More information about the linux-arm-kernel mailing list