Skip to contentSkip to conversation

use the generic dma-noncoherent code for microblaze

PATCH New Christoph Hellwig 2 participants 5 messages Jul 19, 2018 – Jul 20, 2018 Microblaze architecture

lore
Share & tools
lore
#0 lore raw

Hi Michal,

can you review these patches to switch microblaze to use the generic dma-noncoherent code? All the requirements are in mainline already and we've switched various architectures over to it already.

#1 lore raw

PATCH 1/2 microblaze: use generic dma_noncoherent_ops

Switch to the generic noncoherent direct mapping implementation.

This removes the direction-based optimizations in sync_{single,sg}_for_{cpu,device} which were marked untestested and do not match the usually very well tested {un,}map_{single,sg} implementations.

---
 arch/microblaze/Kconfig                   |   4 +
 arch/microblaze/include/asm/Kbuild        |   1 +
 arch/microblaze/include/asm/dma-mapping.h |  28 -----
 arch/microblaze/include/asm/pgtable.h     |   2 -
 arch/microblaze/kernel/dma.c              | 144 ++--------------------
 arch/microblaze/mm/consistent.c           |   9 +-
 6 files changed, 22 insertions(+), 166 deletions(-)
 delete mode 100644 arch/microblaze/include/asm/dma-mapping.h
arch/microblaze/Kconfig +4 -0
index d14782100088..848e31a86ba5 100644
@@ -1,6 +1,8 @@
 config MICROBLAZE
 	def_bool y
 	select ARCH_HAS_GCOV_PROFILE_ALL
+	select ARCH_HAS_SYNC_DMA_FOR_CPU
+	select ARCH_HAS_SYNC_DMA_FOR_DEVICE
 	select ARCH_MIGHT_HAVE_PC_PARPORT
 	select ARCH_NO_COHERENT_DMA_MMAP if !MMU
 	select ARCH_WANT_IPC_PARSE_VERSION
@@ -8,6 +10,8 @@ config MICROBLAZE
 	select TIMER_OF
 	select CLONE_BACKWARDS3
 	select COMMON_CLK
+	select DMA_NONCOHERENT_OPS
+	select DMA_NONCOHERENT_MMAP
 	select GENERIC_ATOMIC64
 	select GENERIC_CLOCKEVENTS
 	select GENERIC_CPU_DEVICES
arch/microblaze/include/asm/Kbuild +1 -0
index fe6a6c6e5003..569ba9e670c1 100644
@@ -5,6 +5,7 @@ generic-y += bugs.h
 generic-y += compat.h
 generic-y += device.h
 generic-y += div64.h
+generic-y += dma-mapping.h
 generic-y += emergency-restart.h
 generic-y += exec.h
 generic-y += extable.h
arch/microblaze/include/asm/dma-mapping.h deleted +0 -28
deleted file mode 100644
index add50c1373bf..000000000000
@@ -1,28 +0,0 @@
-/*
- * Implements the generic device dma API for microblaze and the pci
- *
- * Copyright (C) 2009-2010 Michal Simek <[email protected]>
- * Copyright (C) 2009-2010 PetaLogix
- *
- * This file is subject to the terms and conditions of the GNU General
- * Public License. See the file COPYING in the main directory of this
- * archive for more details.
- *
- * This file is base on powerpc and x86 dma-mapping.h versions
- * Copyright (C) 2004 IBM
- */
-
-#ifndef _ASM_MICROBLAZE_DMA_MAPPING_H
-#define _ASM_MICROBLAZE_DMA_MAPPING_H
-
-/*
- * Available generic sets of operations
- */
-extern const struct dma_map_ops dma_nommu_ops;
-
-static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus)
-{
-	return &dma_nommu_ops;
-}
-
-#endif	/* _ASM_MICROBLAZE_DMA_MAPPING_H */
arch/microblaze/include/asm/pgtable.h +0 -2
index db8b1fa83452..8a2e654b709f 100644
@@ -553,8 +553,6 @@ void __init *early_get_page(void);
 
 extern unsigned long ioremap_bot, ioremap_base;
 
