git: ba4d9d9d5b24 - main - Revert "if_mvneta: Build the driver as a kernel module"

Wojciech Macek wma at FreeBSD.org
Tue Sep 14 09:50:09 UTC 2021


The branch main has been updated by wma:

URL: https://cgit.FreeBSD.org/src/commit/?id=ba4d9d9d5b2478bb97676a7fa031ef271f1075c9

commit ba4d9d9d5b2478bb97676a7fa031ef271f1075c9
Author:     Wojciech Macek <wma at FreeBSD.org>
AuthorDate: 2021-09-14 09:49:59 +0000
Commit:     Wojciech Macek <wma at FreeBSD.org>
CommitDate: 2021-09-14 09:49:59 +0000

    Revert "if_mvneta: Build the driver as a kernel module"
    
    This reverts commit bcf5c7a8b1dcdcd5f27c1aa694f66208dc07a0dd.
---
 sys/dev/neta/if_mvneta.c  | 73 +++++++++++++++++++----------------------------
 sys/modules/Makefile      |  2 --
 sys/modules/neta/Makefile | 10 -------
 3 files changed, 30 insertions(+), 55 deletions(-)

diff --git a/sys/dev/neta/if_mvneta.c b/sys/dev/neta/if_mvneta.c
index 242e139b8cac..debb4a922cbc 100644
--- a/sys/dev/neta/if_mvneta.c
+++ b/sys/dev/neta/if_mvneta.c
@@ -222,11 +222,6 @@ static device_method_t mvneta_methods[] = {
 	DEVMETHOD_END
 };
 
-static struct ofw_compat_data compat_data[] = {
-	{ "marvell,armada-3700-neta",		true },
-	{ NULL,					false }
-};
-
 DEFINE_CLASS_0(mvneta, mvneta_driver, mvneta_methods, sizeof(struct mvneta_softc));
 
 DRIVER_MODULE(miibus, mvneta, miibus_driver, miibus_devclass, 0, 0);
@@ -234,7 +229,7 @@ DRIVER_MODULE(mdio, mvneta, mdio_driver, mdio_devclass, 0, 0);
 MODULE_DEPEND(mvneta, mdio, 1, 1, 1);
 MODULE_DEPEND(mvneta, ether, 1, 1, 1);
 MODULE_DEPEND(mvneta, miibus, 1, 1, 1);
-SIMPLEBUS_PNP_INFO(compat_data);
+MODULE_DEPEND(mvneta, mvxpbm, 1, 1, 1);
 
 /*
  * List of MIB register and names
@@ -614,16 +609,6 @@ mvneta_attach(device_t self)
 	}
 #endif
 
-	error = bus_setup_intr(self, sc->res[1],
-	    INTR_TYPE_NET | INTR_MPSAFE, NULL, mvneta_intrs[0].handler, sc,
-	    &sc->ih_cookie[0]);
-	if (error) {
-		device_printf(self, "could not setup %s\n",
-		    mvneta_intrs[0].description);
-		mvneta_detach(self);
-		return (error);
-	}
-
 	/*
 	 * MAC address
 	 */
@@ -719,6 +704,8 @@ mvneta_attach(device_t self)
 		}
 	}
 
+	ether_ifattach(ifp, sc->enaddr);
+
 	/*
 	 * Enable DMA engines and Initialize Device Registers.
 	 */
@@ -848,11 +835,20 @@ mvneta_attach(device_t self)
 		mvneta_update_media(sc, ifm_target);
 	}
 
-	ether_ifattach(ifp, sc->enaddr);
+	sysctl_mvneta_init(sc);
 
 	callout_reset(&sc->tick_ch, 0, mvneta_tick, sc);
 
-	sysctl_mvneta_init(sc);
+	error = bus_setup_intr(self, sc->res[1],
+	    INTR_TYPE_NET | INTR_MPSAFE, NULL, mvneta_intrs[0].handler, sc,
+	    &sc->ih_cookie[0]);
+	if (error) {
+		device_printf(self, "could not setup %s\n",
+		    mvneta_intrs[0].description);
+		ether_ifdetach(sc->ifp);
+		mvneta_detach(self);
+		return (error);
+	}
 
 	return (0);
 }
