Re: [PATCH 01/11] iommu/vt-d: Add pasid private data helpers

From: Lu Baolu
Date: Sun May 23 2021 - 22:17:20 EST


Hi Jacob,

Thanks for reviewing my patch.

On 5/22/21 5:25 AM, Jacob Pan wrote:
Hi BaoLu,

On Thu, 20 May 2021 11:15:21 +0800, Lu Baolu <baolu.lu@xxxxxxxxxxxxxxx>
wrote:

We are about to use iommu_sva_alloc/free_pasid() helpers in iommu core.
That means the pasid life cycle will be managed by iommu core. Use a
local array to save the per pasid private data instead of attaching it
the real pasid.

I feel a little awkward to have a separate xarray for storing per IOASID
data. Seems duplicated.
Jason suggested in another thread that we can make ioasid_data public
and embeded in struct intel_svm, then we can get rid of the private data
pointer. ioasid_find will return the ioasid_data, then we can retrieve the
private data with container_of.

The problem that this patch wants to solve is that the
iommu_sva_alloc_pasid() will attach the mm pointer to the sva pasid.

pasid = ioasid_alloc(&iommu_sva_pasid, min, max, mm);

Assuming that each sva pasid can have only a single private data
pointer, the vendor iommu driver shouldn't set the private data again.


roughly,

struct intel_svm {
...
struct ioasid_data;
};

struct ioasid_data {
ioasid_t id;
refcount_t refs;
struct mm_struct *mm;
};

This can be a separate patch/effort if it make sense to you.

Yes if we have a better solution.

Best regards,
baolu