Re: [PATCH v4 3/6] iommu: Add return value rules to attach_dev op and APIs

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

 



On 9/21/22 4:23 PM, Nicolin Chen wrote:
Cases like VFIO wish to attach a device to an existing domain that was
not allocated specifically from the device. This raises a condition
where the IOMMU driver can fail the domain attach because the domain and
device are incompatible with each other.

This is a soft failure that can be resolved by using a different domain.

Provide a dedicated errno EINVAL from the IOMMU driver during attach that
the reason why the attach failed is because of domain incompatibility.

VFIO can use this to know that the attach is a soft failure and it should
continue searching. Otherwise, the attach will be a hard failure and VFIO
will return the code to userspace.

Update kdocs to add rules of return value to the attach_dev op and APIs.

Suggested-by: Jason Gunthorpe<jgg@xxxxxxxxxx>
Signed-off-by: Nicolin Chen<nicolinc@xxxxxxxxxx>
---
  drivers/iommu/iommu.c | 22 ++++++++++++++++++++++
  include/linux/iommu.h | 12 ++++++++++++
  2 files changed, 34 insertions(+)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 3a808146b50f..1d1e32aeaae6 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1975,6 +1975,17 @@ static int __iommu_attach_device(struct iommu_domain *domain,
  	return ret;
  }
+/**
+ * iommu_attach_device - Attach a device to an IOMMU domain

Normally we say "attach an iommu domain to a device/group ...".

Best regards,
baolu



[Index of Archives]     [ARM Kernel]     [Linux ARM]     [Linux ARM MSM]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux