summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorDavid Gwynne <dlg@cvs.openbsd.org>2009-04-09 03:08:37 +0000
committerDavid Gwynne <dlg@cvs.openbsd.org>2009-04-09 03:08:37 +0000
commit6ed681497d2b8b62db93df36541e57c6cac57336 (patch)
treed6ae7e52bbf11b967cf07c1592bd6c621539b0f8 /sys
parenta8535b957bcf4e4327c83c754da8337aca72bea3 (diff)
in bus_dmamap_load_raw, only map the requested number of bytes into the
dmamap rather than all the bytes that are described by the sg list we're mapping. tested on iwn by me and beck@
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/amd64/amd64/bus_dma.c10
-rw-r--r--sys/arch/i386/i386/bus_dma.c10
2 files changed, 12 insertions, 8 deletions
diff --git a/sys/arch/amd64/amd64/bus_dma.c b/sys/arch/amd64/amd64/bus_dma.c
index 56c2ad868e0..8b24447cc64 100644
--- a/sys/arch/amd64/amd64/bus_dma.c
+++ b/sys/arch/amd64/amd64/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.20 2009/04/09 03:06:35 dlg Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.21 2009/04/09 03:08:36 dlg Exp $ */
/* $NetBSD: bus_dma.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */
/*-
@@ -318,9 +318,9 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs,
bmask = ~(map->_dm_boundary - 1);
- for (i = 0; i < nsegs; i++) {
+ for (i = 0; i < nsegs && size > 0; i++) {
paddr = segs[i].ds_addr;
- plen = segs[i].ds_len;
+ plen = MIN(segs[i].ds_len, size);
while (plen > 0) {
/*
@@ -363,9 +363,11 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs,
}
}
- lastaddr = paddr + sgsize;
paddr += sgsize;
plen -= sgsize;
+ size -= sgsize;
+
+ lastaddr = paddr;
}
}
diff --git a/sys/arch/i386/i386/bus_dma.c b/sys/arch/i386/i386/bus_dma.c
index 509f453bf82..7cbd3a8c9b5 100644
--- a/sys/arch/i386/i386/bus_dma.c
+++ b/sys/arch/i386/i386/bus_dma.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bus_dma.c,v 1.10 2009/04/09 03:06:35 dlg Exp $ */
+/* $OpenBSD: bus_dma.c,v 1.11 2009/04/09 03:08:36 dlg Exp $ */
/*-
* Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
* All rights reserved.
@@ -285,9 +285,9 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs,
bmask = ~(map->_dm_boundary - 1);
- for (i = 0; i < nsegs; i++) {
+ for (i = 0; i < nsegs && size > 0; i++) {
paddr = segs[i].ds_addr;
- plen = segs[i].ds_len;
+ plen = MIN(segs[i].ds_len, size);
while (plen > 0) {
/*
@@ -330,9 +330,11 @@ _bus_dmamap_load_raw(bus_dma_tag_t t, bus_dmamap_t map, bus_dma_segment_t *segs,
}
}
- lastaddr = paddr + sgsize;
paddr += sgsize;
plen -= sgsize;
+ size -= sgsize;
+
+ lastaddr = paddr;
}
}