From owner-svn-src-all@FreeBSD.ORG Sun Feb 8 22:54:59 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6624D1065674; Sun, 8 Feb 2009 22:54:59 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 53A588FC1A; Sun, 8 Feb 2009 22:54:59 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n18MsxXN037313; Sun, 8 Feb 2009 22:54:59 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n18MsxVt037307; Sun, 8 Feb 2009 22:54:59 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <200902082254.n18MsxVt037307@svn.freebsd.org> From: Warner Losh Date: Sun, 8 Feb 2009 22:54:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Sun, 08 Feb 2009 22:55:00 -0000 Author: imp Date: Sun Feb 8 22:54:58 2009 New Revision: 188350 URL: http://svn.freebsd.org/changeset/base/188350 Log: When bouncing pages, allow a new option to preserve the intra-page offset. This is needed for the ehci hardware buffer rings that assume this behavior. This is an interim solution, and a more general one is being worked on. This solution doesn't break anything that doesn't ask for it directly. The mbuf and uio variants with this flag likely don't work and haven't been tested. Universe builds with these changes. I don't have a huge-memory machine to test these changes with, but will be happy to work with folks that do and hps if this changes turns out not to be sufficient. Submitted by: alfred@ from Hans Peter Selasky's original Modified: head/sys/amd64/amd64/busdma_machdep.c head/sys/arm/arm/busdma_machdep.c head/sys/dev/usb2/core/usb2_busdma.c head/sys/i386/i386/busdma_machdep.c head/sys/ia64/ia64/busdma_machdep.c head/sys/sys/bus_dma.h Modified: head/sys/amd64/amd64/busdma_machdep.c ============================================================================== --- head/sys/amd64/amd64/busdma_machdep.c Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/amd64/amd64/busdma_machdep.c Sun Feb 8 22:54:58 2009 (r188350) @@ -1128,6 +1128,13 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ bz->active_bpages++; mtx_unlock(&bounce_lock); + if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) { + /* page offset needs to be preserved */ + bpage->vaddr &= ~PAGE_MASK; + bpage->busaddr &= ~PAGE_MASK; + bpage->vaddr |= vaddr & PAGE_MASK; + bpage->busaddr |= vaddr & PAGE_MASK; + } bpage->datavaddr = vaddr; bpage->datacount = size; STAILQ_INSERT_TAIL(&(map->bpages), bpage, links); Modified: head/sys/arm/arm/busdma_machdep.c ============================================================================== --- head/sys/arm/arm/busdma_machdep.c Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/arm/arm/busdma_machdep.c Sun Feb 8 22:54:58 2009 (r188350) @@ -1417,6 +1417,13 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ bz->active_bpages++; mtx_unlock(&bounce_lock); + if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) { + /* page offset needs to be preserved */ + bpage->vaddr &= ~PAGE_MASK; + bpage->busaddr &= ~PAGE_MASK; + bpage->vaddr |= vaddr & PAGE_MASK; + bpage->busaddr |= vaddr & PAGE_MASK; + } bpage->datavaddr = vaddr; bpage->datacount = size; STAILQ_INSERT_TAIL(&(map->bpages), bpage, links); Modified: head/sys/dev/usb2/core/usb2_busdma.c ============================================================================== --- head/sys/dev/usb2/core/usb2_busdma.c Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/dev/usb2/core/usb2_busdma.c Sun Feb 8 22:54:58 2009 (r188350) @@ -351,7 +351,7 @@ usb2_dma_tag_create(struct usb2_dma_tag (2 + (size / USB_PAGE_SIZE)) : 1, /* maxsegsz */ (align == 1) ? USB_PAGE_SIZE : size, - /* flags */ 0, + /* flags */ BUS_DMA_KEEP_PG_OFFSET, /* lockfn */ &usb2_dma_lock_cb, /* lockarg */ NULL, &tag)) { Modified: head/sys/i386/i386/busdma_machdep.c ============================================================================== --- head/sys/i386/i386/busdma_machdep.c Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/i386/i386/busdma_machdep.c Sun Feb 8 22:54:58 2009 (r188350) @@ -1146,6 +1146,13 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ bz->active_bpages++; mtx_unlock(&bounce_lock); + if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) { + /* page offset needs to be preserved */ + bpage->vaddr &= ~PAGE_MASK; + bpage->busaddr &= ~PAGE_MASK; + bpage->vaddr |= vaddr & PAGE_MASK; + bpage->busaddr |= vaddr & PAGE_MASK; + } bpage->datavaddr = vaddr; bpage->datacount = size; STAILQ_INSERT_TAIL(&(map->bpages), bpage, links); Modified: head/sys/ia64/ia64/busdma_machdep.c ============================================================================== --- head/sys/ia64/ia64/busdma_machdep.c Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/ia64/ia64/busdma_machdep.c Sun Feb 8 22:54:58 2009 (r188350) @@ -936,6 +936,13 @@ add_bounce_page(bus_dma_tag_t dmat, bus_ active_bpages++; mtx_unlock(&bounce_lock); + if (dmat->flags & BUS_DMA_KEEP_PG_OFFSET) { + /* page offset needs to be preserved */ + bpage->vaddr &= ~PAGE_MASK; + bpage->busaddr &= ~PAGE_MASK; + bpage->vaddr |= vaddr & PAGE_MASK; + bpage->busaddr |= vaddr & PAGE_MASK; + } bpage->datavaddr = vaddr; bpage->datacount = size; STAILQ_INSERT_TAIL(&(map->bpages), bpage, links); Modified: head/sys/sys/bus_dma.h ============================================================================== --- head/sys/sys/bus_dma.h Sun Feb 8 22:31:31 2009 (r188349) +++ head/sys/sys/bus_dma.h Sun Feb 8 22:54:58 2009 (r188350) @@ -102,6 +102,13 @@ #define BUS_DMA_NOWRITE 0x100 #define BUS_DMA_NOCACHE 0x200 +/* + * The following flag is a DMA tag hint that the page offset of the + * loaded kernel virtual address must be preserved in the first + * physical segment address, when the KVA is loaded into DMA. + */ +#define BUS_DMA_KEEP_PG_OFFSET 0x400 + /* Forwards needed by prototypes below. */ struct mbuf; struct uio;