CVS commit: src/sys/dev/ic

2024-09-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 15 07:38:08 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c bcmgenetvar.h

Log Message:
genet(4): Remove the non-MP-safe scaffolding.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/bcmgenet.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/bcmgenetvar.h

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/ic/bcmgenet.c
diff -u src/sys/dev/ic/bcmgenet.c:1.19 src/sys/dev/ic/bcmgenet.c:1.20
--- src/sys/dev/ic/bcmgenet.c:1.19	Sun Aug 25 12:38:20 2024
+++ src/sys/dev/ic/bcmgenet.c	Sun Sep 15 07:38:08 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: bcmgenet.c,v 1.19 2024/08/25 12:38:20 mlelstv Exp $ */
+/* $NetBSD: bcmgenet.c,v 1.20 2024/09/15 07:38:08 skrll Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill 
@@ -30,11 +30,10 @@
  * Broadcom GENETv5
  */
 
-#include "opt_net_mpsafe.h"
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.19 2024/08/25 12:38:20 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.20 2024/09/15 07:38:08 skrll Exp $");
 
 #include 
 #include 
@@ -67,13 +66,6 @@ CTASSERT(MCLBYTES == 2048);
 #define	DPRINTF(...)	((void)0)
 #endif
 
-#ifdef NET_MPSAFE
-#define	GENET_MPSAFE		1
-#define	CALLOUT_FLAGS		CALLOUT_MPSAFE
-#else
-#define	CALLOUT_FLAGS		0
-#endif
-
 #define	TX_MAX_SEGS		128
 #define	TX_DESC_COUNT		256 /* GENET_DMA_DESC_COUNT */
 #define	RX_DESC_COUNT		256 /* GENET_DMA_DESC_COUNT */
@@ -84,9 +76,9 @@ CTASSERT(MCLBYTES == 2048);
 #define	TX_NEXT(n)		TX_SKIP(n, 1)
 #define	RX_NEXT(n)		(((n) + 1) % RX_DESC_COUNT)
 
-#define	GENET_LOCK(sc)		mutex_enter(&(sc)->sc_lock)
-#define	GENET_UNLOCK(sc)	mutex_exit(&(sc)->sc_lock)
-#define	GENET_ASSERT_LOCKED(sc)	KASSERT(mutex_owned(&(sc)->sc_lock))
+#define	GENET_LOCK(sc)			mutex_enter(&(sc)->sc_lock)
+#define	GENET_UNLOCK(sc)		mutex_exit(&(sc)->sc_lock)
+#define	GENET_ASSERT_LOCKED(sc)		KASSERT(mutex_owned(&(sc)->sc_lock))
 
 #define	GENET_TXLOCK(sc)		mutex_enter(&(sc)->sc_txlock)
 #define	GENET_TXUNLOCK(sc)		mutex_exit(&(sc)->sc_txlock)
@@ -324,18 +316,12 @@ genet_tick(void *softc)
 {
 	struct genet_softc *sc = softc;
 	struct mii_data *mii = &sc->sc_mii;
-#ifndef GENET_MPSAFE
-	int s = splnet();
-#endif
 
 	GENET_LOCK(sc);
 	mii_tick(mii);
-	callout_schedule(&sc->sc_stat_ch, hz);
+	if (sc->sc_running)
+		callout_schedule(&sc->sc_stat_ch, hz);
 	GENET_UNLOCK(sc);
-
-#ifndef GENET_MPSAFE
-	splx(s);
-#endif
 }
 
 static void
