PERFORCE change 155927 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Sat Jan 10 10:35:53 PST 2009
http://perforce.freebsd.org/chv.cgi?CH=155927
Change 155927 by hselasky at hselasky_laptop001 on 2009/01/10 18:35:24
Like Marcel Moolenaar has pointed out, we can unconditionally
preserve the page offset, hence on platforms without DMA
bouncing this is always the case.
Repeating the background for this:
/*
* Background: Some kinds of DMA hardware only store the full
* physical address of the first memory page when multiple memory
* pages are loaded into DMA. For consecutive memory pages, only the
* non-offset part of the physical address is updated. The hardware
* computes the amount of data that should be stored in the first
* memory page from the minimum of the total transfer length and
* PAGE_SIZE, minus the initial page offset. When the initial page
* offset is not preserved, the hardware ends up transferring an
* invalid number of bytes to or from the initial memory page.
*/
Affected files ...
.. //depot/projects/usb/src/sys/amd64/amd64/busdma_machdep.c#10 edit
.. //depot/projects/usb/src/sys/arm/arm/busdma_machdep.c#12 edit
.. //depot/projects/usb/src/sys/i386/i386/busdma_machdep.c#13 edit
.. //depot/projects/usb/src/sys/ia64/ia64/busdma_machdep.c#9 edit
.. //depot/projects/usb/src/sys/sys/bus_dma.h#7 edit
Differences ...
==== //depot/projects/usb/src/sys/amd64/amd64/busdma_machdep.c#10 (text+ko) ====
@@ -1128,17 +1128,11 @@
bz->active_bpages++;
mtx_unlock(&bounce_lock);
- /* reset page offset */
+ /* page offset needs to be preserved */
bpage->vaddr &= ~PAGE_MASK;
bpage->busaddr &= ~PAGE_MASK;
-
- if (BUS_DMA_NO_REALIGN(dmat->alignment, dmat->boundary,
- dmat->maxsegsz)) {
- /* preserve page offset */
- bpage->vaddr |= vaddr & PAGE_MASK;
- bpage->busaddr |= vaddr & 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);
==== //depot/projects/usb/src/sys/arm/arm/busdma_machdep.c#12 (text+ko) ====
@@ -1415,17 +1415,11 @@
bz->active_bpages++;
mtx_unlock(&bounce_lock);
- /* reset page offset */
+ /* page offset needs to be preserved */
bpage->vaddr &= ~PAGE_MASK;
bpage->busaddr &= ~PAGE_MASK;
-
- if (BUS_DMA_NO_REALIGN(dmat->alignment, dmat->boundary,
- dmat->maxsegsz)) {
- /* preserve page offset */
- bpage->vaddr |= vaddr & PAGE_MASK;
- bpage->busaddr |= vaddr & 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);
==== //depot/projects/usb/src/sys/i386/i386/busdma_machdep.c#13 (text+ko) ====
@@ -1146,17 +1146,11 @@
bz->active_bpages++;
mtx_unlock(&bounce_lock);
- /* reset page offset */
+ /* page offset needs to be preserved */
bpage->vaddr &= ~PAGE_MASK;
bpage->busaddr &= ~PAGE_MASK;
-
- if (BUS_DMA_NO_REALIGN(dmat->alignment, dmat->boundary,
- dmat->maxsegsz)) {
- /* preserve page offset */
- bpage->vaddr |= vaddr & PAGE_MASK;
- bpage->busaddr |= vaddr & 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);
==== //depot/projects/usb/src/sys/ia64/ia64/busdma_machdep.c#9 (text+ko) ====
@@ -936,16 +936,11 @@
active_bpages++;
mtx_unlock(&bounce_lock);
- /* reset page offset */
+ /* page offset needs to be preserved */
bpage->vaddr &= ~PAGE_MASK;
bpage->busaddr &= ~PAGE_MASK;
-
- if (BUS_DMA_NO_REALIGN(dmat->alignment, dmat->boundary,
- dmat->maxsegsz)) {
- /* preserve page offset */
- bpage->vaddr |= vaddr & PAGE_MASK;
- bpage->busaddr |= vaddr & PAGE_MASK;
- }
+ bpage->vaddr |= vaddr & PAGE_MASK;
+ bpage->busaddr |= vaddr & PAGE_MASK;
bpage->datavaddr = vaddr;
bpage->datacount = size;
==== //depot/projects/usb/src/sys/sys/bus_dma.h#7 (text+ko) ====
@@ -102,24 +102,6 @@
#define BUS_DMA_NOWRITE 0x100
#define BUS_DMA_NOCACHE 0x200
-/*
- * The following flag specifies that no re-alignment of individual
- * memory pages is allowed when loaded into DMA. It can only be used
- * when "maxsegsz" is equal to "PAGE_SIZE" and "alignment" is less
- * than or equal to 1.
- *
- * Background: Some kinds of DMA hardware only stores the full
- * physical address of the first memory page when multiple memory
- * pages are loaded into DMA. Consequtive memory pages only gets the
- * non-offset part of the physical address updated. The hardware
- * computes the amount of data that should be stored in the first
- * memory page from the minimum of the total transfer length and
- * PAGE_SIZE minus the initial page offset. When the initial page
- * offset is not preserved the hardware ends up transferring an
- * invalid number of bytes to or from the initial memory page.
- */
-#define BUS_DMA_NOREAL 0x400 /* no page re-alignment allowed */
-
/* Forwards needed by prototypes below. */
struct mbuf;
struct uio;
@@ -133,23 +115,6 @@
#define BUS_DMASYNC_POSTWRITE 8
/*
- * Background: Some kinds of DMA hardware only store the full
- * physical address of the first memory page when multiple memory
- * pages are loaded into DMA. For consecutive memory pages, only the
- * non-offset part of the physical address is updated. The hardware
- * computes the amount of data that should be stored in the first
- * memory page from the minimum of the total transfer length and
- * PAGE_SIZE, minus the initial page offset. When the initial page
- * offset is not preserved, the hardware ends up transferring an
- * invalid number of bytes to or from the initial memory page.
- *
- * The following macro returns true when the initial page offset must
- * be preserved:
- */
-#define BUS_DMA_NO_REALIGN(align,boundary,maxsegsz) \
- (((align) == 1) && ((boundary) == PAGE_SIZE) && ((maxsegsz) == PAGE_SIZE))
-
-/*
* bus_dma_segment_t
*
* Describes a single contiguous DMA transaction. Values
More information about the p4-projects
mailing list