Re: [PATCH v13 09/13] iommu/sva: Refactoring iommu_sva_bind/unbind_device()

From: Baolu Lu
Date: Thu Sep 08 2022 - 21:54:20 EST


On 2022/9/9 0:41, Jason Gunthorpe wrote:
On Thu, Sep 08, 2022 at 05:25:32PM +0100, Jean-Philippe Brucker wrote:
On Wed, Sep 07, 2022 at 02:33:11PM -0300, Jason Gunthorpe wrote:
On Wed, Sep 07, 2022 at 10:54:54AM +0100, Jean-Philippe Brucker wrote:

Is iommu_domain still going to represent both a device context (whole
PASID table) and individual address spaces, or are you planning to move
away from that? What happens when a driver does:

d1 = iommu_domain_alloc()
iommu_attach_device(d1)
d2 = iommu_sva_bind_device()
iommu_detach_device(d1)

Does detach
(a) only disable the non-PASID address space?
(b) disable everything?
(c) fail because the driver didn't unbind first?
I think it must be (a), considering how everything is defined and the
needs for vIOMMU emulation.
Yes (a) is probably better. The SMMU driver currently implements (c) to
ensure that you can't switch device driver without unbinding everything
first, and we should keep that check somewhere
Yes, the owner stuff is a logical place to put that, when ownership
is all released the PASID table of the group must be empty. Lu?

I agree. The ownership is about the whole device (more precisely,
group), including the RID and PASIDs. When the ownership is converted,
the pasid array must be empty. I will add code in this series to enforce
this. Thanks for pointing out this.

Best regards,
baolu