From owner-svn-src-all@freebsd.org Fri Aug 9 10:28:21 2019 Return-Path: Delivered-To: svn-src-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 66A35C4CBE; Fri, 9 Aug 2019 10:28:21 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 464hKK25QFz4MKJ; Fri, 9 Aug 2019 10:28:21 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 29746C4FC; Fri, 9 Aug 2019 10:28:21 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x79ASLh4081617; Fri, 9 Aug 2019 10:28:21 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x79ASLAV081616; Fri, 9 Aug 2019 10:28:21 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201908091028.x79ASLAV081616@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Fri, 9 Aug 2019 10:28:21 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r350819 - stable/12/sys/arm/arm X-SVN-Group: stable-12 X-SVN-Commit-Author: mmel X-SVN-Commit-Paths: stable/12/sys/arm/arm X-SVN-Commit-Revision: 350819 X-SVN-Commit-Repository: base 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.29 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: Fri, 09 Aug 2019 10:28:21 -0000 Author: mmel Date: Fri Aug 9 10:28:20 2019 New Revision: 350819 URL: https://svnweb.freebsd.org/changeset/base/350819 Log: MFC r343962,r343965: r343962: Properly handle alignment requests bigger that page size. - for now, alignments bigger that page size is allowed only for buffers allocated by bus_dmamem_alloc(), cover this fact by KASSERT. - never bounce buffers allocated by bus_dmamem_alloc(), these always comply with the required rules (alignment, boundary, address range). r343965: Fix bug introduced by r343962. DMAMAP_DMAMEM_ALLOC is property of dmamap, not dmatag. Modified: stable/12/sys/arm/arm/busdma_machdep-v6.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/arm/arm/busdma_machdep-v6.c ============================================================================== --- stable/12/sys/arm/arm/busdma_machdep-v6.c Fri Aug 9 10:00:11 2019 (r350818) +++ stable/12/sys/arm/arm/busdma_machdep-v6.c Fri Aug 9 10:28:20 2019 (r350819) @@ -339,16 +339,27 @@ cacheline_bounce(bus_dmamap_t map, bus_addr_t addr, bu * * Note that the addr argument might be either virtual or physical. It doesn't * matter because we only look at the low-order bits, which are the same in both - * address spaces. + * address spaces and maximum alignment of generic buffer is limited up to page + * size. + * Bouncing of buffers allocated by bus_dmamem_alloc()is not necessary, these + * always comply with the required rules (alignment, boundary, and address + * range). */ static __inline int might_bounce(bus_dma_tag_t dmat, bus_dmamap_t map, bus_addr_t addr, bus_size_t size) { - return ((dmat->flags & BUS_DMA_EXCL_BOUNCE) || + KASSERT(map->flags & DMAMAP_DMAMEM_ALLOC || + dmat->alignment <= PAGE_SIZE, + ("%s: unsupported alignment (0x%08lx) for buffer not " + "allocated by bus_dmamem_alloc()", + __func__, dmat->alignment)); + + return (!(map->flags & DMAMAP_DMAMEM_ALLOC) && + ((dmat->flags & BUS_DMA_EXCL_BOUNCE) || alignment_bounce(dmat, addr) || - cacheline_bounce(map, addr, size)); + cacheline_bounce(map, addr, size))); } /*