lkml.org 
[lkml]   [2022]   [Apr]   [2]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRE: [PATCH RFC v2 03/11] iommu/sva: Add iommu_domain type for SVA
Date
> From: Jason Gunthorpe <jgg@nvidia.com>
> Sent: Thursday, March 31, 2022 3:02 AM
>
> On Tue, Mar 29, 2022 at 01:37:52PM +0800, Lu Baolu wrote:
> > @@ -95,6 +101,7 @@ struct iommu_domain {
> > void *handler_token;
> > struct iommu_domain_geometry geometry;
> > struct iommu_dma_cookie *iova_cookie;
> > + struct iommu_sva_cookie *sva_cookie;
>
> Cookie is still the wrong word to use here
>
> > +struct iommu_sva_cookie {
> > + struct mm_struct *mm;
> > + ioasid_t pasid;
> > + refcount_t users;
>
> Really surprised to see a refcount buried inside the iommu_domain..
>
> This design seems inside out, the SVA struct should 'enclose' the domain, not
> be a pointer inside it.
>
> struct iommu_sva_domain {
> struct kref_t kref;
> struct mm_struct *mm;
> ioasid_t pasid;
>
> /* All the domains that are linked to this */
> struct xarray domain_list;
> };
>
> And then you could have a pointer to that inside the mm_struct instead
> of just the naked pasid.
>
> > +static __maybe_unused struct iommu_domain *
>
> Why maybe unused?
>
> > +iommu_sva_get_domain(struct device *dev, struct mm_struct *mm)
> > +{
> > + struct iommu_domain *domain;
> > + ioasid_t pasid = mm->pasid;
> > +
> > + if (pasid == INVALID_IOASID)
> > + return NULL;
> > +
> > + domain = xa_load(&sva_domain_array, pasid);
> > + if (!domain)
> > + return iommu_sva_alloc_domain(dev, mm);
> > + iommu_sva_domain_get_user(domain);
>
> This assumes any domain is interchangeable with any device, which is
> not the iommu model. We need a domain op to check if a device is
> compatiable with the domain for vfio an iommufd, this should do the
> same.

This suggests that mm_struct needs to include the format information
of the CPU page table so the format can be checked by the domain op?

>
> It means each mm can have a list of domains associated with it and a
> new domain is auto-created if the device doesn't work with any of the
> existing domains.
>

mm has only one page table and one format. If a device is incompatible
with an existing domain wrapping that page table, how come creating
another domain could make it compatible?

Thanks
Kevin

\
 
 \ /
  Last update: 2022-04-02 10:45    [W:0.154 / U:1.252 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site