[PATCH 2/8] powerpc/dma: properly wire up the unmap_page and unmap_sg methods
Christophe Leroy
christophe.leroy at c-s.fr
Mon Dec 17 17:41:54 AEDT 2018
Le 16/12/2018 à 18:19, Christoph Hellwig a écrit :
> The unmap methods need to transfer memory ownership back from the device
> to the cpu by identical means as dma_sync_*_to_cpu. I'm not sure powerpc
> needs to do any work in this transfer direction, but given that it does
> invalidate the caches in dma_sync_*_to_cpu already we should make sure
> we also do so on unmapping.
Why do we have to do that on unmapping ? If we are unmapping it means we
are retiring the area, so why would we need to use CPU for syncing an
area than won't be used anymore ?
Christophe
>
> Signed-off-by: Christoph Hellwig <hch at lst.de>
> ---
> arch/powerpc/kernel/dma.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/kernel/dma.c b/arch/powerpc/kernel/dma.c
> index dbfc7056d7df..d442d23e182b 100644
> --- a/arch/powerpc/kernel/dma.c
> +++ b/arch/powerpc/kernel/dma.c
> @@ -210,10 +210,15 @@ static int dma_nommu_map_sg(struct device *dev, struct scatterlist *sgl,
> return nents;
> }
>
> -static void dma_nommu_unmap_sg(struct device *dev, struct scatterlist *sg,
> +static void dma_nommu_unmap_sg(struct device *dev, struct scatterlist *sgl,
> int nents, enum dma_data_direction direction,
> unsigned long attrs)
> {
> + struct scatterlist *sg;
> + int i;
> +
> + for_each_sg(sgl, sg, nents, i)
> + __dma_sync_page(sg_page(sg), sg->offset, sg->length, direction);
> }
>
> static u64 dma_nommu_get_required_mask(struct device *dev)
> @@ -247,6 +252,8 @@ static inline void dma_nommu_unmap_page(struct device *dev,
> enum dma_data_direction direction,
> unsigned long attrs)
> {
> + if (!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
> + __dma_sync(bus_to_virt(dma_address), size, dir);
> }
>
> #ifdef CONFIG_NOT_COHERENT_CACHE
>
More information about the Linuxppc-dev
mailing list