Return-Path: Received: from mx1.suse.de (ns.suse.de [195.135.220.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "mx1.suse.de", Issuer "CAcert Class 3 Root" (verified OK)) by ozlabs.org (Postfix) with ESMTPS id 26754DDEFC for ; Wed, 18 Jun 2008 20:40:42 +1000 (EST) Date: Wed, 18 Jun 2008 12:40:36 +0200 Message-ID: From: Takashi Iwai To: benh@kernel.crashing.org Subject: [PATCH 1/3] ppc: Add dma_mmap_coherent() for PPC32 References: MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=US-ASCII Cc: cjg@cruxppc.org, linuxppc-dev@ozlabs.org List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , A very lazy version of dma_mmap_coherent() implementation for ppc32. Signed-off-by: Takashi Iwai --- include/asm-powerpc/dma-mapping.h | 18 ++++++++++++++++++ 1 files changed, 18 insertions(+), 0 deletions(-) diff --git a/include/asm-powerpc/dma-mapping.h b/include/asm-powerpc/dma-mapping.h index bbefb69..a6a9675 100644 --- a/include/asm-powerpc/dma-mapping.h +++ b/include/asm-powerpc/dma-mapping.h @@ -306,6 +306,24 @@ static inline void dma_unmap_sg(struct device *dev, struct scatterlist *sg, /* We don't do anything here. */ } +/* + * A helper to mmap the pages allocated via dma_alloc_coherent() + */ +static inline 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; +#ifdef CONFIG_NOT_COHERENT_CACHE + /* I'm too lazy and can't stop using bus_to_virt() here... */ + cpu_addr = bus_to_virt(handle); +#endif + 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); +} #endif /* CONFIG_PPC64 */ static inline void dma_sync_single_for_cpu(struct device *dev, -- 1.5.4.5