diff options
author | Nicolin Chen <nicolinc@nvidia.com> | 2022-10-17 16:02:13 -0700 |
---|---|---|
committer | Jason Gunthorpe <jgg@nvidia.com> | 2022-11-01 14:39:59 -0300 |
commit | bd7ebb7719356d750b1b4d671535922bae43fb3b (patch) | |
tree | 8867784273e8e5319862a5a67a9a6f57f8f7d530 /drivers/iommu/intel/pasid.c | |
parent | 00208852d351ca6e4a8b9ff0c5376fa3a8ed8eaa (diff) | |
download | linux-stable-bd7ebb7719356d750b1b4d671535922bae43fb3b.tar.gz linux-stable-bd7ebb7719356d750b1b4d671535922bae43fb3b.tar.bz2 linux-stable-bd7ebb7719356d750b1b4d671535922bae43fb3b.zip |
iommu: Regulate EINVAL in ->attach_dev callback functions
Following the new rules in include/linux/iommu.h kdocs, EINVAL now can be
used to indicate that domain and device are incompatible by a caller that
treats it as a soft failure and tries attaching to another domain.
On the other hand, there are ->attach_dev callback functions returning it
for obvious device-specific errors. They will result in some inefficiency
in the caller handling routine.
Update these places to corresponding errnos following the new rules.
Link: https://lore.kernel.org/r/5924c03bea637f05feb2a20d624bae086b555ec5.1666042872.git.nicolinc@nvidia.com
Reviewed-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Diffstat (limited to 'drivers/iommu/intel/pasid.c')
-rw-r--r-- | drivers/iommu/intel/pasid.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c index c30ddac40ee5..95d73f19ab61 100644 --- a/drivers/iommu/intel/pasid.c +++ b/drivers/iommu/intel/pasid.c @@ -101,8 +101,10 @@ int intel_pasid_alloc_table(struct device *dev) might_sleep(); info = dev_iommu_priv_get(dev); - if (WARN_ON(!info || !dev_is_pci(dev) || info->pasid_table)) - return -EINVAL; + if (WARN_ON(!info || !dev_is_pci(dev))) + return -ENODEV; + if (WARN_ON(info->pasid_table)) + return -EEXIST; pasid_table = kzalloc(sizeof(*pasid_table), GFP_KERNEL); if (!pasid_table) |