Re: [PATCH 2/2] xen: swiotlb: Implement map_resource callback

From: Stefano Stabellini
Date: Thu May 08 2025 - 19:15:02 EST


On Wed, 7 May 2025, Christoph Hellwig wrote:
> On Wed, May 07, 2025 at 04:09:15PM -0700, Stefano Stabellini wrote:
> > > This mapping is not for a RAM backed address. In the eDMA case for the
> > > iMX8QXP the `phys` coming in here is the address of a register.
> >
> > Ok, this information is important :-)
> >
> > I am not certain whether the map_resource interface can only be called
> > for MMIO addresses or if it can also be called for RAM-backed addresses
> > with a size > PAGE_SIZE. In the latter case, we could run into the issue
> > I was describing.
>
> map_resource is intended for MMIO regions, although those could be >
> PAGE_SIZE. It must not be called on RAM.

In that case, John, you can just use dma_direct_map_resource().

That's because MMIO regions:
- are 1:1 mapped on ARM
- are 1:1 mapped on x86 for PV Dom0
- might not be 1:1 mapped on x86 for PVH Dom0, but in this case we rely
on the IOMMU to do address translation

In none of these cases xen_phys_to_dma would give us any interesting
results. It would be the same as calling phys_to_dma.