Index | Thread | Search

From:
Jonathan Matthew <jonathan@d14n.org>
Subject:
use BUS_DMA_64BIT for mcx(4) dmamem allocations
To:
tech@openbsd.org
Date:
Fri, 29 Nov 2024 14:04:09 +1000

Download raw body.

Thread
  • Jonathan Matthew:

    use BUS_DMA_64BIT for mcx(4) dmamem allocations

mcx(4) makes sizeable dmamem allocations for the nic to use (around 29MB per
port on the machine I'm looking at), so allowing use of memory past 4GB on
amd64 seems worthwhile.  The rings and other memory areas allocated with
mcx_dmamem_alloc() are much smaller, but they can also use memory past
4GB without issue in my limited testing.

ok?

Index: if_mcx.c
===================================================================
RCS file: /cvs/src/sys/dev/pci/if_mcx.c,v
diff -u -p -u -p -r1.117 if_mcx.c
--- if_mcx.c	23 Oct 2024 01:47:47 -0000	1.117
+++ if_mcx.c	29 Nov 2024 03:30:21 -0000
@@ -8278,7 +8278,7 @@ mcx_dmamem_alloc(struct mcx_softc *sc, s
 		return (1);
 	if (bus_dmamem_alloc(sc->sc_dmat, mxm->mxm_size,
 	    align, 0, &mxm->mxm_seg, 1, &mxm->mxm_nsegs,
-	    BUS_DMA_WAITOK | BUS_DMA_ZERO) != 0)
+	    BUS_DMA_WAITOK | BUS_DMA_ZERO | BUS_DMA_64BIT) != 0)
 		goto destroy;
 	if (bus_dmamem_map(sc->sc_dmat, &mxm->mxm_seg, mxm->mxm_nsegs,
 	    mxm->mxm_size, &mxm->mxm_kva, BUS_DMA_WAITOK) != 0)
@@ -8326,7 +8326,8 @@ mcx_hwmem_alloc(struct mcx_softc *sc, st
 	seglen = sizeof(*segs) * pages;
 
 	if (bus_dmamem_alloc(sc->sc_dmat, len, MCX_PAGE_SIZE, 0,
-	    segs, pages, &mhm->mhm_seg_count, BUS_DMA_NOWAIT) != 0)
+	    segs, pages, &mhm->mhm_seg_count,
+            BUS_DMA_NOWAIT|BUS_DMA_64BIT) != 0)
 		goto free_segs;
 
 	if (mhm->mhm_seg_count < pages) {
@@ -8349,7 +8350,7 @@ mcx_hwmem_alloc(struct mcx_softc *sc, st
 		mhm->mhm_segs = segs;
 
 	if (bus_dmamap_create(sc->sc_dmat, len, pages, MCX_PAGE_SIZE,
-	    MCX_PAGE_SIZE, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW /*|BUS_DMA_64BIT*/,
+	    MCX_PAGE_SIZE, BUS_DMA_NOWAIT|BUS_DMA_ALLOCNOW|BUS_DMA_64BIT,
 	    &mhm->mhm_map) != 0)
 		goto free_dmamem;