@@ -584,6 +570,7 @@ genet_init_locked(struct genet_softc *sc
 	WR4(sc, GENET_UMAC_MAC1, val);
 
 	/* Setup RX filter */
+	sc->sc_promisc = ifp->if_flags & IFF_PROMISC;
 	genet_setup_rxfilter(sc);
 
 	/* Setup TX/RX rings */
@@ -598,6 +585,10 @@ genet_init_locked(struct genet_softc *sc
 	/* Enable interrupts */
 	genet_enable_intr(sc);
 
+	GENET_ASSERT_TXLOCKED(sc);
+	sc->sc_txrunning = true;
+
+	sc->sc_running = true;
 	ifp->if_flags |= IFF_RUNNING;
 
 	mii_mediachg(mii);
@@ -651,7 +642,12 @@ genet_stop_locked(struct genet_softc *sc
 
 	GENET_ASSERT_LOCKED(sc);
 
-	callout_stop(&sc->sc_stat_ch);
+	GENET_TXLOCK(sc);
+	sc->sc_txrunning = false;
+	GENET_TXUNLOCK(sc);
+
+	sc->sc_running = false;
+	callout_halt(&sc->sc_stat_ch, &sc->sc_lock);
 
 	mii_down(&sc->sc_mii);
 
@@ -824,7 +820,7 @@ genet_start_locked(struct genet_softc *s
 
 	GENET_ASSERT_TXLOCKED(sc);
 
-	if ((ifp->if_flags & IFF_RUNNING) == 0)
+	if (!sc->sc_txrunning)
 		return;
 
 	const int qid = GENET_DMA_DEFAULT_QUEUE;
@@ -904,42 +900,26 @@ static int
 genet_ioctl(struct ifnet *ifp, u_long cmd, void *data)
 {
 	struct genet_softc *sc = ifp->if_softc;
-	int error, s;
+	int error;
 
-#ifndef GENET_MPSAFE
-	s = splnet();
-#endif
+	const int s = splnet();
+	error = ether_ioctl(ifp, cmd, data);
+	splx(s);
 
-	switch (cmd) {
-	default:
-#ifdef GENET_MPSAFE
-		s = splnet();
-#endif
-		error = ether_ioctl(ifp, cmd, data);
-#ifdef GENET_MPSAFE
-		splx(s);
-#endif
-		if (error != ENETRESET)
-			break;
+	if (error != ENETRESET)
+		return error;
 
-		error = 0;
+	error = 0;
 
-		if (cmd == SIOCSIFCAP)
-			error = if_init(ifp);
-		else if (cmd != SIOCADDMULTI && cmd != SIOCDELMULTI)
-			;
-		else if ((ifp->if_flags & IFF_RUNNING) != 0) {
-			GENET_LOCK(sc);
+	if (cmd == SIOCSIFCAP)
+		error = if_init(ifp);
+	else if (cmd == SIOCADDMULTI || cmd == SIOCDELMULTI) {
+		GENET_LOCK(sc);
+		sc->sc_promisc = ifp->if_flags & IFF_PROMISC;
+		if (sc->sc_running)
 			genet_setup_rxfilter(sc);
-			GENET_UNLOCK(sc);
-		}
-		break;
+		GENET_UNLOCK(sc);
 	}
-
-#ifndef GENET_MPSAFE
-	splx(s);
-#endif
-
 	return error;
 }
 
@@ -1082,7 +1062,7 @@ genet_attach(struct genet_softc *sc)
 
 	mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NET);
 	mutex_init(&sc->sc_txlock, MUTEX_DEFAULT, IPL_NET);
-	callout_init(&sc->sc_stat_ch, CALLOUT_FLAGS);
+	callout_init(&sc->sc_stat_ch, CALLOUT_MPSAFE);
 	callout_setfunc(&sc->sc_stat_ch, genet_tick, sc);
 
 	genet_get_eaddr(sc, eaddr);
@@ -1101,9

CVS commit: src/sys/dev/ic

2024-09-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 15 07:38:08 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c bcmgenetvar.h

Log Message:
genet(4): Remove the non-MP-safe scaffolding.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/bcmgenet.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/bcmgenetvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-09-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 15 07:33:33 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_eqos_var.h

Log Message:
Remove unused struct eqos_softc member


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/dwc_eqos_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-09-15 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Sep 15 07:33:33 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_eqos_var.h

Log Message:
Remove unused struct eqos_softc member


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/dwc_eqos_var.h

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/ic/dwc_eqos_var.h
diff -u src/sys/dev/ic/dwc_eqos_var.h:1.9 src/sys/dev/ic/dwc_eqos_var.h:1.10
--- src/sys/dev/ic/dwc_eqos_var.h:1.9	Thu Nov  2 13:50:02 2023
+++ src/sys/dev/ic/dwc_eqos_var.h	Sun Sep 15 07:33:33 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_eqos_var.h,v 1.9 2023/11/02 13:50:02 riastradh Exp $ */
+/* $NetBSD: dwc_eqos_var.h,v 1.10 2024/09/15 07:33:33 skrll Exp $ */
 
 /*-
  * Copyright (c) 2022 Jared McNeill 
@@ -73,7 +73,6 @@ struct eqos_softc {
 	bool			sc_running;
 	bool			sc_txrunning;
 	bool			sc_promisc;
-	bool			sc_allmulti;
 
 	struct eqos_ring	sc_tx;
 	struct eqos_ring	sc_rx;



CVS commit: src/sys/dev/ic

2024-09-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Sep 14 07:30:41 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_eqos.c

Log Message:
Update sc_promisc in eqos_ioctl before calling eqos_setup_rxfilter so the
new value is used.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/ic/dwc_eqos.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-09-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Sep 14 07:30:41 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_eqos.c

Log Message:
Update sc_promisc in eqos_ioctl before calling eqos_setup_rxfilter so the
new value is used.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/ic/dwc_eqos.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/ic/dwc_eqos.c
diff -u src/sys/dev/ic/dwc_eqos.c:1.38 src/sys/dev/ic/dwc_eqos.c:1.39
--- src/sys/dev/ic/dwc_eqos.c:1.38	Mon Aug 26 18:25:29 2024
+++ src/sys/dev/ic/dwc_eqos.c	Sat Sep 14 07:30:41 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_eqos.c,v 1.38 2024/08/26 18:25:29 bsiegert Exp $ */
+/* $NetBSD: dwc_eqos.c,v 1.39 2024/09/14 07:30:41 skrll Exp $ */
 
 /*-
  * Copyright (c) 2022 Jared McNeill 
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwc_eqos.c,v 1.38 2024/08/26 18:25:29 bsiegert Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc_eqos.c,v 1.39 2024/09/14 07:30:41 skrll Exp $");
 
 #include 
 #include 
@@ -1234,6 +1234,7 @@ eqos_ioctl(struct ifnet *ifp, u_long cmd
 			error = (*ifp->if_init)(ifp);
 		else if (cmd == SIOCADDMULTI || cmd == SIOCDELMULTI) {
 			EQOS_LOCK(sc);
+			sc->sc_promisc = ifp->if_flags & IFF_PROMISC;
 			if (sc->sc_running)
 eqos_setup_rxfilter(sc);
 			EQOS_UNLOCK(sc);



CVS commit: src/sys/dev/ic

2024-09-04 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Sep  4 10:45:50 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
more annotations:
- 'transfer data' is actually a pixel mask
- transparency
- bg colour register confirmed
all found by experiment


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/stireg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-09-04 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Sep  4 10:45:50 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
more annotations:
- 'transfer data' is actually a pixel mask
- transparency
- bg colour register confirmed
all found by experiment


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/ic/stireg.h

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/ic/stireg.h
diff -u src/sys/dev/ic/stireg.h:1.13 src/sys/dev/ic/stireg.h:1.14
--- src/sys/dev/ic/stireg.h:1.13	Mon Aug 19 10:57:32 2024
+++ src/sys/dev/ic/stireg.h	Wed Sep  4 10:45:50 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: stireg.h,v 1.13 2024/08/19 10:57:32 macallan Exp $	*/
+/*	$NetBSD: stireg.h,v 1.14 2024/09/04 10:45:50 macallan Exp $	*/
 
 /*	$OpenBSD: stireg.h,v 1.14 2015/04/05 23:25:57 miod Exp $	*/
 
@@ -650,6 +650,8 @@ STI_DEP(util);
 	(((R)<<8)|((M)<<16)|((X)<<24)|((S)<<29)|((D)<<28)|((L)<<31)|((B)<<1)|(F))
 	/* LSSD       ??BF */
 
+/* B = 1 -> background transparency for masked fills */
+
 #define	IndexedDcd	0	/* Pixel data is indexed (pseudo) color */
 #define	FractDcd	1	/* Pixel data is Fractional 8-8-8 */
 #define	Otc04	2	/* Pixels in each longword transfer (4) */
@@ -687,7 +689,8 @@ STI_DEP(util);
 #define	NGLE_REG_6		0x000800	/* rectfill XY */
 #define	NGLE_REG_7		0x000804	/* bitblt size WH */
 #define	NGLE_REG_24		0x000808	/* bitblt src XY */
-#define	NGLE_REG_8		0x000820	/* transfer data */
+#define	NGLE_REG_8		0x000820	/* 'transfer data' - this is */
+		/* a pixel mask on fills */
 #define	NGLE_REG_37		0x000944	/* HCRX fast rect fill, size */
 #define	NGLE_REG_9		0x000a04	/* rect fill size, start */
 #define	NGLE_REG_25		0x000b00	/* bitblt dst XY, start */
@@ -695,8 +698,8 @@ STI_DEP(util);
 #define	NGLE_REG_10		0x018000	/* buffer ctl */
 #define	NGLE_REG_11		0x018004	/* dest bitmap access */
 #define	NGLE_REG_12		0x01800c	/* control plane register */
-#define	NGLE_REG_35		0x018010	/* fg color */
-#define	NGLE_REG_36		0x018014	/* bg colour? */
+#define	NGLE_REG_35		0x018010	/* fg colour */
+#define	NGLE_REG_36		0x018014	/* bg colour */
 #define	NGLE_REG_13		0x018018	/* image planemask */
 #define	NGLE_REG_14		0x01801c	/* raster op */
 #define	NGLE_REG_15		0x20	/* 'busy dodger' idle */



CVS commit: src/sys/dev/ic

2024-08-26 Thread Benny Siegert
Module Name:src
Committed By:   bsiegert
Date:   Mon Aug 26 18:25:29 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_eqos.c

Log Message:
dwc_eqos: grammar fix

If the MAC address has the multicast bit set, the driver outputs
"Clearing the multicast bit" instead of "Clear the multicast bit".


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/ic/dwc_eqos.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/ic/dwc_eqos.c
diff -u src/sys/dev/ic/dwc_eqos.c:1.37 src/sys/dev/ic/dwc_eqos.c:1.38
--- src/sys/dev/ic/dwc_eqos.c:1.37	Fri Jul  5 04:31:51 2024
+++ src/sys/dev/ic/dwc_eqos.c	Mon Aug 26 18:25:29 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_eqos.c,v 1.37 2024/07/05 04:31:51 rin Exp $ */
+/* $NetBSD: dwc_eqos.c,v 1.38 2024/08/26 18:25:29 bsiegert Exp $ */
 
 /*-
  * Copyright (c) 2022 Jared McNeill 
@@ -36,7 +36,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwc_eqos.c,v 1.37 2024/07/05 04:31:51 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwc_eqos.c,v 1.38 2024/08/26 18:25:29 bsiegert Exp $");
 
 #include 
 #include 
@@ -1265,7 +1265,7 @@ eqos_get_eaddr(struct eqos_softc *sc, ui
 	machi = RD4(sc, GMAC_MAC_ADDRESS0_HIGH) & 0x;
 	if ((maclo & 0x0001) != 0) {
 		aprint_error_dev(sc->sc_dev,
-		"Wrong MAC address. Clear the multicast bit.\n");
+		"Wrong MAC address. Clearing the multicast bit.\n");
 		maclo &= ~0x0001;
 	}
 



CVS commit: src/sys/dev/ic

2024-08-26 Thread Benny Siegert
Module Name:src
Committed By:   bsiegert
Date:   Mon Aug 26 18:25:29 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_eqos.c

Log Message:
dwc_eqos: grammar fix

If the MAC address has the multicast bit set, the driver outputs
"Clearing the multicast bit" instead of "Clear the multicast bit".


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/ic/dwc_eqos.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 25 12:38:21 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c

Log Message:
Fix off-by-one.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/bcmgenet.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/ic/bcmgenet.c
diff -u src/sys/dev/ic/bcmgenet.c:1.18 src/sys/dev/ic/bcmgenet.c:1.19
--- src/sys/dev/ic/bcmgenet.c:1.18	Sun Aug 25 08:31:07 2024
+++ src/sys/dev/ic/bcmgenet.c	Sun Aug 25 12:38:20 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: bcmgenet.c,v 1.18 2024/08/25 08:31:07 mlelstv Exp $ */
+/* $NetBSD: bcmgenet.c,v 1.19 2024/08/25 12:38:20 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill 
@@ -34,7 +34,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.18 2024/08/25 08:31:07 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.19 2024/08/25 12:38:20 mlelstv Exp $");
 
 #include 
 #include 
@@ -684,7 +684,7 @@ genet_stop_locked(struct genet_softc *sc
 	genet_disable_intr(sc);
 
 	/* Free TX buffers */
-	for (i=0; i<=TX_DESC_COUNT; ++i)
+	for (i=0; iif_flags &= ~IFF_RUNNING;



CVS commit: src/sys/dev/ic

2024-08-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 25 12:38:21 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c

Log Message:
Fix off-by-one.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/bcmgenet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 25 08:31:07 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c

Log Message:
Fix mbuf leak.
Minor optimizations for send queue.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/bcmgenet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 25 08:31:07 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c

Log Message:
Fix mbuf leak.
Minor optimizations for send queue.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/bcmgenet.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/ic/bcmgenet.c
diff -u src/sys/dev/ic/bcmgenet.c:1.17 src/sys/dev/ic/bcmgenet.c:1.18
--- src/sys/dev/ic/bcmgenet.c:1.17	Sun Aug 25 08:27:06 2024
+++ src/sys/dev/ic/bcmgenet.c	Sun Aug 25 08:31:07 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: bcmgenet.c,v 1.17 2024/08/25 08:27:06 mlelstv Exp $ */
+/* $NetBSD: bcmgenet.c,v 1.18 2024/08/25 08:31:07 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill 
@@ -34,7 +34,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.17 2024/08/25 08:27:06 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.18 2024/08/25 08:31:07 mlelstv Exp $");
 
 #include 
 #include 
@@ -621,11 +621,33 @@ genet_init(struct ifnet *ifp)
 	return error;
 }
 
+static int
+genet_free_txbuf(struct genet_softc *sc, int index)
+{
+	struct genet_bufmap *bmap;
+
+	bmap = &sc->sc_tx.buf_map[index];
+	if (bmap->mbuf == NULL)
+		return 0;
+
+	if (bmap->map->dm_mapsize > 0) {
+		bus_dmamap_sync(sc->sc_tx.buf_tag, bmap->map,
+		0, bmap->map->dm_mapsize,
+		BUS_DMASYNC_POSTWRITE);
+	}
+	bus_dmamap_unload(sc->sc_tx.buf_tag, bmap->map);
+	m_freem(bmap->mbuf);
+	bmap->mbuf = NULL;
+
+	return 1;
+}
+
 static void
 genet_stop_locked(struct genet_softc *sc, int disable)
 {
 	struct ifnet *ifp = &sc->sc_ec.ec_if;
 	uint32_t val;
+	int i;
 
 	GENET_ASSERT_LOCKED(sc);
 
@@ -661,6 +683,10 @@ genet_stop_locked(struct genet_softc *sc
 	/* Disable interrupts */
 	genet_disable_intr(sc);
 
+	/* Free TX buffers */
+	for (i=0; i<=TX_DESC_COUNT; ++i)
+		genet_free_txbuf(sc, i);
+
 	ifp->if_flags &= ~IFF_RUNNING;
 }
 
@@ -771,34 +797,22 @@ static void
 genet_txintr(struct genet_softc *sc, int qid)
 {
 	struct ifnet *ifp = &sc->sc_ec.ec_if;
-	struct genet_bufmap *bmap;
 	int cidx, i, pkts = 0;
 
 	cidx = RD4(sc, GENET_TX_DMA_CONS_INDEX(qid)) & 0x;
 	i = sc->sc_tx.cidx % TX_DESC_COUNT;
 	while (sc->sc_tx.cidx != cidx) {
-		bmap = &sc->sc_tx.buf_map[i];
-		if (bmap->mbuf != NULL) {
-			/* XXX first segment already unloads */
-			if (bmap->map->dm_mapsize > 0) {
-bus_dmamap_sync(sc->sc_tx.buf_tag, bmap->map,
-0, bmap->map->dm_mapsize,
-BUS_DMASYNC_POSTWRITE);
-			}
-			bus_dmamap_unload(sc->sc_tx.buf_tag, bmap->map);
-			m_freem(bmap->mbuf);
-			bmap->mbuf = NULL;
-			++pkts;
-		}
-
+		pkts += genet_free_txbuf(sc, i);
 		i = TX_NEXT(i);
 		sc->sc_tx.cidx = (sc->sc_tx.cidx + 1) & 0x;
 	}
 
-	if_statadd(ifp, if_opackets, pkts);
-
-	if (pkts != 0)
+	if (pkts != 0) {
+		if_statadd(ifp, if_opackets, pkts);
 		rnd_add_uint32(&sc->sc_rndsource, pkts);
+	}
+
+	if_schedule_deferred_start(ifp);
 }
 
 static void
@@ -819,7 +833,11 @@ genet_start_locked(struct genet_softc *s
 	cnt = 0;
 
 	sc->sc_tx.queued = (RD4(sc, GENET_TX_DMA_PROD_INDEX(qid))
-	  - RD4(sc, GENET_TX_DMA_CONS_INDEX(qid))) & 0x;
+	  - sc->sc_tx.cidx) & 0x;
+
+	/* At least one descriptor free ? */
+	if (sc->sc_tx.queued >= TX_DESC_COUNT - 1)
+		return;
 
 	for (;;) {
 		IFQ_POLL(&ifp->if_snd, m);
@@ -863,9 +881,7 @@ int
 genet_intr(void *arg)
 {
 	struct genet_softc *sc = arg;
-	struct ifnet *ifp = &sc->sc_ec.ec_if;
 	uint32_t val;
-	bool dotx = false;
 
 	val = RD4(sc, GENET_INTRL2_CPU_STAT);
 	val &= ~RD4(sc, GENET_INTRL2_CPU_STAT_MASK);
@@ -879,12 +895,8 @@ genet_intr(void *arg)
 
 	if (val & GENET_IRQ_TXDMA_DONE) {
 		genet_txintr(sc, GENET_DMA_DEFAULT_QUEUE);
-		dotx = true;
 	}
 
-	if (dotx)
-		if_schedule_deferred_start(ifp);
-
 	return 1;
 }
 



CVS commit: src/sys/dev/ic

2024-08-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 25 08:27:06 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c

Log Message:
Fix MBUFTRACE


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ic/bcmgenet.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/ic/bcmgenet.c
diff -u src/sys/dev/ic/bcmgenet.c:1.16 src/sys/dev/ic/bcmgenet.c:1.17
--- src/sys/dev/ic/bcmgenet.c:1.16	Sun Aug 25 08:24:42 2024
+++ src/sys/dev/ic/bcmgenet.c	Sun Aug 25 08:27:06 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: bcmgenet.c,v 1.16 2024/08/25 08:24:42 mlelstv Exp $ */
+/* $NetBSD: bcmgenet.c,v 1.17 2024/08/25 08:27:06 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill 
@@ -34,7 +34,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.16 2024/08/25 08:24:42 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.17 2024/08/25 08:27:06 mlelstv Exp $");
 
 #include 
 #include 
@@ -722,10 +722,12 @@ genet_rxintr(struct genet_softc *sc, int
 			if_statinc(ifp, if_ierrors);
 			goto next;
 		}
+		MCLAIM(m0, &sc->sc_ec.ec_rx_mowner);
 
 		/* unload map before it gets loaded in setup_rxbuf */
 		if (sc->sc_rx.buf_map[index].map->dm_mapsize > 0) {
-			bus_dmamap_sync(sc->sc_rx.buf_tag, sc->sc_rx.buf_map[index].map,
+			bus_dmamap_sync(sc->sc_rx.buf_tag,
+			sc->sc_rx.buf_map[index].map,
 			0, sc->sc_rx.buf_map[index].map->dm_mapsize,
 			BUS_DMASYNC_POSTREAD);
 		}
@@ -1011,6 +1013,21 @@ genet_setup_dma(struct genet_softc *sc, 
 	return 0;
 }
 
+static void
+genet_claim_rxring(struct genet_softc *sc, int qid)
+{
+	struct mbuf *m;
+	int i;
+
+	/* Claim mbufs from RX ring */
+	for (i = 0; i < RX_DESC_COUNT; i++) {
+		m = sc->sc_rx.buf_map[i].mbuf;
+		if (m != NULL) {
+			MCLAIM(m, &sc->sc_ec.ec_rx_mowner);
+		}
+	}
+}
+
 int
 genet_attach(struct genet_softc *sc)
 {
@@ -1110,6 +1127,9 @@ genet_attach(struct genet_softc *sc)
 	/* Attach ethernet interface */
 	ether_ifattach(ifp, eaddr);
 
+	/* MBUFTRACE */
+	genet_claim_rxring(sc, GENET_DMA_DEFAULT_QUEUE);
+
 	rnd_attach_source(&sc->sc_rndsource, ifp->if_xname, RND_TYPE_NET,
 	RND_FLAG_DEFAULT);
 



CVS commit: src/sys/dev/ic

2024-08-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 25 08:27:06 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c

Log Message:
Fix MBUFTRACE


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/dev/ic/bcmgenet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 25 08:24:42 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c

Log Message:
Don't mix endianess and MAC address layout.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/bcmgenet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-25 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Aug 25 08:24:42 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c

Log Message:
Don't mix endianess and MAC address layout.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/dev/ic/bcmgenet.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/ic/bcmgenet.c
diff -u src/sys/dev/ic/bcmgenet.c:1.15 src/sys/dev/ic/bcmgenet.c:1.16
--- src/sys/dev/ic/bcmgenet.c:1.15	Sun Aug 25 07:02:27 2024
+++ src/sys/dev/ic/bcmgenet.c	Sun Aug 25 08:24:42 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: bcmgenet.c,v 1.15 2024/08/25 07:02:27 skrll Exp $ */
+/* $NetBSD: bcmgenet.c,v 1.16 2024/08/25 08:24:42 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill 
@@ -34,7 +34,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.15 2024/08/25 07:02:27 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.16 2024/08/25 08:24:42 mlelstv Exp $");
 
 #include 
 #include 
@@ -949,8 +949,8 @@ genet_get_eaddr(struct genet_softc *sc, 
 
 	val = RD4(sc, GENET_SYS_RBUF_FLUSH_CTRL);
 	if ((val & GENET_SYS_RBUF_FLUSH_RESET) == 0) {
-		maclo = htobe32(RD4(sc, GENET_UMAC_MAC0));
-		machi = htobe16(RD4(sc, GENET_UMAC_MAC1) & 0x);
+		maclo = RD4(sc, GENET_UMAC_MAC0);
+		machi = RD4(sc, GENET_UMAC_MAC1) & 0x;
 	}
 
 	if (maclo == 0 && machi == 0) {
@@ -959,12 +959,12 @@ genet_get_eaddr(struct genet_softc *sc, 
 		machi = cprng_strong32() & 0x;
 	}
 
-	eaddr[0] = maclo & 0xff;
-	eaddr[1] = (maclo >> 8) & 0xff;
-	eaddr[2] = (maclo >> 16) & 0xff;
-	eaddr[3] = (maclo >> 24) & 0xff;
-	eaddr[4] = machi & 0xff;
-	eaddr[5] = (machi >> 8) & 0xff;
+	eaddr[0] = (maclo >> 24) & 0xff;
+	eaddr[1] = (maclo >> 16) & 0xff;
+	eaddr[2] = (maclo >>  8) & 0xff;
+	eaddr[3] = (maclo >>  0) & 0xff;
+	eaddr[4] = (machi >>  8) & 0xff;
+	eaddr[5] = (machi >>  0) & 0xff;
 }
 
 static int



CVS commit: src/sys/dev/ic

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 07:02:27 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/bcmgenet.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/ic/bcmgenet.c
diff -u src/sys/dev/ic/bcmgenet.c:1.14 src/sys/dev/ic/bcmgenet.c:1.15
--- src/sys/dev/ic/bcmgenet.c:1.14	Sun Sep 18 17:18:19 2022
+++ src/sys/dev/ic/bcmgenet.c	Sun Aug 25 07:02:27 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: bcmgenet.c,v 1.14 2022/09/18 17:18:19 thorpej Exp $ */
+/* $NetBSD: bcmgenet.c,v 1.15 2024/08/25 07:02:27 skrll Exp $ */
 
 /*-
  * Copyright (c) 2020 Jared McNeill 
@@ -34,7 +34,7 @@
 #include "opt_ddb.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.14 2022/09/18 17:18:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcmgenet.c,v 1.15 2024/08/25 07:02:27 skrll Exp $");
 
 #include 
 #include 
@@ -115,7 +115,6 @@ genet_mii_readreg(device_t dev, int phy,
 		delay(10);
 	}
 
-
 	if (retry == 0) {
 		device_printf(dev, "phy read timeout, phy=%d reg=%d\n",
 		phy, reg);



CVS commit: src/sys/dev/ic

2024-08-25 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Aug 25 07:02:27 UTC 2024

Modified Files:
src/sys/dev/ic: bcmgenet.c

Log Message:
Whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/ic/bcmgenet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Aug 19 16:09:42 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
Whitespace fixes


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/ic/sti.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/ic/sti.c
diff -u src/sys/dev/ic/sti.c:1.38 src/sys/dev/ic/sti.c:1.39
--- src/sys/dev/ic/sti.c:1.38	Mon Aug 19 10:57:32 2024
+++ src/sys/dev/ic/sti.c	Mon Aug 19 16:09:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti.c,v 1.38 2024/08/19 10:57:32 macallan Exp $	*/
+/*	$NetBSD: sti.c,v 1.39 2024/08/19 16:09:42 skrll Exp $	*/
 
 /*	$OpenBSD: sti.c,v 1.61 2009/09/05 14:09:35 miod Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.38 2024/08/19 10:57:32 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.39 2024/08/19 16:09:42 skrll Exp $");
 
 #include "wsdisplay.h"
 
@@ -1082,7 +1082,7 @@ sti_ioctl(void *v, void *vs, u_long cmd,
 	ret = 0;
 	switch (cmd) {
 	case GCID:
-		*(u_int *) data = rom->rom_dd.dd_grid[0];
+		*(u_int *)data = rom->rom_dd.dd_grid[0];
 		break;
 
 	case WSDISPLAYIO_GMODE:
@@ -1122,7 +1122,6 @@ sti_ioctl(void *v, void *vs, u_long cmd,
 		*(u_int *)data = WSDISPLAY_TYPE_STI;
 		break;
 
-
 	case WSDISPLAYIO_GINFO:
 		wdf = (struct wsdisplay_fbinfo *)data;
 		wdf->height = scr->scr_cfg.scr_height;



CVS commit: src/sys/dev/ic

2024-08-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Mon Aug 19 16:09:42 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
Whitespace fixes


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/dev/ic/sti.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-19 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Aug 19 10:57:32 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c stireg.h

Log Message:
add an ioctl() to read a device's graphics ID, mimic HP/UX's GCID
that way an xorg driver can identify which WSDISPLAY_TYPE_STI it's talking to
without having to setup its own STI


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/ic/sti.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ic/stireg.h

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/ic/sti.c
diff -u src/sys/dev/ic/sti.c:1.37 src/sys/dev/ic/sti.c:1.38
--- src/sys/dev/ic/sti.c:1.37	Wed Jul  3 13:08:36 2024
+++ src/sys/dev/ic/sti.c	Mon Aug 19 10:57:32 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti.c,v 1.37 2024/07/03 13:08:36 macallan Exp $	*/
+/*	$NetBSD: sti.c,v 1.38 2024/08/19 10:57:32 macallan Exp $	*/
 
 /*	$OpenBSD: sti.c,v 1.61 2009/09/05 14:09:35 miod Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.37 2024/07/03 13:08:36 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.38 2024/08/19 10:57:32 macallan Exp $");
 
 #include "wsdisplay.h"
 
@@ -1073,6 +1073,7 @@ int
 sti_ioctl(void *v, void *vs, u_long cmd, void *data, int flag, struct lwp *l)
 {
 	struct sti_screen *scr = (struct sti_screen *)v;
+	struct sti_rom *rom = scr->scr_rom;
 	struct wsdisplay_fbinfo *wdf;
 	struct wsdisplay_cmap *cmapp;
 	u_int mode, idx, count;
@@ -1080,6 +1081,10 @@ sti_ioctl(void *v, void *vs, u_long cmd,
 
 	ret = 0;
 	switch (cmd) {
+	case GCID:
+		*(u_int *) data = rom->rom_dd.dd_grid[0];
+		break;
+
 	case WSDISPLAYIO_GMODE:
 		*(u_int *)data = scr->scr_wsmode;
 		break;
@@ -1117,6 +1122,7 @@ sti_ioctl(void *v, void *vs, u_long cmd,
 		*(u_int *)data = WSDISPLAY_TYPE_STI;
 		break;
 
+
 	case WSDISPLAYIO_GINFO:
 		wdf = (struct wsdisplay_fbinfo *)data;
 		wdf->height = scr->scr_cfg.scr_height;

Index: src/sys/dev/ic/stireg.h
diff -u src/sys/dev/ic/stireg.h:1.12 src/sys/dev/ic/stireg.h:1.13
--- src/sys/dev/ic/stireg.h:1.12	Tue Aug  6 07:26:56 2024
+++ src/sys/dev/ic/stireg.h	Mon Aug 19 10:57:32 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: stireg.h,v 1.12 2024/08/06 07:26:56 macallan Exp $	*/
+/*	$NetBSD: stireg.h,v 1.13 2024/08/19 10:57:32 macallan Exp $	*/
 
 /*	$OpenBSD: stireg.h,v 1.14 2015/04/05 23:25:57 miod Exp $	*/
 
@@ -747,4 +747,7 @@ STI_DEP(util);
 #define	NGLE_BUFF1_CMAP3	0x0c001e02
 #define	NGLE_ARTIST_CMAP0	0x0102
 
+/* mimic HP/UX, this will return the device's graphics ID */
+#define	GCID	_IOR('G', 40, u_int)
+
 #endif /* _IC_STIREG_H_ */



CVS commit: src/sys/dev/ic

2024-08-19 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Aug 19 10:57:32 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c stireg.h

Log Message:
add an ioctl() to read a device's graphics ID, mimic HP/UX's GCID
that way an xorg driver can identify which WSDISPLAY_TYPE_STI it's talking to
without having to setup its own STI


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/dev/ic/sti.c
cvs rdiff -u -r1.12 -r1.13 src/sys/dev/ic/stireg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Aug 12 21:27:34 UTC 2024

Modified Files:
src/sys/dev/ic: rtl8169.c

Log Message:
fix whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/sys/dev/ic/rtl8169.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/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.178 src/sys/dev/ic/rtl8169.c:1.179
--- src/sys/dev/ic/rtl8169.c:1.178	Mon Aug 12 14:55:01 2024
+++ src/sys/dev/ic/rtl8169.c	Mon Aug 12 17:27:34 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.178 2024/08/12 18:55:01 christos Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.179 2024/08/12 21:27:34 christos Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.178 2024/08/12 18:55:01 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.179 2024/08/12 21:27:34 christos Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -2179,15 +2179,15 @@ re_stop(struct ifnet *ifp, int disable)
 
 	mii_down(&sc->mii);
 
-/*  
- * Disable accepting frames to put RX MAC into idle state.
- * Otherwise it's possible to get frames while stop command
- * execution is in progress and controller can DMA the frame
- * to already freed RX buffer during that period.
- */ 
-CSR_WRITE_4(sc, RTK_RXCFG, CSR_READ_4(sc, RTK_RXCFG) &
-~(RTK_RXCFG_RX_ALLPHYS | RTK_RXCFG_RX_INDIV | RTK_RXCFG_RX_MULTI |
-RTK_RXCFG_RX_BROAD));
+	/*
+	 * Disable accepting frames to put RX MAC into idle state.
+	 * Otherwise it's possible to get frames while stop command
+	 * execution is in progress and controller can DMA the frame
+	 * to already freed RX buffer during that period.
+	 */
+	CSR_WRITE_4(sc, RTK_RXCFG, CSR_READ_4(sc, RTK_RXCFG) &
+	~(RTK_RXCFG_RX_ALLPHYS | RTK_RXCFG_RX_INDIV | RTK_RXCFG_RX_MULTI |
+	RTK_RXCFG_RX_BROAD));
 
 	if (sc->sc_quirk & RTKQ_RXDV_GATED) {
 		CSR_WRITE_4(sc, RTK_MISC,



CVS commit: src/sys/dev/ic

2024-08-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Aug 12 21:27:34 UTC 2024

Modified Files:
src/sys/dev/ic: rtl8169.c

Log Message:
fix whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/sys/dev/ic/rtl8169.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Aug 12 18:55:01 UTC 2024

Modified Files:
src/sys/dev/ic: rtl8169.c rtl81x9reg.h rtl81x9var.h

Log Message:
PR/58588: Christos Zoulas: Avoid crashes when exiting promiscuous mode (^C
tcpdump) by disabling RX in re_stop. Also add some earlyoff stuff while here.
>From FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/ic/rtl81x9reg.h
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/ic/rtl81x9var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-12 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Aug 12 18:55:01 UTC 2024

Modified Files:
src/sys/dev/ic: rtl8169.c rtl81x9reg.h rtl81x9var.h

Log Message:
PR/58588: Christos Zoulas: Avoid crashes when exiting promiscuous mode (^C
tcpdump) by disabling RX in re_stop. Also add some earlyoff stuff while here.
>From FreeBSD.


To generate a diff of this commit:
cvs rdiff -u -r1.177 -r1.178 src/sys/dev/ic/rtl8169.c
cvs rdiff -u -r1.54 -r1.55 src/sys/dev/ic/rtl81x9reg.h
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/ic/rtl81x9var.h

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/ic/rtl8169.c
diff -u src/sys/dev/ic/rtl8169.c:1.177 src/sys/dev/ic/rtl8169.c:1.178
--- src/sys/dev/ic/rtl8169.c:1.177	Fri Jul  5 00:31:51 2024
+++ src/sys/dev/ic/rtl8169.c	Mon Aug 12 14:55:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl8169.c,v 1.177 2024/07/05 04:31:51 rin Exp $	*/
+/*	$NetBSD: rtl8169.c,v 1.178 2024/08/12 18:55:01 christos Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998-2003
@@ -33,7 +33,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.177 2024/07/05 04:31:51 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rtl8169.c,v 1.178 2024/08/12 18:55:01 christos Exp $");
 /* $FreeBSD: /repoman/r/ncvs/src/sys/dev/re/if_re.c,v 1.20 2004/04/11 20:34:08 ru Exp $ */
 
 /*
@@ -669,6 +669,8 @@ re_attach(struct rtk_softc *sc)
 			break;
 		case RTK_HWREV_8168E_VL:
 		case RTK_HWREV_8168F:
+			sc->sc_quirk |= RTKQ_EARLYOFF;
+			/*FALLTHROUGH*/
 		case RTK_HWREV_8411:
 			sc->sc_quirk |= RTKQ_DESCV2 | RTKQ_NOEECMD |
 			RTKQ_MACSTAT | RTKQ_CMDSTOP | RTKQ_NOJUMBO;
@@ -1969,6 +1971,10 @@ re_init(struct ifnet *ifp)
 	/* Set the individual bit to receive frames for this host only. */
 	rxcfg = CSR_READ_4(sc, RTK_RXCFG);
 	rxcfg |= RTK_RXCFG_RX_INDIV;
+	if (sc->sc_quirk & RTKQ_EARLYOFF)
+		rxcfg |= RTK_RXCFG_EARLYOFF;
+	else if (sc->sc_quirk & RTKQ_RXDV_GATED)
+		rxcfg |= RTK_RXCFG_EARLYOFFV2;
 
 	/* If we want promiscuous mode, set the allframes bit. */
 	if (ifp->if_flags & IFF_PROMISC)
@@ -2173,6 +2179,21 @@ re_stop(struct ifnet *ifp, int disable)
 
 	mii_down(&sc->mii);
 
+/*  
+ * Disable accepting frames to put RX MAC into idle state.
+ * Otherwise it's possible to get frames while stop command
+ * execution is in progress and controller can DMA the frame
+ * to already freed RX buffer during that period.
+ */ 
+CSR_WRITE_4(sc, RTK_RXCFG, CSR_READ_4(sc, RTK_RXCFG) &
+~(RTK_RXCFG_RX_ALLPHYS | RTK_RXCFG_RX_INDIV | RTK_RXCFG_RX_MULTI |
+RTK_RXCFG_RX_BROAD));
+
+	if (sc->sc_quirk & RTKQ_RXDV_GATED) {
+		CSR_WRITE_4(sc, RTK_MISC,
+		CSR_READ_4(sc, RTK_MISC) | RTK_MISC_RXDV_GATED_EN);
+	}
+
 	if ((sc->sc_quirk & RTKQ_CMDSTOP) != 0)
 		CSR_WRITE_1(sc, RTK_COMMAND, RTK_CMD_STOPREQ | RTK_CMD_TX_ENB |
 		RTK_CMD_RX_ENB);

Index: src/sys/dev/ic/rtl81x9reg.h
diff -u src/sys/dev/ic/rtl81x9reg.h:1.54 src/sys/dev/ic/rtl81x9reg.h:1.55
--- src/sys/dev/ic/rtl81x9reg.h:1.54	Mon Sep 21 02:57:00 2020
+++ src/sys/dev/ic/rtl81x9reg.h	Mon Aug 12 14:55:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl81x9reg.h,v 1.54 2020/09/21 06:57:00 msaitoh Exp $	*/
+/*	$NetBSD: rtl81x9reg.h,v 1.55 2024/08/12 18:55:01 christos Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998
@@ -291,8 +291,10 @@
 #define RTK_RXCFG_RX_RUNT	0x0010
 #define RTK_RXCFG_RX_ERRPKT	0x0020
 #define RTK_RXCFG_WRAP		0x0080
+#define RTK_RXCFG_EARLYOFFV2	0x0800 
 #define RTK_RXCFG_MAXDMA	0x0700
 #define RTK_RXCFG_BUFSZ		0x1800
+#define RTK_RXCFG_EARLYOFF	0x3800 
 #define RTK_RXCFG_FIFOTHRESH	0xE000
 #define RTK_RXCFG_EARLYTHRESH	0x0700
 

Index: src/sys/dev/ic/rtl81x9var.h
diff -u src/sys/dev/ic/rtl81x9var.h:1.58 src/sys/dev/ic/rtl81x9var.h:1.59
--- src/sys/dev/ic/rtl81x9var.h:1.58	Mon Sep 21 02:57:00 2020
+++ src/sys/dev/ic/rtl81x9var.h	Mon Aug 12 14:55:01 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: rtl81x9var.h,v 1.58 2020/09/21 06:57:00 msaitoh Exp $	*/
+/*	$NetBSD: rtl81x9var.h,v 1.59 2024/08/12 18:55:01 christos Exp $	*/
 
 /*
  * Copyright (c) 1997, 1998
@@ -196,6 +196,7 @@ struct rtk_softc {
 #define RTKQ_RXDV_GATED		0x0800
 #define RTKQ_IM_HW		0x1000	/* HW interrupt mitigation */
 #define RTKQ_TXRXEN_LATER	0x2000	/* TX/RX enable timing */
+#define RTKQ_EARLYOFF		0x4000	/* Enable early receive? */
 
 	bus_dma_tag_t		sc_dmat;
 



CVS commit: src/sys/dev/ic

2024-08-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug 11 12:48:09 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c dwc_gmac_var.h

Log Message:
awge(4): Narrow scope of `core' lock and rename to mcast lock.

Sprinkle locking notes.

Proposed at:

https://mail-index.netbsd.org/source-changes-d/2024/08/10/msg014251.html

Comment-only changes from the updated patch at:

https://mail-index.netbsd.org/source-changes-d/2024/08/10/msg014252.html


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/ic/dwc_gmac.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/ic/dwc_gmac_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Aug 11 12:48:09 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c dwc_gmac_var.h

Log Message:
awge(4): Narrow scope of `core' lock and rename to mcast lock.

Sprinkle locking notes.

Proposed at:

https://mail-index.netbsd.org/source-changes-d/2024/08/10/msg014251.html

Comment-only changes from the updated patch at:

https://mail-index.netbsd.org/source-changes-d/2024/08/10/msg014252.html


To generate a diff of this commit:
cvs rdiff -u -r1.93 -r1.94 src/sys/dev/ic/dwc_gmac.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/ic/dwc_gmac_var.h

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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.93 src/sys/dev/ic/dwc_gmac.c:1.94
--- src/sys/dev/ic/dwc_gmac.c:1.93	Sat Aug 10 12:16:47 2024
+++ src/sys/dev/ic/dwc_gmac.c	Sun Aug 11 12:48:09 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.93 2024/08/10 12:16:47 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.94 2024/08/11 12:48:09 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -39,9 +39,16 @@
  *  http://www.synopsys.com/dw/ipdir.php?ds=dwc_ether_mac10_100_1000_unive
  */
 
+/*
+ * Lock order:
+ *
+ *	IFNET_LOCK -> sc_mcast_lock
+ *	IFNET_LOCK -> sc_intr_lock -> {sc_txq.t_mtx, sc_rxq.r_mtx}
+ */
+
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.93 2024/08/10 12:16:47 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.94 2024/08/11 12:48:09 riastradh Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -87,9 +94,7 @@ static void dwc_gmac_reset_tx_ring(struc
 static void dwc_gmac_free_tx_ring(struct dwc_gmac_softc *, struct dwc_gmac_tx_ring *);
 static void dwc_gmac_txdesc_sync(struct dwc_gmac_softc *, int, int, int);
 static int dwc_gmac_init(struct ifnet *);
-static int dwc_gmac_init_locked(struct ifnet *);
 static void dwc_gmac_stop(struct ifnet *, int);
-static void dwc_gmac_stop_locked(struct ifnet *, int);
 static void dwc_gmac_start(struct ifnet *);
 static void dwc_gmac_start_locked(struct ifnet *);
 static int dwc_gmac_queue(struct dwc_gmac_softc *, struct mbuf *);
@@ -297,7 +302,7 @@ dwc_gmac_attach(struct dwc_gmac_softc *s
 	sc->sc_stopping = false;
 	sc->sc_txbusy = false;
 
-	sc->sc_core_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NONE);
+	sc->sc_mcast_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_SOFTNET);
 	sc->sc_intr_lock = mutex_obj_alloc(MUTEX_DEFAULT, IPL_NET);
 	mutex_init(&sc->sc_txq.t_mtx, MUTEX_DEFAULT, IPL_NET);
 	mutex_init(&sc->sc_rxq.r_mtx, MUTEX_DEFAULT, IPL_NET);
@@ -863,28 +868,13 @@ static int
 dwc_gmac_init(struct ifnet *ifp)
 {
 	struct dwc_gmac_softc * const sc = ifp->if_softc;
-
-	KASSERT(IFNET_LOCKED(ifp));
-
-	mutex_enter(sc->sc_core_lock);
-	int ret = dwc_gmac_init_locked(ifp);
-	mutex_exit(sc->sc_core_lock);
-
-	return ret;
-}
-
-static int
-dwc_gmac_init_locked(struct ifnet *ifp)
-{
-	struct dwc_gmac_softc * const sc = ifp->if_softc;
 	uint32_t ffilt;
 
 	ASSERT_SLEEPABLE();
 	KASSERT(IFNET_LOCKED(ifp));
-	KASSERT(mutex_owned(sc->sc_core_lock));
 	KASSERT(ifp == &sc->sc_ec.ec_if);
 
-	dwc_gmac_stop_locked(ifp, 0);
+	dwc_gmac_stop(ifp, 0);
 
 	/*
 	 * Configure DMA burst/transfer mode and RX/TX priorities.
@@ -914,7 +904,9 @@ dwc_gmac_init_locked(struct ifnet *ifp)
 	/*
 	 * Set up multicast filter
 	 */
+	mutex_enter(sc->sc_mcast_lock);
 	dwc_gmac_setmulti(sc);
+	mutex_exit(sc->sc_mcast_lock);
 
 	/*
 	 * Set up dma pointer for RX and TX ring
@@ -942,11 +934,11 @@ dwc_gmac_init_locked(struct ifnet *ifp)
 
 	mutex_enter(sc->sc_intr_lock);
 	sc->sc_stopping = false;
+	mutex_exit(sc->sc_intr_lock);
 
 	mutex_enter(&sc->sc_txq.t_mtx);
 	sc->sc_txbusy = false;
 	mutex_exit(&sc->sc_txq.t_mtx);
-	mutex_exit(sc->sc_intr_lock);
 
 	return 0;
 }
@@ -1015,29 +1007,23 @@ dwc_gmac_stop(struct ifnet *ifp, int dis
 {
 	struct dwc_gmac_softc * const sc = ifp->if_softc;
 
-	mutex_enter(sc->sc_core_lock);
-	dwc_gmac_stop_locked(ifp, disable);
-	mutex_exit(sc->sc_core_lock);
-}
-
-static void
-dwc_gmac_stop_locked(struct ifnet *ifp, int disable)
-{
-	struct dwc_gmac_softc * const sc = ifp->if_softc;
-
 	ASSERT_SLEEPABLE();
 	KASSERT(IFNET_LOCKED(ifp));
-	KASSERT(mutex_owned(sc->sc_core_lock));
+
+	ifp->if_flags &= ~IFF_RUNNING;
+
+	mutex_enter(sc->sc_mcast_lock);
+	sc->sc_if_flags = ifp->if_flags;
+	mutex_exit(sc->sc_mcast_lock);
 
 	mutex_enter(sc->sc_intr_lock);
 	sc->sc_stopping = true;
+	mutex_exit(sc->sc_intr_lock);
 
 	mutex_enter(&sc->sc_txq.t_mtx);
 	sc->sc_txbusy = false;
 	mutex_exit(&sc->sc_txq.t_mtx);
 
-	mutex_exit(sc->sc_intr_lock);
-
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh,
 	AWIN_GMAC_DMA_OPMODE,
 	bus_space_read_4(sc->sc_bst, sc->sc_bsh,
@@ -1051,9 +1037,6 @@ dwc_gmac_stop_locked(struct ifnet *ifp, 
 	mii_down(&sc->sc_mii);
 	dwc_gmac_reset_tx_ring(sc, &sc->sc_txq);
 	dwc_gmac_reset_rx_ring(sc, &sc->sc_rxq);
-
-	ifp->if_flags &= ~IFF_RUNNING;
-	sc->sc_if_flags = i

CVS commit: src/sys/dev/ic

2024-08-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 10 12:11:14 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Sprinkle some const


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.91 src/sys/dev/ic/dwc_gmac.c:1.92
--- src/sys/dev/ic/dwc_gmac.c:1.91	Sat Jul 27 12:56:27 2024
+++ src/sys/dev/ic/dwc_gmac.c	Sat Aug 10 12:11:14 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.91 2024/07/27 12:56:27 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.92 2024/08/10 12:11:14 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.91 2024/07/27 12:56:27 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.92 2024/08/10 12:11:14 skrll Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -860,7 +860,7 @@ dwc_gmac_miibus_statchg(struct ifnet *if
 static int
 dwc_gmac_init(struct ifnet *ifp)
 {
-	struct dwc_gmac_softc *sc = ifp->if_softc;
+	struct dwc_gmac_softc * const sc = ifp->if_softc;
 
 	mutex_enter(sc->sc_lock);
 	int ret = dwc_gmac_init_locked(ifp);
@@ -872,7 +872,7 @@ dwc_gmac_init(struct ifnet *ifp)
 static int
 dwc_gmac_init_locked(struct ifnet *ifp)
 {
-	struct dwc_gmac_softc *sc = ifp->if_softc;
+	struct dwc_gmac_softc * const sc = ifp->if_softc;
 	uint32_t ffilt;
 
 	if (ifp->if_flags & IFF_RUNNING)
@@ -942,7 +942,7 @@ dwc_gmac_init_locked(struct ifnet *ifp)
 static void
 dwc_gmac_start(struct ifnet *ifp)
 {
-	struct dwc_gmac_softc *sc = ifp->if_softc;
+	struct dwc_gmac_softc * const sc = ifp->if_softc;
 #ifdef DWCGMAC_MPSAFE
 	KASSERT(if_is_mpsafe(ifp));
 #endif
@@ -959,7 +959,7 @@ dwc_gmac_start(struct ifnet *ifp)
 static void
 dwc_gmac_start_locked(struct ifnet *ifp)
 {
-	struct dwc_gmac_softc *sc = ifp->if_softc;
+	struct dwc_gmac_softc * const sc = ifp->if_softc;
 	int old = sc->sc_txq.t_queued;
 	int start = sc->sc_txq.t_cur;
 	struct mbuf *m0;
@@ -1001,7 +1001,7 @@ dwc_gmac_start_locked(struct ifnet *ifp)
 static void
 dwc_gmac_stop(struct ifnet *ifp, int disable)
 {
-	struct dwc_gmac_softc *sc = ifp->if_softc;
+	struct dwc_gmac_softc * const sc = ifp->if_softc;
 
 	mutex_enter(sc->sc_lock);
 	dwc_gmac_stop_locked(ifp, disable);
@@ -1011,7 +1011,7 @@ dwc_gmac_stop(struct ifnet *ifp, int dis
 static void
 dwc_gmac_stop_locked(struct ifnet *ifp, int disable)
 {
-	struct dwc_gmac_softc *sc = ifp->if_softc;
+	struct dwc_gmac_softc * const sc = ifp->if_softc;
 
 	sc->sc_stopping = true;
 
@@ -1122,8 +1122,8 @@ dwc_gmac_queue(struct dwc_gmac_softc *sc
 static int
 dwc_gmac_ifflags_cb(struct ethercom *ec)
 {
-	struct ifnet *ifp = &ec->ec_if;
-	struct dwc_gmac_softc *sc = ifp->if_softc;
+	struct ifnet * const ifp = &ec->ec_if;
+	struct dwc_gmac_softc * const sc = ifp->if_softc;
 	int ret = 0;
 
 	mutex_enter(sc->sc_lock);
@@ -1146,7 +1146,7 @@ out:
 static int
 dwc_gmac_ioctl(struct ifnet *ifp, u_long cmd, void *data)
 {
-	struct dwc_gmac_softc *sc = ifp->if_softc;
+	struct dwc_gmac_softc * const sc = ifp->if_softc;
 	int error = 0;
 
 	int s = splnet();
@@ -1186,7 +1186,7 @@ dwc_gmac_ioctl(struct ifnet *ifp, u_long
 static void
 dwc_gmac_tx_intr(struct dwc_gmac_softc *sc)
 {
-	struct ifnet *ifp = &sc->sc_ec.ec_if;
+	struct ifnet * const ifp = &sc->sc_ec.ec_if;
 	struct dwc_gmac_tx_data *data;
 	struct dwc_gmac_dev_dmadesc *desc;
 	int i, nsegs;
@@ -1245,7 +1245,7 @@ dwc_gmac_tx_intr(struct dwc_gmac_softc *
 static void
 dwc_gmac_rx_intr(struct dwc_gmac_softc *sc)
 {
-	struct ifnet *ifp = &sc->sc_ec.ec_if;
+	struct ifnet * const ifp = &sc->sc_ec.ec_if;
 	struct dwc_gmac_dev_dmadesc *desc;
 	struct dwc_gmac_rx_data *data;
 	bus_addr_t physaddr;



CVS commit: src/sys/dev/ic

2024-08-10 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Aug 10 12:11:14 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Sprinkle some const


To generate a diff of this commit:
cvs rdiff -u -r1.91 -r1.92 src/sys/dev/ic/dwc_gmac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Aug  8 06:44:20 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac_var.h

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/dwc_gmac_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-07 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Aug  8 06:44:20 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac_var.h

Log Message:
KNF


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/dev/ic/dwc_gmac_var.h

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/ic/dwc_gmac_var.h
diff -u src/sys/dev/ic/dwc_gmac_var.h:1.19 src/sys/dev/ic/dwc_gmac_var.h:1.20
--- src/sys/dev/ic/dwc_gmac_var.h:1.19	Tue Feb 27 08:33:06 2024
+++ src/sys/dev/ic/dwc_gmac_var.h	Thu Aug  8 06:44:19 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac_var.h,v 1.19 2024/02/27 08:33:06 skrll Exp $ */
+/* $NetBSD: dwc_gmac_var.h,v 1.20 2024/08/08 06:44:19 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -129,6 +129,6 @@ struct dwc_gmac_softc {
 	void (*sc_set_speed)(struct dwc_gmac_softc *, int);
 };
 
-int dwc_gmac_attach(struct dwc_gmac_softc*, int /*phy_id*/,
+int dwc_gmac_attach(struct dwc_gmac_softc *, int /*phy_id*/,
 uint32_t /*mii_clk*/);
-int dwc_gmac_intr(struct dwc_gmac_softc*);
+int dwc_gmac_intr(struct dwc_gmac_softc *);



CVS commit: src/sys/dev/ic

2024-08-06 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Aug  6 07:26:56 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
moar bits & pieces


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ic/stireg.h

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/ic/stireg.h
diff -u src/sys/dev/ic/stireg.h:1.11 src/sys/dev/ic/stireg.h:1.12
--- src/sys/dev/ic/stireg.h:1.11	Mon Aug  5 09:43:37 2024
+++ src/sys/dev/ic/stireg.h	Tue Aug  6 07:26:56 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: stireg.h,v 1.11 2024/08/05 09:43:37 macallan Exp $	*/
+/*	$NetBSD: stireg.h,v 1.12 2024/08/06 07:26:56 macallan Exp $	*/
 
 /*	$OpenBSD: stireg.h,v 1.14 2015/04/05 23:25:57 miod Exp $	*/
 
@@ -644,23 +644,28 @@ STI_DEP(util);
 
 #define BA(F,C,S,A,J,B,I)		\
 	(((F)<<31)|((C)<<27)|((S)<<24)|((A)<<21)|((J)<<16)|((B)<<12)|(I))
-	/* FSSSAAAJ */
+	/* FCCC CSSS AAAJ      */
 
 #define IBOvals(R,M,X,S,D,L,B,F)	\
 	(((R)<<8)|((M)<<16)|((X)<<24)|((S)<<29)|((D)<<28)|((L)<<31)|((B)<<1)|(F))
-	/* LSSD??BF */
+	/* LSSD       ??BF */
 
 #define	IndexedDcd	0	/* Pixel data is indexed (pseudo) color */
+#define	FractDcd	1	/* Pixel data is Fractional 8-8-8 */
 #define	Otc04	2	/* Pixels in each longword transfer (4) */
 #define	Otc32	5	/* Pixels in each longword transfer (32) */
+#define	Otc24	7	/* NGLE uses this for 24bit blits */
 #define	Ots08	3	/* Each pixel is size (8)d transfer (1) */
 #define	OtsIndirect	6	/* Each bit goes through FG/BG color(8) */
+#define	AddrByte	3	/* byte access? Used by NGLE for direct fb */
 #define	AddrLong	5	/* FB address is Long aligned (pixel) */
-#define	BINovly	0x2	/* 8 bit overlay */
 #define	BINapp0I	0x0	/* Application Buffer 0, Indexed */
 #define	BINapp1I	0x1	/* Application Buffer 1, Indexed */
+#define	BINovly	0x2	/* 8 bit overlay */
+#define	BINcursor	0x7	/* cursor bitmap on EG */
 #define	BINapp0F8	0xa	/* Application Buffer 0, Fractional 8-8-8 */
 #define	BINattr	0xd	/* Attribute Bitmap */
+#define	BINcmap	0xf	/* colour map(s) */
 #define	RopClr 	0x0
 #define	RopSrc 	0x3
 #define	RopInv 	0xc



CVS commit: src/sys/dev/ic

2024-08-06 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Aug  6 07:26:56 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
moar bits & pieces


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/ic/stireg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-08-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Aug  5 09:43:38 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
describe more register functions


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ic/stireg.h

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/ic/stireg.h
diff -u src/sys/dev/ic/stireg.h:1.10 src/sys/dev/ic/stireg.h:1.11
--- src/sys/dev/ic/stireg.h:1.10	Wed Jul 31 09:54:13 2024
+++ src/sys/dev/ic/stireg.h	Mon Aug  5 09:43:37 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: stireg.h,v 1.10 2024/07/31 09:54:13 macallan Exp $	*/
+/*	$NetBSD: stireg.h,v 1.11 2024/08/05 09:43:37 macallan Exp $	*/
 
 /*	$OpenBSD: stireg.h,v 1.14 2015/04/05 23:25:57 miod Exp $	*/
 
@@ -672,11 +672,11 @@ STI_DEP(util);
 #define	MaskOtc	0	/* Mask contains Object Count valid bits */
 
 #define	NGLE_REG_1		0x000118	/* Artist LUT blt ctrl */
-#define	NGLE_REG_28		0x000420
-#define	NGLE_REG_2		0x000480	/* LUT blt src? */
-#define	NGLE_REG_3		0x0004a0	/* palette index */
-#define	NGLE_REG_22		0x0005a0
-#define	NGLE_REG_23		0x0005c0
+#define	NGLE_REG_28		0x000420	/* HCRX video bus access */
+#define	NGLE_REG_2		0x000480	/* BINC src */
+#define	NGLE_REG_3		0x0004a0	/* BINC dst */
+#define	NGLE_REG_22		0x0005a0	/* BINC dst mask */
+#define	NGLE_REG_23		0x0005c0	/* BINC data */
 #define	NGLE_REG_4		0x000600	/* palette data */
 #define	NGLE_REG_5		0x0006a0	/* cursor data */
 #define	NGLE_REG_6		0x000800	/* rectfill XY */
@@ -691,19 +691,20 @@ STI_DEP(util);
 #define	NGLE_REG_11		0x018004	/* dest bitmap access */
 #define	NGLE_REG_12		0x01800c	/* control plane register */
 #define	NGLE_REG_35		0x018010	/* fg color */
-#define	NGLE_REG_36		0x018014
+#define	NGLE_REG_36		0x018014	/* bg colour? */
 #define	NGLE_REG_13		0x018018	/* image planemask */
 #define	NGLE_REG_14		0x01801c	/* raster op */
-#define	NGLE_REG_15		0x20
+#define	NGLE_REG_15		0x20	/* 'busy dodger' idle */
+	#define DODGER_IDLE	0x1000	/* or 0x1, likely tpyo */
 #define	NGLE_REG_15b0		0x20	/* busy register */
 #define	NGLE_REG_16		0x24
-#define	NGLE_REG_16b1		0x25
-#define	NGLE_REG_16b3		0x27
+#define	NGLE_REG_16b1		0x25	/* setup copyarea */
+#define	NGLE_REG_16b3		0x27	/* ROM table index on CRX */
 #define	NGLE_REG_34		0x28	/* # of fifo slots */
 #define	NGLE_REG_17		0x200100	/* cursor coordinates */
 #define	NGLE_REG_18		0x200104	/* cursor enable */
 #define	NGLE_REG_26		0x200118	/* EG LUT blt ctrl */
-#define	NGLE_REG_19		0x200200
+#define	NGLE_REG_19		0x200200	/* artist sprite size */
 #define	NGLE_REG_20		0x200208	/* cursor geometry */
 #define	NGLE_REG_21		0x200218	/* Artist misc video */
 #define	NGLE_REG_27		0x200308	/* Artist misc ctrl */
@@ -722,11 +723,11 @@ STI_DEP(util);
 	#define LBC_TYPE_OVERLAY	0xc000
 	#define LBC_LENGTH_SHIFT	0
 #define	NGLE_REG_41		0x210024
-#define	NGLE_REG_42		0x210028
-#define	NGLE_REG_43		0x21002c
-#define	NGLE_REG_44		0x210030
-#define	NGLE_REG_45		0x210034
-#define	NGLE_REG_32		0x21003c
+#define	NGLE_REG_42		0x210028	/* these seem to control */
+#define	NGLE_REG_43		0x21002c	/* how the 24bit planes */
+#define	NGLE_REG_44		0x210030	/* are displayed on HCRX - */
+#define	NGLE_REG_45		0x210034	/* no info on bits */
+#define	NGLE_REG_32		0x21003c	/* HCRX plane enable */ 
 #define	NGLE_REG_33		0x210040	/* HCRX misc video */
 	#define HCRX_VIDEO_ENABLE	0x0A00
 #define	NGLE_REG_39		0x210120	/* HCRX 'hyperbowl' mode 2 */



CVS commit: src/sys/dev/ic

2024-08-05 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Aug  5 09:43:38 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
describe more register functions


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/dev/ic/stireg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-07-31 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 31 09:54:13 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
moar ROPs


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/stireg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-07-31 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 31 09:54:13 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
moar ROPs


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/ic/stireg.h

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/ic/stireg.h
diff -u src/sys/dev/ic/stireg.h:1.9 src/sys/dev/ic/stireg.h:1.10
--- src/sys/dev/ic/stireg.h:1.9	Wed Jul 17 08:28:22 2024
+++ src/sys/dev/ic/stireg.h	Wed Jul 31 09:54:13 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: stireg.h,v 1.9 2024/07/17 08:28:22 macallan Exp $	*/
+/*	$NetBSD: stireg.h,v 1.10 2024/07/31 09:54:13 macallan Exp $	*/
 
 /*	$OpenBSD: stireg.h,v 1.14 2015/04/05 23:25:57 miod Exp $	*/
 
@@ -648,7 +648,7 @@ STI_DEP(util);
 
 #define IBOvals(R,M,X,S,D,L,B,F)	\
 	(((R)<<8)|((M)<<16)|((X)<<24)|((S)<<29)|((D)<<28)|((L)<<31)|((B)<<1)|(F))
-	/* LSSDBBBF */
+	/* LSSD??BF */
 
 #define	IndexedDcd	0	/* Pixel data is indexed (pseudo) color */
 #define	Otc04	2	/* Pixels in each longword transfer (4) */
@@ -661,8 +661,10 @@ STI_DEP(util);
 #define	BINapp1I	0x1	/* Application Buffer 1, Indexed */
 #define	BINapp0F8	0xa	/* Application Buffer 0, Fractional 8-8-8 */
 #define	BINattr	0xd	/* Attribute Bitmap */
+#define	RopClr 	0x0
 #define	RopSrc 	0x3
 #define	RopInv 	0xc
+#define	RopSet 	0xf
 #define	BitmapExtent08  3	/* Each write hits ( 8) bits in depth */
 #define	BitmapExtent32  5	/* Each write hits (32) bits in depth */
 #define	DataDynamic	0	/* Data register reloaded by direct access */



CVS commit: src/sys/dev/ic

2024-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul 27 12:56:27 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c dwc_gmac_reg.h

Log Message:
Handle GMAC_MAC_Version's that include USERVER.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/dev/ic/dwc_gmac.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ic/dwc_gmac_reg.h

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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.90 src/sys/dev/ic/dwc_gmac.c:1.91
--- src/sys/dev/ic/dwc_gmac.c:1.90	Sun Jul 14 09:38:41 2024
+++ src/sys/dev/ic/dwc_gmac.c	Sat Jul 27 12:56:27 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.90 2024/07/14 09:38:41 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.91 2024/07/27 12:56:27 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.90 2024/07/14 09:38:41 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.91 2024/07/27 12:56:27 skrll Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -182,7 +182,7 @@ int
 dwc_gmac_attach(struct dwc_gmac_softc *sc, int phy_id, uint32_t mii_clk)
 {
 	uint8_t enaddr[ETHER_ADDR_LEN];
-	uint32_t maclo, machi, ver, hwft;
+	uint32_t maclo, machi, hwft;
 	struct mii_data * const mii = &sc->sc_mii;
 	struct ifnet * const ifp = &sc->sc_ec.ec_if;
 	prop_dictionary_t dict;
@@ -225,8 +225,11 @@ dwc_gmac_attach(struct dwc_gmac_softc *s
 		enaddr[5] = (machi >> 8) & 0x0ff;
 	}
 
-	ver = bus_space_read_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_MAC_VERSION);
-	aprint_normal_dev(sc->sc_dev, "Core version: %08x\n", ver);
+	const uint32_t ver =
+	bus_space_read_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_MAC_VERSION);
+	const uint32_t snpsver =
+	__SHIFTOUT(ver, AWIN_GMAC_MAC_VERSION_SNPSVER_MASK);
+	aprint_normal_dev(sc->sc_dev, "Core version: %08x\n", snpsver);
 
 	/*
 	 * Init chip and do initial setup
@@ -238,7 +241,7 @@ dwc_gmac_attach(struct dwc_gmac_softc *s
 	ether_sprintf(enaddr));
 
 	hwft = 0;
-	if (ver >= 0x35) {
+	if (snpsver >= 0x35) {
 		hwft = bus_space_read_4(sc->sc_bst, sc->sc_bsh,
 		AWIN_GMAC_DMA_HWFEATURES);
 		aprint_normal_dev(sc->sc_dev,

Index: src/sys/dev/ic/dwc_gmac_reg.h
diff -u src/sys/dev/ic/dwc_gmac_reg.h:1.22 src/sys/dev/ic/dwc_gmac_reg.h:1.23
--- src/sys/dev/ic/dwc_gmac_reg.h:1.22	Tue Feb 27 08:21:24 2024
+++ src/sys/dev/ic/dwc_gmac_reg.h	Sat Jul 27 12:56:27 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac_reg.h,v 1.22 2024/02/27 08:21:24 skrll Exp $ */
+/* $NetBSD: dwc_gmac_reg.h,v 1.23 2024/07/27 12:56:27 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -38,6 +38,8 @@
 #define	AWIN_GMAC_MAC_FLOWCTRL		0x0018
 #define	AWIN_GMAC_MAC_VLANTAG		0x001c
 #define	AWIN_GMAC_MAC_VERSION		0x0020	/* not always implemented? */
+#define	 AWIN_GMAC_MAC_VERSION_USERVER_MASK	__BITS(15, 8)
+#define	 AWIN_GMAC_MAC_VERSION_SNPSVER_MASK	__BITS( 7, 0)
 #define	AWIN_GMAC_MAC_INTR		0x0038
 #define	AWIN_GMAC_MAC_INTMASK		0x003c
 #define	AWIN_GMAC_MAC_ADDR0HI		0x0040



CVS commit: src/sys/dev/ic

2024-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Jul 27 12:56:27 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c dwc_gmac_reg.h

Log Message:
Handle GMAC_MAC_Version's that include USERVER.


To generate a diff of this commit:
cvs rdiff -u -r1.90 -r1.91 src/sys/dev/ic/dwc_gmac.c
cvs rdiff -u -r1.22 -r1.23 src/sys/dev/ic/dwc_gmac_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-07-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 17 08:28:22 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
moar bits
these should probably go into their own header since they don't actually
have anything to do with STI


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/stireg.h

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/ic/stireg.h
diff -u src/sys/dev/ic/stireg.h:1.8 src/sys/dev/ic/stireg.h:1.9
--- src/sys/dev/ic/stireg.h:1.8	Wed Jul 17 07:06:21 2024
+++ src/sys/dev/ic/stireg.h	Wed Jul 17 08:28:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: stireg.h,v 1.8 2024/07/17 07:06:21 macallan Exp $	*/
+/*	$NetBSD: stireg.h,v 1.9 2024/07/17 08:28:22 macallan Exp $	*/
 
 /*	$OpenBSD: stireg.h,v 1.14 2015/04/05 23:25:57 miod Exp $	*/
 
@@ -641,6 +641,34 @@ STI_DEP(util);
  * NGLE register layout.
  * Based upon xc/programs/Xserver/hw/hp/ngle/dregs.h
  */
+
+#define BA(F,C,S,A,J,B,I)		\
+	(((F)<<31)|((C)<<27)|((S)<<24)|((A)<<21)|((J)<<16)|((B)<<12)|(I))
+	/* FSSSAAAJ */
+
+#define IBOvals(R,M,X,S,D,L,B,F)	\
+	(((R)<<8)|((M)<<16)|((X)<<24)|((S)<<29)|((D)<<28)|((L)<<31)|((B)<<1)|(F))
+	/* LSSDBBBF */
+
+#define	IndexedDcd	0	/* Pixel data is indexed (pseudo) color */
+#define	Otc04	2	/* Pixels in each longword transfer (4) */
+#define	Otc32	5	/* Pixels in each longword transfer (32) */
+#define	Ots08	3	/* Each pixel is size (8)d transfer (1) */
+#define	OtsIndirect	6	/* Each bit goes through FG/BG color(8) */
+#define	AddrLong	5	/* FB address is Long aligned (pixel) */
+#define	BINovly	0x2	/* 8 bit overlay */
+#define	BINapp0I	0x0	/* Application Buffer 0, Indexed */
+#define	BINapp1I	0x1	/* Application Buffer 1, Indexed */
+#define	BINapp0F8	0xa	/* Application Buffer 0, Fractional 8-8-8 */
+#define	BINattr	0xd	/* Attribute Bitmap */
+#define	RopSrc 	0x3
+#define	RopInv 	0xc
+#define	BitmapExtent08  3	/* Each write hits ( 8) bits in depth */
+#define	BitmapExtent32  5	/* Each write hits (32) bits in depth */
+#define	DataDynamic	0	/* Data register reloaded by direct access */
+#define	MaskDynamic	1	/* Mask register reloaded by direct access */
+#define	MaskOtc	0	/* Mask contains Object Count valid bits */
+
 #define	NGLE_REG_1		0x000118	/* Artist LUT blt ctrl */
 #define	NGLE_REG_28		0x000420
 #define	NGLE_REG_2		0x000480	/* LUT blt src? */



CVS commit: src/sys/dev/ic

2024-07-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 17 08:28:22 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
moar bits
these should probably go into their own header since they don't actually
have anything to do with STI


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/ic/stireg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-07-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 17 07:06:22 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
document a few more registers & bits


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/stireg.h

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/ic/stireg.h
diff -u src/sys/dev/ic/stireg.h:1.7 src/sys/dev/ic/stireg.h:1.8
--- src/sys/dev/ic/stireg.h:1.7	Mon Jul 15 10:30:42 2024
+++ src/sys/dev/ic/stireg.h	Wed Jul 17 07:06:21 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: stireg.h,v 1.7 2024/07/15 10:30:42 macallan Exp $	*/
+/*	$NetBSD: stireg.h,v 1.8 2024/07/17 07:06:21 macallan Exp $	*/
 
 /*	$OpenBSD: stireg.h,v 1.14 2015/04/05 23:25:57 miod Exp $	*/
 
@@ -641,9 +641,9 @@ STI_DEP(util);
  * NGLE register layout.
  * Based upon xc/programs/Xserver/hw/hp/ngle/dregs.h
  */
-#define	NGLE_REG_1		0x000118
+#define	NGLE_REG_1		0x000118	/* Artist LUT blt ctrl */
 #define	NGLE_REG_28		0x000420
-#define	NGLE_REG_2		0x000480
+#define	NGLE_REG_2		0x000480	/* LUT blt src? */
 #define	NGLE_REG_3		0x0004a0	/* palette index */
 #define	NGLE_REG_22		0x0005a0
 #define	NGLE_REG_23		0x0005c0
@@ -672,15 +672,25 @@ STI_DEP(util);
 #define	NGLE_REG_34		0x28	/* # of fifo slots */
 #define	NGLE_REG_17		0x200100	/* cursor coordinates */
 #define	NGLE_REG_18		0x200104	/* cursor enable */
-#define	NGLE_REG_26		0x200118
+#define	NGLE_REG_26		0x200118	/* EG LUT blt ctrl */
 #define	NGLE_REG_19		0x200200
 #define	NGLE_REG_20		0x200208	/* cursor geometry */
 #define	NGLE_REG_21		0x200218	/* Artist misc video */
 #define	NGLE_REG_27		0x200308	/* Artist misc ctrl */
 #define	NGLE_REG_29		0x21	/* HCRX cursor coord & enable */
+	#define HCRX_ENABLE_CURSOR	0x8000
 #define	NGLE_REG_30		0x210004	/* HCRX cursor address */
 #define	NGLE_REG_31		0x210008	/* HCRX cursor data */
-#define	NGLE_REG_38		0x210020	/* colormap data */
+#define	NGLE_REG_38		0x210020	/* HCRX LUT blt ctrl */
+	/* EWOO  TTLL  */
+	#define LBC_ENABLE	0x8000
+	#define LBC_WAIT_BLANK	0x4000
+	#define LBS_OFFSET_SHIFT	16
+	#define LBC_TYPE_MASK		0xc000
+	#define LBC_TYPE_CMAP		0
+	#define LBC_TYPE_CURSOR		0x8000
+	#define LBC_TYPE_OVERLAY	0xc000
+	#define LBC_LENGTH_SHIFT	0
 #define	NGLE_REG_41		0x210024
 #define	NGLE_REG_42		0x210028
 #define	NGLE_REG_43		0x21002c
@@ -688,8 +698,13 @@ STI_DEP(util);
 #define	NGLE_REG_45		0x210034
 #define	NGLE_REG_32		0x21003c
 #define	NGLE_REG_33		0x210040	/* HCRX misc video */
-#define	NGLE_REG_39		0x210120
-#define	NGLE_REG_40		0x210130
+	#define HCRX_VIDEO_ENABLE	0x0A00
+#define	NGLE_REG_39		0x210120	/* HCRX 'hyperbowl' mode 2 */
+	#define HYPERBOWL_MODE2_8_24	15
+#define	NGLE_REG_40		0x210130	/* HCRX 'hyperbowl' */
+	#define HYPERBOWL_MODE_FOR_8_OVER_88_LUT0_NO_TRANSPARENCIES	4
+	#define HYPERBOWL_MODE01_8_24_LUT0_TRANSPARENT_LUT1_OPAQUE	8
+	#define HYPERBOWL_MODE01_8_24_LUT0_OPAQUE_LUT1_OPAQUE		10
 
 #define	NGLE_BUFF0_CMAP0	0x1e02
 #define	NGLE_BUFF1_CMAP0	0x02001e02



CVS commit: src/sys/dev/ic

2024-07-17 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 17 07:06:22 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
document a few more registers & bits


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/stireg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-07-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Jul 15 10:30:42 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
annotate (some) registers if we know what they do
fix a tpyo while there


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/stireg.h

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/ic/stireg.h
diff -u src/sys/dev/ic/stireg.h:1.6 src/sys/dev/ic/stireg.h:1.7
--- src/sys/dev/ic/stireg.h:1.6	Wed Sep  9 11:56:53 2015
+++ src/sys/dev/ic/stireg.h	Mon Jul 15 10:30:42 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: stireg.h,v 1.6 2015/09/09 11:56:53 skrll Exp $	*/
+/*	$NetBSD: stireg.h,v 1.7 2024/07/15 10:30:42 macallan Exp $	*/
 
 /*	$OpenBSD: stireg.h,v 1.14 2015/04/05 23:25:57 miod Exp $	*/
 
@@ -649,16 +649,16 @@ STI_DEP(util);
 #define	NGLE_REG_23		0x0005c0
 #define	NGLE_REG_4		0x000600	/* palette data */
 #define	NGLE_REG_5		0x0006a0	/* cursor data */
-#define	NGLE_REG_6		0x000800
-#define	NGLE_REG_7		0x000804
-#define	NGLE_REG_24		0x000808
-#define	NGLE_REG_8		0x000820
-#define	NGLE_REG_73		0x000944
-#define	NGLE_REG_9		0x000a04
-#define	NGLE_REG_25		0x000b00
+#define	NGLE_REG_6		0x000800	/* rectfill XY */
+#define	NGLE_REG_7		0x000804	/* bitblt size WH */
+#define	NGLE_REG_24		0x000808	/* bitblt src XY */
+#define	NGLE_REG_8		0x000820	/* transfer data */
+#define	NGLE_REG_37		0x000944	/* HCRX fast rect fill, size */
+#define	NGLE_REG_9		0x000a04	/* rect fill size, start */
+#define	NGLE_REG_25		0x000b00	/* bitblt dst XY, start */
 #define	NGLE_REG_RAMDAC		0x001000
-#define	NGLE_REG_10		0x018000
-#define	NGLE_REG_11		0x018004	/* dest coords */
+#define	NGLE_REG_10		0x018000	/* buffer ctl */
+#define	NGLE_REG_11		0x018004	/* dest bitmap access */
 #define	NGLE_REG_12		0x01800c	/* control plane register */
 #define	NGLE_REG_35		0x018010	/* fg color */
 #define	NGLE_REG_36		0x018014



CVS commit: src/sys/dev/ic

2024-07-15 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Mon Jul 15 10:30:42 UTC 2024

Modified Files:
src/sys/dev/ic: stireg.h

Log Message:
annotate (some) registers if we know what they do
fix a tpyo while there


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/stireg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-07-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul 14 09:38:42 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Improve and add new debug output


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/dev/ic/dwc_gmac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-07-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul 14 09:38:42 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Improve and add new debug output


To generate a diff of this commit:
cvs rdiff -u -r1.89 -r1.90 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.89 src/sys/dev/ic/dwc_gmac.c:1.90
--- src/sys/dev/ic/dwc_gmac.c:1.89	Sun Jul 14 09:31:55 2024
+++ src/sys/dev/ic/dwc_gmac.c	Sun Jul 14 09:38:41 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.89 2024/07/14 09:31:55 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.90 2024/07/14 09:38:41 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.89 2024/07/14 09:31:55 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.90 2024/07/14 09:38:41 skrll Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -923,6 +923,10 @@ dwc_gmac_init_locked(struct ifnet *ifp)
 		opmode |= GMAC_DMA_OP_RXSTOREFORWARD | GMAC_DMA_OP_TXSTOREFORWARD;
 	}
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_OPMODE, opmode);
+#ifdef DWC_GMAC_DEBUG
+	aprint_normal_dev(sc->sc_dev,
+	"setting DMA opmode register: %08x\n", opmode);
+#endif
 
 	sc->sc_stopping = false;
 
@@ -1189,7 +1193,7 @@ dwc_gmac_tx_intr(struct dwc_gmac_softc *
 	for (i = sc->sc_txq.t_next; sc->sc_txq.t_queued > 0; i = TX_NEXT(i)) {
 #ifdef DWC_GMAC_DEBUG
 		aprint_normal_dev(sc->sc_dev,
-		"dwc_gmac_tx_intr: checking desc #%d (t_queued: %d)\n",
+		"%s: checking desc #%d (t_queued: %d)\n", __func__,
 		i, sc->sc_txq.t_queued);
 #endif
 
@@ -1217,8 +1221,8 @@ dwc_gmac_tx_intr(struct dwc_gmac_softc *
 
 #ifdef DWC_GMAC_DEBUG
 		aprint_normal_dev(sc->sc_dev,
-		"dwc_gmac_tx_intr: done with packet at desc #%d, "
-		"freeing mbuf %p\n", i, data->td_m);
+		"%s: done with packet at desc #%d, freeing mbuf %p\n",
+		__func__, i, data->td_m);
 #endif
 
 		m_freem(data->td_m);
@@ -1247,6 +1251,10 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 
 	mutex_enter(&sc->sc_rxq.r_mtx);
 	for (i = sc->sc_rxq.r_cur; ; i = RX_NEXT(i)) {
+#ifdef DWC_GMAC_DEBUG
+		aprint_normal_dev(sc->sc_dev, "%s: checking desc #%d\n",
+		__func__, i);
+#endif
 		bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
 		RX_DESC_OFFSET(i), sizeof(*desc),
 		BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
@@ -1259,8 +1267,8 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 		if (sc->sc_descm->rx_has_error(desc)) {
 #ifdef DWC_GMAC_DEBUG
 			aprint_normal_dev(sc->sc_dev,
-			"RX error: descriptor status %08x, skipping\n",
-			le32toh(desc->ddesc_status0));
+			"%s: RX error: status %08x, skipping\n",
+			__func__, le32toh(desc->ddesc_status0));
 #endif
 			if_statinc(ifp, if_ierrors);
 			goto skip;
@@ -1270,8 +1278,8 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 
 #ifdef DWC_GMAC_DEBUG
 		aprint_normal_dev(sc->sc_dev,
-		"rx int: device is done with descriptor #%d, len: %d\n",
-		i, len);
+		"%s: device is done with descriptor #%d, len: %d\n",
+		__func__, i, len);
 #endif
 
 		/*
@@ -1317,6 +1325,11 @@ dwc_gmac_rx_intr(struct dwc_gmac_softc *
 		}
 		physaddr = data->rd_map->dm_segs[0].ds_addr;
 
+#ifdef DWC_GMAC_DEBUG
+		aprint_normal_dev(sc->sc_dev,
+		"%s: receiving packet at desc #%d,   using mbuf %p\n",
+		__func__, i, data->rd_m);
+#endif
 		/*
 		 * New mbuf loaded, update RX ring and continue
 		 */
@@ -1626,19 +1639,19 @@ dwc_gmac_dump_dma(struct dwc_gmac_softc 
 	bus_space_read_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_RX_ADDR));
 	aprint_normal_dev(sc->sc_dev, "tx descriptors: %08x\n",
 	bus_space_read_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_TX_ADDR));
-	aprint_normal_dev(sc->sc_dev, "status: %08x\n",
+	aprint_normal_dev(sc->sc_dev, " status: %08x\n",
 	bus_space_read_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_STATUS));
 	aprint_normal_dev(sc->sc_dev, "op mode: %08x\n",
 	bus_space_read_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_OPMODE));
-	aprint_normal_dev(sc->sc_dev, "int enable: %08x\n",
+	aprint_normal_dev(sc->sc_dev, "int en.: %08x\n",
 	bus_space_read_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_INTENABLE));
-	aprint_normal_dev(sc->sc_dev, "cur tx: %08x\n",
+	aprint_normal_dev(sc->sc_dev, " cur tx: %08x\n",
 	bus_space_read_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_CUR_TX_DESC));
-	aprint_normal_dev(sc->sc_dev, "cur rx: %08x\n",
+	aprint_normal_dev(sc->sc_dev, " cur rx: %08x\n",
 	bus_space_read_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_CUR_RX_DESC));
-	aprint_normal_dev(sc->sc_dev, "cur tx buffer: %08x\n",
+	aprint_normal_dev(sc->sc_dev, "cur txb: %08x\n",
 	bus_space_read_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_CUR_TX_BUFADDR));
-	aprint_normal_dev(sc->sc_dev, "cur rx buffer: %08x\n",
+	aprint_normal_dev(sc->sc_dev, "cur rxb: %08x\n",
 	bus

CVS commit: src/sys/dev/ic

2024-07-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul 14 09:31:55 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Fix some bus_dmamap_sync calls.
- ensure new descriptors are written before handing ownership of the
  first in the list to the device.
- ensure descriptors are sync'ed before dumping them in
  dwc_gmac_dump_[rt]x_desc
- don't sync the TX packet buffer twice (and not after we've passed
  ownership of its TX descriptor)

Change some variable names to better reflect what they are while I'm here.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.88 src/sys/dev/ic/dwc_gmac.c:1.89
--- src/sys/dev/ic/dwc_gmac.c:1.88	Fri Jul  5 04:31:51 2024
+++ src/sys/dev/ic/dwc_gmac.c	Sun Jul 14 09:31:55 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.88 2024/07/05 04:31:51 rin Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.89 2024/07/14 09:31:55 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.88 2024/07/05 04:31:51 rin Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.89 2024/07/14 09:31:55 skrll Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -473,11 +473,11 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 {
 	struct dwc_gmac_rx_data *data;
 	bus_addr_t physaddr;
-	const size_t descsize = AWGE_RX_RING_COUNT * sizeof(*ring->r_desc);
+	const size_t rxringsz = AWGE_RX_RING_COUNT * sizeof(*ring->r_desc);
 	int error, i, next;
 
 	ring->r_cur = ring->r_next = 0;
-	memset(ring->r_desc, 0, descsize);
+	memset(ring->r_desc, 0, rxringsz);
 
 	/*
 	 * Pre-allocate Rx buffers and populate Rx ring.
@@ -537,7 +537,8 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 		sc->sc_descm->rx_set_owned_by_dev(desc);
 	}
 
-	bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map, 0,
+	bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
+	RX_DESC_OFFSET(0),
 	AWGE_RX_RING_COUNT * sizeof(struct dwc_gmac_dev_dmadesc),
 	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_RX_ADDR,
@@ -581,12 +582,12 @@ dwc_gmac_reset_rx_ring(struct dwc_gmac_s
 static int
 dwc_gmac_alloc_dma_rings(struct dwc_gmac_softc *sc)
 {
-	const size_t descsize = AWGE_TOTAL_RING_COUNT *
+	const size_t ringsize = AWGE_TOTAL_RING_COUNT *
 		sizeof(struct dwc_gmac_dev_dmadesc);
 	int error, nsegs;
 	void *rings;
 
-	error = bus_dmamap_create(sc->sc_dmat, descsize, 1, descsize, 0,
+	error = bus_dmamap_create(sc->sc_dmat, ringsize, 1, ringsize, 0,
 	BUS_DMA_NOWAIT, &sc->sc_dma_ring_map);
 	if (error != 0) {
 		aprint_error_dev(sc->sc_dev,
@@ -595,7 +596,7 @@ dwc_gmac_alloc_dma_rings(struct dwc_gmac
 		goto fail;
 	}
 
-	error = bus_dmamem_alloc(sc->sc_dmat, descsize, PAGE_SIZE, 0,
+	error = bus_dmamem_alloc(sc->sc_dmat, ringsize, PAGE_SIZE, 0,
 	&sc->sc_dma_ring_seg, 1, &nsegs, BUS_DMA_NOWAIT |BUS_DMA_COHERENT);
 	if (error != 0) {
 		aprint_error_dev(sc->sc_dev,
@@ -604,7 +605,7 @@ dwc_gmac_alloc_dma_rings(struct dwc_gmac
 	}
 
 	error = bus_dmamem_map(sc->sc_dmat, &sc->sc_dma_ring_seg, nsegs,
-	descsize, &rings, BUS_DMA_NOWAIT | BUS_DMA_COHERENT);
+	ringsize, &rings, BUS_DMA_NOWAIT | BUS_DMA_COHERENT);
 	if (error != 0) {
 		aprint_error_dev(sc->sc_dev,
 		"could not allocate DMA memory\n");
@@ -612,7 +613,7 @@ dwc_gmac_alloc_dma_rings(struct dwc_gmac
 	}
 
 	error = bus_dmamap_load(sc->sc_dmat, sc->sc_dma_ring_map, rings,
-	descsize, NULL, BUS_DMA_NOWAIT | BUS_DMA_COHERENT);
+	ringsize, NULL, BUS_DMA_NOWAIT | BUS_DMA_COHERENT);
 	if (error != 0) {
 		aprint_error_dev(sc->sc_dev,
 		"could not load desc DMA map\n");
@@ -683,7 +684,7 @@ dwc_gmac_alloc_tx_ring(struct dwc_gmac_s
 	bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
 	TX_DESC_OFFSET(0),
 	AWGE_TX_RING_COUNT * sizeof(struct dwc_gmac_dev_dmadesc),
-	BUS_DMASYNC_POSTWRITE);
+	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
 	for (i = 0; i < AWGE_TX_RING_COUNT; i++) {
 		error = bus_dmamap_create(sc->sc_dmat, MCLBYTES,
@@ -700,6 +701,10 @@ dwc_gmac_alloc_tx_ring(struct dwc_gmac_s
 		ring->t_physaddr + sizeof(struct dwc_gmac_dev_dmadesc)
 		* TX_NEXT(i));
 	}
+	bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
+	TX_DESC_OFFSET(0),
+	AWGE_TX_RING_COUNT * sizeof(struct dwc_gmac_dev_dmadesc),
+	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
 	return 0;
 
@@ -1088,15 +1093,17 @@ dwc_gmac_queue(struct dwc_gmac_softc *sc
 	data->td_m = m0;
 	data->td_active = map;
 
+	/* sync the packet buffer */
 	bus_dmamap_sync(sc->sc_dmat, map, 0, map->dm_mapsize,
 	BUS_DMASYNC_PREWRITE);
 
+	/* sync the new descriptors - ownership not transferred yet */
+	dwc_gmac_txdesc_sync(sc, first, sc->sc_txq.t_cur,
+	BUS_DMASYNC_PREREAD | BUS_DMASYNC_P

CVS commit: src/sys/dev/ic

2024-07-14 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jul 14 09:31:55 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Fix some bus_dmamap_sync calls.
- ensure new descriptors are written before handing ownership of the
  first in the list to the device.
- ensure descriptors are sync'ed before dumping them in
  dwc_gmac_dump_[rt]x_desc
- don't sync the TX packet buffer twice (and not after we've passed
  ownership of its TX descriptor)

Change some variable names to better reflect what they are while I'm here.


To generate a diff of this commit:
cvs rdiff -u -r1.88 -r1.89 src/sys/dev/ic/dwc_gmac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-07-03 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul  3 13:08:36 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
fix HXRC colour map handling
With this we can run X in 8bit with correct colours.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/ic/sti.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/ic/sti.c
diff -u src/sys/dev/ic/sti.c:1.36 src/sys/dev/ic/sti.c:1.37
--- src/sys/dev/ic/sti.c:1.36	Tue Jun 25 11:52:11 2024
+++ src/sys/dev/ic/sti.c	Wed Jul  3 13:08:36 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti.c,v 1.36 2024/06/25 11:52:11 macallan Exp $	*/
+/*	$NetBSD: sti.c,v 1.37 2024/07/03 13:08:36 macallan Exp $	*/
 
 /*	$OpenBSD: sti.c,v 1.61 2009/09/05 14:09:35 miod Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.36 2024/06/25 11:52:11 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.37 2024/07/03 13:08:36 macallan Exp $");
 
 #include "wsdisplay.h"
 
@@ -133,6 +133,7 @@ void	ngle_artist_setupfb(struct sti_scre
 void	ngle_elk_setupfb(struct sti_screen *);
 void	ngle_timber_setupfb(struct sti_screen *);
 int	ngle_putcmap(struct sti_screen *, u_int, u_int);
+int	ngle_hcrx_putcmap(struct sti_screen *, u_int, u_int);
 #endif
 
 #define	STI_ENABLE_ROM(sc) \
@@ -685,7 +686,7 @@ sti_screen_setup(struct sti_screen *scr,
 
 	case STI_DD_HCRX:
 		scr->setupfb = ngle_elk_setupfb;
-		scr->putcmap = ngle_putcmap;
+		scr->putcmap = ngle_hcrx_putcmap;
 
 		if (scr->scr_bpp > 8) {
 			scr->reg12_value = NGLE_BUFF1_CMAP3;
@@ -694,7 +695,7 @@ sti_screen_setup(struct sti_screen *scr,
 			scr->reg12_value = NGLE_BUFF1_CMAP0;
 			scr->reg10_value = 0x13602000;
 		}
-		scr->cmap_finish_register = NGLE_REG_1;
+		scr->cmap_finish_register = NGLE_REG_38;
 		break;
 
 	case STI_DD_GRX:
@@ -1649,6 +1650,7 @@ ngle_putcmap(struct sti_screen *scr, u_i
 		r++, g++, b++;
 	}
 
+
 	bus_space_write_stream_4(memt, memh, NGLE_REG_2, 0x400);
 	bus_space_write_stream_4(memt, memh, scr->cmap_finish_register,
 	cmap_finish);
@@ -1658,6 +1660,49 @@ ngle_putcmap(struct sti_screen *scr, u_i
 	return 0;
 }
 
+int
+ngle_hcrx_putcmap(struct sti_screen *scr, u_int idx, u_int count)
+{
+	struct sti_rom *rom = scr->scr_rom;
+	bus_space_tag_t memt = rom->memt;
+	bus_space_handle_t memh = rom->regh[2];
+	uint8_t *r, *g, *b;
+	uint32_t cmap_finish;
+
+	if (scr->scr_bpp > 8)
+		cmap_finish = 0x8100;
+	else
+		cmap_finish = 0x82000100;
+
+	r = scr->scr_rcmap + idx;
+	g = scr->scr_gcmap + idx;
+	b = scr->scr_bcmap + idx;
+
+	ngle_setup_hw(memt, memh);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_10, 0xbbe0f000);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_14, 0x03000300);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_13, 0x);
+
+	while (count-- != 0) {
+		ngle_setup_hw(memt, memh);
+		bus_space_write_stream_4(memt, memh, NGLE_REG_3,
+		0x400 | (idx << 2));
+		bus_space_write_stream_4(memt, memh, NGLE_REG_4,
+		(*r << 16) | (*g << 8) | *b);
+
+		idx++;
+		r++, g++, b++;
+	}
+
+
+	bus_space_write_stream_4(memt, memh, NGLE_REG_2, 0x400);
+	bus_space_write_stream_4(memt, memh, NGLE_REG_38, cmap_finish);
+	ngle_setup_fb(memt, memh, scr->reg10_value);
+
+
+	return 0;
+}
+
 void
 ngle_setup_hw(bus_space_tag_t memt, bus_space_handle_t memh)
 {



CVS commit: src/sys/dev/ic

2024-07-03 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul  3 13:08:36 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
fix HXRC colour map handling
With this we can run X in 8bit with correct colours.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/dev/ic/sti.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-06-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jun 25 11:52:12 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
first step to HCRX support
this gets us an 8bit framebuffer with wrong colours, as opposed to X just
erroring out


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/ic/sti.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/ic/sti.c
diff -u src/sys/dev/ic/sti.c:1.35 src/sys/dev/ic/sti.c:1.36
--- src/sys/dev/ic/sti.c:1.35	Tue Feb 13 13:17:51 2024
+++ src/sys/dev/ic/sti.c	Tue Jun 25 11:52:11 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti.c,v 1.35 2024/02/13 13:17:51 macallan Exp $	*/
+/*	$NetBSD: sti.c,v 1.36 2024/06/25 11:52:11 macallan Exp $	*/
 
 /*	$OpenBSD: sti.c,v 1.61 2009/09/05 14:09:35 miod Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.35 2024/02/13 13:17:51 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.36 2024/06/25 11:52:11 macallan Exp $");
 
 #include "wsdisplay.h"
 
@@ -683,12 +683,25 @@ sti_screen_setup(struct sti_screen *scr,
 		}
 		break;
 
+	case STI_DD_HCRX:
+		scr->setupfb = ngle_elk_setupfb;
+		scr->putcmap = ngle_putcmap;
+
+		if (scr->scr_bpp > 8) {
+			scr->reg12_value = NGLE_BUFF1_CMAP3;
+			scr->reg10_value = 0xBBA0A000;
+		} else {
+			scr->reg12_value = NGLE_BUFF1_CMAP0;
+			scr->reg10_value = 0x13602000;
+		}
+		scr->cmap_finish_register = NGLE_REG_1;
+		break;
+
 	case STI_DD_GRX:
 	case STI_DD_CRX24:
 	case STI_DD_EVRX:
 	case STI_DD_3X2V:
 	case STI_DD_DUAL_CRX:
-	case STI_DD_HCRX:
 	case STI_DD_LEGO:
 	case STI_DD_SUMMIT:
 	case STI_DD_PINNACLE:



CVS commit: src/sys/dev/ic

2024-06-25 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jun 25 11:52:12 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
first step to HCRX support
this gets us an 8bit framebuffer with wrong colours, as opposed to X just
erroring out


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/dev/ic/sti.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-06-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun 16 17:11:12 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Misc whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/dev/ic/dwc_gmac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-06-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Jun 16 17:11:12 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Misc whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.86 -r1.87 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.86 src/sys/dev/ic/dwc_gmac.c:1.87
--- src/sys/dev/ic/dwc_gmac.c:1.86	Thu Mar 14 16:43:00 2024
+++ src/sys/dev/ic/dwc_gmac.c	Sun Jun 16 17:11:11 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.86 2024/03/14 16:43:00 jakllsch Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.87 2024/06/16 17:11:11 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.86 2024/03/14 16:43:00 jakllsch Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.87 2024/06/16 17:11:11 skrll Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -655,7 +655,6 @@ dwc_gmac_free_rx_ring(struct dwc_gmac_so
 	if (ring->r_desc == NULL)
 		return;
 
-
 	for (i = 0; i < AWGE_RX_RING_COUNT; i++) {
 		data = &ring->r_data[i];
 
@@ -700,7 +699,7 @@ dwc_gmac_alloc_tx_ring(struct dwc_gmac_s
 		}
 		ring->t_desc[i].ddesc_next = htole32(
 		ring->t_physaddr + sizeof(struct dwc_gmac_dev_dmadesc)
-		*TX_NEXT(i));
+		* TX_NEXT(i));
 	}
 
 	return 0;
@@ -1674,9 +1673,9 @@ static void
 dwc_dump_status(struct dwc_gmac_softc *sc)
 {
 	uint32_t status = bus_space_read_4(sc->sc_bst, sc->sc_bsh,
-	 AWIN_GMAC_MAC_INTR);
+	AWIN_GMAC_MAC_INTR);
 	uint32_t dma_status = bus_space_read_4(sc->sc_bst, sc->sc_bsh,
-	 AWIN_GMAC_DMA_STATUS);
+	AWIN_GMAC_DMA_STATUS);
 	char buf[200];
 
 	/* print interrupt state */



CVS commit: src/sys/dev/ic

2024-05-21 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue May 21 08:04:20 UTC 2024

Modified Files:
src/sys/dev/ic: ne2000.c

Log Message:
nix extra whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/dev/ic/ne2000.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/ic/ne2000.c
diff -u src/sys/dev/ic/ne2000.c:1.78 src/sys/dev/ic/ne2000.c:1.79
--- src/sys/dev/ic/ne2000.c:1.78	Tue May 21 07:29:40 2024
+++ src/sys/dev/ic/ne2000.c	Tue May 21 08:04:20 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ne2000.c,v 1.78 2024/05/21 07:29:40 andvar Exp $	*/
+/*	$NetBSD: ne2000.c,v 1.79 2024/05/21 08:04:20 andvar Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ne2000.c,v 1.78 2024/05/21 07:29:40 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ne2000.c,v 1.79 2024/05/21 08:04:20 andvar Exp $");
 
 #include "rtl80x9.h"
 
@@ -373,7 +373,7 @@ ne2000_detect(bus_space_tag_t nict, bus_
 
 	/*
 	 * Generic probe routine for testing for the existence of a DS8390.
-	 * Must be performed  after the NIC has just been reset.  This
+	 * Must be performed after the NIC has just been reset.  This
 	 * works by looking at certain register values that are guaranteed
 	 * to be initialized a certain way after power-up or reset.
 	 *



CVS commit: src/sys/dev/ic

2024-05-21 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue May 21 08:04:20 UTC 2024

Modified Files:
src/sys/dev/ic: ne2000.c

Log Message:
nix extra whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/dev/ic/ne2000.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-05-21 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue May 21 07:29:40 UTC 2024

Modified Files:
src/sys/dev/ic: mx98905.c ne2000.c

Log Message:
s/amout/amount/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/mx98905.c
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/ic/ne2000.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/ic/mx98905.c
diff -u src/sys/dev/ic/mx98905.c:1.17 src/sys/dev/ic/mx98905.c:1.18
--- src/sys/dev/ic/mx98905.c:1.17	Tue Aug  1 20:52:43 2023
+++ src/sys/dev/ic/mx98905.c	Tue May 21 07:29:40 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mx98905.c,v 1.17 2023/08/01 20:52:43 andvar Exp $	*/
+/*	$NetBSD: mx98905.c,v 1.18 2024/05/21 07:29:40 andvar Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -59,7 +59,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: mx98905.c,v 1.17 2023/08/01 20:52:43 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mx98905.c,v 1.18 2024/05/21 07:29:40 andvar Exp $");
 
 #include 
 #include 
@@ -282,7 +282,7 @@ mx98905_write_mbuf(struct dp8390_softc *
 }
 
 /*
- * Given a source and destination address, copy 'amout' of a packet from
+ * Given a source and destination address, copy 'amount' of a packet from
  * the ring buffer into a linear destination buffer.  Takes into account
  * ring-wrap.
  */

Index: src/sys/dev/ic/ne2000.c
diff -u src/sys/dev/ic/ne2000.c:1.77 src/sys/dev/ic/ne2000.c:1.78
--- src/sys/dev/ic/ne2000.c:1.77	Fri Aug 20 20:25:28 2021
+++ src/sys/dev/ic/ne2000.c	Tue May 21 07:29:40 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ne2000.c,v 1.77 2021/08/20 20:25:28 andvar Exp $	*/
+/*	$NetBSD: ne2000.c,v 1.78 2024/05/21 07:29:40 andvar Exp $	*/
 
 /*-
  * Copyright (c) 1997, 1998 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ne2000.c,v 1.77 2021/08/20 20:25:28 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ne2000.c,v 1.78 2024/05/21 07:29:40 andvar Exp $");
 
 #include "rtl80x9.h"
 
@@ -716,7 +716,7 @@ ne2000_write_mbuf(struct dp8390_softc *s
 }
 
 /*
- * Given a source and destination address, copy 'amout' of a packet from
+ * Given a source and destination address, copy 'amount' of a packet from
  * the ring buffer into a linear destination buffer.  Takes into account
  * ring-wrap.
  */



CVS commit: src/sys/dev/ic

2024-05-21 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Tue May 21 07:29:40 UTC 2024

Modified Files:
src/sys/dev/ic: mx98905.c ne2000.c

Log Message:
s/amout/amount/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/mx98905.c
cvs rdiff -u -r1.77 -r1.78 src/sys/dev/ic/ne2000.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 13:41:15 UTC 2024

Modified Files:
src/sys/dev/ic: tpm.c

Log Message:
tpm(4): device_printf needs \n.

Observed in PR 58255.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ic/tpm.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/ic/tpm.c
diff -u src/sys/dev/ic/tpm.c:1.28 src/sys/dev/ic/tpm.c:1.29
--- src/sys/dev/ic/tpm.c:1.28	Tue Jul  4 01:02:26 2023
+++ src/sys/dev/ic/tpm.c	Tue May 14 13:41:15 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: tpm.c,v 1.28 2023/07/04 01:02:26 riastradh Exp $	*/
+/*	$NetBSD: tpm.c,v 1.29 2024/05/14 13:41:15 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -48,7 +48,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.28 2023/07/04 01:02:26 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tpm.c,v 1.29 2024/05/14 13:41:15 riastradh Exp $");
 
 #include 
 #include 
@@ -150,7 +150,7 @@ tpm12_suspend(struct tpm_softc *sc)
 	 */
 	error = (*sc->sc_intf->start)(sc, UIO_WRITE);
 	if (error) {
-		device_printf(sc->sc_dev, "start write failed: %d", error);
+		device_printf(sc->sc_dev, "start write failed: %d\n", error);
 		goto out;
 	}
 
@@ -158,8 +158,8 @@ tpm12_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf->write)(sc, &command, sizeof(command));
 	if (error) {
-		device_printf(sc->sc_dev, "write TPM_ORD_SaveState failed: %d",
-		error);
+		device_printf(sc->sc_dev, "write TPM_ORD_SaveState failed:"
+		" %d\n", error);
 		goto out;
 	}
 
@@ -167,7 +167,7 @@ tpm12_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf->end)(sc, UIO_WRITE, 0);
 	if (error) {
-		device_printf(sc->sc_dev, "end write failed: %d", error);
+		device_printf(sc->sc_dev, "end write failed: %d\n", error);
 		goto out;
 	}
 
@@ -177,7 +177,7 @@ tpm12_suspend(struct tpm_softc *sc)
 	 */
 	error = (*sc->sc_intf->start)(sc, UIO_READ);
 	if (error) {
-		device_printf(sc->sc_dev, "start read failed: %d", error);
+		device_printf(sc->sc_dev, "start read failed: %d\n", error);
 		goto out;
 	}
 
@@ -186,11 +186,11 @@ tpm12_suspend(struct tpm_softc *sc)
 	error = (*sc->sc_intf->read)(sc, &response, sizeof(response), &nread,
 	0);
 	if (error) {
-		device_printf(sc->sc_dev, "read failed: %d", error);
+		device_printf(sc->sc_dev, "read failed: %d\n", error);
 		goto out;
 	}
 	if (nread != sizeof(response)) {
-		device_printf(sc->sc_dev, "short header read: %zu", nread);
+		device_printf(sc->sc_dev, "short header read: %zu\n", nread);
 		goto out;
 	}
 
@@ -198,7 +198,7 @@ tpm12_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf->end)(sc, UIO_READ, 0);
 	if (error) {
-		device_printf(sc->sc_dev, "end read failed: %d", error);
+		device_printf(sc->sc_dev, "end read failed: %d\n", error);
 		goto out;
 	}
 
@@ -209,7 +209,8 @@ tpm12_suspend(struct tpm_softc *sc)
 	be32toh(response.length) != sizeof(response) ||
 	be32toh(response.code) != 0) {
 		device_printf(sc->sc_dev,
-		"TPM_ORD_SaveState failed: tag=0x%x length=0x%x code=0x%x",
+		"TPM_ORD_SaveState failed:"
+		" tag=0x%x length=0x%x code=0x%x\n",
 		be16toh(response.tag),
 		be32toh(response.length),
 		be32toh(response.code));
@@ -248,7 +249,7 @@ tpm20_suspend(struct tpm_softc *sc)
 	 */
 	error = (*sc->sc_intf->start)(sc, UIO_WRITE);
 	if (error) {
-		device_printf(sc->sc_dev, "start write failed: %d", error);
+		device_printf(sc->sc_dev, "start write failed: %d\n", error);
 		goto out;
 	}
 
@@ -256,8 +257,8 @@ tpm20_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf->write)(sc, &command, sizeof(command));
 	if (error) {
-		device_printf(sc->sc_dev, "write TPM_ORD_SaveState failed: %d",
-		error);
+		device_printf(sc->sc_dev, "write TPM_ORD_SaveState failed:"
+		" %d\n", error);
 		goto out;
 	}
 
@@ -265,7 +266,7 @@ tpm20_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf->end)(sc, UIO_WRITE, 0);
 	if (error) {
-		device_printf(sc->sc_dev, "end write failed: %d", error);
+		device_printf(sc->sc_dev, "end write failed: %d\n", error);
 		goto out;
 	}
 
@@ -275,7 +276,7 @@ tpm20_suspend(struct tpm_softc *sc)
 	 */
 	error = (*sc->sc_intf->start)(sc, UIO_READ);
 	if (error) {
-		device_printf(sc->sc_dev, "start read failed: %d", error);
+		device_printf(sc->sc_dev, "start read failed: %d\n", error);
 		goto out;
 	}
 
@@ -284,11 +285,11 @@ tpm20_suspend(struct tpm_softc *sc)
 	error = (*sc->sc_intf->read)(sc, &response, sizeof(response), &nread,
 	0);
 	if (error) {
-		device_printf(sc->sc_dev, "read failed: %d", error);
+		device_printf(sc->sc_dev, "read failed: %d\n", error);
 		goto out;
 	}
 	if (nread != sizeof(response)) {
-		device_printf(sc->sc_dev, "short header read: %zu", nread);
+		device_printf(sc->sc_dev, "short header read: %zu\n", nread);
 		goto out;
 	}
 
@@ -296,7 +297,7 @@ tpm20_suspend(struct tpm_softc *sc)
 
 	error = (*sc->sc_intf-

CVS commit: src/sys/dev/ic

2024-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Tue May 14 13:41:15 UTC 2024

Modified Files:
src/sys/dev/ic: tpm.c

Log Message:
tpm(4): device_printf needs \n.

Observed in PR 58255.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/dev/ic/tpm.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-04-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Apr  6 13:42:18 UTC 2024

Modified Files:
src/sys/dev/ic: qemufwcfg.c

Log Message:
Add RISC-V support


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/qemufwcfg.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/ic/qemufwcfg.c
diff -u src/sys/dev/ic/qemufwcfg.c:1.2 src/sys/dev/ic/qemufwcfg.c:1.3
--- src/sys/dev/ic/qemufwcfg.c:1.2	Mon Sep  3 16:29:31 2018
+++ src/sys/dev/ic/qemufwcfg.c	Sat Apr  6 13:42:18 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: qemufwcfg.c,v 1.2 2018/09/03 16:29:31 riastradh Exp $ */
+/* $NetBSD: qemufwcfg.c,v 1.3 2024/04/06 13:42:18 skrll Exp $ */
 
 /*-
  * Copyright (c) 2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: qemufwcfg.c,v 1.2 2018/09/03 16:29:31 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: qemufwcfg.c,v 1.3 2024/04/06 13:42:18 skrll Exp $");
 
 #include 
 #include 
@@ -52,6 +52,11 @@ __KERNEL_RCSID(0, "$NetBSD: qemufwcfg.c,
 #define	FWCFG_SEL_SWAP		htobe16
 #define	FWCFG_DATA_REG		0x00
 #define	FWCFG_DMA_ADDR		0x10
+#elif defined(__riscv)
+#define	FWCFG_SEL_REG		0x08
+#define	FWCFG_SEL_SWAP		htobe16
+#define	FWCFG_DATA_REG		0x00
+#define	FWCFG_DMA_ADDR		0x10
 #else
 #error driver does not support this architecture
 #endif



CVS commit: src/sys/dev/ic

2024-04-06 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Apr  6 13:42:18 UTC 2024

Modified Files:
src/sys/dev/ic: qemufwcfg.c

Log Message:
Add RISC-V support


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/dev/ic/qemufwcfg.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-03-16 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Mar 16 18:17:39 UTC 2024

Modified Files:
src/sys/dev/ic: lan9118reg.h

Log Message:
s/Broardcast/Broadcast/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/lan9118reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-03-16 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Sat Mar 16 18:17:39 UTC 2024

Modified Files:
src/sys/dev/ic: lan9118reg.h

Log Message:
s/Broardcast/Broadcast/ in comment.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/ic/lan9118reg.h

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/ic/lan9118reg.h
diff -u src/sys/dev/ic/lan9118reg.h:1.3 src/sys/dev/ic/lan9118reg.h:1.4
--- src/sys/dev/ic/lan9118reg.h:1.3	Mon Sep 27 12:29:03 2010
+++ src/sys/dev/ic/lan9118reg.h	Sat Mar 16 18:17:39 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: lan9118reg.h,v 1.3 2010/09/27 12:29:03 kiyohara Exp $	*/
+/*	$NetBSD: lan9118reg.h,v 1.4 2024/03/16 18:17:39 andvar Exp $	*/
 /*
  * Copyright (c) 2008 KIYOHARA Takashi
  * All rights reserved.
@@ -206,7 +206,7 @@
 #define LAN9118_MAC_CR_HO		(1 << 15) /* Hash Only Filtering mode */
 #define LAN9118_MAC_CR_HPFILT		(1 << 13) /* Hash/Perfect Flt Mode */
 #define LAN9118_MAC_CR_LCOLL		(1 << 12) /* Late Collision Control */
-#define LAN9118_MAC_CR_BCAST		(1 << 11) /* Disable Broardcast Frms */
+#define LAN9118_MAC_CR_BCAST		(1 << 11) /* Disable Broadcast Frms */
 #define LAN9118_MAC_CR_DISRTY		(1 << 10) /* Disable Retry */
 #define LAN9118_MAC_CR_PADSTR		(1 << 8)  /* Automatic Pad String */
 #define LAN9118_MAC_CR_BOLMT		(1 << 7)  /* BackOff Limit */



CVS commit: src/sys/dev/ic

2024-03-14 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Mar 14 16:43:00 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Use ether_crc32_be() instead of having a local bitrev32() function to
munge ether_crc32_le() output when programming multicast filter.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/dev/ic/dwc_gmac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-03-14 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Mar 14 16:43:00 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Use ether_crc32_be() instead of having a local bitrev32() function to
munge ether_crc32_le() output when programming multicast filter.


To generate a diff of this commit:
cvs rdiff -u -r1.85 -r1.86 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.85 src/sys/dev/ic/dwc_gmac.c:1.86
--- src/sys/dev/ic/dwc_gmac.c:1.85	Sun Mar  3 10:09:42 2024
+++ src/sys/dev/ic/dwc_gmac.c	Thu Mar 14 16:43:00 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.85 2024/03/03 10:09:42 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.86 2024/03/14 16:43:00 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.85 2024/03/03 10:09:42 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.86 2024/03/14 16:43:00 jakllsch Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -98,7 +98,6 @@ static void dwc_gmac_tx_intr(struct dwc_
 static void dwc_gmac_rx_intr(struct dwc_gmac_softc *);
 static void dwc_gmac_setmulti(struct dwc_gmac_softc *);
 static int dwc_gmac_ifflags_cb(struct ethercom *);
-static uint32_t	bitrev32(uint32_t);
 static void dwc_gmac_desc_set_owned_by_dev(struct dwc_gmac_dev_dmadesc *);
 static int  dwc_gmac_desc_is_owned_by_dev(struct dwc_gmac_dev_dmadesc *);
 static void dwc_gmac_desc_std_set_len(struct dwc_gmac_dev_dmadesc *, int);
@@ -1346,20 +1345,6 @@ skip:
 	mutex_exit(&sc->sc_rxq.r_mtx);
 }
 
-/*
- * Reverse order of bits - http://aggregate.org/MAGIC/#Bit%20Reversal
- */
-static uint32_t
-bitrev32(uint32_t x)
-{
-	x = (((x & 0x) >> 1) | ((x & 0x) << 1));
-	x = (((x & 0x) >> 2) | ((x & 0x) << 2));
-	x = (((x & 0xf0f0f0f0) >> 4) | ((x & 0x0f0f0f0f) << 4));
-	x = (((x & 0xff00ff00) >> 8) | ((x & 0x00ff00ff) << 8));
-
-	return (x >> 16) | (x << 16);
-}
-
 static void
 dwc_gmac_setmulti(struct dwc_gmac_softc *sc)
 {
@@ -1398,9 +1383,7 @@ dwc_gmac_setmulti(struct dwc_gmac_softc 
 			goto special_filter;
 		}
 
-		h = bitrev32(
-			~ether_crc32_le(enm->enm_addrlo, ETHER_ADDR_LEN)
-		) >> 26;
+		h = ~ether_crc32_be(enm->enm_addrlo, ETHER_ADDR_LEN) >> 26;
 		hashes[h >> 5] |= (1 << (h & 0x1f));
 
 		mcnt++;



CVS commit: src/sys/dev/ic

2024-03-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 11 21:10:46 UTC 2024

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
nvme(4): Disestablish admin q interrupt while suspended.

And re-establish on resume.  Fixes nvmectl(8) after a suspend/resume
cycle on some systems.

Adapted from a patch by mrg@.

PR kern/58025


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/ic/nvme.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/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.68 src/sys/dev/ic/nvme.c:1.69
--- src/sys/dev/ic/nvme.c:1.68	Sun Mar 10 04:49:22 2024
+++ src/sys/dev/ic/nvme.c	Mon Mar 11 21:10:46 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.68 2024/03/10 04:49:22 mrg Exp $	*/
+/*	$NetBSD: nvme.c,v 1.69 2024/03/11 21:10:46 riastradh Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.68 2024/03/10 04:49:22 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.69 2024/03/11 21:10:46 riastradh Exp $");
 
 #include 
 #include 
@@ -575,7 +575,6 @@ nvme_detach(struct nvme_softc *sc, int f
 		return error;
 
 	/* from now on we are committed to detach, following will never fail */
-	sc->sc_intr_disestablish(sc, NVME_ADMIN_Q);
 	for (i = 0; i < sc->sc_nq; i++)
 		nvme_q_free(sc, sc->sc_q[i]);
 	kmem_free(sc->sc_q, sizeof(*sc->sc_q) * sc->sc_nq);
@@ -603,6 +602,11 @@ nvme_resume(struct nvme_softc *sc)
 	}
 
 	nvme_q_reset(sc, sc->sc_admin_q);
+	if (sc->sc_intr_establish(sc, NVME_ADMIN_Q, sc->sc_admin_q)) {
+		error = EIO;
+		device_printf(sc->sc_dev, "unable to establish admin q\n");
+		goto disable;
+	}
 
 	error = nvme_enable(sc, ffs(sc->sc_mps) - 1);
 	if (error) {
@@ -651,6 +655,8 @@ nvme_shutdown(struct nvme_softc *sc)
 	if (disabled)
 		goto disable;
 
+	sc->sc_intr_disestablish(sc, NVME_ADMIN_Q);
+
 	cc = nvme_read4(sc, NVME_CC);
 	CLR(cc, NVME_CC_SHN_MASK);
 	SET(cc, NVME_CC_SHN(NVME_CC_SHN_NORMAL));



CVS commit: src/sys/dev/ic

2024-03-11 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Mon Mar 11 21:10:46 UTC 2024

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
nvme(4): Disestablish admin q interrupt while suspended.

And re-establish on resume.  Fixes nvmectl(8) after a suspend/resume
cycle on some systems.

Adapted from a patch by mrg@.

PR kern/58025


To generate a diff of this commit:
cvs rdiff -u -r1.68 -r1.69 src/sys/dev/ic/nvme.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:16:26 UTC 2024

Modified Files:
src/sys/dev/ic: lsi64854reg.h

Log Message:
lsi64854reg: fix snprintb formats DDMACSR_BITS and PDMACSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/lsi64854reg.h

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/ic/lsi64854reg.h
diff -u src/sys/dev/ic/lsi64854reg.h:1.6 src/sys/dev/ic/lsi64854reg.h:1.7
--- src/sys/dev/ic/lsi64854reg.h:1.6	Mon Apr 28 20:23:50 2008
+++ src/sys/dev/ic/lsi64854reg.h	Sun Mar 10 17:16:26 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: lsi64854reg.h,v 1.6 2008/04/28 20:23:50 martin Exp $ */
+/*	$NetBSD: lsi64854reg.h,v 1.7 2024/03/10 17:16:26 rillig Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
 #define DDMACSR_BITS	"\177\020"\
 	"b\00INT\0b\01ERR\0f\02\02DRAINING\0b\04IEN\0"		\
 	"b\06SLVERR\0b\07RST\0b\10WRITE\0b\11ENDMA\0"		\
-	"b\15ENCNT\0b\16TC\0\b\20DSBL_CSR_DRN\0"		\
+	"b\15ENCNT\0b\16TC\0b\20DSBL_CSR_DRN\0"			\
 	"b\21DSBL_SCSI_DRN\0f\22\2BURST\0b\25TWOCYCLE\0"	\
 	"b\26FASTER\0b\27TCIDIS\0b\30ENNXT\0b\031DMAON\0"	\
 	"b\32ALOADED\0b\33NALOADED\0"
@@ -192,5 +192,5 @@
 #define PDMACSR_BITS	"\177\020"\
 	"b\00INT\0b\01ERR\0f\02\02DRAINING\0b\04IEN\0"		\
 	"b\06SLVERR\0b\07RST\0b\10WRITE\0b\11ENDMA\0"		\
-	"b\15ENCNT\0b\16TC\0\b\24DIAG\0b\27TCIDIS\0"		\
+	"b\15ENCNT\0b\16TC\0b\24DIAG\0b\27TCIDIS\0"		\
 	"b\30ENNXT\0b\031DMAON\0b\32ALOADED\0b\33NALOADED\0"



CVS commit: src/sys/dev/ic

2024-03-10 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Sun Mar 10 17:16:26 UTC 2024

Modified Files:
src/sys/dev/ic: lsi64854reg.h

Log Message:
lsi64854reg: fix snprintb formats DDMACSR_BITS and PDMACSR_BITS


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/ic/lsi64854reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-03-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Mar 10 04:49:22 UTC 2024

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
nvme(4): don't write to INTMC register if in intx mode

this matches the handling of INTMS, both of which have the same
restrictions on access in MSI-X mode.

ideally, this register should be written to with a full set of
values for MSI (upto 32 bits), but trying to force MSI mode for
my test machine makes the system unstable.

tested with samsung SM981 256GB, samsung 980 PRO 1TB, and intel
760p 250G.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/ic/nvme.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/ic/nvme.c
diff -u src/sys/dev/ic/nvme.c:1.67 src/sys/dev/ic/nvme.c:1.68
--- src/sys/dev/ic/nvme.c:1.67	Tue Sep 13 10:14:20 2022
+++ src/sys/dev/ic/nvme.c	Sun Mar 10 04:49:22 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: nvme.c,v 1.67 2022/09/13 10:14:20 riastradh Exp $	*/
+/*	$NetBSD: nvme.c,v 1.68 2024/03/10 04:49:22 mrg Exp $	*/
 /*	$OpenBSD: nvme.c,v 1.49 2016/04/18 05:59:50 dlg Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.67 2022/09/13 10:14:20 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nvme.c,v 1.68 2024/03/10 04:49:22 mrg Exp $");
 
 #include 
 #include 
@@ -620,7 +620,8 @@ nvme_resume(struct nvme_softc *sc)
 		}
 	}
 
-	nvme_write4(sc, NVME_INTMC, 1);
+	if (!sc->sc_use_mq)
+		nvme_write4(sc, NVME_INTMC, 1);
 
 	return 0;
 
@@ -2023,6 +2024,8 @@ nvme_intr(void *xsc)
 {
 	struct nvme_softc *sc = xsc;
 
+	KASSERT(!sc->sc_use_mq);
+
 	/*
 	 * INTx is level triggered, controller deasserts the interrupt only
 	 * when we advance command queue head via write to the doorbell.
@@ -2043,6 +2046,8 @@ nvme_softintr_intx(void *xq)
 	struct nvme_queue *q = xq;
 	struct nvme_softc *sc = q->q_sc;
 
+	KASSERT(!sc->sc_use_mq);
+
 	nvme_q_complete(sc, sc->sc_admin_q);
 	if (sc->sc_q != NULL)
 	nvme_q_complete(sc, sc->sc_q[0]);



CVS commit: src/sys/dev/ic

2024-03-09 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Sun Mar 10 04:49:22 UTC 2024

Modified Files:
src/sys/dev/ic: nvme.c

Log Message:
nvme(4): don't write to INTMC register if in intx mode

this matches the handling of INTMS, both of which have the same
restrictions on access in MSI-X mode.

ideally, this register should be written to with a full set of
values for MSI (upto 32 bits), but trying to force MSI mode for
my test machine makes the system unstable.

tested with samsung SM981 256GB, samsung 980 PRO 1TB, and intel
760p 250G.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/ic/nvme.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 02:31:44 UTC 2024

Modified Files:
src/sys/dev/ic: mc146818.c mc146818var.h

Log Message:
Expose mc146818_{get,set}time_ymdhms() and allow a front-end to override
these function pointers in the TODR handle, allowing the front-end to
wrap mc146818_{get,set}time_ymdhms() with special handling, if needed.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/ic/mc146818.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/mc146818var.h

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/ic/mc146818.c
diff -u src/sys/dev/ic/mc146818.c:1.20 src/sys/dev/ic/mc146818.c:1.21
--- src/sys/dev/ic/mc146818.c:1.20	Wed Jan  1 19:24:03 2020
+++ src/sys/dev/ic/mc146818.c	Wed Mar  6 02:31:44 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mc146818.c,v 1.20 2020/01/01 19:24:03 thorpej Exp $	*/
+/*	$NetBSD: mc146818.c,v 1.21 2024/03/06 02:31:44 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2003 Izumi Tsutsui.  All rights reserved.
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mc146818.c,v 1.20 2020/01/01 19:24:03 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mc146818.c,v 1.21 2024/03/06 02:31:44 thorpej Exp $");
 
 #include 
 #include 
@@ -43,9 +43,6 @@ __KERNEL_RCSID(0, "$NetBSD: mc146818.c,v
 #include 
 #include 
 
-int mc146818_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
-int mc146818_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
-
 void
 mc146818_attach(struct mc146818_softc *sc)
 {
@@ -61,11 +58,14 @@ mc146818_attach(struct mc146818_softc *s
 
 	handle = &sc->sc_handle;
 	handle->cookie = sc;
-	handle->todr_gettime = NULL;
-	handle->todr_settime = NULL;
-	handle->todr_gettime_ymdhms = mc146818_gettime_ymdhms;
-	handle->todr_settime_ymdhms = mc146818_settime_ymdhms;
-	handle->todr_setwen  = NULL;
+	KASSERT(handle->todr_gettime == NULL);
+	KASSERT(handle->todr_settime == NULL);
+	if (handle->todr_gettime_ymdhms == NULL) {
+		handle->todr_gettime_ymdhms = mc146818_gettime_ymdhms;
+	}
+	if (handle->todr_settime_ymdhms == NULL) {
+		handle->todr_settime_ymdhms = mc146818_settime_ymdhms;
+	}
 
 	todr_attach(handle);
 }
@@ -103,7 +103,7 @@ mc146818_gettime_ymdhms(todr_chip_handle
 	dt->dt_wday = FROMREG((*sc->sc_mcread)(sc, MC_DOW));
 	dt->dt_day  = FROMREG((*sc->sc_mcread)(sc, MC_DOM));
 	dt->dt_mon  = FROMREG((*sc->sc_mcread)(sc, MC_MONTH));
-	year   = FROMREG((*sc->sc_mcread)(sc, MC_YEAR));
+	year= FROMREG((*sc->sc_mcread)(sc, MC_YEAR));
 	if (sc->sc_getcent) {
 		cent = (*sc->sc_getcent)(sc);
 		year += cent * 100;

Index: src/sys/dev/ic/mc146818var.h
diff -u src/sys/dev/ic/mc146818var.h:1.7 src/sys/dev/ic/mc146818var.h:1.8
--- src/sys/dev/ic/mc146818var.h:1.7	Wed May 14 13:29:29 2008
+++ src/sys/dev/ic/mc146818var.h	Wed Mar  6 02:31:44 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mc146818var.h,v 1.7 2008/05/14 13:29:29 tsutsui Exp $	*/
+/*	$NetBSD: mc146818var.h,v 1.8 2024/03/06 02:31:44 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2003 Izumi Tsutsui.  All rights reserved.
@@ -24,6 +24,9 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+#ifndef _DEV_IC_MC146818VAR_H_
+#define	_DEV_IC_MC146818VAR_H_
+
 struct mc146818_softc {
 	device_t sc_dev;
 
@@ -45,4 +48,8 @@ struct mc146818_softc {
 	void (*sc_setcent)(struct mc146818_softc *, u_int);
 };
 
-void mc146818_attach(struct mc146818_softc *);
+void	mc146818_attach(struct mc146818_softc *);
+int	mc146818_gettime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
+int	mc146818_settime_ymdhms(todr_chip_handle_t, struct clock_ymdhms *);
+
+#endif /* _DEV_IC_MC146818VAR_H_ */



CVS commit: src/sys/dev/ic

2024-03-05 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Mar  6 02:31:44 UTC 2024

Modified Files:
src/sys/dev/ic: mc146818.c mc146818var.h

Log Message:
Expose mc146818_{get,set}time_ymdhms() and allow a front-end to override
these function pointers in the TODR handle, allowing the front-end to
wrap mc146818_{get,set}time_ymdhms() with special handling, if needed.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/ic/mc146818.c
cvs rdiff -u -r1.7 -r1.8 src/sys/dev/ic/mc146818var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-03-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar  3 10:09:42 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Reorder the bus_dmamap_sync sync operations

 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD to
 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE

for consistency.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.84 src/sys/dev/ic/dwc_gmac.c:1.85
--- src/sys/dev/ic/dwc_gmac.c:1.84	Sun Mar  3 10:02:11 2024
+++ src/sys/dev/ic/dwc_gmac.c	Sun Mar  3 10:09:42 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.84 2024/03/03 10:02:11 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.85 2024/03/03 10:09:42 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.84 2024/03/03 10:02:11 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.85 2024/03/03 10:09:42 skrll Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -540,7 +540,7 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 
 	bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map, 0,
 	AWGE_RX_RING_COUNT * sizeof(struct dwc_gmac_dev_dmadesc),
-	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
+	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_RX_ADDR,
 	ring->r_physaddr);
 



CVS commit: src/sys/dev/ic

2024-03-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar  3 10:09:42 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Reorder the bus_dmamap_sync sync operations

 BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD to
 BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE

for consistency.


To generate a diff of this commit:
cvs rdiff -u -r1.84 -r1.85 src/sys/dev/ic/dwc_gmac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-03-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar  3 10:02:11 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
More KNF (whitespace around binary operators)


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.83 src/sys/dev/ic/dwc_gmac.c:1.84
--- src/sys/dev/ic/dwc_gmac.c:1.83	Tue Feb 27 08:28:56 2024
+++ src/sys/dev/ic/dwc_gmac.c	Sun Mar  3 10:02:11 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.83 2024/02/27 08:28:56 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.84 2024/03/03 10:02:11 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.83 2024/02/27 08:28:56 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.84 2024/03/03 10:02:11 skrll Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -718,20 +718,20 @@ dwc_gmac_txdesc_sync(struct dwc_gmac_sof
 	if (end > start) {
 		bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
 		TX_DESC_OFFSET(start),
-		TX_DESC_OFFSET(end)-TX_DESC_OFFSET(start),
+		TX_DESC_OFFSET(end) - TX_DESC_OFFSET(start),
 		ops);
 		return;
 	}
 	/* sync from 'start' to end of ring */
 	bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
 	TX_DESC_OFFSET(start),
-	TX_DESC_OFFSET(AWGE_TX_RING_COUNT)-TX_DESC_OFFSET(start),
+	TX_DESC_OFFSET(AWGE_TX_RING_COUNT) - TX_DESC_OFFSET(start),
 	ops);
 	if (TX_DESC_OFFSET(end) - TX_DESC_OFFSET(0) > 0) {
 		/* sync from start of ring to 'end' */
 		bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
 		TX_DESC_OFFSET(0),
-		TX_DESC_OFFSET(end)-TX_DESC_OFFSET(0),
+		TX_DESC_OFFSET(end) - TX_DESC_OFFSET(0),
 		ops);
 	}
 }



CVS commit: src/sys/dev/ic

2024-03-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Mar  3 10:02:11 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
More KNF (whitespace around binary operators)


To generate a diff of this commit:
cvs rdiff -u -r1.83 -r1.84 src/sys/dev/ic/dwc_gmac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-02-29 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Thu Feb 29 22:02:41 UTC 2024

Modified Files:
src/sys/dev/ic: mpc106reg.h

Log Message:
Fix couple typos in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/mpc106reg.h

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/ic/mpc106reg.h
diff -u src/sys/dev/ic/mpc106reg.h:1.4 src/sys/dev/ic/mpc106reg.h:1.5
--- src/sys/dev/ic/mpc106reg.h:1.4	Mon Apr 28 20:23:50 2008
+++ src/sys/dev/ic/mpc106reg.h	Thu Feb 29 22:02:41 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: mpc106reg.h,v 1.4 2008/04/28 20:23:50 martin Exp $	*/
+/*	$NetBSD: mpc106reg.h,v 1.5 2024/02/29 22:02:41 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2001,2007 The NetBSD Foundation, Inc.
@@ -86,7 +86,7 @@
 	/* must be read with MPC106_PICR1_EXT_L2_EN :
 	 * L2_EN	L2_MP	Meaning
 	 * 0		00	Uniprocessor/none
-	 * 0		01	internal conrol/write-through
+	 * 0		01	internal control/write-through
 	 * 0		10	internal control/write-back
 	 * 0		11	Multiproc/none
 	 * 1		00	Uniprocessor/external L2
@@ -185,7 +185,7 @@
 #define  MPC106_MCRR2_EXT_ECM_ECC_EN	__BIT(18) /* ext. ECM ECC enable */
 #define  MPC106_MCRR2_ECC_EN	__BIT(17)	/* ECC enable */
 #define  MPC106_MCRR2_EDO	__BIT(16)	/* EDO enable */
-#define  MPC106_MCRR2_REFINT	__BITS(15,2)	/* refreash interval */
+#define  MPC106_MCRR2_REFINT	__BITS(15,2)	/* refresh interval */
 #define  MPC106_MCRR2_BUFMODE	__BIT(1)	/* buffer mode */
 #define  MPC106_MCRR2_RMW_PAR	__BIT(0)	/* RMW parity enable */
 #define	MPC106_MCCR3		0xf8	/* Memory control configuration 3 */



CVS commit: src/sys/dev/ic

2024-02-29 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Thu Feb 29 22:02:41 UTC 2024

Modified Files:
src/sys/dev/ic: mpc106reg.h

Log Message:
Fix couple typos in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/ic/mpc106reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-02-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Feb 27 08:33:07 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac_var.h

Log Message:
Use __BIT.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/dwc_gmac_var.h

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/ic/dwc_gmac_var.h
diff -u src/sys/dev/ic/dwc_gmac_var.h:1.18 src/sys/dev/ic/dwc_gmac_var.h:1.19
--- src/sys/dev/ic/dwc_gmac_var.h:1.18	Sun Feb 11 12:25:20 2024
+++ src/sys/dev/ic/dwc_gmac_var.h	Tue Feb 27 08:33:06 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac_var.h,v 1.18 2024/02/11 12:25:20 skrll Exp $ */
+/* $NetBSD: dwc_gmac_var.h,v 1.19 2024/02/27 08:33:06 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -108,7 +108,7 @@ struct dwc_gmac_softc {
 	bus_space_handle_t sc_bsh;
 	bus_dma_tag_t sc_dmat;
 	uint32_t sc_flags;
-#define	DWC_GMAC_FORCE_THRESH_DMA_MODE	0x01	/* force DMA to use threshold mode */
+#define	DWC_GMAC_FORCE_THRESH_DMA_MODE	__BIT(0)/* force DMA to use threshold mode */
 	struct ethercom sc_ec;
 	struct mii_data sc_mii;
 	kmutex_t sc_mdio_lock;



CVS commit: src/sys/dev/ic

2024-02-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Feb 27 08:33:07 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac_var.h

Log Message:
Use __BIT.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/ic/dwc_gmac_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-02-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Feb 27 08:28:56 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Enforce the device 32 bit DMA limitation via bus_dmatag_subregion if bus
can address more than 4GB.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.82 src/sys/dev/ic/dwc_gmac.c:1.83
--- src/sys/dev/ic/dwc_gmac.c:1.82	Tue Feb 27 08:25:38 2024
+++ src/sys/dev/ic/dwc_gmac.c	Tue Feb 27 08:28:56 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.82 2024/02/27 08:25:38 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.83 2024/02/27 08:28:56 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.82 2024/02/27 08:25:38 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.83 2024/02/27 08:28:56 skrll Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -245,6 +245,17 @@ dwc_gmac_attach(struct dwc_gmac_softc *s
 		aprint_normal_dev(sc->sc_dev,
 		"HW feature mask: %x\n", hwft);
 	}
+
+	if (sizeof(bus_addr_t) > 4) {
+		int error = bus_dmatag_subregion(sc->sc_dmat, 0, __MASK(32),
+		&sc->sc_dmat, BUS_DMA_WAITOK);
+		if (error != 0) {
+			aprint_error_dev(sc->sc_dev,
+			"failed to create DMA subregion\n");
+			return ENOMEM;
+		}
+	}
+
 	if (hwft & GMAC_DMA_FEAT_ENHANCED_DESC) {
 		aprint_normal_dev(sc->sc_dev,
 		"Using enhanced descriptor format\n");



CVS commit: src/sys/dev/ic

2024-02-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Feb 27 08:28:56 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Enforce the device 32 bit DMA limitation via bus_dmatag_subregion if bus
can address more than 4GB.


To generate a diff of this commit:
cvs rdiff -u -r1.82 -r1.83 src/sys/dev/ic/dwc_gmac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-02-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Feb 27 08:25:38 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
KNF - spaces around binary operators.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.81 src/sys/dev/ic/dwc_gmac.c:1.82
--- src/sys/dev/ic/dwc_gmac.c:1.81	Sun Feb 11 12:28:20 2024
+++ src/sys/dev/ic/dwc_gmac.c	Tue Feb 27 08:25:38 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.81 2024/02/11 12:28:20 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.82 2024/02/27 08:25:38 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.81 2024/02/11 12:28:20 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.82 2024/02/27 08:25:38 skrll Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -147,12 +147,12 @@ static const struct dwc_gmac_desc_method
 };
 
 
-#define	TX_DESC_OFFSET(N)	((AWGE_RX_RING_COUNT+(N)) \
-*sizeof(struct dwc_gmac_dev_dmadesc))
-#define	TX_NEXT(N)		(((N)+1) & (AWGE_TX_RING_COUNT-1))
+#define	TX_DESC_OFFSET(N)	((AWGE_RX_RING_COUNT + (N)) \
+* sizeof(struct dwc_gmac_dev_dmadesc))
+#define	TX_NEXT(N)		(((N) + 1) & (AWGE_TX_RING_COUNT - 1))
 
