[PATCH 1/2] dma-mapping: Add dma_addr_is_phys_addr()
Ram Pai
linuxram at us.ibm.com
Tue Oct 15 18:30:03 AEDT 2019
On Mon, Oct 14, 2019 at 11:29:24AM +0100, Robin Murphy wrote:
> On 14/10/2019 05:51, David Gibson wrote:
> >On Fri, Oct 11, 2019 at 06:25:18PM -0700, Ram Pai wrote:
> >>From: Thiago Jung Bauermann <bauerman at linux.ibm.com>
> >>
> >>In order to safely use the DMA API, virtio needs to know whether DMA
> >>addresses are in fact physical addresses and for that purpose,
> >>dma_addr_is_phys_addr() is introduced.
> >>
> >>cc: Benjamin Herrenschmidt <benh at kernel.crashing.org>
> >>cc: David Gibson <david at gibson.dropbear.id.au>
> >>cc: Michael Ellerman <mpe at ellerman.id.au>
> >>cc: Paul Mackerras <paulus at ozlabs.org>
> >>cc: Michael Roth <mdroth at linux.vnet.ibm.com>
> >>cc: Alexey Kardashevskiy <aik at linux.ibm.com>
> >>cc: Paul Burton <paul.burton at mips.com>
> >>cc: Robin Murphy <robin.murphy at arm.com>
> >>cc: Bartlomiej Zolnierkiewicz <b.zolnierkie at samsung.com>
> >>cc: Marek Szyprowski <m.szyprowski at samsung.com>
> >>cc: Christoph Hellwig <hch at lst.de>
> >>Suggested-by: Michael S. Tsirkin <mst at redhat.com>
> >>Signed-off-by: Ram Pai <linuxram at us.ibm.com>
> >>Signed-off-by: Thiago Jung Bauermann <bauerman at linux.ibm.com>
> >
> >The change itself looks ok, so
> >
> >Reviewed-by: David Gibson <david at gibson.dropbear.id.au>
> >
> >However, I would like to see the commit message (and maybe the inline
> >comments) expanded a bit on what the distinction here is about. Some
> >of the text from the next patch would be suitable, about DMA addresses
> >usually being in a different address space but not in the case of
> >bounce buffering.
>
> Right, this needs a much tighter definition. "DMA address happens to
> be a valid physical address" is true of various IOMMU setups too,
> but I can't believe it's meaningful in such cases.
The definition by itself is meaningful AFAICT. At its core its just
indicating whether DMA addresses are physical addresses or not.
However its up to the caller to use it meaningfully. For non-virtio caller,
dma_addr_is_phys_addr() by itself may or may not be meaningful.
But for a virtio caller, this information when paired with
mem_encrypt_active() is meaningful.
For IOMMU setups DMA API will get used regardless of "DMA address
happens to be a valid physical address"
>
> If what you actually want is "DMA is direct or SWIOTLB" - i.e. "DMA
> address is physical address of DMA data (not necessarily the
> original buffer)" - wouldn't dma_is_direct() suffice?
This may also work, I think. MST: thoughts?
RP
More information about the Linuxppc-dev
mailing list