Module Name: src
Committed By: thorpej
Date: Sat Feb 29 20:39:09 UTC 2020
Modified Files:
src/sys/dev/pci: if_stge.c
Log Message:
Use the 64-bit PCI DMA tag if it's available, but range-limit to
40-bit because that's what the hardware can do.
To generate a diff of this commit:
cvs rdiff -u -r1.79 -r1.80 src/sys/dev/pci/if_stge.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/pci/if_stge.c
diff -u src/sys/dev/pci/if_stge.c:1.79 src/sys/dev/pci/if_stge.c:1.80
--- src/sys/dev/pci/if_stge.c:1.79 Fri Feb 7 00:04:28 2020
+++ src/sys/dev/pci/if_stge.c Sat Feb 29 20:39:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: if_stge.c,v 1.79 2020/02/07 00:04:28 thorpej Exp $ */
+/* $NetBSD: if_stge.c,v 1.80 2020/02/29 20:39:09 thorpej Exp $ */
/*-
* Copyright (c) 2001 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.79 2020/02/07 00:04:28 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_stge.c,v 1.80 2020/02/29 20:39:09 thorpej Exp $");
#include <sys/param.h>
@@ -442,7 +442,24 @@ stge_attach(device_t parent, device_t se
return;
}
- sc->sc_dmat = pa->pa_dmat;
+ /*
+ * We have a 40-bit limit on our DMA addresses. This isn't an
+ * issue if we're only using a 32-bit DMA tag, but we have to
+ * account for it if the 64-bit DMA tag is available.
+ */
+ if (pci_dma64_available(pa)) {
+ if (bus_dmatag_subregion(pa->pa_dmat64,
+ 0,
+ FRAG_ADDR_MASK + 1ULL,
+ &sc->sc_dmat,
+ BUS_DMA_WAITOK) != 0) {
+ aprint_error_dev(self,
+ "unable to create 40-bit DMA tag\n");
+ return;
+ }
+ } else {
+ sc->sc_dmat = pa->pa_dmat;
+ }
/* Enable bus mastering. */
pci_conf_write(pc, pa->pa_tag, PCI_COMMAND_STATUS_REG,