-#define RX_DESC_OFFSET(N)	((N)*sizeof(struct dwc_gmac_dev_dmadesc))
-#define	RX_NEXT(N)		(((N)+1) & (AWGE_RX_RING_COUNT-1))
+#define RX_DESC_OFFSET(N)	((N) * sizeof(struct dwc_gmac_dev_dmadesc))
+#define	RX_NEXT(N)		(((N) + 1) & (AWGE_RX_RING_COUNT - 1))
 
 
 
@@ -528,7 +528,7 @@ dwc_gmac_alloc_rx_ring(struct dwc_gmac_s
 	}
 
 	bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map, 0,
-	AWGE_RX_RING_COUNT*sizeof(struct dwc_gmac_dev_dmadesc),
+	AWGE_RX_RING_COUNT * sizeof(struct dwc_gmac_dev_dmadesc),
 	BUS_DMASYNC_PREWRITE | BUS_DMASYNC_PREREAD);
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_RX_ADDR,
 	ring->r_physaddr);
@@ -558,7 +558,7 @@ dwc_gmac_reset_rx_ring(struct dwc_gmac_s
 	}
 
 	bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map, 0,
-	AWGE_RX_RING_COUNT*sizeof(struct dwc_gmac_dev_dmadesc),
+	AWGE_RX_RING_COUNT * sizeof(struct dwc_gmac_dev_dmadesc),
 	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 
 	ring->r_cur = ring->r_next = 0;
