Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/pci - Range-limit our DMA tag to 40-bit.
details: https://anonhg.NetBSD.org/src/rev/fd615891e74b
branches: trunk
changeset: 969786:fd615891e74b
user: thorpej <thorpej%NetBSD.org@localhost>
date: Sun Mar 01 15:43:58 2020 +0000
description:
- Range-limit our DMA tag to 40-bit.
- Eliminate __LP64__ ifdefs.
diffstat:
sys/dev/pci/if_nfe.c | 48 ++++++++++++++++++++++++------------------------
sys/dev/pci/if_nfevar.h | 3 ++-
2 files changed, 26 insertions(+), 25 deletions(-)
diffs (130 lines):
diff -r 08de79f543bd -r fd615891e74b sys/dev/pci/if_nfe.c
--- a/sys/dev/pci/if_nfe.c Sun Mar 01 15:22:55 2020 +0000
+++ b/sys/dev/pci/if_nfe.c Sun Mar 01 15:43:58 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_nfe.c,v 1.74 2020/02/04 05:44:14 thorpej Exp $ */
+/* $NetBSD: if_nfe.c,v 1.75 2020/03/01 15:43:58 thorpej Exp $ */
/* $OpenBSD: if_nfe.c,v 1.77 2008/02/05 16:52:50 brad Exp $ */
/*-
@@ -21,7 +21,7 @@
/* Driver for NVIDIA nForce MCP Fast Ethernet and Gigabit Ethernet */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.74 2020/02/04 05:44:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_nfe.c,v 1.75 2020/03/01 15:43:58 thorpej Exp $");
#include "opt_inet.h"
#include "vlan.h"
@@ -145,10 +145,6 @@
#define PCI_PRODUCT_NVIDIA_MCP51_LAN2 \
PCI_PRODUCT_NVIDIA_NFORCE430_LAN2
-#ifdef _LP64
-#define __LP64__ 1
-#endif
-
const struct nfe_product {
pci_vendor_id_t vendor;
pci_product_id_t product;
@@ -325,9 +321,18 @@
break;
}
- if (pci_dma64_available(pa) && (sc->sc_flags & NFE_40BIT_ADDR) != 0)
- sc->sc_dmat = pa->pa_dmat64;
- else
+ if (pci_dma64_available(pa) && (sc->sc_flags & NFE_40BIT_ADDR) != 0) {
+ if (bus_dmatag_subregion(pa->pa_dmat64,
+ 0,
+ (1ULL << 40),
+ &sc->sc_dmat,
+ BUS_DMA_WAITOK) != 0) {
+ aprint_error_dev(self,
+ "unable to create 40-bit DMA tag\n");
+ sc->sc_dmat = pa->pa_dmat64;
+ } else
+ sc->sc_dmat_needs_free = true;
+ } else
sc->sc_dmat = pa->pa_dmat;
nfe_poweron(self);
@@ -458,6 +463,9 @@
mutex_destroy(&sc->rxq.mtx);
nfe_free_tx_ring(sc, &sc->txq);
+ if (sc->sc_dmat_needs_free)
+ bus_dmatag_destroy(sc->sc_dmat);
+
if (sc->sc_ih != NULL) {
pci_intr_disestablish(sc->sc_pc, sc->sc_ih);
sc->sc_ih = NULL;
@@ -958,9 +966,8 @@
skip1:
/* update mapping address in h/w descriptor */
if (sc->sc_flags & NFE_40BIT_ADDR) {
-#if defined(__LP64__)
- desc64->physaddr[0] = htole32(physaddr >> 32);
-#endif
+ desc64->physaddr[0] =
+ htole32(((uint64_t)physaddr) >> 32);
desc64->physaddr[1] = htole32(physaddr & 0xffffffff);
} else {
desc32->physaddr = htole32(physaddr);
@@ -1123,10 +1130,8 @@
if (sc->sc_flags & NFE_40BIT_ADDR) {
desc64 = &sc->txq.desc64[sc->txq.cur];
-#if defined(__LP64__)
desc64->physaddr[0] =
- htole32(map->dm_segs[i].ds_addr >> 32);
-#endif
+ htole32(((uint64_t)map->dm_segs[i].ds_addr) >> 32);
desc64->physaddr[1] =
htole32(map->dm_segs[i].ds_addr & 0xffffffff);
desc64->length = htole16(map->dm_segs[i].ds_len - 1);
@@ -1291,13 +1296,9 @@
nfe_set_macaddr(sc, sc->sc_enaddr);
/* tell MAC where rings are in memory */
-#ifdef __LP64__
- NFE_WRITE(sc, NFE_RX_RING_ADDR_HI, sc->rxq.physaddr >> 32);
-#endif
+ NFE_WRITE(sc, NFE_RX_RING_ADDR_HI, ((uint64_t)sc->rxq.physaddr) >> 32);
NFE_WRITE(sc, NFE_RX_RING_ADDR_LO, sc->rxq.physaddr & 0xffffffff);
-#ifdef __LP64__
- NFE_WRITE(sc, NFE_TX_RING_ADDR_HI, sc->txq.physaddr >> 32);
-#endif
+ NFE_WRITE(sc, NFE_TX_RING_ADDR_HI, ((uint64_t)sc->txq.physaddr) >> 32);
NFE_WRITE(sc, NFE_TX_RING_ADDR_LO, sc->txq.physaddr & 0xffffffff);
NFE_WRITE(sc, NFE_RING_SIZE,
@@ -1516,9 +1517,8 @@
if (sc->sc_flags & NFE_40BIT_ADDR) {
desc64 = &sc->rxq.desc64[i];
-#if defined(__LP64__)
- desc64->physaddr[0] = htole32(physaddr >> 32);
-#endif
+ desc64->physaddr[0] =
+ htole32(((uint64_t)physaddr) >> 32);
desc64->physaddr[1] = htole32(physaddr & 0xffffffff);
desc64->length = htole16(sc->rxq.bufsz);
desc64->flags = htole16(NFE_RX_READY);
diff -r 08de79f543bd -r fd615891e74b sys/dev/pci/if_nfevar.h
--- a/sys/dev/pci/if_nfevar.h Sun Mar 01 15:22:55 2020 +0000
+++ b/sys/dev/pci/if_nfevar.h Sun Mar 01 15:43:58 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_nfevar.h,v 1.11 2019/09/13 07:55:07 msaitoh Exp $ */
+/* $NetBSD: if_nfevar.h,v 1.12 2020/03/01 15:43:58 thorpej Exp $ */
/* $OpenBSD: if_nfevar.h,v 1.13 2007/12/05 08:30:33 jsg Exp $ */
/*-
@@ -77,6 +77,7 @@
bus_size_t sc_mems;
void *sc_ih;
bus_dma_tag_t sc_dmat;
+ bool sc_dmat_needs_free;
struct mii_data sc_mii;
struct callout sc_tick_ch;
Home |
Main Index |
Thread Index |
Old Index