Messages in this thread | | | Date | Wed, 7 Sep 2022 09:27:30 +0800 | From | Baolu Lu <> | Subject | Re: [PATCH v13 09/13] iommu/sva: Refactoring iommu_sva_bind/unbind_device() |
| |
Hi Jean,
On 2022/9/7 0:36, Jean-Philippe Brucker wrote: > On Tue, Sep 06, 2022 at 08:44:54PM +0800, Lu Baolu wrote: >> +/** >> + * iommu_sva_bind_device() - Bind a process address space to a device >> + * @dev: the device >> + * @mm: the mm to bind, caller must hold a reference to mm_users >> + * >> + * Create a bond between device and address space, allowing the device to access >> + * the mm using the returned PASID. If a bond already exists between @device and >> + * @mm, it is returned and an additional reference is taken. Caller must call >> + * iommu_sva_unbind_device() to release each reference. > This isn't true anymore. How about storing handle in the domain?
Yes, agreed. How about making the comments like this:
/** * iommu_sva_bind_device() - Bind a process address space to a device * @dev: the device * @mm: the mm to bind, caller must hold a reference to mm_users * * Create a bond between device and address space, allowing the device to * access the mm using the pasid returned by iommu_sva_get_pasid(). If a * bond already exists between @device and @mm, an additional internal * reference is taken. The reference will be released when the caller calls * iommu_sva_unbind_device().
Storing the handle in the domain looks odd. Conceptually an iommu domain represents a hardware page table and the SVA handle represents a relationship between device and the page table for a consumer. It's better to make them separated.
In a separated series, probably we can discuss the possibility of removing handle from the driver APIs. Just simply return the sva domain instead.
struct iommu_domain *iommu_sva_bind_device(struct device *dev, struct mm_struct *mm); void iommu_sva_unbind_device(struct device *dev, struct iommu_domain *domain); u32 iommu_sva_get_pasid(struct iommu_domain *domain);
If you think it's appropriate, I can send out the code for discussion.
> > (Maybe also drop my Reviewed-by tags since this has changed significantly, > I tend to ignore patches that have them)
I am sorry that after your review, the SVA domain and attach/detach device pasid interfaces have undergone some changes. They mainly exist in the following patches. Can you please help to take a look.
iommu/sva: Refactoring iommu_sva_bind/unbind_device() arm-smmu-v3/sva: Add SVA domain support iommu: Add IOMMU SVA domain support iommu: Add attach/detach_dev_pasid iommu interfaces
Best regards, baolu
| |