Re: [PATCH 5/5] iommufd: Flush CPU caches on DMA pages in non-coherent domains

From: Jason Gunthorpe
Date: Sat Jun 01 2024 - 12:48:46 EST


On Mon, May 27, 2024 at 03:15:39PM +0800, Yan Zhao wrote:
> On Wed, May 22, 2024 at 02:01:50PM -0300, Jason Gunthorpe wrote:
> > On Wed, May 22, 2024 at 02:29:19PM +0800, Yan Zhao wrote:
> > > > > If you want to minimize flushes then you can't store flush
> > > > > minimization information in the pages because it isn't global to the
> > > > > pages and will not be accurate enough.
> > > > >
> > > > > > > If pfn_reader_fill_span() does batch_from_domain() and
> > > > > > > the source domain's storage_domain is non-coherent then you can skip
> > > > > > > the flush. This is not pedantically perfect in skipping all flushes, but
> > > > > > > in practice it is probably good enough.
> > > > >
> > > > > > We don't know whether the source storage_domain is non-coherent since
> > > > > > area->storage_domain is of "struct iommu_domain".
> > > > >
> > > > > > Do you want to add a flag in "area", e.g. area->storage_domain_is_noncoherent,
> > > > > > and set this flag along side setting storage_domain?
> > > > >
> > > > > Sure, that could work.
> > > > When the storage_domain is set in iopt_area_fill_domains(),
> > > > "area->storage_domain = xa_load(&area->iopt->domains, 0);"
> > > > is there a convenient way to know the storage_domain is non-coherent?
> > > Also asking for when storage_domain is switching to an arbitrary remaining domain
> > > in iopt_unfill_domain().
> > >
> > > And in iopt_area_unfill_domains(), after iopt_area_unmap_domain_range()
> > > of a non-coherent domain which is not the storage domain, how can we know that
> > > the domain is non-coherent?
> >
> > Yes, it would have to keep track of hwpts in more case unfortunately
> > :(
> Current iopt keeps an xarray of domains. Could I modify the xarray to store
> hwpt instead?

Probably yes

Jason