[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <76092d0d-3e74-9433-5fae-afc512e34b20@arm.com>
Date: Tue, 2 Jan 2018 16:26:27 +0000
From: Vladimir Murzin <vladimir.murzin@....com>
To: Christoph Hellwig <hch@....de>, iommu@...ts.linux-foundation.org
Cc: linux-mips@...ux-mips.org, linux-ia64@...r.kernel.org,
linux-sh@...r.kernel.org, sparclinux@...r.kernel.org,
Guan Xuetao <gxt@...c.pku.edu.cn>, linux-arch@...r.kernel.org,
linux-s390@...r.kernel.org, linux-c6x-dev@...ux-c6x.org,
linux-hexagon@...r.kernel.org, x86@...nel.org,
linux-snps-arc@...ts.infradead.org,
adi-buildroot-devel@...ts.sourceforge.net,
linux-m68k@...ts.linux-m68k.org, patches@...ups.riscv.org,
linux-metag@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
Michal Simek <monstr@...str.eu>, linux-parisc@...r.kernel.org,
linux-cris-kernel@...s.com, linux-kernel@...r.kernel.org,
linux-alpha@...r.kernel.org, linuxppc-dev@...ts.ozlabs.org
Subject: Re: [PATCH 26/67] dma-direct: use phys_to_dma
On 29/12/17 08:18, Christoph Hellwig wrote:
> This means it uses whatever linear remapping scheme that the architecture
> provides is used in the generic dma_direct ops.
>
> Signed-off-by: Christoph Hellwig <hch@....de>
> ---
> lib/dma-direct.c | 18 +++++++-----------
> 1 file changed, 7 insertions(+), 11 deletions(-)
>
> diff --git a/lib/dma-direct.c b/lib/dma-direct.c
> index 439db40854b7..0e087650e86b 100644
> --- a/lib/dma-direct.c
> +++ b/lib/dma-direct.c
> @@ -1,12 +1,11 @@
> // SPDX-License-Identifier: GPL-2.0
> /*
> - * lib/dma-noop.c
> - *
> - * DMA operations that map to physical addresses without flushing memory.
> + * DMA operations that map physical memory directly without using an IOMMU or
> + * flushing caches.
> */
> #include <linux/export.h>
> #include <linux/mm.h>
> -#include <linux/dma-mapping.h>
> +#include <linux/dma-direct.h>
> #include <linux/scatterlist.h>
> #include <linux/pfn.h>
>
> @@ -17,7 +16,7 @@ static void *dma_direct_alloc(struct device *dev, size_t size,
>
> ret = (void *)__get_free_pages(gfp, get_order(size));
> if (ret)
> - *dma_handle = virt_to_phys(ret) - PFN_PHYS(dev->dma_pfn_offset);
> + *dma_handle = phys_to_dma(dev, virt_to_phys(ret));
>
> return ret;
> }
> @@ -32,7 +31,7 @@ static dma_addr_t dma_direct_map_page(struct device *dev, struct page *page,
> unsigned long offset, size_t size, enum dma_data_direction dir,
> unsigned long attrs)
> {
> - return page_to_phys(page) + offset - PFN_PHYS(dev->dma_pfn_offset);
> + return phys_to_dma(dev, page_to_phys(page)) + offset;
> }
>
> static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
> @@ -42,12 +41,9 @@ static int dma_direct_map_sg(struct device *dev, struct scatterlist *sgl,
> struct scatterlist *sg;
>
> for_each_sg(sgl, sg, nents, i) {
> - dma_addr_t offset = PFN_PHYS(dev->dma_pfn_offset);
> - void *va;
> -
> BUG_ON(!sg_page(sg));
> - va = sg_virt(sg);
> - sg_dma_address(sg) = (dma_addr_t)virt_to_phys(va) - offset;
> +
> + sg_dma_address(sg) = phys_to_dma(dev, sg_phys(sg));
> sg_dma_len(sg) = sg->length;
> }
>
>
>From ARM NOMMU perspective
Reviewed-by: Vladimir Murzin <vladimir.murzin@....com>
Thanks
Vladimir
Powered by blists - more mailing lists