summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2015-01-09 14:23:26 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2015-01-09 14:23:26 +0000
commita97b8c76f989c83d99a14658e9dbcae596791aae (patch)
treebbb1eec2d19b61cd2f79233a8bbc95dc70dea879 /sys
parentab1aaf860e72550ba75b8cc805e81601ef51f662 (diff)
Fix loading memory allocated with bus_dmamem_alloc(9). The old could would
always load all allocated pages instead of the size specified in the bus_dmamap_load_raw(9) call. Also fixes the corner case where a specified boundary is less than the page size, which would always create multiple segments, even if the specified size was smaller than the boundary. Fixes xhci(4) on sparc64.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/sparc64/dev/iommu.c9
-rw-r--r--sys/arch/sparc64/dev/viommu.c9
2 files changed, 12 insertions, 6 deletions
diff --git a/sys/arch/sparc64/dev/iommu.c b/sys/arch/sparc64/dev/iommu.c
index da63933f805..13f48d22fbb 100644
--- a/sys/arch/sparc64/dev/iommu.c
+++ b/sys/arch/sparc64/dev/iommu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: iommu.c,v 1.71 2014/11/16 12:30:59 deraadt Exp $ */
+/* $OpenBSD: iommu.c,v 1.72 2015/01/09 14:23:25 kettenis Exp $ */
/* $NetBSD: iommu.c,v 1.47 2002/02/08 20:03:45 eeh Exp $ */
/*
@@ -1252,8 +1252,8 @@ iommu_dvmamap_load_mlist(bus_dma_tag_t t, struct iommu_state *is,
for (m = TAILQ_FIRST(mlist); m != NULL; m = TAILQ_NEXT(m,pageq)) {
pa = VM_PAGE_TO_PHYS(m);
- err = iommu_dvmamap_append_range(t, map, pa, PAGE_SIZE,
- flags, boundary);
+ err = iommu_dvmamap_append_range(t, map, pa,
+ MIN(PAGE_SIZE, size), flags, boundary);
if (err == EFBIG)
return (err);
if (err) {
@@ -1262,6 +1262,9 @@ iommu_dvmamap_load_mlist(bus_dma_tag_t t, struct iommu_state *is,
pa + PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
return (err);
}
+ if (size < PAGE_SIZE)
+ break;
+ size -= PAGE_SIZE;
}
return (0);
diff --git a/sys/arch/sparc64/dev/viommu.c b/sys/arch/sparc64/dev/viommu.c
index d9c31d85e7b..2b95a707488 100644
--- a/sys/arch/sparc64/dev/viommu.c
+++ b/sys/arch/sparc64/dev/viommu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: viommu.c,v 1.15 2014/05/10 12:20:38 kettenis Exp $ */
+/* $OpenBSD: viommu.c,v 1.16 2015/01/09 14:23:25 kettenis Exp $ */
/* $NetBSD: iommu.c,v 1.47 2002/02/08 20:03:45 eeh Exp $ */
/*
@@ -784,8 +784,8 @@ viommu_dvmamap_load_mlist(bus_dma_tag_t t, struct iommu_state *is,
for (m = TAILQ_FIRST(mlist); m != NULL; m = TAILQ_NEXT(m,pageq)) {
pa = VM_PAGE_TO_PHYS(m);
- err = viommu_dvmamap_append_range(t, map, pa, PAGE_SIZE,
- flags, boundary);
+ err = viommu_dvmamap_append_range(t, map, pa,
+ MIN(PAGE_SIZE, size), flags, boundary);
if (err == EFBIG)
return (err);
if (err) {
@@ -794,6 +794,9 @@ viommu_dvmamap_load_mlist(bus_dma_tag_t t, struct iommu_state *is,
pa + PAGE_SIZE, PAGE_SIZE, PAGE_SIZE);
return (err);
}
+ if (size < PAGE_SIZE)
+ break;
+ size -= PAGE_SIZE;
}
return (0);