-void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle);
-void consistent_free(size_t size, void *vaddr);
 void consistent_sync(void *vaddr, size_t size, int direction);
 void consistent_sync_page(struct page *page, unsigned long offset,
 	size_t size, int direction);
arch/microblaze/kernel/dma.c +12 -132

171 lines not on this page · raw message

arch/microblaze/mm/consistent.c +5 -4
index b06c3a7faf20..b9a9c8c3397b 100644
@@ -33,6 +33,7 @@
 #include <linux/pci.h>
 #include <linux/interrupt.h>
 #include <linux/gfp.h>
+#include <linux/dma-noncoherent.h>
 
 #include <asm/pgalloc.h>
 #include <linux/io.h>
@@ -59,7 +60,8 @@
  * uncached region.  This will no doubt cause big problems if memory allocated
  * here is not also freed properly. -- JW
  */
-void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle)
+void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle,
+		gfp_t gfp, unsigned long attrs)
 {
 	unsigned long order, vaddr;
 	void *ret;
@@ -154,7 +156,6 @@ void *consistent_alloc(gfp_t gfp, size_t size, dma_addr_t *dma_handle)
 
 	return ret;
 }
-EXPORT_SYMBOL(consistent_alloc);
 
 #ifdef CONFIG_MMU
 static pte_t *consistent_virt_to_pte(void *vaddr)
@@ -178,7 +179,8 @@ unsigned long consistent_virt_to_pfn(void *vaddr)
 /*
  * free page(s) as defined by the above mapping.
  */
-void consistent_free(size_t size, void *vaddr)
+void arch_dma_free(struct device *dev, size_t size, void *vaddr,
+		dma_addr_t dma_addr, unsigned long attrs)
 {
 	struct page *page;
 
@@ -218,7 +220,6 @@ void consistent_free(size_t size, void *vaddr)
 	flush_tlb_all();
 #endif
 }
-EXPORT_SYMBOL(consistent_free);
 
 /*
  * make an area consistent.
Signature · 1 line
2.18.0
#2 lore raw

PATCH 2/2 microblaze: remove consistent_sync and consistent_sync_page

In reply to Christoph Hellwig

Both unused.

---
 arch/microblaze/include/asm/pgtable.h |  3 --
 arch/microblaze/mm/consistent.c       | 45 ---------------------------
 2 files changed, 48 deletions(-)
arch/microblaze/include/asm/pgtable.h +0 -3
index 8a2e654b709f..7b650ab14fa0 100644
@@ -553,9 +553,6 @@ void __init *early_get_page(void);
 
 extern unsigned long ioremap_bot, ioremap_base;
 
-void consistent_sync(void *vaddr, size_t size, int direction);
-void consistent_sync_page(struct page *page, unsigned long offset,
-	size_t size, int direction);
 unsigned long consistent_virt_to_pfn(void *vaddr);
 
 void setup_memory(void);
arch/microblaze/mm/consistent.c +0 -45

48 lines not on this page · raw message

Signature · 1 line
2.18.0
#3 lore raw
In reply to Christoph Hellwig

Hi,

Quoted 6 lines · Christoph Hellwig

Hi Michal,

can you review these patches to switch microblaze to use the generic dma-noncoherent code? All the requirements are in mainline already and we've switched various architectures over to it already.

I can't see any issue with them.
Both applied to next.

Thanks,
Michal

#4 lore raw
Quoted 5 lines · Michal Simek

Hi,

Quoted 2 lines · Christoph Hellwig

Hi Michal,

Quoted 7 lines
Quoted 4 lines

can you review these patches to switch microblaze to use the generic dma-noncoherent code? All the requirements are in mainline already and we've switched various architectures over to it already.

I can't see any issue with them.
Both applied to next.

!