@@ -616,7 +616,7 @@ dwc_gmac_alloc_dma_rings(struct dwc_gmac
 	/* and next rings to the TX side */
 	sc->sc_txq.t_desc = sc->sc_rxq.r_desc + AWGE_RX_RING_COUNT;
 	sc->sc_txq.t_physaddr = sc->sc_rxq.r_physaddr +
-	AWGE_RX_RING_COUNT*sizeof(struct dwc_gmac_dev_dmadesc);
+	AWGE_RX_RING_COUNT * sizeof(struct dwc_gmac_dev_dmadesc);
 
 	return 0;
 
@@ -652,7 +652,7 @@ dwc_gmac_free_rx_ring(struct dwc_gmac_so
 		if (data->rd_map != NULL) {
 			bus_dmamap_sync(sc->sc_dmat, data->rd_map, 0,
 			AWGE_RX_RING_COUNT
-*sizeof(struct dwc_gmac_dev_dmadesc),
+* sizeof(struct dwc_gmac_dev_dmadesc),
 			BUS_DMASYNC_POSTREAD);
 			bus_dmamap_unload(sc->sc_dmat, data->rd_map);
 			bus_dmamap_destroy(sc->sc_dmat, data->rd_map);
@@ -671,10 +671,10 @@ dwc_gmac_alloc_tx_ring(struct dwc_gmac_s
 	ring->t_queued = 0;
 	ring->t_cur = ring->t_next = 0;
 
-	memset(ring->t_desc, 0, AWGE_TX_RING_COUNT*sizeof(*ring->t_desc));
+	memset(ring->t_desc, 0, AWGE_TX_RING_COUNT * sizeof(*ring->t_desc));
 	bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
 	TX_DESC_OFFSET(0),
-	AWGE_TX_RING_COUNT*sizeof(struct dwc_gmac_dev_dmadesc),
+	AWGE_TX_RING_COUNT * sizeof(struct dwc_gmac_dev_dmadesc),
 	BUS_DMASYNC_POSTWRITE);
 
 	for (i = 0; i < AWGE_TX_RING_COUNT; i++) {
@@ -747,7 +747,7 @@ dwc_gmac_reset_tx_ring(struct dwc_gmac_s
 
 	bus_dmamap_sync(sc->sc_dmat, sc->sc_dma_ring_map,
 	TX_DESC_OFFSET(0),
-	AWGE_TX_RING_COUNT*sizeof(struct dwc_gmac_dev_dmadesc),
+	AWGE_TX_RING_COUNT * sizeof(struct dwc_gmac_dev_dmadesc),
 	BUS_DMASYNC_PREREAD | BUS_DMASYNC_PREWRITE);
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, AWIN_GMAC_DMA_TX_ADDR,
 	sc->sc_txq.t_physaddr);
@@ -1179,11 +1179,11 @@ dwc_gmac_tx_intr(struct dwc_gmac_softc *
 #endif
 
 		/*
-		 * i+1 does not need to be a valid descriptor,
+		 * i + 1 does not need to be a valid descriptor,
 		 * this is just a special notion to just sync
 		 * a single tx descriptor (i)
 		 */
-		dwc_gmac_txdesc_sync(sc, i, i+1,
+		dwc_gmac_txdesc_sync(sc, i, i + 1,
 		BUS_DMASYNC_POSTREAD | BUS_DMASYNC_POSTWRITE);
 
 		desc = &sc->sc_txq.t_desc[i];
@@ -1651,7 +1651,7 @@ dwc_gmac_dump_tx_desc(struct dwc_gmac_so
 		aprint_normal("#%d (%08lx): status: %08x cntl: %08x "
 		"data: %08x next: %08x\n",
 		i, sc->sc_txq.t_physaddr +
-			i*sizeof(struct dwc_gmac_dev_dmadesc),
+			i * sizeof(struct dwc_gmac_dev_dmadesc),
 		le32toh(desc->ddesc_status0), le32toh(desc->ddesc_cntl1),
 		le32toh(desc->ddesc_data), le32toh(desc->ddesc_next));
 	}
@@ 

CVS commit: src/sys/dev/ic

2024-02-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Feb 27 08:25:38 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
KNF - spaces around binary operators.


To generate a diff of this commit:
cvs rdiff -u -r1.81 -r1.82 src/sys/dev/ic/dwc_gmac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-02-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Feb 27 08:21:24 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac_reg.h

Log Message:
Remove unused "SHIFT" defines. The "MASK" versions exist.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/ic/dwc_gmac_reg.h

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/ic/dwc_gmac_reg.h
diff -u src/sys/dev/ic/dwc_gmac_reg.h:1.21 src/sys/dev/ic/dwc_gmac_reg.h:1.22
--- src/sys/dev/ic/dwc_gmac_reg.h:1.21	Wed May 11 14:58:01 2022
+++ src/sys/dev/ic/dwc_gmac_reg.h	Tue Feb 27 08:21:24 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac_reg.h,v 1.21 2022/05/11 14:58:01 andvar Exp $ */
+/* $NetBSD: dwc_gmac_reg.h,v 1.22 2024/02/27 08:21:24 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -133,9 +133,7 @@
 #define	AWIN_GMAC_DMA_CUR_RX_BUFADDR	0x1054
 #define	AWIN_GMAC_DMA_HWFEATURES	0x1058	/* not always implemented? */
 
-#define	GMAC_MII_PHY_SHIFT		11
 #define	GMAC_MII_PHY_MASK		__BITS(15,11)
-#define	GMAC_MII_REG_SHIFT		6
 #define	GMAC_MII_REG_MASK		__BITS(10,6)
 
 #define	GMAC_MII_BUSY			__BIT(0)
@@ -221,7 +219,6 @@ struct dwc_gmac_dev_dmadesc {
 /* for RX descriptors */
 #define	DDESC_STATUS_DAFILTERFAIL	__BIT(30)
 #define	DDESC_STATUS_FRMLENMSK		__BITS(29,16)
-#define	DDESC_STATUS_FRMLENSHIFT	16
 #define	DDESC_STATUS_RXERROR		__BIT(15)
 #define	DDESC_STATUS_RXTRUNCATED	__BIT(14)
 #define	DDESC_STATUS_SAFILTERFAIL	__BIT(13)



CVS commit: src/sys/dev/ic

2024-02-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Feb 27 08:21:24 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac_reg.h

Log Message:
Remove unused "SHIFT" defines. The "MASK" versions exist.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/ic/dwc_gmac_reg.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-02-19 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Feb 19 14:54:04 UTC 2024

Modified Files:
src/sys/dev/ic: ciss.c

Log Message:
ciss(4): Fix panic when the number of logical drive is zero.

 Currently, this drives requires at least one logical drive.
If there is no any logical volume, don't attach the driver.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/ic/ciss.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/ic/ciss.c
diff -u src/sys/dev/ic/ciss.c:1.55 src/sys/dev/ic/ciss.c:1.56
--- src/sys/dev/ic/ciss.c:1.55	Thu Aug 17 14:19:50 2023
+++ src/sys/dev/ic/ciss.c	Mon Feb 19 14:54:04 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: ciss.c,v 1.55 2023/08/17 14:19:50 andvar Exp $	*/
+/*	$NetBSD: ciss.c,v 1.56 2024/02/19 14:54:04 msaitoh Exp $	*/
 /*	$OpenBSD: ciss.c,v 1.68 2013/05/30 16:15:02 deraadt Exp $	*/
 
 /*
@@ -19,7 +19,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ciss.c,v 1.55 2023/08/17 14:19:50 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ciss.c,v 1.56 2024/02/19 14:54:04 msaitoh Exp $");
 
 #include "bio.h"
 
@@ -427,6 +427,14 @@ ciss_attach(struct ciss_softc *sc)
 
 	mutex_exit(&sc->sc_mutex_scratch);
 
+	if (sc->maxunits == 0) {
+		bus_dmamem_free(sc->sc_dmat, sc->cmdseg, 1);
+		bus_dmamap_destroy(sc->sc_dmat, sc->cmdmap);
+		aprint_error_dev(sc->sc_dev,
+		"No any LD. This driver can't attach.\n");
+		return -1;
+	}
+
 	callout_init(&sc->sc_hb, 0);
 	callout_setfunc(&sc->sc_hb, ciss_heartbeat, sc);
 	callout_schedule(&sc->sc_hb, hz * 3);



CVS commit: src/sys/dev/ic

2024-02-19 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Mon Feb 19 14:54:04 UTC 2024

Modified Files:
src/sys/dev/ic: ciss.c

Log Message:
ciss(4): Fix panic when the number of logical drive is zero.

 Currently, this drives requires at least one logical drive.
If there is no any logical volume, don't attach the driver.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/dev/ic/ciss.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-02-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Feb 13 13:17:51 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
in sti_screen_setup() don't bother looking for fonts if STI_FBMODE is requested


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/ic/sti.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/ic/sti.c
diff -u src/sys/dev/ic/sti.c:1.34 src/sys/dev/ic/sti.c:1.35
--- src/sys/dev/ic/sti.c:1.34	Thu Feb  1 06:50:36 2024
+++ src/sys/dev/ic/sti.c	Tue Feb 13 13:17:51 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: sti.c,v 1.34 2024/02/01 06:50:36 skrll Exp $	*/
+/*	$NetBSD: sti.c,v 1.35 2024/02/13 13:17:51 macallan Exp $	*/
 
 /*	$OpenBSD: sti.c,v 1.61 2009/09/05 14:09:35 miod Exp $	*/
 
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.34 2024/02/01 06:50:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sti.c,v 1.35 2024/02/13 13:17:51 macallan Exp $");
 
 #include "wsdisplay.h"
 
@@ -556,6 +556,12 @@ sti_screen_setup(struct sti_screen *scr,
 	scr->owidth = cfg.owidth;
 	memcpy(scr->name, cfg.name, sizeof(scr->name));
 
+	if (flags & STI_FBMODE) {
+		/* we're done here */
+		sti_init(scr, STI_FBMODE);
+		return 0;
+	}
+
 	if ((error = sti_init(scr, STI_TEXTMODE | flags))) {
 		aprint_error(": cannot initialize (%d)\n", error);
 		goto fail;



CVS commit: src/sys/dev/ic

2024-02-13 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Feb 13 13:17:51 UTC 2024

Modified Files:
src/sys/dev/ic: sti.c

Log Message:
in sti_screen_setup() don't bother looking for fonts if STI_FBMODE is requested


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/dev/ic/sti.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-02-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb 11 12:28:20 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Fix spello in debug output


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/dev/ic/dwc_gmac.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/ic/dwc_gmac.c
diff -u src/sys/dev/ic/dwc_gmac.c:1.80 src/sys/dev/ic/dwc_gmac.c:1.81
--- src/sys/dev/ic/dwc_gmac.c:1.80	Wed Dec 20 18:09:19 2023
+++ src/sys/dev/ic/dwc_gmac.c	Sun Feb 11 12:28:20 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac.c,v 1.80 2023/12/20 18:09:19 skrll Exp $ */
+/* $NetBSD: dwc_gmac.c,v 1.81 2024/02/11 12:28:20 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
 
 #include 
 
-__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.80 2023/12/20 18:09:19 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: dwc_gmac.c,v 1.81 2024/02/11 12:28:20 skrll Exp $");
 
 /* #define	DWC_GMAC_DEBUG	1 */
 
@@ -1052,7 +1052,7 @@ dwc_gmac_queue(struct dwc_gmac_softc *sc
 		desc->ddesc_data = htole32(map->dm_segs[i].ds_addr);
 
 #ifdef DWC_GMAC_DEBUG
-		aprint_normal_dev(sc->sc_dev, "enqueing desc #%d data %08lx "
+		aprint_normal_dev(sc->sc_dev, "enqueuing desc #%d data %08lx "
 		"len %lu\n", sc->sc_txq.t_cur,
 		(unsigned long)map->dm_segs[i].ds_addr,
 		(unsigned long)map->dm_segs[i].ds_len);



CVS commit: src/sys/dev/ic

2024-02-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb 11 12:28:20 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac.c

Log Message:
Fix spello in debug output


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/dev/ic/dwc_gmac.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/dev/ic

2024-02-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb 11 12:25:20 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac_var.h

Log Message:
Fix a comment. arm32 stopped using 8K pages a long time ago.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/dwc_gmac_var.h

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/ic/dwc_gmac_var.h
diff -u src/sys/dev/ic/dwc_gmac_var.h:1.17 src/sys/dev/ic/dwc_gmac_var.h:1.18
--- src/sys/dev/ic/dwc_gmac_var.h:1.17	Sun Sep 18 18:26:53 2022
+++ src/sys/dev/ic/dwc_gmac_var.h	Sun Feb 11 12:25:20 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: dwc_gmac_var.h,v 1.17 2022/09/18 18:26:53 thorpej Exp $ */
+/* $NetBSD: dwc_gmac_var.h,v 1.18 2024/02/11 12:25:20 skrll Exp $ */
 
 /*-
  * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc.
@@ -45,12 +45,9 @@
 #endif
 
 /*
- * We could use 1024 DMA descriptors to fill up an 8k page (each is 16 byte).
- * However, on TX we probably will not need that many, and on RX we allocate
- * a full mbuf cluster for each, so secondary memory consumption will grow
- * rapidly.
- * So currently we waste half a page of dma memory and consume 512k Byte of
- * RAM for mbuf clusters.
+ * Rx and Tx Ring counts that map into single 4K page with 16byte descriptor
+ * size. For Rx a full mbuf cluster is allocated for each which consumes
+ * around 512k Byte of RAM for mbuf clusters.
  * XXX Maybe fine-tune later, or reconsider unsharing of RX/TX dmamap.
  */
 #define		AWGE_RX_RING_COUNT	256



CVS commit: src/sys/dev/ic

2024-02-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Feb 11 12:25:20 UTC 2024

Modified Files:
src/sys/dev/ic: dwc_gmac_var.h

Log Message:
Fix a comment. arm32 stopped using 8K pages a long time ago.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/dev/ic/dwc_gmac_var.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



  1   2   3   4   5   6   7   >