From afee86301d6cf1e8e12a68fb0cde0e4cd9c4371f Mon Sep 17 00:00:00 2001 From: kettenis Date: Tue, 8 Oct 2024 19:40:00 +0000 Subject: [PATCH] Make bus_dmamem_alloc(9) recognize the BUS_DMA_64BIT flag and interpret it as a request for memory without any DMA restrictions, which means that the call is allowed to allocate memory above the 4GB boundary on amd64. ok mpi@, mlarkin@ --- sys/arch/amd64/amd64/bus_dma.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/sys/arch/amd64/amd64/bus_dma.c b/sys/arch/amd64/amd64/bus_dma.c index 56c750ec88e..465401fbb53 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.58 2024/08/28 18:21:15 bluhm Exp $ */ +/* $OpenBSD: bus_dma.c,v 1.59 2024/10/08 19:40:00 kettenis Exp $ */ /* $NetBSD: bus_dma.c,v 1.3 2003/05/07 21:33:58 fvdl Exp $ */ /*- @@ -537,15 +537,18 @@ _bus_dmamem_alloc(bus_dma_tag_t t, bus_size_t size, bus_size_t alignment, bus_size_t boundary, bus_dma_segment_t *segs, int nsegs, int *rsegs, int flags) { + paddr_t low, high; + + if (flags & BUS_DMA_64BIT) { + low = no_constraint.ucr_low; + high = no_constraint.ucr_high; + } else { + low = dma_constraint.ucr_low; + high = dma_constraint.ucr_high; + } - /* - * XXX in the presence of decent (working) iommus and bouncebuffers - * we can then fallback this allocation to a range of { 0, -1 }. - * However for now we err on the side of caution and allocate dma - * memory under the 4gig boundary. - */ - return (_bus_dmamem_alloc_range(t, size, alignment, boundary, - segs, nsegs, rsegs, flags, (bus_addr_t)0, (bus_addr_t)0xffffffff)); + return _bus_dmamem_alloc_range(t, size, alignment, boundary, + segs, nsegs, rsegs, flags, low, high); } /* -- 2.20.1