[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAFgf54rkwipUMQH6452xoKXT_FwcE2s=TNwoTZd3_TrK5WJNCg@mail.gmail.com>
Date: Thu, 8 Jan 2026 16:21:10 +0000
From: Mostafa Saleh <smostafa@...gle.com>
To: Jason Gunthorpe <jgg@...pe.ca>
Cc: iommu@...ts.linux.dev, linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org, robin.murphy@....com, will@...nel.org,
joro@...tes.org
Subject: Re: [PATCH] iommu/io-pgtable-arm: Drop DMA API usage for CMOs
On Thu, Jan 8, 2026 at 2:45 PM Jason Gunthorpe <jgg@...pe.ca> wrote:
>
> On Thu, Jan 08, 2026 at 01:44:51PM +0000, Mostafa Saleh wrote:
> > On Thu, Jan 8, 2026 at 1:27 PM Mostafa Saleh <smostafa@...gle.com> wrote:
> > >
> > > On Thu, Jan 8, 2026 at 12:59 PM Jason Gunthorpe <jgg@...pe.ca> wrote:
> > > >
> > > > On Thu, Jan 08, 2026 at 11:38:46AM +0000, Mostafa Saleh wrote:
> > > > > Jason pointed out that the DMA-API calls are not really needed [2].
> > > > >
> > > > > Looking more into this. Initially, the io-pgtable API let drivers
> > > > > do the CMOs using tlb::flush_pgtable() where drivers were using the
> > > > > DMA API (map/unmap_single) only to do CMOs as the low-level cache
> > > > > functions won’t be available for modules.
> > > >
> > > > This isn't what I ment at all, the iommu-pages.h could do the flush
> > > > inside itself using the already existing
> > > > iommu_pages_flush_incoherent() instead of open coding the dma api
> > > > calls everwhere, and maybe that could directly call the arch function
> > > > on arm (as x86 does) which would be easier to implement in pkvm's
> > > > hypervisor.
> > > >
> > >
> > > I see, so basically, we add the check for IOMMU_PAGES_USE_DMA_API in
> > > iommu_pages_flush_incoherent() with the DMA-API stuff and call it from
> > > the io-pgtable-arm instead.
> > >
> >
> > iommu_pages_flush_incoherent() is also used to flush non-cacheable
> > pages in generic_pt from flush_writes_*(), so it might not be that
> > simple; We might need to add a new variant.
>
> There are no non-cachable pages in the iommu-pages system???
>
Sorry I meant to flush writes for memory accessed by not-coherent IOMMUs.
> All memory comes from folios and is mapped to the CPU cachable.
>
> The general API requires the user of iommu-pages to know if the
> underlying HW is going to do non-coherent DMA, in this case it must
> call iommu_pages_flush_incoherent() before the HW does DMA.
>
> Effectively what I'm saying here is to convert the arm page table to
> use iommu-pages and then put your pkvm abstraction at the iommu-pages
> level instead of trying to hack up all these users.
>
I see, I need to check how that plays with the custom allocator in the
io-pgtable though. I will look further into it.
Thanks,
Mostafa
> You can also do the same conversion to the smmu driver to use
> iommu-pages instead of DMA API, AMD and Intel are doing this already.
>
> Jason
Powered by blists - more mailing lists