* [luxis1999-iommufd:iommufd-v5.19-rc5 84/104] drivers/iommu/iommufd/device.c:131:21: sparse: sparse: dubious: !x & y
@ 2022-07-14 18:34 kernel test robot
0 siblings, 0 replies; only message in thread
From: kernel test robot @ 2022-07-14 18:34 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 8568 bytes --]
::::::
:::::: Manual check reason: "low confidence static check warning: drivers/iommu/iommufd/device.c:131:21: sparse: sparse: dubious: !x & y"
::::::
CC: kbuild-all(a)lists.01.org
BCC: lkp(a)intel.com
TO: Liu Yi L <yi.l.liu@intel.com>
tree: https://github.com/luxis1999/iommufd iommufd-v5.19-rc5
head: f200d9a1de755f3bb98e21535e22b9adf6ba83f7
commit: 4e9347bc44832ec0e1557796ed0b42674a960a4e [84/104] iommufd: Add driver facing API for PASID support
:::::: branch date: 8 hours ago
:::::: commit date: 10 hours ago
config: i386-randconfig-s003 (https://download.01.org/0day-ci/archive/20220715/202207150258.it1dsIG7-lkp(a)intel.com/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce:
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/luxis1999/iommufd/commit/4e9347bc44832ec0e1557796ed0b42674a960a4e
git remote add luxis1999-iommufd https://github.com/luxis1999/iommufd
git fetch --no-tags luxis1999-iommufd iommufd-v5.19-rc5
git checkout 4e9347bc44832ec0e1557796ed0b42674a960a4e
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash ./ drivers/iommu/iommufd/ kernel/bpf/
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> drivers/iommu/iommufd/device.c:131:21: sparse: sparse: dubious: !x & y
vim +131 drivers/iommu/iommufd/device.c
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 53
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 54 /**
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 55 * iommufd_bind_device - Bind a physical device to an iommu fd
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 56 * @fd: iommufd file descriptor.
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 57 * @pdev: Pointer to a physical PCI device struct
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 58 * @id: Output ID number to return to userspace for this device
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 59 *
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 60 * A successful bind establishes an ownership over the device and returns
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 61 * struct iommufd_device pointer, otherwise returns error pointer.
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 62 *
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 63 * A driver using this API must set driver_managed_dma and must not touch
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 64 * the device until this routine succeeds and establishes ownership.
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 65 *
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 66 * Binding a PCI device places the entire RID under iommufd control.
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 67 *
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 68 * The caller must undo this with iommufd_unbind_device()
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 69 */
4e9347bc44832e Yi Liu 2022-06-22 70 struct iommufd_device *iommufd_bind_device(int fd, struct device *dev,
4e9347bc44832e Yi Liu 2022-06-22 71 unsigned int flags, u32 *id)
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 72 {
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 73 struct iommufd_device *idev;
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 74 struct iommufd_ctx *ictx;
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 75 struct iommu_group *group;
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 76 int rc;
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 77
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 78 /*
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 79 * iommufd always sets IOMMU_CACHE because we offer no way for userspace
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 80 * to restore cache coherency.
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 81 */
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 82 if (!iommu_capable(dev->bus, IOMMU_CAP_CACHE_COHERENCY))
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 83 return ERR_PTR(-EINVAL);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 84
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 85 ictx = iommufd_fget(fd);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 86 if (!ictx)
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 87 return ERR_PTR(-EINVAL);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 88
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 89 group = iommu_group_get(dev);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 90 if (!group) {
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 91 rc = -ENODEV;
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 92 goto out_file_put;
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 93 }
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 94
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 95 /*
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 96 * FIXME: Use a device-centric iommu api and this won't work with
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 97 * multi-device groups
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 98 */
4e9347bc44832e Yi Liu 2022-06-22 99 if (!(flags & IOMMUFD_BIND_FLAGS_BYPASS_DMA_OWNERSHIP)) {
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 100 rc = iommu_group_claim_dma_owner(group, ictx->filp);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 101 if (rc)
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 102 goto out_group_put;
4e9347bc44832e Yi Liu 2022-06-22 103 }
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 104
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 105 idev = iommufd_object_alloc(ictx, idev, IOMMUFD_OBJ_DEVICE);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 106 if (IS_ERR(idev)) {
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 107 rc = PTR_ERR(idev);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 108 goto out_release_owner;
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 109 }
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 110 idev->ictx = ictx;
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 111 idev->dev = dev;
4e9347bc44832e Yi Liu 2022-06-22 112 idev->dma_owner_claimed =
4e9347bc44832e Yi Liu 2022-06-22 113 !(flags & IOMMUFD_BIND_FLAGS_BYPASS_DMA_OWNERSHIP);
4e9347bc44832e Yi Liu 2022-06-22 114 xa_init_flags(&idev->pasid_xa, XA_FLAGS_ALLOC | XA_FLAGS_ACCOUNT);
4e9347bc44832e Yi Liu 2022-06-22 115 mutex_init(&idev->pasid_lock);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 116 /* The calling driver is a user until iommufd_unbind_device() */
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 117 refcount_inc(&idev->obj.users);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 118 /* group refcount moves into iommufd_device */
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 119 idev->group = group;
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 120
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 121 /*
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 122 * If the caller fails after this success it must call
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 123 * iommufd_unbind_device() which is safe since we hold this refcount.
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 124 * This also means the device is a leaf in the graph and no other object
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 125 * can take a reference on it.
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 126 */
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 127 iommufd_object_finalize(ictx, &idev->obj);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 128 *id = idev->obj.id;
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 129 return idev;
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 130 out_release_owner:
4e9347bc44832e Yi Liu 2022-06-22 @131 if ((!flags & IOMMUFD_BIND_FLAGS_BYPASS_DMA_OWNERSHIP))
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 132 iommu_group_release_dma_owner(group);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 133 out_group_put:
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 134 iommu_group_put(group);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 135 out_file_put:
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 136 fput(ictx->filp);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 137 return ERR_PTR(rc);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 138 }
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 139 EXPORT_SYMBOL_GPL(iommufd_bind_device);
6f915f4df4ae49 Jason Gunthorpe 2021-11-11 140
--
0-DAY CI Kernel Test Service
https://01.org/lkp
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2022-07-14 18:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-14 18:34 [luxis1999-iommufd:iommufd-v5.19-rc5 84/104] drivers/iommu/iommufd/device.c:131:21: sparse: sparse: dubious: !x & y kernel 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.