From: Takashi Iwai Subject: [PATCH 4/8] sh: implement dma_mmap_coherent() Date: Fri, 10 Jul 2009 15:14:21 +0200 Message-ID: References: Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Return-path: Received: from cantor2.suse.de ([195.135.220.15]:43035 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750809AbZGJNOW (ORCPT ); Fri, 10 Jul 2009 09:14:22 -0400 Sender: linux-arch-owner@vger.kernel.org List-ID: To: linux-arch@vger.kernel.org Cc: Gerhard Pircher A lazy version of dma_mmap_coherent() implementation for SH architecture. Signed-off-by: Takashi Iwai --- arch/sh/include/asm/dma-mapping.h | 4 ++++ arch/sh/mm/consistent.c | 13 +++++++++++++ 2 files changed, 17 insertions(+), 0 deletions(-) diff --git a/arch/sh/include/asm/dma-mapping.h b/arch/sh/include/asm/dma-mapping.h index 69d56dd..120fe1a 100644 --- a/arch/sh/include/asm/dma-mapping.h +++ b/arch/sh/include/asm/dma-mapping.h @@ -28,6 +28,10 @@ void *dma_alloc_coherent(struct device *dev, size_t size, void dma_free_coherent(struct device *dev, size_t size, void *vaddr, dma_addr_t dma_handle); +#define ARCH_HAS_DMA_MMAP_COHERENT +int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma, + void *cpu_addr, dma_addr_t handle, size_t size); + void dma_cache_sync(struct device *dev, void *vaddr, size_t size, enum dma_data_direction dir); diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c index e098ec1..f45aaff 100644 --- a/arch/sh/mm/consistent.c +++ b/arch/sh/mm/consistent.c @@ -107,6 +107,19 @@ void dma_cache_sync(struct device *dev, void *vaddr, size_t size, } EXPORT_SYMBOL(dma_cache_sync); +int dma_mmap_coherent(struct device *dev, struct vm_area_struct *vma, + void *cpu_addr, dma_addr_t handle, size_t size) +{ + struct page *pg; + vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + cpu_addr = (void *)phys_to_virt(handle); + pg = virt_to_page(cpu_addr); + return remap_pfn_range(vma, vma->vm_start, + page_to_pfn(pg) + vma->vm_pgoff, + size, vma->vm_page_prot); +} +EXPORT_SYMBOL(dma_mmap_coherent); + static int __init memchunk_setup(char *str) { return 1; /* accept anything that begins with "memchunk." */ -- 1.6.3.2