From: Mark Kettenis Subject: Re: bge 64 bit dma To: Alexander Bluhm Cc: tech@openbsd.org Date: Sat, 28 Feb 2026 00:33:55 +0100 > Date: Fri, 27 Feb 2026 23:47:57 +0100 > From: Alexander Bluhm > > Hi, > > Brad sent me this diff. I have tested it on > > bge0 at pci12 dev 0 function 0 "Broadcom BCM5720" rev 0x00, BCM5720 A0 (0x5720000): msi, address 04:32:01:f1:4e:7c > > and Hrvoje here > > bge1 at pci14 dev 0 function 1 "Broadcom BCM5720" rev 0x00, BCM5720 A0 (0x5720000), APE firmware NCSI 1.5.61.0: msi, address d0:94:66:5b:66:0e > > Is that enough test coverage to enable 64 bit dma for bge(4)? According to the Linux tg3 driver, some variants only do 32-bit DMA or have an integrated PCI-PCI bridge that can only do 40-bit DMA. It is not clear to me how those map onto PCIe vs non-PCIe. > Index: dev/pci/if_bge.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_bge.c,v > diff -u -p -r1.408 if_bge.c > --- dev/pci/if_bge.c 15 Jul 2025 13:40:02 -0000 1.408 > +++ dev/pci/if_bge.c 27 Feb 2026 22:37:33 -0000 > @@ -1285,7 +1285,8 @@ bge_init_rx_ring_std(struct bge_softc *s > > for (i = 0; i < BGE_STD_RX_RING_CNT; i++) { > if (bus_dmamap_create(sc->bge_dmatag, sc->bge_rx_std_len, 1, > - sc->bge_rx_std_len, 0, BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, > + sc->bge_rx_std_len, 0, > + BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW | sc->bge_dmaflags, > &sc->bge_cdata.bge_rx_std_map[i]) != 0) { > printf("%s: unable to create dmamap for slot %d\n", > sc->bge_dev.dv_xname, i); > @@ -1411,7 +1412,7 @@ bge_init_rx_ring_jumbo(struct bge_softc > > for (i = 0; i < BGE_JUMBO_RX_RING_CNT; i++) { > if (bus_dmamap_create(sc->bge_dmatag, BGE_JLEN, 4, BGE_JLEN, 0, > - BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW, > + BUS_DMA_NOWAIT | BUS_DMA_ALLOCNOW | sc->bge_dmaflags, > &sc->bge_cdata.bge_rx_jumbo_map[i]) != 0) { > printf("%s: unable to create dmamap for slot %d\n", > sc->bge_dev.dv_xname, i); > @@ -1560,7 +1561,8 @@ bge_init_tx_ring(struct bge_softc *sc) > > for (i = 0; i < BGE_TX_RING_CNT; i++) { > if (bus_dmamap_create(sc->bge_dmatag, txmaxsegsz, > - BGE_NTXSEG, txsegsz, 0, BUS_DMA_NOWAIT, &sc->bge_txdma[i])) > + BGE_NTXSEG, txsegsz, 0, BUS_DMA_NOWAIT | sc->bge_dmaflags, > + &sc->bge_txdma[i])) > return (ENOBUFS); > } > > @@ -2906,6 +2908,8 @@ bge_attach(struct device *parent, struct > BGE_ASICREV(sc->bge_chipid) == BGE_ASICREV_BCM57780) > sc->bge_flags |= BGE_CPMU_PRESENT; > > + sc->bge_dmaflags = (sc->bge_flags & BGE_PCIE) ? BUS_DMA_64BIT : 0; > + > if (pci_get_capability(pa->pa_pc, pa->pa_tag, PCI_CAP_MSI, > &sc->bge_msicap, NULL)) { > if (bge_can_use_msi(sc) == 0) > @@ -3000,7 +3004,7 @@ bge_attach(struct device *parent, struct > DPRINTFN(5, ("bus_dmamem_alloc\n")); > if (bus_dmamem_alloc(sc->bge_dmatag, sizeof(struct bge_ring_data), > PAGE_SIZE, 0, &sc->bge_ring_seg, 1, &sc->bge_ring_nseg, > - BUS_DMA_NOWAIT)) { > + BUS_DMA_NOWAIT | sc->bge_dmaflags)) { > printf(": can't alloc rx buffers\n"); > goto fail_2; > } > @@ -3015,7 +3019,7 @@ bge_attach(struct device *parent, struct > DPRINTFN(5, ("bus_dmamap_create\n")); > if (bus_dmamap_create(sc->bge_dmatag, sizeof(struct bge_ring_data), 1, > sizeof(struct bge_ring_data), 0, > - BUS_DMA_NOWAIT, &sc->bge_ring_map)) { > + BUS_DMA_NOWAIT | sc->bge_dmaflags, &sc->bge_ring_map)) { > printf(": can't create dma map\n"); > goto fail_4; > } > Index: dev/pci/if_bgereg.h > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/dev/pci/if_bgereg.h,v > diff -u -p -r1.136 if_bgereg.h > --- dev/pci/if_bgereg.h 4 Jul 2023 10:22:39 -0000 1.136 > +++ dev/pci/if_bgereg.h 27 Feb 2026 22:37:33 -0000 > @@ -2942,6 +2942,7 @@ struct bge_softc { > u_int32_t bge_rx_overruns; > u_int32_t bge_tx_collisions; > bus_dmamap_t bge_txdma[BGE_TX_RING_CNT]; > + int bge_dmaflags; > > struct mutex bge_kstat_mtx; > struct kstat *bge_kstat; > >