CC: [email protected]
BCC: [email protected]
TO: Liu Yi L <[email protected]>

tree:   https://github.com/luxis1999/iommufd iommufd-v5.18-rc4-nesting
head:   402999460191d8f40e06d874b1ea2e860957ead5
commit: 953f3f716a272968792cd61ebbe82941d31d0a64 [46/53] iommufd/device: Add 
iommufd_device_at[de]tach_pasid()
:::::: branch date: 32 hours ago
:::::: commit date: 3 days ago
config: sparc-randconfig-s031-20220516 
(https://download.01.org/0day-ci/archive/20220517/[email protected]/config)
compiler: sparc-linux-gcc (GCC) 11.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.4-dirty
        # 
https://github.com/luxis1999/iommufd/commit/953f3f716a272968792cd61ebbe82941d31d0a64
        git remote add luxis1999-iommufd https://github.com/luxis1999/iommufd
        git fetch --no-tags luxis1999-iommufd iommufd-v5.18-rc4-nesting
        git checkout 953f3f716a272968792cd61ebbe82941d31d0a64
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.3.0 make.cross C=1 
CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=sparc 
SHELL=/bin/bash drivers/iommu/iommufd/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <[email protected]>


sparse warnings: (new ones prefixed by >>)
>> drivers/iommu/iommufd/device.c:78:21: sparse: sparse: dubious: !x & y
   drivers/iommu/iommufd/device.c:107:21: sparse: sparse: dubious: !x & y

vim +78 drivers/iommu/iommufd/device.c

a9447b06c53bd3f Jason Gunthorpe 2021-11-11   39  
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   40  /**
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   41   * iommufd_bind_pci_device - 
Bind a physical device to an iommu fd
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   42   * @fd: iommufd file 
descriptor.
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   43   * @pdev: Pointer to a 
physical PCI device struct
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   44   * @id: Output ID number to 
return to userspace for this device
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   45   *
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   46   * A successful bind 
establishes an ownership over the device and returns
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   47   * struct iommufd_device 
pointer, otherwise returns error pointer.
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   48   *
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   49   * A driver using this API 
must set driver_managed_dma and must not touch
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   50   * the device until this 
routine succeeds and establishes ownership.
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   51   *
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   52   * Binding a PCI device places 
the entire RID under iommufd control.
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   53   *
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   54   * The caller must undo this 
with iommufd_unbind_device()
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   55   */
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   56  struct iommufd_device 
*iommufd_bind_pci_device(int fd, struct pci_dev *pdev,
953f3f716a27296 Yi Liu          2022-05-13   57                                 
               unsigned int flags, u32 *id)
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   58  {
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   59         struct iommufd_device 
*idev;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   60         struct iommufd_ctx 
*ictx;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   61         struct iommu_group 
*group;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   62         int rc;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   63  
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   64         ictx = iommufd_fget(fd);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   65         if (!ictx)
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   66                 return 
ERR_PTR(-EINVAL);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   67  
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   68         group = 
iommu_group_get(&pdev->dev);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   69         if (!group) {
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   70                 rc = -ENODEV;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   71                 goto 
out_file_put;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   72         }
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   73  
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   74         /*
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   75          * FIXME: Use a 
device-centric iommu api and this won't work with
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   76          * multi-device groups
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   77          */
953f3f716a27296 Yi Liu          2022-05-13  @78         if ((!flags & 
IOMMUFD_BIND_FLAGS_BYPASS_DMA_OWNERSHIP)) {
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   79                 rc = 
iommu_group_claim_dma_owner(group, ictx->filp);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   80                 if (rc)
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   81                         goto 
out_group_put;
953f3f716a27296 Yi Liu          2022-05-13   82         }
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   83  
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   84         idev = 
iommufd_object_alloc(ictx, idev, IOMMUFD_OBJ_DEVICE);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   85         if (IS_ERR(idev)) {
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   86                 rc = 
PTR_ERR(idev);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   87                 goto 
out_release_owner;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   88         }
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   89         idev->ictx = ictx;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   90         idev->dev = &pdev->dev;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   91         /* The calling driver 
is a user until iommufd_unbind_device() */
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   92         
refcount_inc(&idev->obj.users);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   93         /* group refcount moves 
into iommufd_device */
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   94         idev->group = group;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   95  
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   96         /*
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   97          * If the caller fails 
after this success it must call
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   98          * 
iommufd_unbind_device() which is safe since we hold this refcount.
a9447b06c53bd3f Jason Gunthorpe 2021-11-11   99          * This also means the 
device is a leaf in the graph and no other object
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  100          * can take a reference 
on it.
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  101          */
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  102         
iommufd_object_finalize(ictx, &idev->obj);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  103         *id = idev->obj.id;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  104         return idev;
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  105  
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  106  out_release_owner:
953f3f716a27296 Yi Liu          2022-05-13  107         if ((!flags & 
IOMMUFD_BIND_FLAGS_BYPASS_DMA_OWNERSHIP))
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  108                 
iommu_group_release_dma_owner(group);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  109  out_group_put:
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  110         iommu_group_put(group);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  111  out_file_put:
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  112         fput(ictx->filp);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  113         return ERR_PTR(rc);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  114  }
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  115  
EXPORT_SYMBOL_GPL(iommufd_bind_pci_device);
a9447b06c53bd3f Jason Gunthorpe 2021-11-11  116  

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp
_______________________________________________
kbuild mailing list -- [email protected]
To unsubscribe send an email to [email protected]

Reply via email to