diff options
author | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-04-21 07:57:18 +0000 |
---|---|---|
committer | Mark Kettenis <kettenis@cvs.openbsd.org> | 2020-04-21 07:57:18 +0000 |
commit | 59a9cc94ad93deb1dc3bdc72cdf162c951ea0712 (patch) | |
tree | 182c58abab4c5148ebb8522a27234a04235779ec | |
parent | 64d433281041bd75332e646b75dc027b3b16ad83 (diff) |
Set DMA constraint based on the openbsd,dma-constraint property if
present. Make sure bus_dmamap_alloc(9) allocates memory that meets that
constraint.
ok patrick@
-rw-r--r-- | sys/arch/arm64/arm64/bus_dma.c | 5 | ||||
-rw-r--r-- | sys/arch/arm64/arm64/machdep.c | 13 |
2 files changed, 14 insertions, 4 deletions
diff --git a/sys/arch/arm64/arm64/bus_dma.c b/sys/arch/arm64/arm64/bus_dma.c index 744abfefac9..6336497e750 100644 --- a/sys/arch/arm64/arm64/bus_dma.c +++ b/sys/arch/arm64/arm64/bus_dma.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bus_dma.c,v 1.12 2020/03/03 10:33:50 kettenis Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.13 2020/04/21 07:57:17 kettenis Exp $ */ /* * Copyright (c) 2003-2004 Opsycon AB (www.opsycon.se / www.opsycon.com) @@ -449,7 +449,8 @@ _dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, int flags) { return _dmamem_alloc_range(t, size, alignment, boundary, - segs, nsegs, rsegs, flags, (paddr_t)0, (paddr_t)-1); + segs, nsegs, rsegs, flags, dma_constraint.ucr_low, + dma_constraint.ucr_high); } /* diff --git a/sys/arch/arm64/arm64/machdep.c b/sys/arch/arm64/arm64/machdep.c index e149a0d9668..a4ddaca8f46 100644 --- a/sys/arch/arm64/arm64/machdep.c +++ b/sys/arch/arm64/arm64/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.43 2019/08/26 09:10:22 kettenis Exp $ */ +/* $OpenBSD: machdep.c,v 1.44 2020/04/21 07:57:17 kettenis Exp $ */ /* * Copyright (c) 2014 Patrick Wildt <patrick@blueri.se> * @@ -83,7 +83,10 @@ paddr_t msgbufphys; struct user *proc0paddr; struct uvm_constraint_range dma_constraint = { 0x0, (paddr_t)-1 }; -struct uvm_constraint_range *uvm_md_constraints[] = { NULL }; +struct uvm_constraint_range *uvm_md_constraints[] = { + &dma_constraint, + NULL, +}; /* the following is used externally (sysctl_hw) */ char machine[] = MACHINE; /* from <machine/param.h> */ @@ -874,6 +877,12 @@ initarm(struct arm64_bootparams *abp) len = fdt_node_property(node, "openbsd,uefi-system-table", &prop); if (len == sizeof(system_table)) system_table = bemtoh64((uint64_t *)prop); + + len = fdt_node_property(node, "openbsd,dma-constraint", &prop); + if (len == sizeof(dma_constraint)) { + dma_constraint.ucr_low = bemtoh64((uint64_t *)prop); + dma_constraint.ucr_high = bemtoh64((uint64_t *)prop + 1); + } } /* Set the pcpu data, this is needed by pmap_bootstrap */ |