> +IOMMUFD User API > +================ > + > +.. kernel-doc:: include/uapi/linux/iommufd.h I noticed this isn't working It needs this patch: https://lore.kernel.org/r/0-v1-c80e152ce63b+12-kdoc_export_ns_jgg@xxxxxxxxxx And also some updating to capture kdocs for all the exported symbols: diff --git a/Documentation/userspace-api/iommufd.rst b/Documentation/userspace-api/iommufd.rst index 64a135f3055adc..ffc5f4bc65492e 100644 --- a/Documentation/userspace-api/iommufd.rst +++ b/Documentation/userspace-api/iommufd.rst @@ -186,6 +186,9 @@ explicitly imposing the group semantics in its uAPI as VFIO does. .. kernel-doc:: drivers/iommu/iommufd/device.c :export: +.. kernel-doc:: drivers/iommu/iommufd/main.c + :export: + VFIO and IOMMUFD ---------------- diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c index dc3058e063d8de..8f4a0e11c51bae 100644 --- a/drivers/iommu/iommufd/device.c +++ b/drivers/iommu/iommufd/device.c @@ -107,6 +107,14 @@ struct iommufd_device *iommufd_device_bind(struct iommufd_ctx *ictx, } EXPORT_SYMBOL_NS_GPL(iommufd_device_bind, IOMMUFD); +/** + * iommufd_device_unbind - Undo iommufd_device_bind() + * @idev: Device returned by iommufd_device_bind() + * + * Release the device from iommufd control. The DMA ownership will return back + * to unowned with blocked DMA. This invalidates the iommufd_device pointer, + * other APIs that consume it must not be called concurrently. + */ void iommufd_device_unbind(struct iommufd_device *idev) { bool was_destroyed; @@ -372,6 +380,13 @@ int iommufd_device_attach(struct iommufd_device *idev, u32 *pt_id, } EXPORT_SYMBOL_NS_GPL(iommufd_device_attach, IOMMUFD); +/** + * iommufd_device_detach - Disconnect a device to an iommu_domain + * @idev: device to detach + * + * Undoes iommufd_device_attach(). This disconnects the idev from the previously + * attached pt_id. The device returns back to a blocked DMA translation. + */ void iommufd_device_detach(struct iommufd_device *idev) { struct iommufd_hw_pagetable *hwpt = idev->hwpt; @@ -412,6 +427,19 @@ void iommufd_access_destroy_object(struct iommufd_object *obj) refcount_dec(&access->ioas->obj.users); } +/** + * iommufd_access_create - Create an iommufd_access + * @ictx: iommufd file descriptor + * @ioas_id: ID for a IOMMUFD_OBJ_IOAS + * @ops: Driver's ops to associate with the access + * @data: Opaque data to pass into ops functions + * + * An iommufd_access allows a driver to read/write to the IOAS without using + * DMA. The underlying CPU memory can be accessed using the + * iommufd_access_pin_pages() or iommufd_access_rw() functions. + * + * The provided ops are required to use iommufd_access_pin_pages(). + */ struct iommufd_access * iommufd_access_create(struct iommufd_ctx *ictx, u32 ioas_id, const struct iommufd_access_ops *ops, void *data) @@ -461,6 +489,12 @@ iommufd_access_create(struct iommufd_ctx *ictx, u32 ioas_id, } EXPORT_SYMBOL_NS_GPL(iommufd_access_create, IOMMUFD); +/** + * iommufd_access_destroy - Destroy an iommufd_access + * @access: The access to destroy + * + * The caller must stop using the access before destroying it. + */ void iommufd_access_destroy(struct iommufd_access *access) { bool was_destroyed;