switch nios2 and microblaze to use the generic uncached segement support
Subsystems (3)
Hi all,
can you take a look at this series? It switches niops2 and microblaze to use the generic dma layer support for uncached segements.
The dma mapping for-next git tree that includes the support is available here:
git://git.infradead.org/users/hch/dma-mapping.git for-next
Gitweb:
http://git.infradead.org/users/hch/dma-mapping.git/shortlog/refs/heads/for-next
PATCH 1/2 nios2: use the generic uncached segment support in dma-direct
Stop providing our own arch alloc/free hooks and just expose the segment offset and use the generic dma-direct allocator.
--- arch/nios2/Kconfig | 1 + arch/nios2/include/asm/page.h | 6 ------ arch/nios2/mm/dma-mapping.c | 34 +++++++++++++++------------------- 3 files changed, 16 insertions(+), 25 deletions(-)
arch/nios2/Kconfig +1 -0
@@ -4,6 +4,7 @@ config NIOS2 select ARCH_32BIT_OFF_T select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_HAS_UNCACHED_SEGMENT select ARCH_NO_SWAP select TIMER_OF select GENERIC_ATOMIC64
arch/nios2/include/asm/page.h +0 -6
@@ -101,12 +101,6 @@ static inline bool pfn_valid(unsigned long pfn)# define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -# define UNCAC_ADDR (addr) \ - ((void *)((unsigned)(addr) | CONFIG_NIOS2_IO_REGION_BASE)) -# define CAC_ADDR (addr) \ - ((void *)(((unsigned)(addr) & ~CONFIG_NIOS2_IO_REGION_BASE) | \ - CONFIG_NIOS2_KERNEL_REGION_BASE)) -#include <asm-generic/memory_model.h> #include <asm-generic/getorder.h>
arch/nios2/mm/dma-mapping.c +15 -19
@@ -60,32 +60,28 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr, } } -void *arch_dma_alloc (struct device *dev,size_t size,dma_addr_t *dma_handle, -gfp_t gfp,unsigned long attrs) +void arch_dma_prep_coherent (struct page *page,size_t size) { -void *ret; +unsigned long start = (unsigned long )page_address (page); -/* optimized page clearing */ - gfp |= __GFP_ZERO; +flush_dcache_range (start, start + size); +} -if (dev ==NULL || (dev->coherent_dma_mask <0xffffffff )) - gfp |=GFP_DMA ; +void *uncached_kernel_address (void *ptr) +{ +unsigned long addr = (unsigned long )ptr; - ret = (void *)__get_free_pages (gfp,get_order (size)); -if (ret !=NULL ) { - *dma_handle =virt_to_phys (ret); -flush_dcache_range ((unsigned long ) ret, - (unsigned long ) ret + size); - ret =UNCAC_ADDR (ret); - } + addr |=CONFIG_NIOS2_IO_REGION_BASE ; -return ret; +return (void *)ptr; } -void arch_dma_free (struct device *dev,size_t size,void *vaddr, -dma_addr_t dma_handle,unsigned long attrs) +void *cached_kernel_address (void *ptr) { -unsigned long addr = (unsigned long )CAC_ADDR ((unsigned long ) vaddr); +unsigned long addr = (unsigned long )ptr; + + addr &= ~CONFIG_NIOS2_IO_REGION_BASE ; + addr |=CONFIG_NIOS2_KERNEL_REGION_BASE ; -free_pages (addr,get_order (size)); +return (void *)ptr; }
Signature · 1 line
2.20.1
Re: [PATCH 1/2] nios2: use the generic uncached segment support in dma-direct
Quoted 5 lines · Christoph Hellwig
Stop providing our own arch alloc/free hooks and just expose the segment offset and use the generic dma-direct allocator.
Signed-off-by Christoph Hellwig <[email protected]>
Quoted 90 lines
--- arch/nios2/Kconfig | 1 + arch/nios2/include/asm/page.h | 6 ------ arch/nios2/mm/dma-mapping.c | 34 +++++++++++++++------------------- 3 files changed, 16 insertions(+), 25 deletions(-)arch/nios2/Kconfig +1
-0@@ -4,6 +4,7 @@ config NIOS2 select ARCH_32BIT_OFF_T select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_HAS_UNCACHED_SEGMENT select ARCH_NO_SWAP select TIMER_OF select GENERIC_ATOMIC64arch/nios2/include/asm/page.h +0
-6@@ -101,12 +101,6 @@ static inline bool pfn_valid(unsigned long pfn)# define VM_DATA_DEFAULT_FLAGS (VM_READ | VM_WRITE | \ VM_MAYREAD | VM_MAYWRITE | VM_MAYEXEC) -# define UNCAC_ADDR (addr) \ - ((void *)((unsigned)(addr) | CONFIG_NIOS2_IO_REGION_BASE)) -# define CAC_ADDR (addr) \ - ((void *)(((unsigned)(addr) & ~CONFIG_NIOS2_IO_REGION_BASE) | \ - CONFIG_NIOS2_KERNEL_REGION_BASE)) -#include <asm-generic/memory_model.h> #include <asm-generic/getorder.h> arch/nios2/mm/dma-mapping.c +15
-20@@ -60,32 +60,28 @@ void arch_sync_dma_for_cpu(struct device *dev, phys_addr_t paddr, } } -void *arch_dma_alloc (struct device *dev,size_t size,dma_addr_t *dma_handle, -gfp_t gfp,unsigned long attrs) +void arch_dma_prep_coherent (struct page *page,size_t size) { -void *ret; +unsigned long start = (unsigned long )page_address (page); -/* optimized page clearing */ - gfp |= __GFP_ZERO; +flush_dcache_range (start, start + size); +} -if (dev ==NULL || (dev->coherent_dma_mask <0xffffffff )) - gfp |=GFP_DMA ; +void *uncached_kernel_address (void *ptr) +{ +unsigned long addr = (unsigned long )ptr; - ret = (void *)__get_free_pages (gfp,get_order (size)); -if (ret !=NULL ) { - *dma_handle =virt_to_phys (ret); -flush_dcache_range ((unsigned long ) ret, - (unsigned long ) ret + size); - ret =UNCAC_ADDR (ret); - } + addr |=CONFIG_NIOS2_IO_REGION_BASE ; -return ret; +return (void *)ptr; } -void arch_dma_free (struct device *dev,size_t size,void *vaddr, -dma_addr_t dma_handle,unsigned long attrs) +void *cached_kernel_address (void *ptr) { -unsigned long addr = (unsigned long )CAC_ADDR ((unsigned long ) vaddr); +unsigned long addr = (unsigned long )ptr; + + addr &= ~CONFIG_NIOS2_IO_REGION_BASE ; + addr |=CONFIG_NIOS2_KERNEL_REGION_BASE ; -free_pages (addr,get_order (size)); +return (void *)ptr; } --2.20.1
Christoph Hellwig
AppliedRe: [PATCH 1/2] nios2: use the generic uncached segment support in dma-direct
Quoted 8 lines · Ley Foon Tan
Quoted 5 lines · Christoph Hellwig
Stop providing our own arch alloc/free hooks and just expose the segment offset and use the generic dma-direct allocator.
Signed-off-by Christoph Hellwig <[email protected]>Acked-by Ley Foon Tan <[email protected]>
Thanks,
applied to dma-mapping for-next.
PATCH 2/2 microblaze: use the generic uncached segment support in dma-direct
In reply to Christoph HellwigStop providing our own arch alloc/free hooks for nommu platforms and just expose the segment offset and use the generic dma-direct allocator.
--- arch/microblaze/Kconfig | 2 + arch/microblaze/mm/consistent.c | 97 +++++++++++++++------------------ 2 files changed, 47 insertions(+), 52 deletions(-)
arch/microblaze/Kconfig +2 -0
@@ -4,9 +4,11 @@ config MICROBLAZE select ARCH_32BIT_OFF_T select ARCH_NO_SWAP select ARCH_HAS_DMA_COHERENT_TO_PFN if MMU + select ARCH_HAS_DMA_PREP_COHERENT select ARCH_HAS_GCOV_PROFILE_ALL select ARCH_HAS_SYNC_DMA_FOR_CPU select ARCH_HAS_SYNC_DMA_FOR_DEVICE + select ARCH_HAS_UNCACHED_SEGMENT if !MMU select ARCH_MIGHT_HAVE_PC_PARPORT select ARCH_NO_COHERENT_DMA_MMAP if !MMU select ARCH_WANT_IPC_PARSE_VERSION
arch/microblaze/mm/consistent.c +45 -52
158 lines not on this page · raw message
Signature · 1 line
2.20.1
Quoted 10 lines · Christoph Hellwig
Hi all,
can you take a look at this series? It switches niops2 and microblaze to
use the generic dma layer support for uncached segements.The dma mapping for-next git tree that includes the support is available
here:
Quoted 7 lines
git://git.infradead.org/users/hch/dma-mapping.git for-next
Gitweb:
http://git.infradead.org/users/hch/dma-mapping.git/shortlog/refs/
heads/for-next
Hi Christoph
Can this patch in http://git.infradead.org/users/hch/dma-mapping.git/sh
ortlog/refs/heads/for-next
[PATCH 1/2] nios2: use the generic uncached segment support in dma- direct
Regards
Ley Foon
Quoted 7 lines · Ley Foon Tan
Hi Christoph
Can this patch in http://git.infradead.org/users/hch/dma-mapping.git/sh
ortlog/refs/heads/for-next[PATCH 1/2] nios2: use the generic uncached segment support in dma- direct
Hi Ley Foon,
I don't understand the above sentence. Does it imply a Reviewed-by?
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · Ley Foon Tan
Hi Christoph
Can this patch in http://git.infradead.org/users/hch/dma-mapping.gi
t/sh
ortlog/refs/heads/for-next
Quoted 5 lines
Quoted 2 lines
[PATCH 1/2] nios2: use the generic uncached segment support in dma- direct
Hi Ley Foon,
I don't understand the above sentence. Does it imply a Reviewed-by?
Sorry, typo in my previous email.
Can't find this patch in the git link you provided (for-next branch). Did you push the patch?
Regards
Ley Foon
Quoted 9 lines · Ley Foon
Quoted 8 lines · Christoph Hellwig
Quoted 7 lines · Ley Foon Tan
Hi Christoph
Can this patch in http://git.infradead.org/users/hch/dma-mapping.gi
t/sh
ortlog/refs/heads/for-next
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
[PATCH 1/2] nios2: use the generic uncached segment support in dma- direct
Hi Ley Foon,
I don't understand the above sentence. Does it imply a Reviewed-by?
Sorry, typo in my previous email.
Can't find this patch in the git link you provided (for-next branch). Did you push the patch?
No, I did not push the microblaze and nios2 patches there. The for-next patch just has the baseline, you'll need to apply the nios2 on top of that branch to test it. If it tests good and you are fine with it I'd like to apply it to that branch.