@@ -861,28 +857,20 @@ STATIC int
 mvneta_detach(device_t dev)
 {
 	struct mvneta_softc *sc;
-	struct ifnet *ifp;
 	int q;
 
 	sc = device_get_softc(dev);
-	ifp = sc->ifp;
 
-	if (device_is_attached(dev)) {
-		mvneta_stop(sc);
-		callout_drain(&sc->tick_ch);
-		ether_ifdetach(sc->ifp);
-	}
+	mvneta_stop(sc);
+	/* Detach network interface */
+	if (sc->ifp)
+		if_free(sc->ifp);
 
 	for (q = 0; q < MVNETA_RX_QNUM_MAX; q++)
 		mvneta_ring_dealloc_rx_queue(sc, q);
 	for (q = 0; q < MVNETA_TX_QNUM_MAX; q++)
 		mvneta_ring_dealloc_tx_queue(sc, q);
 
-	device_delete_children(dev);
-
-	if (sc->ih_cookie[0] != NULL)
-		bus_teardown_intr(dev, sc->res[1], sc->ih_cookie[0]);
-
 	if (sc->tx_dtag != NULL)
 		bus_dma_tag_destroy(sc->tx_dtag);
 	if (sc->rx_dtag != NULL)
@@ -893,13 +881,6 @@ mvneta_detach(device_t dev)
 		bus_dma_tag_destroy(sc->rxbuf_dtag);
 
 	bus_release_resources(dev, res_spec, sc->res);
-
-	if (sc->ifp)
-		if_free(sc->ifp);
-
-	if (mtx_initialized(&sc->mtx))
-		mtx_destroy(&sc->mtx);
-
 	return (0);
 }
 
@@ -1273,9 +1254,6 @@ mvneta_ring_alloc_rx_queue(struct mvneta_softc *sc, int q)
 
 	return (0);
 fail:
-	mvneta_rx_lockq(sc, q);
-	mvneta_ring_flush_rx_queue(sc, q);
-	mvneta_rx_unlockq(sc, q);
 	mvneta_ring_dealloc_rx_queue(sc, q);
 	device_printf(sc->dev, "DMA Ring buffer allocation failure.\n");
 	return (error);
@@ -1317,9 +1295,6 @@ mvneta_ring_alloc_tx_queue(struct mvneta_softc *sc, int q)
 
 	return (0);
 fail:
-	mvneta_tx_lockq(sc, q);
-	mvneta_ring_flush_tx_queue(sc, q);
-	mvneta_tx_unlockq(sc, q);
 	mvneta_ring_dealloc_tx_queue(sc, q);
 	device_printf(sc->dev, "DMA Ring buffer allocation failure.\n");
 	return (error);
@@ -1349,6 +1324,16 @@ mvneta_ring_dealloc_tx_queue(struct mvneta_softc *sc, int q)
 #endif
 
 	if (sc->txmbuf_dtag != NULL) {
+		if (mtx_name(&tx->ring_mtx) != NULL) {
+			/*
+			 * It is assumed that maps are being loaded after mutex
+			 * is initialized. Therefore we can skip unloading maps
+			 * when mutex is empty.
+			 */
+			mvneta_tx_lockq(sc, q);
+			mvneta_ring_flush_tx_queue(sc, q);
+			mvneta_tx_unlockq(sc, q);
+		}
 		for (i = 0; i < MVNETA_TX_RING_CNT; i++) {
 			txbuf = &tx->txbuf[i];
 			if (txbuf->dmap != NULL) {
@@ -1387,6 +1372,8 @@ mvneta_ring_dealloc_rx_queue(struct mvneta_softc *sc, int q)
 
 	rx = MVNETA_RX_RING(sc, q);
 
+	mvneta_ring_flush_rx_queue(sc, q);
+
 	if (rx->desc_pa != 0)
 		bus_dmamap_unload(sc->rx_dtag, rx->desc_map);
 
diff --git a/sys/modules/Makefile b/sys/modules/Makefile
index b1063ad003d8..7ed2169445e4 100644
--- a/sys/modules/Makefile
+++ b/sys/modules/Makefile
@@ -264,7 +264,6 @@ SUBDIR=	\
 	mxge \
 	my \
 	${_nctgpio} \
-	${_neta} \
 	${_netgraph} \
 	${_nfe} \
 	nfscl \
@@ -627,7 +626,6 @@ _rockchip=	rockchip
 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "arm"
 _sdhci_fdt=	sdhci_fdt
 _e6000sw=	e6000sw
-_neta=		neta
 .endif
 
 .if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
diff --git a/sys/modules/neta/Makefile b/sys/modules/neta/Makefile
deleted file mode 100644
index 8845e181efaa..000000000000
--- a/sys/modules/neta/Makefile
+++ /dev/null
@@ -1,10 +0,0 @@
-# $FreeBSD$
-
-.PATH: ${SRCTOP}/sys/dev/neta
-
-CFLAGS+= -DFDT	
-
-KMOD=	if_mvneta
-SRCS=	if_mvneta.c if_mvneta_fdt.c if_mvnetavar.h
-SRCS+=	bus_if.h device_if.h mdio_if.h miibus_if.h ofw_bus_if.h opt_platform.h
-.include <bsd.kmod.mk>


More information about the dev-commits-src-main mailing list