From owner-svn-src-all@FreeBSD.ORG Tue Jul 29 02:31:30 2014 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2E503E98; Tue, 29 Jul 2014 02:31:30 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 1BFD025F1; Tue, 29 Jul 2014 02:31:30 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id s6T2VTJU071605; Tue, 29 Jul 2014 02:31:29 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id s6T2VTSp071604; Tue, 29 Jul 2014 02:31:29 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201407290231.s6T2VTSp071604@svn.freebsd.org> From: Ian Lepore Date: Tue, 29 Jul 2014 02:31:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r269206 - head/sys/arm/arm X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Jul 2014 02:31:30 -0000 Author: ian Date: Tue Jul 29 02:31:29 2014 New Revision: 269206 URL: http://svnweb.freebsd.org/changeset/base/269206 Log: Rename _bus_dma_can_bounce(), add new inline routines. DMA on arm can bounce for several reasons, and _bus_dma_can_bounce() only checks for the lowaddr/highaddr exclusion ranges in the dma tag, so now it's named exclusion_bounce(). The other reasons for bouncing are checked by the new functions alignment_bounce() and cacheline_bounce(). Reviewed by: cognet Modified: head/sys/arm/arm/busdma_machdep-v6.c Modified: head/sys/arm/arm/busdma_machdep-v6.c ============================================================================== --- head/sys/arm/arm/busdma_machdep-v6.c Tue Jul 29 01:46:31 2014 (r269205) +++ head/sys/arm/arm/busdma_machdep-v6.c Tue Jul 29 02:31:29 2014 (r269206) @@ -241,8 +241,8 @@ SYSINIT(busdma, SI_SUB_KMEM, SI_ORDER_FO * possibly have RAM at an address higher than the highest address we can * express, so we take a fast out. */ -static __inline int -_bus_dma_can_bounce(vm_offset_t lowaddr, vm_offset_t highaddr) +static int +exclusion_bounce(vm_offset_t lowaddr, vm_offset_t highaddr) { int i; @@ -258,6 +258,26 @@ _bus_dma_can_bounce(vm_offset_t lowaddr, return (0); } +/* + * Return true if the given address does not fall on the alignment boundary. + */ +static __inline int +alignment_bounce(bus_dma_tag_t dmat, bus_addr_t addr) +{ + + return (addr & (dmat->alignment - 1)); +} + +/* + * Return true if the buffer start or end does not fall on a cacheline boundary. + */ +static __inline int +cacheline_bounce(bus_addr_t addr, bus_size_t size) +{ + + return ((addr | size) & arm_dcache_align_mask); +} + static __inline struct arm32_dma_range * _bus_dma_inrange(struct arm32_dma_range *ranges, int nranges, bus_addr_t curaddr) @@ -291,9 +311,8 @@ run_filter(bus_dma_tag_t dmat, bus_addr_ do { if (((paddr > dmat->lowaddr && paddr <= dmat->highaddr) - || ((paddr & (dmat->alignment - 1)) != 0) || - (!coherent && (size & arm_dcache_align_mask)) || - (!coherent && (paddr & arm_dcache_align_mask))) + || alignment_bounce(dmat, paddr) || + (!coherent && cacheline_bounce(paddr, size))) && (dmat->filter == NULL || (*dmat->filter)(dmat->filterarg, paddr) != 0)) retval = 1; @@ -438,8 +457,8 @@ bus_dma_tag_create(bus_dma_tag_t parent, atomic_add_int(&parent->ref_count, 1); } - if (_bus_dma_can_bounce(newtag->lowaddr, newtag->highaddr) - || newtag->alignment > 1) + if (exclusion_bounce(newtag->lowaddr, newtag->highaddr) + || alignment_bounce(newtag, 1)) newtag->flags |= BUS_DMA_COULD_BOUNCE; /* @@ -718,7 +737,7 @@ bus_dmamem_alloc(bus_dma_tag_t dmat, voi * constraints is something that only the contig allocator can fulfill. */ if (bufzone != NULL && dmat->alignment <= bufzone->size && - !_bus_dma_can_bounce(dmat->lowaddr, dmat->highaddr)) { + !exclusion_bounce(dmat->lowaddr, dmat->highaddr)) { *vaddr = uma_zalloc(bufzone->umazone, mflags); } else if (dmat->nsegments >= btoc(dmat->maxsize) && dmat->alignment <= PAGE_SIZE && dmat->boundary == 0) { @@ -765,7 +784,7 @@ bus_dmamem_free(bus_dma_tag_t dmat, void bufzone = busdma_bufalloc_findzone(ba, dmat->maxsize); if (bufzone != NULL && dmat->alignment <= bufzone->size && - !_bus_dma_can_bounce(dmat->lowaddr, dmat->highaddr)) + !exclusion_bounce(dmat->lowaddr, dmat->highaddr)) uma_zfree(bufzone->umazone, vaddr); else kmem_free(kernel_arena, (vm_offset_t)vaddr, dmat->maxsize);