Skip to content

Commit aae3955

Browse files
committed
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@
1 parent a88d149 commit aae3955

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

sys/arch/arm64/arm64/bus_dma.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: bus_dma.c,v 1.12 2020/03/03 10:33:50 kettenis Exp $ */
1+
/* $OpenBSD: bus_dma.c,v 1.13 2020/04/21 07:57:17 kettenis Exp $ */
22

33
/*
44
* 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,
449449
int flags)
450450
{
451451
return _dmamem_alloc_range(t, size, alignment, boundary,
452-
segs, nsegs, rsegs, flags, (paddr_t)0, (paddr_t)-1);
452+
segs, nsegs, rsegs, flags, dma_constraint.ucr_low,
453+
dma_constraint.ucr_high);
453454
}
454455

455456
/*

sys/arch/arm64/arm64/machdep.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: machdep.c,v 1.43 2019/08/26 09:10:22 kettenis Exp $ */
1+
/* $OpenBSD: machdep.c,v 1.44 2020/04/21 07:57:17 kettenis Exp $ */
22
/*
33
* Copyright (c) 2014 Patrick Wildt <patrick@blueri.se>
44
*
@@ -83,7 +83,10 @@ paddr_t msgbufphys;
8383
struct user *proc0paddr;
8484

8585
struct uvm_constraint_range dma_constraint = { 0x0, (paddr_t)-1 };
86-
struct uvm_constraint_range *uvm_md_constraints[] = { NULL };
86+
struct uvm_constraint_range *uvm_md_constraints[] = {
87+
&dma_constraint,
88+
NULL,
89+
};
8790

8891
/* the following is used externally (sysctl_hw) */
8992
char machine[] = MACHINE; /* from <machine/param.h> */
@@ -874,6 +877,12 @@ initarm(struct arm64_bootparams *abp)
874877
len = fdt_node_property(node, "openbsd,uefi-system-table", &prop);
875878
if (len == sizeof(system_table))
876879
system_table = bemtoh64((uint64_t *)prop);
880+
881+
len = fdt_node_property(node, "openbsd,dma-constraint", &prop);
882+
if (len == sizeof(dma_constraint)) {
883+
dma_constraint.ucr_low = bemtoh64((uint64_t *)prop);
884+
dma_constraint.ucr_high = bemtoh64((uint64_t *)prop + 1);
885+
}
877886
}
878887

879888
/* Set the pcpu data, this is needed by pmap_bootstrap */

0 commit comments

Comments
 (0)