Re: [PATCH 2/2] MIPS: Loongson64: Add cache_sync to loongson_dma_map_ops

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 16, 2017 at 04:35:55PM +0800, Huacai Chen wrote:
> To support coherent & non-coherent DMA co-exsistance, we should add
> cache_sync to loongson_dma_map_ops.
> 
> Signed-off-by: Huacai Chen <chenhc@xxxxxxxxxx>

I presume this was broken by commit c9eb6172c328 ("dma-mapping: turn
dma_cache_sync into a dma_map_ops method") in 4.15-rc1? (Christoph Cc'd)

In that case:

1) we should have a fixes tag:
Fixes: c9eb6172c328 ("dma-mapping: turn dma_cache_sync into a dma_map_ops method")

2) we should get this into 4.15 final (though its probably pushing it a
bit now).

3) Loongson might not be the only MIPS platform that was broken by that
commit. Octeon appears to be coherent, so thats fine. However Netlogic
appears not to be (Jayachandran Cc'd).

Should the following be added?

diff --git a/arch/mips/netlogic/common/nlm-dma.c b/arch/mips/netlogic/common/nlm-dma.c
index 0ec9d9da6d51..58049da72c82 100644
--- a/arch/mips/netlogic/common/nlm-dma.c
+++ b/arch/mips/netlogic/common/nlm-dma.c
@@ -79,7 +79,8 @@ const struct dma_map_ops nlm_swiotlb_dma_ops = {
 	.sync_sg_for_cpu = swiotlb_sync_sg_for_cpu,
 	.sync_sg_for_device = swiotlb_sync_sg_for_device,
 	.mapping_error = swiotlb_dma_mapping_error,
-	.dma_supported = swiotlb_dma_supported
+	.dma_supported = swiotlb_dma_supported,
+	.cache_sync = mips_dma_cache_sync,
 };
 
 void __init plat_swiotlb_setup(void)

Cheers
James

> ---
>  arch/mips/include/asm/dma-mapping.h       | 3 +++
>  arch/mips/loongson64/common/dma-swiotlb.c | 1 +
>  arch/mips/mm/dma-default.c                | 2 +-
>  3 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
> index 0d9418d..5544276 100644
> --- a/arch/mips/include/asm/dma-mapping.h
> +++ b/arch/mips/include/asm/dma-mapping.h
> @@ -37,4 +37,7 @@ static inline void arch_setup_dma_ops(struct device *dev, u64 dma_base,
>  #endif
>  }
>  
> +void mips_dma_cache_sync(struct device *dev, void *vaddr,
> +		size_t size, enum dma_data_direction direction);
> +
>  #endif /* _ASM_DMA_MAPPING_H */
> diff --git a/arch/mips/loongson64/common/dma-swiotlb.c b/arch/mips/loongson64/common/dma-swiotlb.c
> index ef07740..17956f2 100644
> --- a/arch/mips/loongson64/common/dma-swiotlb.c
> +++ b/arch/mips/loongson64/common/dma-swiotlb.c
> @@ -120,6 +120,7 @@ static const struct dma_map_ops loongson_dma_map_ops = {
>  	.sync_sg_for_device = loongson_dma_sync_sg_for_device,
>  	.mapping_error = swiotlb_dma_mapping_error,
>  	.dma_supported = loongson_dma_supported,
> +	.cache_sync = mips_dma_cache_sync,
>  };
>  
>  void __init plat_swiotlb_setup(void)
> diff --git a/arch/mips/mm/dma-default.c b/arch/mips/mm/dma-default.c
> index e3e94d0..e86bf5d 100644
> --- a/arch/mips/mm/dma-default.c
> +++ b/arch/mips/mm/dma-default.c
> @@ -383,7 +383,7 @@ static int mips_dma_supported(struct device *dev, u64 mask)
>  	return plat_dma_supported(dev, mask);
>  }
>  
> -static void mips_dma_cache_sync(struct device *dev, void *vaddr, size_t size,
> +void mips_dma_cache_sync(struct device *dev, void *vaddr, size_t size,
>  			 enum dma_data_direction direction)
>  {
>  	BUG_ON(direction == DMA_NONE);
> -- 
> 2.7.0
> 

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux