svn commit: r188350 - in head/sys: amd64/amd64 arm/arm dev/usb2/core i386/i386 ia64/ia64 sys

Warner Losh imp at FreeBSD.org
Sun Feb 8 14:55:00 PST 2009


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;


More information about the svn-src-all mailing list