Re: [PATCH v13 05/13] iommu: Add attach/detach_dev_pasid iommu interfaces

From: Jason Gunthorpe
Date: Thu Sep 22 2022 - 11:50:04 EST


On Tue, Sep 06, 2022 at 08:44:50PM +0800, Lu Baolu wrote:
> Attaching an IOMMU domain to a PASID of a device is a generic operation
> for modern IOMMU drivers which support PASID-granular DMA address
> translation. Currently visible usage scenarios include (but not limited):
>
> - SVA (Shared Virtual Address)
> - kernel DMA with PASID
> - hardware-assist mediated device
>
> This adds the set_dev_pasid domain ops for setting the domain onto a
> PASID of a device and remove_dev_pasid iommu ops for removing any setup
> on a PASID of device. This also adds interfaces for device drivers to
> attach/detach/retrieve a domain for a PASID of a device.
>
> If multiple devices share a single group, it's fine as long the fabric
> always routes every TLP marked with a PASID to the host bridge and only
> the host bridge. For example, ACS achieves this universally and has been
> checked when pci_enable_pasid() is called. As we can't reliably tell the
> source apart in a group, all the devices in a group have to be considered
> as the same source, and mapped to the same PASID table.
>
> Signed-off-by: Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
> Reviewed-by: Jean-Philippe Brucker <jean-philippe@xxxxxxxxxx>
> Reviewed-by: Kevin Tian <kevin.tian@xxxxxxxxx>
> Reviewed-by: Yi Liu <yi.l.liu@xxxxxxxxx>
> Tested-by: Zhangfei Gao <zhangfei.gao@xxxxxxxxxx>
> Tested-by: Tony Zhu <tony.zhu@xxxxxxxxx>
> ---
> include/linux/iommu.h | 32 +++++++++++
> drivers/iommu/iommu.c | 130 ++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 162 insertions(+)

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Jason