CVS commit: src/sys/arch/evbarm/conf

2020-03-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Mar 26 07:38:32 UTC 2020

Modified Files:
src/sys/arch/evbarm/conf: RPI_INSTALL

Log Message:
Increase MEMORY_DISK_ROOT_SIZE


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/evbarm/conf/RPI_INSTALL

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

Modified files:

Index: src/sys/arch/evbarm/conf/RPI_INSTALL
diff -u src/sys/arch/evbarm/conf/RPI_INSTALL:1.13 src/sys/arch/evbarm/conf/RPI_INSTALL:1.14
--- src/sys/arch/evbarm/conf/RPI_INSTALL:1.13	Mon Mar 23 22:29:23 2020
+++ src/sys/arch/evbarm/conf/RPI_INSTALL	Thu Mar 26 07:38:31 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: RPI_INSTALL,v 1.13 2020/03/23 22:29:23 prlw1 Exp $
+#	$NetBSD: RPI_INSTALL,v 1.14 2020/03/26 07:38:31 skrll Exp $
 #
 #	RPI_INSTALL -- RPI kernel with installation-sized
 #	ramdisk
@@ -8,7 +8,7 @@ include "arch/evbarm/conf/RPI"
 include "arch/evbarm/conf/INSTALL"
 
 no options	MEMORY_DISK_ROOT_SIZE
-options 	MEMORY_DISK_ROOT_SIZE=86000
+options 	MEMORY_DISK_ROOT_SIZE=9
 
 makeoptions	RAMDISKNAME=sshramdisk
 no makeoptions	DEBUG



CVS commit: src/distrib/evbarm/instkernel/sshramdisk

2020-03-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Mar 26 07:44:43 UTC 2020

Modified Files:
src/distrib/evbarm/instkernel/sshramdisk: Makefile

Log Message:
Bump IMAGESIZE


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/distrib/evbarm/instkernel/sshramdisk/Makefile

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

Modified files:

Index: src/distrib/evbarm/instkernel/sshramdisk/Makefile
diff -u src/distrib/evbarm/instkernel/sshramdisk/Makefile:1.24 src/distrib/evbarm/instkernel/sshramdisk/Makefile:1.25
--- src/distrib/evbarm/instkernel/sshramdisk/Makefile:1.24	Mon Mar 23 11:45:00 2020
+++ src/distrib/evbarm/instkernel/sshramdisk/Makefile	Thu Mar 26 07:44:43 2020
@@ -1,10 +1,10 @@
-#	$NetBSD: Makefile,v 1.24 2020/03/23 11:45:00 martin Exp $
+#	$NetBSD: Makefile,v 1.25 2020/03/26 07:44:43 skrll Exp $
 
 .include 
 .include "${NETBSDSRCDIR}/distrib/common/Makefile.distrib"
 
 IMAGE=		sshramdisk.fs
-IMAGESIZE=	43000k
+IMAGESIZE=	45000k
 MAKEFS_FLAGS+=	-f 15
 
 .if ${MKREPRO_TIMESTAMP:Uno} != "no"



CVS commit: src/distrib/evbarm/instkernel

2020-03-26 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Mar 26 08:02:55 UTC 2020

Modified Files:
src/distrib/evbarm/instkernel: Makefile

Log Message:
Only build sshramdisk when building RPI_INSTALLx


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/distrib/evbarm/instkernel/Makefile

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

Modified files:

Index: src/distrib/evbarm/instkernel/Makefile
diff -u src/distrib/evbarm/instkernel/Makefile:1.4 src/distrib/evbarm/instkernel/Makefile:1.5
--- src/distrib/evbarm/instkernel/Makefile:1.4	Tue Mar 19 22:16:52 2013
+++ src/distrib/evbarm/instkernel/Makefile	Thu Mar 26 08:02:55 2020
@@ -1,6 +1,12 @@
-#	$NetBSD: Makefile,v 1.4 2013/03/19 22:16:52 garbled Exp $
+#	$NetBSD: Makefile,v 1.5 2020/03/26 08:02:55 skrll Exp $
 
-SUBDIR=		ramdisk sshramdisk .WAIT instkernel
+SUBDIR=		ramdisk
+
+.if !empty(ALL_KERNELS:MRPI_INSTALL)
+SUBDIR+=	sshramdisk
+.endif
+
+SUBDIR+=	.WAIT instkernel
 TARGETS+=	release
 
 .include 



CVS commit: src/sys/arch/arm/sociox

2020-03-26 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Mar 26 08:28:50 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: if_scx.c

Log Message:
correct global reset logic. still remains MII speed trouble.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/arm/sociox/if_scx.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/arch/arm/sociox/if_scx.c
diff -u src/sys/arch/arm/sociox/if_scx.c:1.15 src/sys/arch/arm/sociox/if_scx.c:1.16
--- src/sys/arch/arm/sociox/if_scx.c:1.15	Thu Mar 26 01:05:26 2020
+++ src/sys/arch/arm/sociox/if_scx.c	Thu Mar 26 08:28:50 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_scx.c,v 1.15 2020/03/26 01:05:26 nisimura Exp $	*/
+/*	$NetBSD: if_scx.c,v 1.16 2020/03/26 08:28:50 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.15 2020/03/26 01:05:26 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.16 2020/03/26 08:28:50 nisimura Exp $");
 
 #include 
 #include 
@@ -202,7 +202,7 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 	 */
 #define  _BMR		0x00412080	/* XXX TBD */
 #define  _BMR0		0x00020181	/* XXX TBD */
-#define  BMR_RST	(1U<<0)		/* reset op. self clear when done */
+#define  BMR_RST	(1)		/* reset op. self clear when done */
 #define GMACTDS		0x1004		/* write any to resume tdes */
 #define GMACRDS		0x1008		/* write any to resume rdes */
 #define GMACRDLAR	0x100c		/* rdes base address 32bit paddr */
@@ -585,6 +585,8 @@ aprint_normal_dev(self,
 	sc->sc_100mii = (phy_mode && strcmp(phy_mode, "rgmii") != 0);
 	sc->sc_phy_id = (int)acpi_phy;
 	sc->sc_freq = acpi_freq;
+aprint_normal_dev(self,
+"GMACGAR %08x\n", mac_read(sc, GMACGAR));
 
 	scx_attach_i(sc);
 
@@ -631,7 +633,7 @@ scx_attach_i(struct scx_softc *sc)
 
 sc->sc_phy_id = MII_PHY_ANY;
 	sc->sc_mdclk = get_mdioclk(sc->sc_freq); /* 5:2 clk control */
-sc->sc_mdclk = 5; /* XXX */
+sc->sc_mdclk = 0; /* XXX */
 aprint_normal_dev(sc->sc_dev, "using %d for mdclk\n", sc->sc_mdclk);
 sc->sc_mdclk <<= 2;
 
@@ -776,16 +778,18 @@ aprint_normal_dev(sc->sc_dev, "descripto
 static void
 scx_reset(struct scx_softc *sc)
 {
+	int loop = 0, busy;
 
-	mac_write(sc, GMACBMR, BMR_RST); /* may take for a while */
-	(void)spin_waitfor(sc, GMACBMR, BMR_RST);
+	mac_write(sc, GMACBMR, _BMR0); /* may take for a while */
+	do {
+		DELAY(10);
+		busy = mac_read(sc, GMACBMR) & BMR_RST;
+	} while (++loop < 3000 && busy);
+printf("reset done with %d loop\n", loop);
 
 	CSR_WRITE(sc, DESCENG_SRST, 1);
 	CSR_WRITE(sc, DESCENG_INIT, 1);
 	mac_write(sc, GMACBMR, _BMR);
-	mac_write(sc, GMACRDLAR, _RDLAR);
-	mac_write(sc, GMACTDLAR, _TDLAR);
-	mac_write(sc, GMACAFR, _AFR);
 	mac_write(sc, GMACEVCTL, 1);
 }
 
@@ -1444,16 +1448,16 @@ add_rxbuf(struct scx_softc *sc, int i)
 static int
 spin_waitfor(struct scx_softc *sc, int reg, int exist)
 {
-	int val, loop;
+	int busy, loop;
 
-	val = CSR_READ(sc, reg);
-	if ((val & exist) == 0)
+	busy = CSR_READ(sc, reg) & exist;
+	if (busy == 0)
 		return 0;
 	loop = 3000;
 	do {
 		DELAY(10);
-		val = CSR_READ(sc, reg);
-	} while (--loop > 0 && (val & exist));
+		busy = CSR_READ(sc, reg) & exist;
+	} while (--loop > 0 && busy);
 	return (loop > 0) ? 0 : ETIMEDOUT;
 }
 



CVS commit: src/sys/arch/arm/sociox

2020-03-26 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Thu Mar 26 10:38:16 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: if_scx.c

Log Message:
update register definition. from UEFI source code.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/arm/sociox/if_scx.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/arch/arm/sociox/if_scx.c
diff -u src/sys/arch/arm/sociox/if_scx.c:1.16 src/sys/arch/arm/sociox/if_scx.c:1.17
--- src/sys/arch/arm/sociox/if_scx.c:1.16	Thu Mar 26 08:28:50 2020
+++ src/sys/arch/arm/sociox/if_scx.c	Thu Mar 26 10:38:16 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_scx.c,v 1.16 2020/03/26 08:28:50 nisimura Exp $	*/
+/*	$NetBSD: if_scx.c,v 1.17 2020/03/26 10:38:16 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -40,14 +40,14 @@
  *   to designify ring number from which to arrive or to which go.
  * - memory mapped EEPROM to hold MAC address. The rest of the area is
  *   occupied by a set of ucode for two DMA engines and one packet engine.
- * - The size of frame address filter is unknown. Might be 16 or even 128.
+ * - The size of frame address filter is 16 plus 32.
  * - The first slot is my own station address. Always enabled to perform
  *   to identify oneself.
  * - 1~16 are for supplimental MAC addresses. Independently enabled for
  *   use. Good to catch multicast. Byte-wise selective match available.
  *   Use the mask to catch { 0x01, 0x00, 0x00 } and/or { 0x33, 0x33 }.
- * - 16~128 might be exact match without byte-mask.
- * - The size of multicast hash filter store is unknown. Might be 256 bit.
+ * - 16~32 might be exact match without byte-mask.
+ * - The size of multicast hash filter store is 64 bit.
  * - Socionext/Linaro "NetSec" code makes many cut shorts. Some constants
  *   are left unexplained. The values should be handled via external
  *   controls like FDT descriptions. Fortunately, Intel/Altera CycloneV PDFs
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.16 2020/03/26 08:28:50 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.17 2020/03/26 10:38:16 nisimura Exp $");
 
 #include 
 #include 
@@ -86,6 +86,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 
 /* SC2A11 register block */
 #define SWRESET		0x104
+#define MACADRH		0x10c
+#define MACADRL		0x110
 #define COMINIT		0x120
 #define INTRST		0x200
 #define  IRQ_RX		(1U<<1)
@@ -115,8 +117,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define H2MENG		0x210		/* DMAC host2media ucode port */
 #define M2HENG		0x21c		/* DMAC media2host ucode port */
 #define PKTENG		0x0d0		/* packet engine ucode port */
-#define HWVER0		0x22c
-#define HWVER1		0x230
+#define MCVER		0x22c		/* micro controller version */
+#define HWVER		0x230		/* hardware version */
 
 #define MACSTAT		0x1024		/* gmac status */
 #define MACDATA		0x11c0		/* gmac rd/wr data */
@@ -154,8 +156,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define  AFR_UHTE	(1U<<1)		/* use additional MAC addresses */
 #define  AFR_PM		(1U<<0)		/* run promisc mode */
 #define  _AFR		0x8001	/* XXX TBD */
-#define GMACMHTH	0x0008		/* XXX multicast hash table 63:32 */
-#define GMACMHTL	0x000c		/* XXX multicast hash table 31:0 */
+#define GMACMHTH	0x0008		/* multicast hash table 63:32 */
+#define GMACMHTL	0x000c		/* multicast hash table 31:0 */
 #define GMACGAR		0x0010		/* MDIO operation */
 #define  GAR_PHY	(11)		/* mii phy 15:11 */
 #define  GAR_REG	(6)		/* mii reg 10:6 */
@@ -180,13 +182,13 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 	 *	2 125Mhz (1000Mbps)
 	 *  1   full duplex detected */
 
-#define GMACMHT0	0x0500		/* multicast hash table 0 - 7 */
+#define GMACMHT0	0x0500		/* XXX multicast hash table 0 - 7 */
 #define GMACMHT(i)	((i)*4+0x500)
 #define GMACVHT		0x0588		/* VLAN tag hash */
-#define GMACAMAH(i)	((i)*8+0x800)	/* supplimental MAC addr 16-127 */
+#define GMACAMAH(i)	((i)*8+0x800)	/* supplimental MAC addr 16-31 */
 #define GMACAMAL(i)	((i)*8+0x804)
+#define GMACEVCTL	0x0100		/* event counter control */
 #define GMACEVCNT(i)	((i)*4+0x114)	/* event counter 0x114~284 */
-#define GMACEVCTL	0x0100		/* clear event counter registers */
 
 #define GMACBMR		0x1000		/* DMA bus mode control
 	 * 244PBL
@@ -613,7 +615,7 @@ scx_attach_i(struct scx_softc *sc)
 	uint32_t csr;
 	int i, nseg, error = 0;
 
-	hwver = CSR_READ(sc, HWVER1);	/* Socionext HW */
+	hwver = CSR_READ(sc, HWVER);	/* Socionext HW */
 	/* stored in big endian order */
 	csr = bus_space_read_4(sc->sc_st, sc->sc_eesh, 0);
 	enaddr[0] = csr >> 24;
@@ -953,7 +955,7 @@ scx_set_rcvfilt(struct scx_softc *sc)
 	struct ifnet * const ifp = &ec->ec_if;
 	struct ether_multistep step;
 	struct ether_multi *enm;
-	uint32_t mchash[8]; 	/* 8x 32 = 256 bit */
+	uint32_t mchash[2]; 	/* 2x 32 = 64 bit */
 	uint32_t csr, crc;
 	int i;
 
@@ -972,9 +974,8 @@ scx_set_rcvfilt(struct scx_softc *sc)
 	/* clear 15 ent

CVS commit: src/sys/dev/audio

2020-03-26 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Mar 26 13:32:03 UTC 2020

Modified Files:
src/sys/dev/audio: audio.c

Log Message:
Fix to start recording immediately when open() with READ mode is
called (unless pause).
- Opening /dev/audio always initializes pause with false.  Therefore
  it always starts recording.
- Opening /dev/sound inherites pause from the sticky parameter.
  Therefore whether /dev/sound starts recording or not depends on the
  sticky pause parameter.
This fixes two problems:
- Opening /dev/audio didn't start recording after merging isaki-audio2.
- Opening /dev/sound didn't start recording regardless of the sticky
  pause, probably since long time ago (at least netbsd-7).


To generate a diff of this commit:
cvs rdiff -u -r1.64 -r1.65 src/sys/dev/audio/audio.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/audio/audio.c
diff -u src/sys/dev/audio/audio.c:1.64 src/sys/dev/audio/audio.c:1.65
--- src/sys/dev/audio/audio.c:1.64	Sat Mar  7 06:27:19 2020
+++ src/sys/dev/audio/audio.c	Thu Mar 26 13:32:03 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.64 2020/03/07 06:27:19 isaki Exp $	*/
+/*	$NetBSD: audio.c,v 1.65 2020/03/26 13:32:03 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.64 2020/03/07 06:27:19 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.65 2020/03/26 13:32:03 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -2229,7 +2229,10 @@ audio_open(dev_t dev, struct audio_softc
 goto bad3;
 		}
 	}
-	/* Call init_input if this is the first recording open. */
+	/*
+	 * Call init_input and start rmixer, if this is the first recording
+	 * open.  See pause consideration notes.
+	 */
 	if (af->rtrack && sc->sc_ropens == 0) {
 		if (sc->hw_if->init_input) {
 			hwbuf = &sc->sc_rmixer->hwbuf;
@@ -2244,6 +2247,10 @@ audio_open(dev_t dev, struct audio_softc
 			if (error)
 goto bad3;
 		}
+
+		mutex_enter(sc->sc_lock);
+		audio_rmixer_start(sc);
+		mutex_exit(sc->sc_lock);
 	}
 
 	if (bellfile == NULL) {
@@ -2462,21 +2469,18 @@ audio_read(struct audio_softc *sc, struc
 
 	TRACET(2, track, "resid=%zd", uio->uio_resid);
 
+#ifdef AUDIO_PM_IDLE
 	error = audio_exlock_mutex_enter(sc);
 	if (error)
 		return error;
 
-#ifdef AUDIO_PM_IDLE
 	if (device_is_active(&sc->sc_dev) || sc->sc_idle)
 		device_active(&sc->sc_dev, DVA_SYSTEM);
-#endif
 
-	/*
-	 * The first read starts rmixer.
-	 */
-	if (sc->sc_rbusy == false)
-		audio_rmixer_start(sc);
+	/* In recording, unlike playback, read() never operates rmixer. */
+
 	audio_exlock_mutex_exit(sc);
+#endif
 
 	usrbuf = &track->usrbuf;
 	input = track->input;
@@ -6680,10 +6684,22 @@ audio_mixers_get_format(struct audio_sof
 /*
  * Pause consideration:
  *
- * The introduction of these two behavior makes pause/unpause operation
- * simple.
- * 1. The first read/write access of the first track makes mixer start.
- * 2. A pause of the last track doesn't make mixer stop.
+ * Pausing/unpausing never affect [pr]mixer.  This single rule makes
+ * operation simple.  Note that playback and recording are asymmetric.
+ *
+ * For playback,
+ *  1. Any playback open doesn't start pmixer regardless of initial pause
+ * state of this track.
+ *  2. The first write access among playback tracks only starts pmixer
+ * regardless of this track's pause state.
+ *  3. Even a pause of the last playback track doesn't stop pmixer.
+ *  4. The last close of all playback tracks only stops pmixer.
+ *
+ * For recording,
+ *  1. The first recording open only starts rmixer regardless of initial
+ * pause state of this track.
+ *  2. Even a pause of the last track doesn't stop rmixer.
+ *  3. The last close of all recording tracks only stops rmixer.
  */
 
 /*



CVS commit: src/tests/dev/audio

2020-03-26 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Mar 26 13:37:44 UTC 2020

Modified Files:
src/tests/dev/audio: audiotest.c

Log Message:
Sync with sys/dev/audio/audio.c rev1.65.
> Fix to start recording immediately when open() with READ mode is called.
This affects only standalone test, not atf.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/dev/audio/audiotest.c

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

Modified files:

Index: src/tests/dev/audio/audiotest.c
diff -u src/tests/dev/audio/audiotest.c:1.8 src/tests/dev/audio/audiotest.c:1.9
--- src/tests/dev/audio/audiotest.c:1.8	Wed Mar 25 13:07:04 2020
+++ src/tests/dev/audio/audiotest.c	Thu Mar 26 13:37:44 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiotest.c,v 1.8 2020/03/25 13:07:04 isaki Exp $	*/
+/*	$NetBSD: audiotest.c,v 1.9 2020/03/26 13:37:44 isaki Exp $	*/
 
 /*
  * Copyright (C) 2019 Tetsuya Isaki. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: audiotest.c,v 1.8 2020/03/25 13:07:04 isaki Exp $");
+__RCSID("$NetBSD: audiotest.c,v 1.9 2020/03/26 13:37:44 isaki Exp $");
 
 #include 
 #include 
@@ -1557,14 +1557,14 @@ test_open(const char *devname, int mode)
 	XP_EQ(0, ai.record.waiting);
 		/* balance */
 	XP_EQ(exp_ropen, ai.record.open);
-	/*
-	 * NetBSD7,8 (may?) be active when opened in recording mode but
-	 * recording has not started yet. (?)
-	 * NetBSD9 is not active at that time.
-	 */
-	if (netbsd < 9) {
-	} else {
+	if (netbsd < 9 && strcmp(devname, "sound") == 0) {
+		/*
+		 * On NetBSD7/8, it doesn't seem to start recording on open
+		 * for /dev/sound.  It should be a bug.
+		 */
 		XP_EQ(0, ai.record.active);
+	} else {
+		XP_EQ(exp_ropen, ai.record.active);
 	}
 	/* Save it */
 	ai0 = ai;
@@ -1645,9 +1645,14 @@ test_open(const char *devname, int mode)
 	XP_EQ(0, ai.record.waiting);
 		/* balance */
 	XP_EQ(exp_ropen, ai.record.open);
-	if (netbsd < 9) {
-	} else {
+	if (netbsd < 9 && strcmp(devname, "sound") == 0) {
+		/*
+		 * On NetBSD7/8, it doesn't seem to start recording on open
+		 * for /dev/sound.  It should be a bug.
+		 */
 		XP_EQ(0, ai.record.active);
+	} else {
+		XP_EQ(exp_ropen, ai.record.active);
 	}
 
 	r = CLOSE(fd);
@@ -2921,6 +2926,9 @@ test_poll_mode(int mode, int events, int
 	fd = OPEN(devaudio, mode);
 	REQUIRED_SYS_OK(fd);
 
+	/* Wait a bit to be recorded. */
+	usleep(100 * 1000);
+
 	memset(&pfd, 0, sizeof(pfd));
 	pfd.fd = fd;
 	pfd.events = events;
@@ -2948,15 +2956,23 @@ test_poll_mode(int mode, int events, int
 	r = CLOSE(fd);
 	XP_SYS_EQ(0, r);
 }
-DEF(poll_mode_RDONLY_IN)	{ test_poll_mode(O_RDONLY, IN, 0); }
+DEF(poll_mode_RDONLY_IN)	{ test_poll_mode(O_RDONLY, IN, IN); }
 DEF(poll_mode_RDONLY_OUT)	{ test_poll_mode(O_RDONLY, OUT,0); }
-DEF(poll_mode_RDONLY_INOUT)	{ test_poll_mode(O_RDONLY, IN|OUT, 0); }
+DEF(poll_mode_RDONLY_INOUT)	{ test_poll_mode(O_RDONLY, IN|OUT, IN); }
 DEF(poll_mode_WRONLY_IN)	{ test_poll_mode(O_WRONLY, IN, 0); }
 DEF(poll_mode_WRONLY_OUT)	{ test_poll_mode(O_WRONLY, OUT,	   OUT); }
 DEF(poll_mode_WRONLY_INOUT)	{ test_poll_mode(O_WRONLY, IN|OUT, OUT); }
-DEF(poll_mode_RDWR_IN)		{ test_poll_mode(O_RDWR,   IN, 0); }
+DEF(poll_mode_RDWR_IN)		{
+	/* On half-duplex, O_RDWR is the same as O_WRONLY. */
+	if (hw_fulldup()) test_poll_mode(O_RDWR,   IN, IN);
+	else		  test_poll_mode(O_RDWR,   IN, 0);
+}
 DEF(poll_mode_RDWR_OUT)		{ test_poll_mode(O_RDWR,   OUT,	   OUT); }
-DEF(poll_mode_RDWR_INOUT)	{ test_poll_mode(O_RDWR,   IN|OUT, OUT); }
+DEF(poll_mode_RDWR_INOUT)	{
+	/* On half-duplex, O_RDWR is the same as O_WRONLY. */
+	if (hw_fulldup()) test_poll_mode(O_RDWR,   IN|OUT, IN|OUT);
+	else		  test_poll_mode(O_RDWR,   IN|OUT,OUT);
+}
 
 /*
  * Poll(OUT) when buffer is empty.



CVS commit: src/sys/compat/common

2020-03-26 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Mar 26 13:39:29 UTC 2020

Modified Files:
src/sys/compat/common: compat_sysctl_09_43.c

Log Message:
When using SYSCTL_SETUP there is no guarantee of the order in which
the set-up functions will be called, so it is perfectly acceptable
for a compat code's routine to be called ahead of the code in other
parts of the kernel.

So make sure that the 2nd level sysctl node ``vfs.generic'' exists
before trying to add the 3rd level entries.

XXX Rather than creating the 2nd level node in two places, we could
XXX add the shared ``vfs.generic'' node to sysctl_init_base.c but
XXX this is left for another day.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/compat/common/compat_sysctl_09_43.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/compat/common/compat_sysctl_09_43.c
diff -u src/sys/compat/common/compat_sysctl_09_43.c:1.5 src/sys/compat/common/compat_sysctl_09_43.c:1.6
--- src/sys/compat/common/compat_sysctl_09_43.c:1.5	Thu Feb 27 17:42:33 2020
+++ src/sys/compat/common/compat_sysctl_09_43.c	Thu Mar 26 13:39:29 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: compat_sysctl_09_43.c,v 1.5 2020/02/27 17:42:33 pgoyette Exp $	*/
+/*	$NetBSD: compat_sysctl_09_43.c,v 1.6 2020/03/26 13:39:29 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: compat_sysctl_09_43.c,v 1.5 2020/02/27 17:42:33 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: compat_sysctl_09_43.c,v 1.6 2020/03/26 13:39:29 pgoyette Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
@@ -106,6 +106,17 @@ SYSCTL_SETUP(compat_sysctl_vfs, "Top-lev
 	int error;
 
 	error = sysctl_createv(clog, 0, NULL, NULL,
+			CTLFLAG_PERMANENT, 
+			CTLTYPE_NODE, "generic",
+			SYSCTL_DESCR("Non-specific vfs related information"),
+			NULL, 0, NULL, 0,
+			CTL_VFS, VFS_GENERIC, CTL_EOL);
+	if (error == EEXIST)
+		error = 0;
+	if (error != 0)
+		return;
+
+	error = sysctl_createv(clog, 0, NULL, NULL,
 		   CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
 		   CTLTYPE_INT, "maxtypenum",
 		   SYSCTL_DESCR("Highest valid filesystem type number"),



CVS commit: src/tests/dev/audio

2020-03-26 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Thu Mar 26 13:43:10 UTC 2020

Modified Files:
src/tests/dev/audio: audiotest.c

Log Message:
Add tests for poll(POLLIN) before read().
This affects only standalone test, not atf.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/dev/audio/audiotest.c

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

Modified files:

Index: src/tests/dev/audio/audiotest.c
diff -u src/tests/dev/audio/audiotest.c:1.9 src/tests/dev/audio/audiotest.c:1.10
--- src/tests/dev/audio/audiotest.c:1.9	Thu Mar 26 13:37:44 2020
+++ src/tests/dev/audio/audiotest.c	Thu Mar 26 13:43:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiotest.c,v 1.9 2020/03/26 13:37:44 isaki Exp $	*/
+/*	$NetBSD: audiotest.c,v 1.10 2020/03/26 13:43:10 isaki Exp $	*/
 
 /*
  * Copyright (C) 2019 Tetsuya Isaki. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: audiotest.c,v 1.9 2020/03/26 13:37:44 isaki Exp $");
+__RCSID("$NetBSD: audiotest.c,v 1.10 2020/03/26 13:43:10 isaki Exp $");
 
 #include 
 #include 
@@ -1383,6 +1383,7 @@ void test_rdwr_fallback(int, bool, bool)
 void test_rdwr_two(int, int);
 void test_mmap_mode(int, int);
 void test_poll_mode(int, int, int);
+void test_poll_in_open(const char *);
 void test_kqueue_mode(int, int, int);
 volatile int sigio_caught;
 void signal_FIOASYNC(int);
@@ -3372,6 +3373,81 @@ DEF(poll_out_simul)
 }
 
 /*
+ * Open with READ mode starts recording immediately.
+ * Of course, audioctl doesn't start.
+ */
+void
+test_poll_in_open(const char *devname)
+{
+	struct audio_info ai;
+	struct pollfd pfd;
+	char buf[4096];
+	char devfile[16];
+	int fd;
+	int r;
+	bool is_audioctl;
+
+	TEST("poll_in_open_%s", devname);
+	if (hw_canrec() == 0) {
+		XP_SKIP("This test is only for recordable device");
+		return;
+	}
+
+	snprintf(devfile, sizeof(devfile), "/dev/%s%d", devname, unit);
+	is_audioctl = (strcmp(devname, "audioctl") == 0);
+
+	fd = OPEN(devfile, O_RDONLY);
+	REQUIRED_SYS_OK(fd);
+
+	r = IOCTL(fd, AUDIO_GETBUFINFO, &ai, "");
+	REQUIRED_SYS_EQ(0, r);
+	if (is_audioctl) {
+		/* opening /dev/audioctl doesn't start recording. */
+		XP_EQ(0, ai.record.active);
+	} else {
+		/* opening /dev/{audio,sound} starts recording. */
+		/*
+		 * On NetBSD7/8, opening /dev/sound doesn't start recording.
+		 * It must be a bug.
+		 */
+		XP_EQ(1, ai.record.active);
+	}
+
+	memset(&pfd, 0, sizeof(pfd));
+	pfd.fd = fd;
+	pfd.events = POLLIN;
+	r = POLL(&pfd, 1, 1000);
+	if (is_audioctl) {
+		/*
+		 * poll-ing /dev/audioctl always fails.
+		 * XXX Returning error instead of timeout should be better(?).
+		 */
+		REQUIRED_SYS_EQ(0, r);
+	} else {
+		/*
+		 * poll-ing /dev/{audio,sound} will succeed when recorded
+		 * data is arrived.
+		 */
+		/*
+		 * On NetBSD7/8, opening /dev/sound doesn't start recording.
+		 * It must be a bug.
+		 */
+		REQUIRED_SYS_EQ(1, r);
+
+		/* In this case, read() should succeed. */
+		r = READ(fd, buf, sizeof(buf));
+		XP_SYS_OK(r);
+		XP_NE(0, r);
+	}
+
+	r = CLOSE(fd);
+	XP_SYS_EQ(0, r);
+}
+DEF(poll_in_open_audio)		{ test_poll_in_open("audio"); }
+DEF(poll_in_open_sound)		{ test_poll_in_open("sound"); }
+DEF(poll_in_open_audioctl)	{ test_poll_in_open("audioctl"); }
+
+/*
  * poll(2) must not be affected by other recording descriptors even if
  * playback descriptor waits with POLLIN (though it's not normal usage).
  * In other words, two POLLIN must not interfere.
@@ -6216,6 +6292,9 @@ struct testentry testtable[] = {
 	ENT(poll_out_hiwat),
 /**/	ENT(poll_out_unpause),		// XXX does not seem to work on rump
 /**/	ENT(poll_out_simul),		// XXX does not seem to work on rump
+	ENT(poll_in_open_audio),
+	ENT(poll_in_open_sound),
+	ENT(poll_in_open_audioctl),
 	ENT(poll_in_simul),
 	ENT(kqueue_mode_RDONLY_READ),
 	ENT(kqueue_mode_RDONLY_WRITE),



CVS commit: src/share/misc

2020-03-26 Thread Leonardo Taccari
Module Name:src
Committed By:   leot
Date:   Thu Mar 26 18:25:32 UTC 2020

Modified Files:
src/share/misc: acronyms

Log Message:
Add TLDW

>From Rocky Hotas, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.297 -r1.298 src/share/misc/acronyms

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

Modified files:

Index: src/share/misc/acronyms
diff -u src/share/misc/acronyms:1.297 src/share/misc/acronyms:1.298
--- src/share/misc/acronyms:1.297	Mon Feb 17 17:16:51 2020
+++ src/share/misc/acronyms	Thu Mar 26 18:25:32 2020
@@ -1,4 +1,4 @@
-$NetBSD: acronyms,v 1.297 2020/02/17 17:16:51 fcambus Exp $
+$NetBSD: acronyms,v 1.298 2020/03/26 18:25:32 leot Exp $
 10Q	thank you
 10X	thanks
 1337	elite ("leet")
@@ -548,6 +548,7 @@ TLA	three letter acronym
 TLA	true love always
 TLC	tender loving care
 TLDR	too long, didn't read
+TLDW	too long, didn't watch
 TM	trademark
 TM	trust me
 TMA	too many abbreviations



CVS commit: src/share/misc

2020-03-26 Thread Leonardo Taccari
Module Name:src
Committed By:   leot
Date:   Thu Mar 26 18:28:09 UTC 2020

Modified Files:
src/share/misc: acronyms.comp

Log Message:
Add HPD

>From Rocky Hotas, thanks!


To generate a diff of this commit:
cvs rdiff -u -r1.299 -r1.300 src/share/misc/acronyms.comp

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

Modified files:

Index: src/share/misc/acronyms.comp
diff -u src/share/misc/acronyms.comp:1.299 src/share/misc/acronyms.comp:1.300
--- src/share/misc/acronyms.comp:1.299	Wed Feb 26 23:38:08 2020
+++ src/share/misc/acronyms.comp	Thu Mar 26 18:28:09 2020
@@ -1,4 +1,4 @@
-$NetBSD: acronyms.comp,v 1.299 2020/02/26 23:38:08 sevan Exp $
+$NetBSD: acronyms.comp,v 1.300 2020/03/26 18:28:09 leot Exp $
 3WHS	three-way handshake
 8VSB	8-state vestigial side band modulation
 AA	anti-aliasing
@@ -668,6 +668,7 @@ HMI	human-machine interface
 HOOD	hierarchical object oriented design
 HP	Hewlett-Packard
 HPC	high performance computing
+HPD	hot plug detection
 HPET	high precision event timer
 HSM	hardware security module
 HSM	hierarchical storage management 



CVS commit: src/sys/arch/xen/xen

2020-03-26 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Mar 26 18:32:21 UTC 2020

Modified Files:
src/sys/arch/xen/xen: if_xennet_xenbus.c

Log Message:
Stop using IFF_OACTIVE, just keep processing until we fill the Tx ring

xennet_tx_complete() is now called only in xennet_softstart() just
before processing Tx queue; xennet_handler() just schedules the
softint for xennet_softstart() iff the Tx ring list is completely empty

no performance changes observed

XXX the detach and suspend code expects xennet_handler() to collect
XXX the Tx responses, the tsleep() loop should still work since the tsleep()
XXX would allow the softint to trigger; untested though


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/xen/xen/if_xennet_xenbus.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/arch/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.94 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.95
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.94	Sun Mar 22 11:20:59 2020
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Thu Mar 26 18:32:21 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.94 2020/03/22 11:20:59 jdolecek Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.95 2020/03/26 18:32:21 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -64,11 +64,8 @@
  * xennet_start() (default output routine of xennet) that schedules a softint,
  * xennet_softstart(). xennet_softstart() generates the requests associated
  * to the TX mbufs queued (see altq(9)).
- * The backend's responses are processed by xennet_tx_complete(), called either
- * from:
- * - xennet_start()
- * - xennet_handler(), during an asynchronous event notification from backend
- *   (similar to an IRQ).
+ * The backend's responses are processed by xennet_tx_complete(), called
+ * from xennet_softstart()
  *
  * for RX:
  * Purpose is to process the packets received from the outside. RX buffers
@@ -84,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.94 2020/03/22 11:20:59 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.95 2020/03/26 18:32:21 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -934,7 +931,7 @@ xennet_rx_free_req(struct xennet_rxreq *
 /*
  * Process responses associated to the TX mbufs sent previously through
  * xennet_softstart()
- * Called at splnet.
+ * Called at splsoftnet.
  */
 static void
 xennet_tx_complete(struct xennet_xenbus_softc *sc)
@@ -958,7 +955,7 @@ again:
 			aprint_verbose_dev(sc->sc_dev,
 			"grant still used by backend\n");
 			sc->sc_tx_ring.rsp_cons = i;
-			goto end;
+			return;
 		}
 		if (__predict_false(
 		RING_GET_RESPONSE(&sc->sc_tx_ring, i)->status !=
@@ -980,11 +977,6 @@ again:
 	xen_wmb();
 	if (resp_prod != sc->sc_tx_ring.sring->rsp_prod)
 		goto again;
-end:
-	if (ifp->if_flags & IFF_OACTIVE) {
-		ifp->if_flags &= ~IFF_OACTIVE;
-		softint_schedule(sc->sc_softintr);
-	}
 }
 
 /*
@@ -1011,7 +1003,11 @@ xennet_handler(void *arg)
 	if (sc->sc_backend_status != BEST_CONNECTED)
 		return 1;
 
-	xennet_tx_complete(sc);
+	/* Poke Tx queue if we run out of Tx buffers earlier */
+	mutex_enter(&sc->sc_tx_lock);
+	if (SLIST_EMPTY(&sc->sc_txreq_head))
+		softint_schedule(sc->sc_softintr);
+	mutex_exit(&sc->sc_tx_lock);
 
 	rnd_add_uint32(&sc->sc_rnd_source, sc->sc_tx_ring.req_prod_pvt);
 
@@ -1162,12 +1158,6 @@ xennet_start(struct ifnet *ifp)
 
 	rnd_add_uint32(&sc->sc_rnd_source, sc->sc_tx_ring.req_prod_pvt);
 
-	xennet_tx_complete(sc);
-
-	if (__predict_false(
-	(ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING))
-		return;
-
 	/*
 	 * The Xen communication channel is much more efficient if we can
 	 * schedule batch of packets for domain0. To achieve this, we
@@ -1196,12 +1186,12 @@ xennet_softstart(void *arg)
 	int notify;
 	int do_notify = 0;
 
-	mutex_enter(&sc->sc_tx_lock);
-	if (__predict_false(
-	(ifp->if_flags & (IFF_RUNNING | IFF_OACTIVE)) != IFF_RUNNING)) {
-		mutex_exit(&sc->sc_tx_lock);
+	if ((ifp->if_flags & IFF_RUNNING) == 0)
 		return;
-	}
+
+	xennet_tx_complete(sc);
+
+	mutex_enter(&sc->sc_tx_lock);
 
 	req_prod = sc->sc_tx_ring.req_prod_pvt;
 	while (/*CONSTCOND*/1) {
@@ -1209,7 +1199,6 @@ xennet_softstart(void *arg)
 
 		req = SLIST_FIRST(&sc->sc_txreq_head);
 		if (__predict_false(req == NULL)) {
-			ifp->if_flags |= IFF_OACTIVE;
 			break;
 		}
 		IFQ_POLL(&ifp->if_snd, m);
@@ -1280,7 +1269,6 @@ xennet_softstart(void *arg)
 			xpmap_ptom_masked(pa),
 			GNTMAP_readonly, &req->txreq_gntref) != 0)) {
 m_freem(new_m);
-ifp->if_flags |= IFF_OACTIVE;
 break;
 			}
 			/* we will be able to send new_m */
@@ -1292,7 +1280,6 @@ xennet_softstart(void *arg)
 			sc->sc_xbusd->xbusd_otherend_id,
 			xpmap_ptom_masked(pa),
 			GNTMAP_readonly, &req->txreq_gntref) != 0)) {
-ifp->if_flags |=

CVS commit: src/sys/arch/xen/xen

2020-03-26 Thread Jaromir Dolecek
Module Name:src
Committed By:   jdolecek
Date:   Thu Mar 26 18:50:17 UTC 2020

Modified Files:
src/sys/arch/xen/xen: if_xennet_xenbus.c

Log Message:
in xennet_tx_complete() replace the grant status condition with just KASSERT()

it's really a possible programming error rather than something actually
happening in wild - since rev. 1.57 in 2012 this condition leaked
locked mutex, and nobody noticed


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/arch/xen/xen/if_xennet_xenbus.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/arch/xen/xen/if_xennet_xenbus.c
diff -u src/sys/arch/xen/xen/if_xennet_xenbus.c:1.95 src/sys/arch/xen/xen/if_xennet_xenbus.c:1.96
--- src/sys/arch/xen/xen/if_xennet_xenbus.c:1.95	Thu Mar 26 18:32:21 2020
+++ src/sys/arch/xen/xen/if_xennet_xenbus.c	Thu Mar 26 18:50:16 2020
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_xennet_xenbus.c,v 1.95 2020/03/26 18:32:21 jdolecek Exp $  */
+/*  $NetBSD: if_xennet_xenbus.c,v 1.96 2020/03/26 18:50:16 jdolecek Exp $  */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -81,7 +81,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.95 2020/03/26 18:32:21 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_xennet_xenbus.c,v 1.96 2020/03/26 18:50:16 jdolecek Exp $");
 
 #include "opt_xen.h"
 #include "opt_nfs_boot.h"
@@ -951,12 +951,7 @@ again:
 		req = &sc->sc_txreqs[RING_GET_RESPONSE(&sc->sc_tx_ring, i)->id];
 		KASSERT(req->txreq_id ==
 		RING_GET_RESPONSE(&sc->sc_tx_ring, i)->id);
-		if (__predict_false(xengnt_status(req->txreq_gntref))) {
-			aprint_verbose_dev(sc->sc_dev,
-			"grant still used by backend\n");
-			sc->sc_tx_ring.rsp_cons = i;
-			return;
-		}
+		KASSERT(xengnt_status(req->txreq_gntref) == 0);
 		if (__predict_false(
 		RING_GET_RESPONSE(&sc->sc_tx_ring, i)->status !=
 		NETIF_RSP_OKAY))



CVS commit: src/sys/kern

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Mar 26 19:23:19 UTC 2020

Modified Files:
src/sys/kern: subr_cpu.c

Log Message:
Don't overwrite ci_is_slow if it has explicitly been set.  Changed for
correctness, should have no impact.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/kern/subr_cpu.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/kern/subr_cpu.c
diff -u src/sys/kern/subr_cpu.c:1.13 src/sys/kern/subr_cpu.c:1.14
--- src/sys/kern/subr_cpu.c:1.13	Sat Feb 15 07:20:40 2020
+++ src/sys/kern/subr_cpu.c	Thu Mar 26 19:23:18 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: subr_cpu.c,v 1.13 2020/02/15 07:20:40 skrll Exp $	*/
+/*	$NetBSD: subr_cpu.c,v 1.14 2020/03/26 19:23:18 ad Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019, 2020
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.13 2020/02/15 07:20:40 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_cpu.c,v 1.14 2020/03/26 19:23:18 ad Exp $");
 
 #include 
 #include 
@@ -151,7 +151,6 @@ cpu_topology_set(struct cpu_info *ci, u_
 	ci->ci_core_id = core_id;
 	ci->ci_smt_id = smt_id;
 	ci->ci_numa_id = numa_id;
-	ci->ci_is_slow = false;
 	for (rel = 0; rel < __arraycount(ci->ci_sibling); rel++) {
 		ci->ci_sibling[rel] = ci;
 		ci->ci_nsibling[rel] = 1;
@@ -246,8 +245,9 @@ cpu_topology_fake1(struct cpu_info *ci)
 	ci->ci_schedstate.spc_flags |=
 	(SPCF_CORE1ST | SPCF_PACKAGE1ST | SPCF_1STCLASS);
 	ci->ci_package1st = ci;
-	ci->ci_is_slow = false;
-	cpu_topology_haveslow = false;
+	if (!cpu_topology_haveslow) {
+		ci->ci_is_slow = false;
+	}
 }
 
 /*



CVS commit: src/sys/kern

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Mar 26 19:25:07 UTC 2020

Modified Files:
src/sys/kern: kern_runq.c

Log Message:
sched_curcpu_runnable_p(): cosmetic change.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/kern/kern_runq.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/kern/kern_runq.c
diff -u src/sys/kern/kern_runq.c:1.63 src/sys/kern/kern_runq.c:1.64
--- src/sys/kern/kern_runq.c:1.63	Sun Mar  8 15:00:31 2020
+++ src/sys/kern/kern_runq.c	Thu Mar 26 19:25:07 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_runq.c,v 1.63 2020/03/08 15:00:31 ad Exp $	*/
+/*	$NetBSD: kern_runq.c,v 1.64 2020/03/26 19:25:07 ad Exp $	*/
 
 /*-
  * Copyright (c) 2019, 2020 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.63 2020/03/08 15:00:31 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_runq.c,v 1.64 2020/03/26 19:25:07 ad Exp $");
 
 #include "opt_dtrace.h"
 
@@ -1086,15 +1086,10 @@ sched_curcpu_runnable_p(void)
 	kpreempt_disable();
 	ci = curcpu();
 	spc = &ci->ci_schedstate;
-
+	rv = (spc->spc_count != 0);
 #ifndef __HAVE_FAST_SOFTINTS
-	if (ci->ci_data.cpu_softints) {
-		kpreempt_enable();
-		return true;
-	}
+	rv |= (ci->ci_data.cpu_softints != 0);
 #endif
-
-	rv = (spc->spc_count != 0) ? true : false;
 	kpreempt_enable();
 
 	return rv;



CVS commit: src/sys/kern

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Mar 26 19:42:39 UTC 2020

Modified Files:
src/sys/kern: kern_idle.c kern_synch.c

Log Message:
Leave the idle LWPs in state LSIDL even when running, so they don't mess up
output from ps/top/etc.  Correctness isn't at stake, LWPs in other states
are temporarily on the CPU at times too (e.g.  LSZOMB, LSSLEEP).


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/kern/kern_idle.c
cvs rdiff -u -r1.344 -r1.345 src/sys/kern/kern_synch.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/kern/kern_idle.c
diff -u src/sys/kern/kern_idle.c:1.32 src/sys/kern/kern_idle.c:1.33
--- src/sys/kern/kern_idle.c:1.32	Sat Feb 15 18:12:15 2020
+++ src/sys/kern/kern_idle.c	Thu Mar 26 19:42:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_idle.c,v 1.32 2020/02/15 18:12:15 ad Exp $	*/
+/*	$NetBSD: kern_idle.c,v 1.33 2020/03/26 19:42:39 ad Exp $	*/
 
 /*-
  * Copyright (c)2002, 2006, 2007 YAMAMOTO Takashi,
@@ -28,7 +28,7 @@
 
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: kern_idle.c,v 1.32 2020/02/15 18:12:15 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_idle.c,v 1.33 2020/03/26 19:42:39 ad Exp $");
 
 #include 
 #include 
@@ -56,8 +56,8 @@ idle_loop(void *dummy)
 	/* Update start time for this thread. */
 	binuptime(&l->l_stime);
 	spc->spc_flags |= SPCF_RUNNING;
-	KASSERT(l->l_stat == LSONPROC);
 	KASSERT((l->l_pflag & LP_RUNNING) != 0);
+	l->l_stat = LSIDL;
 	lwp_unlock(l);
 
 	/*
@@ -91,11 +91,10 @@ idle_loop(void *dummy)
 		}
 		KASSERT(l->l_mutex == l->l_cpu->ci_schedstate.spc_lwplock);
 		lwp_lock(l);
-		l->l_stat = LSIDL;
 		spc_lock(l->l_cpu);
 		mi_switch(l);
 		KASSERT(curlwp == l);
-		KASSERT(l->l_stat == LSONPROC);
+		KASSERT(l->l_stat == LSIDL);
 	}
 }
 
@@ -119,7 +118,7 @@ create_idle_lwp(struct cpu_info *ci)
 		 * mi_switch().  Make the picture look good in case the CPU
 		 * takes an interrupt before it calls idle_loop().
 		 */
-		l->l_stat = LSONPROC;
+		l->l_stat = LSIDL;
 		l->l_pflag |= LP_RUNNING;
 		ci->ci_onproc = l;
 	}

Index: src/sys/kern/kern_synch.c
diff -u src/sys/kern/kern_synch.c:1.344 src/sys/kern/kern_synch.c:1.345
--- src/sys/kern/kern_synch.c:1.344	Sat Mar 14 20:23:51 2020
+++ src/sys/kern/kern_synch.c	Thu Mar 26 19:42:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_synch.c,v 1.344 2020/03/14 20:23:51 ad Exp $	*/
+/*	$NetBSD: kern_synch.c,v 1.345 2020/03/26 19:42:39 ad Exp $	*/
 
 /*-
  * Copyright (c) 1999, 2000, 2004, 2006, 2007, 2008, 2009, 2019, 2020
@@ -69,7 +69,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.344 2020/03/14 20:23:51 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_synch.c,v 1.345 2020/03/26 19:42:39 ad Exp $");
 
 #include "opt_kstack.h"
 #include "opt_dtrace.h"
@@ -387,11 +387,7 @@ kpreempt(uintptr_t where)
 			atomic_swap_uint(&l->l_dopreempt, 0);
 			return true;
 		}
-		if (__predict_false((l->l_flag & LW_IDLE) != 0)) {
-			/* Can't preempt idle loop, don't count as failure. */
-			atomic_swap_uint(&l->l_dopreempt, 0);
-			return true;
-		}
+		KASSERT((l->l_flag & LW_IDLE) == 0);
 		if (__predict_false(l->l_nopreempt != 0)) {
 			/* LWP holds preemption disabled, explicitly. */
 			if ((dop & DOPREEMPT_COUNTED) == 0) {
@@ -547,12 +543,10 @@ nextlwp(struct cpu_info *ci, struct sche
 		lwp_setlock(newl, spc->spc_lwplock);
 	} else {
 		/*
-		 * Updates to newl here are unlocked, but newl is the idle
-		 * LWP and thus sheltered from outside interference, so no
-		 * harm is going to come of it.
+		 * The idle LWP does not get set to LSONPROC, because
+		 * otherwise it screws up the output from top(1) etc.
 		 */
 		newl = ci->ci_data.cpu_idlelwp;
-		newl->l_stat = LSONPROC;
 		newl->l_pflag |= LP_RUNNING;
 		spc->spc_curpriority = PRI_IDLE;
 		spc->spc_flags = (spc->spc_flags & ~SPCF_SWITCHCLEAR) |
@@ -840,7 +834,7 @@ mi_switch(lwp_t *l)
 	}
 
 	KASSERT(l == curlwp);
-	KASSERT(l->l_stat == LSONPROC);
+	KASSERT(l->l_stat == LSONPROC || (l->l_flag & LW_IDLE) != 0); 
 
 	SYSCALL_TIME_WAKEUP(l);
 	LOCKDEBUG_BARRIER(NULL, 1);



CVS commit: src/sys

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Mar 26 19:46:42 UTC 2020

Modified Files:
src/sys/kern: kern_condvar.c kern_sleepq.c kern_turnstile.c
sys_select.c
src/sys/sys: condvar.h lwp.h sleepq.h

Log Message:
Change sleepq_t from a TAILQ to a LIST and remove SOBJ_SLEEPQ_FIFO.  Only
select/poll used the FIFO method and that was for collisions which rarely
occur.  Shrinks sleep_t and condvar_t.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/kern/kern_condvar.c
cvs rdiff -u -r1.62 -r1.63 src/sys/kern/kern_sleepq.c
cvs rdiff -u -r1.36 -r1.37 src/sys/kern/kern_turnstile.c
cvs rdiff -u -r1.52 -r1.53 src/sys/kern/sys_select.c
cvs rdiff -u -r1.14 -r1.15 src/sys/sys/condvar.h
cvs rdiff -u -r1.202 -r1.203 src/sys/sys/lwp.h
cvs rdiff -u -r1.27 -r1.28 src/sys/sys/sleepq.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/kern/kern_condvar.c
diff -u src/sys/kern/kern_condvar.c:1.43 src/sys/kern/kern_condvar.c:1.44
--- src/sys/kern/kern_condvar.c:1.43	Sat Feb 15 17:09:24 2020
+++ src/sys/kern/kern_condvar.c	Thu Mar 26 19:46:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_condvar.c,v 1.43 2020/02/15 17:09:24 ad Exp $	*/
+/*	$NetBSD: kern_condvar.c,v 1.44 2020/03/26 19:46:42 ad Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.43 2020/02/15 17:09:24 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_condvar.c,v 1.44 2020/03/26 19:46:42 ad Exp $");
 
 #include 
 #include 
@@ -48,20 +48,19 @@ __KERNEL_RCSID(0, "$NetBSD: kern_condvar
 /*
  * Accessors for the private contents of the kcondvar_t data type.
  *
- *	cv_opaque[0]	sleepq...
- *	cv_opaque[1]	...pointers
- *	cv_opaque[2]	description for ps(1)
+ *	cv_opaque[0]	sleepq_t
+ *	cv_opaque[1]	description for ps(1)
  *
- * cv_opaque[0..1] is protected by the interlock passed to cv_wait() (enqueue
+ * cv_opaque[0] is protected by the interlock passed to cv_wait() (enqueue
  * only), and the sleep queue lock acquired with sleepq_hashlock() (enqueue
  * and dequeue).
  *
- * cv_opaque[2] (the wmesg) is static and does not change throughout the life
+ * cv_opaque[1] (the wmesg) is static and does not change throughout the life
  * of the CV.
  */
 #define	CV_SLEEPQ(cv)		((sleepq_t *)(cv)->cv_opaque)
-#define	CV_WMESG(cv)		((const char *)(cv)->cv_opaque[2])
-#define	CV_SET_WMESG(cv, v) 	(cv)->cv_opaque[2] = __UNCONST(v)
+#define	CV_WMESG(cv)		((const char *)(cv)->cv_opaque[1])
+#define	CV_SET_WMESG(cv, v) 	(cv)->cv_opaque[1] = __UNCONST(v)
 
 #define	CV_DEBUG_P(cv)	(CV_WMESG(cv) != nodebug)
 #define	CV_RA		((uintptr_t)__builtin_return_address(0))
@@ -486,7 +485,7 @@ cv_signal(kcondvar_t *cv)
 	/* LOCKDEBUG_WAKEUP(CV_DEBUG_P(cv), cv, CV_RA); */
 	KASSERT(cv_is_valid(cv));
 
-	if (__predict_false(!TAILQ_EMPTY(CV_SLEEPQ(cv
+	if (__predict_false(!LIST_EMPTY(CV_SLEEPQ(cv
 		cv_wakeup_one(cv);
 }
 
@@ -508,7 +507,7 @@ cv_wakeup_one(kcondvar_t *cv)
 
 	mp = sleepq_hashlock(cv);
 	sq = CV_SLEEPQ(cv);
-	l = TAILQ_FIRST(sq);
+	l = LIST_FIRST(sq);
 	if (__predict_false(l == NULL)) {
 		mutex_spin_exit(mp);
 		return;
@@ -536,7 +535,7 @@ cv_broadcast(kcondvar_t *cv)
 	/* LOCKDEBUG_WAKEUP(CV_DEBUG_P(cv), cv, CV_RA); */
 	KASSERT(cv_is_valid(cv));
 
-	if (__predict_false(!TAILQ_EMPTY(CV_SLEEPQ(cv  
+	if (__predict_false(!LIST_EMPTY(CV_SLEEPQ(cv  
 		cv_wakeup_all(cv);
 }
 
@@ -558,11 +557,11 @@ cv_wakeup_all(kcondvar_t *cv)
 
 	mp = sleepq_hashlock(cv);
 	sq = CV_SLEEPQ(cv);
-	for (l = TAILQ_FIRST(sq); l != NULL; l = next) {
+	for (l = LIST_FIRST(sq); l != NULL; l = next) {
 		KASSERT(l->l_sleepq == sq);
 		KASSERT(l->l_mutex == mp);
 		KASSERT(l->l_wchan == cv);
-		next = TAILQ_NEXT(l, l_sleepchain);
+		next = LIST_NEXT(l, l_sleepchain);
 		CV_LOCKDEBUG_PROCESS(l, cv);
 		sleepq_remove(sq, l);
 	}
@@ -581,7 +580,7 @@ bool
 cv_has_waiters(kcondvar_t *cv)
 {
 
-	return !TAILQ_EMPTY(CV_SLEEPQ(cv));
+	return !LIST_EMPTY(CV_SLEEPQ(cv));
 }
 
 /*

Index: src/sys/kern/kern_sleepq.c
diff -u src/sys/kern/kern_sleepq.c:1.62 src/sys/kern/kern_sleepq.c:1.63
--- src/sys/kern/kern_sleepq.c:1.62	Tue Mar 24 21:05:06 2020
+++ src/sys/kern/kern_sleepq.c	Thu Mar 26 19:46:42 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sleepq.c,v 1.62 2020/03/24 21:05:06 ad Exp $	*/
+/*	$NetBSD: kern_sleepq.c,v 1.63 2020/03/26 19:46:42 ad Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2009, 2019, 2020 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.62 2020/03/24 21:05:06 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sleepq.c,v 1.63 2020/03/26 19:46:42 ad Exp $");
 
 #include 
 #include 
@@ -98,7 +98,7 @@ void
 sleepq_init(sleepq_t *sq)
 {
 
-	TAILQ_INIT(sq);
+	LIST_INIT(sq);
 }
 
 /*
@@ -116,7 +116,7 @@ sleepq_remove(sleepq_t *sq, lwp_t *l)
 
 	if ((l->l_syncobj->sobj_flag & SOB

CVS commit: src/sys/sys

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Mar 26 19:47:23 UTC 2020

Modified Files:
src/sys/sys: param.h

Log Message:
NetBSD 9.99.52 - sleepq_t & kcondvar_t shrunk


To generate a diff of this commit:
cvs rdiff -u -r1.654 -r1.655 src/sys/sys/param.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/sys/param.h
diff -u src/sys/sys/param.h:1.654 src/sys/sys/param.h:1.655
--- src/sys/sys/param.h:1.654	Sun Mar 22 14:43:05 2020
+++ src/sys/sys/param.h	Thu Mar 26 19:47:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.654 2020/03/22 14:43:05 ad Exp $	*/
+/*	$NetBSD: param.h,v 1.655 2020/03/26 19:47:23 ad Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	999005100	/* NetBSD 9.99.51 */
+#define	__NetBSD_Version__	999005200	/* NetBSD 9.99.52 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Mar 26 20:19:06 UTC 2020

Modified Files:
src/sys/kern: kern_lwp.c kern_softint.c
src/sys/sys: intr.h userret.h

Log Message:
softint_overlay() (slow case) gains ~nothing but creates potential headaches.
In the interests of simplicity remove it and always use the kthreads.


To generate a diff of this commit:
cvs rdiff -u -r1.229 -r1.230 src/sys/kern/kern_lwp.c
cvs rdiff -u -r1.62 -r1.63 src/sys/kern/kern_softint.c
cvs rdiff -u -r1.19 -r1.20 src/sys/sys/intr.h
cvs rdiff -u -r1.32 -r1.33 src/sys/sys/userret.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/kern/kern_lwp.c
diff -u src/sys/kern/kern_lwp.c:1.229 src/sys/kern/kern_lwp.c:1.230
--- src/sys/kern/kern_lwp.c:1.229	Sun Mar  8 17:04:45 2020
+++ src/sys/kern/kern_lwp.c	Thu Mar 26 20:19:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lwp.c,v 1.229 2020/03/08 17:04:45 ad Exp $	*/
+/*	$NetBSD: kern_lwp.c,v 1.230 2020/03/26 20:19:06 ad Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020
@@ -211,7 +211,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.229 2020/03/08 17:04:45 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.230 2020/03/26 20:19:06 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -1593,12 +1593,6 @@ lwp_userret(struct lwp *l)
 	KASSERT(l->l_stat == LSONPROC);
 	p = l->l_proc;
 
-#ifndef __HAVE_FAST_SOFTINTS
-	/* Run pending soft interrupts. */
-	if (l->l_cpu->ci_data.cpu_softints != 0)
-		softint_overlay();
-#endif
-
 	/*
 	 * It is safe to do this read unlocked on a MP system..
 	 */

Index: src/sys/kern/kern_softint.c
diff -u src/sys/kern/kern_softint.c:1.62 src/sys/kern/kern_softint.c:1.63
--- src/sys/kern/kern_softint.c:1.62	Sun Mar  8 15:05:18 2020
+++ src/sys/kern/kern_softint.c	Thu Mar 26 20:19:06 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_softint.c,v 1.62 2020/03/08 15:05:18 ad Exp $	*/
+/*	$NetBSD: kern_softint.c,v 1.63 2020/03/26 20:19:06 ad Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -170,7 +170,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.62 2020/03/08 15:05:18 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.63 2020/03/26 20:19:06 ad Exp $");
 
 #include 
 #include 
@@ -196,7 +196,7 @@ typedef struct softint {
 	uintptr_t		si_machdep;
 	struct evcnt		si_evcnt;
 	struct evcnt		si_evcnt_block;
-	int			si_active;
+	volatile int		si_active;
 	char			si_name[8];
 	char			si_name_block[8+6];
 } softint_t;
@@ -546,11 +546,7 @@ softint_execute(softint_t *si, lwp_t *l,
 {
 	softhand_t *sh;
 
-#ifdef __HAVE_FAST_SOFTINTS
 	KASSERT(si->si_lwp == curlwp);
-#else
-	/* May be running in user context. */
-#endif
 	KASSERT(si->si_cpu == curcpu());
 	KASSERT(si->si_lwp->l_wchan == NULL);
 	KASSERT(si->si_active);
@@ -678,12 +674,22 @@ softint_trigger(uintptr_t machdep)
 	ci = curcpu();
 	ci->ci_data.cpu_softints |= machdep;
 	l = ci->ci_onproc;
+
+	/*
+	 * Arrange for mi_switch() to be called.  If called from interrupt
+	 * mode, we don't know if curlwp is executing in kernel or user, so
+	 * post an AST and have it take a trip through userret().  If not in
+	 * interrupt mode, curlwp is running in kernel and will notice the
+	 * resched soon enough; avoid the AST.
+	 */
 	if (l == ci->ci_data.cpu_idlelwp) {
 		atomic_or_uint(&ci->ci_want_resched,
 		RESCHED_IDLE | RESCHED_UPREEMPT);
 	} else {
-		/* MI equivalent of aston() */
-		cpu_signotify(l);
+		atomic_or_uint(&ci->ci_want_resched, RESCHED_UPREEMPT);
+		if (cpu_intr_p()) {
+			cpu_signotify(l);
+		}
 	}
 }
 
@@ -754,65 +760,6 @@ softint_picklwp(void)
 	return l;
 }
 
-/*
- * softint_overlay:
- *
- *	Slow path: called from lwp_userret() to run a soft interrupt
- *	within the context of a user thread.
- */
-void
-softint_overlay(void)
-{
-	struct cpu_info *ci;
-	u_int softints, oflag;
-	softint_t *si;
-	pri_t obase;
-	lwp_t *l;
-	int s;
-
-	l = curlwp;
-	KASSERT((l->l_pflag & LP_INTR) == 0);
-
-	/*
-	 * Arrange to elevate priority if the LWP blocks.  Also, bind LWP
-	 * to the CPU.  Note: disable kernel preemption before doing that.
-	 */
-	s = splhigh();
-	ci = l->l_cpu;
-	si = ((softcpu_t *)ci->ci_data.cpu_softcpu)->sc_int;
-
-	obase = l->l_kpribase;
-	l->l_kpribase = PRI_KERNEL_RT;
-	oflag = l->l_pflag;
-	l->l_pflag = oflag | LP_INTR | LP_BOUND;
-
-	while ((softints = ci->ci_data.cpu_softints) != 0) {
-		if ((softints & (1 << SOFTINT_SERIAL)) != 0) {
-			ci->ci_data.cpu_softints &= ~(1 << SOFTINT_SERIAL);
-			softint_execute(&si[SOFTINT_SERIAL], l, s);
-			continue;
-		}
-		if ((softints & (1 << SOFTINT_NET)) != 0) {
-			ci->ci_data.cpu_softints &= ~(1 << SOFTINT_NET);
-			softint_execute(&si[SOFTINT_NET], l, s);
-			continue;
-		}
-		if ((softints & (1 << SOFTINT_BIO)) != 0) {
-			ci->ci_data.cpu_softints &= ~(1 << SOFTINT_BIO);
-			softint_execute(&si[SOFTINT_BIO], l, s);
-			conti

CVS commit: src/sys/sys

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Mar 26 21:15:14 UTC 2020

Modified Files:
src/sys/sys: syncobj.h

Log Message:
SOBJ_SLEEPQ_FIFO is gone


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/sys/syncobj.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/sys/syncobj.h
diff -u src/sys/sys/syncobj.h:1.12 src/sys/sys/syncobj.h:1.13
--- src/sys/sys/syncobj.h:1.12	Mon Mar 23 19:14:06 2020
+++ src/sys/sys/syncobj.h	Thu Mar 26 21:15:14 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: syncobj.h,v 1.12 2020/03/23 19:14:06 ad Exp $	*/
+/*	$NetBSD: syncobj.h,v 1.13 2020/03/26 21:15:14 ad Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -52,7 +52,6 @@ typedef struct syncobj {
 struct lwp *syncobj_noowner(wchan_t);
 
 #define	SOBJ_SLEEPQ_SORTED	0x01
-#define	SOBJ_SLEEPQ_FIFO	0x02
 #define	SOBJ_SLEEPQ_LIFO	0x04
 #define	SOBJ_SLEEPQ_NULL	0x08
 



CVS commit: src/sys/kern

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Mar 26 21:25:26 UTC 2020

Modified Files:
src/sys/kern: kern_sig.c

Log Message:
sigpost(): check for LSZOMB, not l_refcnt == 0.


To generate a diff of this commit:
cvs rdiff -u -r1.384 -r1.385 src/sys/kern/kern_sig.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/kern/kern_sig.c
diff -u src/sys/kern/kern_sig.c:1.384 src/sys/kern/kern_sig.c:1.385
--- src/sys/kern/kern_sig.c:1.384	Sat Feb  1 02:23:23 2020
+++ src/sys/kern/kern_sig.c	Thu Mar 26 21:25:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_sig.c,v 1.384 2020/02/01 02:23:23 riastradh Exp $	*/
+/*	$NetBSD: kern_sig.c,v 1.385 2020/03/26 21:25:26 ad Exp $	*/
 
 /*-
  * Copyright (c) 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.384 2020/02/01 02:23:23 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_sig.c,v 1.385 2020/03/26 21:25:26 ad Exp $");
 
 #include "opt_ptrace.h"
 #include "opt_dtrace.h"
@@ -1117,7 +1117,7 @@ sigpost(struct lwp *l, sig_t action, int
 	 * If the LWP is on the way out, sigclear() will be busy draining all
 	 * pending signals.  Don't give it more.
 	 */
-	if (l->l_refcnt == 0)
+	if (l->l_stat == LSZOMB)
 		return 0;
 
 	SDT_PROBE(proc, kernel, , signal__send, l, p, sig, 0, 0);



CVS commit: src/sys/kern

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Mar 26 21:31:55 UTC 2020

Modified Files:
src/sys/kern: kern_exit.c kern_lwp.c

Log Message:
Fix crash observed with procfs on current-users by David Hopper.  LWP refcnt
and p_zomblwp both must reach the needed state, and LSZOMB be set, under a
single hold of p_lock.


To generate a diff of this commit:
cvs rdiff -u -r1.285 -r1.286 src/sys/kern/kern_exit.c
cvs rdiff -u -r1.230 -r1.231 src/sys/kern/kern_lwp.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/kern/kern_exit.c
diff -u src/sys/kern/kern_exit.c:1.285 src/sys/kern/kern_exit.c:1.286
--- src/sys/kern/kern_exit.c:1.285	Sun Mar  8 15:05:18 2020
+++ src/sys/kern/kern_exit.c	Thu Mar 26 21:31:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_exit.c,v 1.285 2020/03/08 15:05:18 ad Exp $	*/
+/*	$NetBSD: kern_exit.c,v 1.286 2020/03/26 21:31:55 ad Exp $	*/
 
 /*-
  * Copyright (c) 1998, 1999, 2006, 2007, 2008, 2020 The NetBSD Foundation, Inc.
@@ -67,7 +67,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.285 2020/03/08 15:05:18 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_exit.c,v 1.286 2020/03/26 21:31:55 ad Exp $");
 
 #include "opt_ktrace.h"
 #include "opt_dtrace.h"
@@ -559,7 +559,9 @@ exit1(struct lwp *l, int exitcode, int s
 	/* Free the linux lwp id */
 	if ((l->l_pflag & LP_PIDLID) != 0 && l->l_lid != p->p_pid)
 		proc_free_pid(l->l_lid);
-	lwp_drainrefs(l);
+	if (l->l_refcnt > 0) {
+		lwp_drainrefs(l);
+	}
 	lwp_lock(l);
 	l->l_prflag &= ~LPR_DETACHED;
 	l->l_stat = LSZOMB;

Index: src/sys/kern/kern_lwp.c
diff -u src/sys/kern/kern_lwp.c:1.230 src/sys/kern/kern_lwp.c:1.231
--- src/sys/kern/kern_lwp.c:1.230	Thu Mar 26 20:19:06 2020
+++ src/sys/kern/kern_lwp.c	Thu Mar 26 21:31:55 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_lwp.c,v 1.230 2020/03/26 20:19:06 ad Exp $	*/
+/*	$NetBSD: kern_lwp.c,v 1.231 2020/03/26 21:31:55 ad Exp $	*/
 
 /*-
  * Copyright (c) 2001, 2006, 2007, 2008, 2009, 2019, 2020
@@ -211,7 +211,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.230 2020/03/26 20:19:06 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_lwp.c,v 1.231 2020/03/26 21:31:55 ad Exp $");
 
 #include "opt_ddb.h"
 #include "opt_lockdebug.h"
@@ -274,7 +274,7 @@ struct lwp lwp0 __aligned(MIN_LWP_ALIGNM
 	.l_stat = LSONPROC,
 	.l_ts = &turnstile0,
 	.l_syncobj = &sched_syncobj,
-	.l_refcnt = 1,
+	.l_refcnt = 0,
 	.l_priority = PRI_USER + NPRI_USER - 1,
 	.l_inheritedprio = -1,
 	.l_class = SCHED_OTHER,
@@ -821,7 +821,7 @@ lwp_create(lwp_t *l1, proc_t *p2, vaddr_
 
 	l2->l_stat = LSIDL;
 	l2->l_proc = p2;
-	l2->l_refcnt = 1;
+	l2->l_refcnt = 0;
 	l2->l_class = sclass;
 
 	/*
@@ -1180,19 +1180,27 @@ lwp_exit(struct lwp *l)
 	 * mark it waiting for collection in the proc structure.  Note that
 	 * before we can do that, we need to free any other dead, deatched
 	 * LWP waiting to meet its maker.
+	 *
+	 * All conditions need to be observed upon under the same hold of
+	 * p_lock, because if the lock is dropped any of them can change.
 	 */
 	mutex_enter(p->p_lock);
-	lwp_drainrefs(l);
-
-	if ((l->l_prflag & LPR_DETACHED) != 0) {
-		while ((l2 = p->p_zomblwp) != NULL) {
-			p->p_zomblwp = NULL;
-			lwp_free(l2, false, false);/* releases proc mutex */
-			mutex_enter(p->p_lock);
-			l->l_refcnt++;
+	for (;;) {
+		if (l->l_refcnt > 0) {
 			lwp_drainrefs(l);
+			continue;
+		}
+		if ((l->l_prflag & LPR_DETACHED) != 0) {
+			if ((l2 = p->p_zomblwp) != NULL) {
+p->p_zomblwp = NULL;
+lwp_free(l2, false, false);
+/* proc now unlocked */
+mutex_enter(p->p_lock);
+continue;
+			}
+			p->p_zomblwp = l;
 		}
-		p->p_zomblwp = l;
+		break;
 	}
 
 	/*
@@ -1692,7 +1700,6 @@ lwp_addref(struct lwp *l)
 
 	KASSERT(mutex_owned(l->l_proc->p_lock));
 	KASSERT(l->l_stat != LSZOMB);
-	KASSERT(l->l_refcnt != 0);
 
 	l->l_refcnt++;
 }
@@ -1724,6 +1731,7 @@ lwp_delref2(struct lwp *l)
 	KASSERT(mutex_owned(p->p_lock));
 	KASSERT(l->l_stat != LSZOMB);
 	KASSERT(l->l_refcnt > 0);
+
 	if (--l->l_refcnt == 0)
 		cv_broadcast(&p->p_lwpcv);
 }
@@ -1737,10 +1745,8 @@ lwp_drainrefs(struct lwp *l)
 	struct proc *p = l->l_proc;
 
 	KASSERT(mutex_owned(p->p_lock));
-	KASSERT(l->l_refcnt != 0);
 
-	l->l_refcnt--;
-	while (l->l_refcnt != 0)
+	while (l->l_refcnt > 0)
 		cv_wait(&p->p_lwpcv, p->p_lock);
 }
 



CVS commit: src/sys/rump/librump/rumpkern

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Mar 26 22:40:10 UTC 2020

Modified Files:
src/sys/rump/librump/rumpkern: sleepq.c

Log Message:
sleepq_t is now a LIST.  Forgot to commit earlier.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/rump/librump/rumpkern/sleepq.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/rump/librump/rumpkern/sleepq.c
diff -u src/sys/rump/librump/rumpkern/sleepq.c:1.17 src/sys/rump/librump/rumpkern/sleepq.c:1.18
--- src/sys/rump/librump/rumpkern/sleepq.c:1.17	Tue Jan 26 23:12:18 2016
+++ src/sys/rump/librump/rumpkern/sleepq.c	Thu Mar 26 22:40:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: sleepq.c,v 1.17 2016/01/26 23:12:18 pooka Exp $	*/
+/*	$NetBSD: sleepq.c,v 1.18 2020/03/26 22:40:10 ad Exp $	*/
 
 /*
  * Copyright (c) 2008 Antti Kantee.  All Rights Reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sleepq.c,v 1.17 2016/01/26 23:12:18 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sleepq.c,v 1.18 2020/03/26 22:40:10 ad Exp $");
 
 #include 
 #include 
@@ -58,7 +58,7 @@ sleepq_init(sleepq_t *sq)
 
 	RUN_ONCE(&sqctl, sqinit1);
 
-	TAILQ_INIT(sq);
+	LIST_INIT(sq);
 }
 
 void
@@ -69,7 +69,7 @@ sleepq_enqueue(sleepq_t *sq, wchan_t wc,
 	l->l_wchan = wc;
 	l->l_wmesg = wmsg;
 	l->l_sleepq = sq;
-	TAILQ_INSERT_TAIL(sq, l, l_sleepchain);
+	LIST_INSERT_HEAD(sq, l, l_sleepchain);
 }
 
 int
@@ -85,7 +85,7 @@ sleepq_block(int timo, bool catch)
 		error = cv_timedwait(&sq_cv, mp, timo);
 		if (error == EWOULDBLOCK || error == EINTR) {
 			if (l->l_wchan) {
-TAILQ_REMOVE(l->l_sleepq, l, l_sleepchain);
+LIST_REMOVE(l, l_sleepchain);
 l->l_wchan = NULL;
 l->l_wmesg = NULL;
 			}
@@ -105,13 +105,13 @@ sleepq_wake(sleepq_t *sq, wchan_t wchan,
 	struct lwp *l, *l_next;
 	bool found = false;
 
-	for (l = TAILQ_FIRST(sq); l; l = l_next) {
-		l_next = TAILQ_NEXT(l, l_sleepchain);
+	for (l = LIST_FIRST(sq); l; l = l_next) {
+		l_next = LIST_NEXT(l, l_sleepchain);
 		if (l->l_wchan == wchan) {
 			found = true;
 			l->l_wchan = NULL;
 			l->l_wmesg = NULL;
-			TAILQ_REMOVE(sq, l, l_sleepchain);
+			LIST_REMOVE(l, l_sleepchain);
 			if (--expected == 0)
 break;
 		}
@@ -128,7 +128,7 @@ sleepq_unsleep(struct lwp *l, bool clean
 
 	l->l_wchan = NULL;
 	l->l_wmesg = NULL;
-	TAILQ_REMOVE(l->l_sleepq, l, l_sleepchain);
+	LIST_REMOVE(l, l_sleepchain);
 	cv_broadcast(&sq_cv);
 
 	if (cleanup) {



CVS commit: src/sys/kern

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Thu Mar 26 22:43:19 UTC 2020

Modified Files:
src/sys/kern: kern_turnstile.c

Log Message:
TAILQ -> LIST


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/kern/kern_turnstile.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/kern/kern_turnstile.c
diff -u src/sys/kern/kern_turnstile.c:1.37 src/sys/kern/kern_turnstile.c:1.38
--- src/sys/kern/kern_turnstile.c:1.37	Thu Mar 26 19:46:42 2020
+++ src/sys/kern/kern_turnstile.c	Thu Mar 26 22:43:19 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_turnstile.c,v 1.37 2020/03/26 19:46:42 ad Exp $	*/
+/*	$NetBSD: kern_turnstile.c,v 1.38 2020/03/26 22:43:19 ad Exp $	*/
 
 /*-
  * Copyright (c) 2002, 2006, 2007, 2009, 2019, 2020
@@ -61,7 +61,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_turnstile.c,v 1.37 2020/03/26 19:46:42 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_turnstile.c,v 1.38 2020/03/26 22:43:19 ad Exp $");
 
 #include 
 #include 
@@ -557,13 +557,13 @@ turnstile_print(volatile void *obj, void
 
 	(*pr)("Turnstile:\n");
 	(*pr)("=> %d waiting readers:", TS_WAITERS(ts, TS_READER_Q));
-	TAILQ_FOREACH(l, rsq, l_sleepchain) {
+	LIST_FOREACH(l, rsq, l_sleepchain) {
 		(*pr)(" %p", l);
 	}
 	(*pr)("\n");
 
 	(*pr)("=> %d waiting writers:", TS_WAITERS(ts, TS_WRITER_Q));
-	TAILQ_FOREACH(l, wsq, l_sleepchain) {
+	LIST_FOREACH(l, wsq, l_sleepchain) {
 		(*pr)(" %p", l);
 	}
 	(*pr)("\n");



CVS commit: src/sys/kern

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Mar 27 00:13:52 UTC 2020

Modified Files:
src/sys/kern: kern_softint.c

Log Message:
Comments


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 src/sys/kern/kern_softint.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/kern/kern_softint.c
diff -u src/sys/kern/kern_softint.c:1.63 src/sys/kern/kern_softint.c:1.64
--- src/sys/kern/kern_softint.c:1.63	Thu Mar 26 20:19:06 2020
+++ src/sys/kern/kern_softint.c	Fri Mar 27 00:13:52 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_softint.c,v 1.63 2020/03/26 20:19:06 ad Exp $	*/
+/*	$NetBSD: kern_softint.c,v 1.64 2020/03/27 00:13:52 ad Exp $	*/
 
 /*-
  * Copyright (c) 2007, 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -170,7 +170,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.63 2020/03/26 20:19:06 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_softint.c,v 1.64 2020/03/27 00:13:52 ad Exp $");
 
 #include 
 #include 
@@ -477,6 +477,11 @@ softint_schedule(void *arg)
 	uintptr_t offset;
 	int s;
 
+	/*
+	 * If this assert fires, rather than disabling preemption explicitly
+	 * to make it stop, consider that you are probably using a softint
+	 * when you don't need to.
+	 */	
 	KASSERT(kpreempt_disabled());
 
 	/* Find the handler record for this CPU. */
@@ -709,17 +714,13 @@ softint_thread(void *cookie)
 	si = l->l_private;
 
 	for (;;) {
-		/*
-		 * Clear pending status and run it.  We must drop the
-		 * spl before mi_switch(), since IPL_HIGH may be higher
-		 * than IPL_SCHED (and it is not safe to switch at a
-		 * higher level).
-		 */
+		/* Clear pending status and run it. */
 		s = splhigh();
 		l->l_cpu->ci_data.cpu_softints &= ~si->si_machdep;
 		softint_execute(si, l, s);
 		splx(s);
 
+		/* Interrupts allowed to run again before switching. */
 		lwp_lock(l);
 		l->l_stat = LSIDL;
 		spc_lock(l->l_cpu);



CVS commit: src/sys/kern

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Mar 27 00:14:25 UTC 2020

Modified Files:
src/sys/kern: vfs_cache.c

Log Message:
- Stats: add a cast to make sure 32-bit wraparound works properly.
- cache_purge_children(): just use RB_TREE_MIN().
- Change the name of the pool to "namecache".
- Update comments.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/kern/vfs_cache.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/kern/vfs_cache.c
diff -u src/sys/kern/vfs_cache.c:1.134 src/sys/kern/vfs_cache.c:1.135
--- src/sys/kern/vfs_cache.c:1.134	Mon Mar 23 20:02:13 2020
+++ src/sys/kern/vfs_cache.c	Fri Mar 27 00:14:25 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_cache.c,v 1.134 2020/03/23 20:02:13 ad Exp $	*/
+/*	$NetBSD: vfs_cache.c,v 1.135 2020/03/27 00:14:25 ad Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc.
@@ -172,7 +172,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.134 2020/03/23 20:02:13 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.135 2020/03/27 00:14:25 ad Exp $");
 
 #define __NAMECACHE_PRIVATE
 #ifdef _KERNEL_OPT
@@ -250,7 +250,7 @@ static kmutex_t cache_stat_lock __cachel
 
 #define	UPDATE(nchcpu, f) do { \
 	uint32_t cur = atomic_load_relaxed(&nchcpu->cur.f); \
-	nchstats.f += cur - nchcpu->last.f; \
+	nchstats.f += (uint32_t)(cur - nchcpu->last.f); \
 	nchcpu->last.f = cur; \
 } while (/* CONSTCOND */ 0)
 
@@ -409,9 +409,9 @@ cache_lookup_entry(struct vnode *dvp, co
 	 * tailored for exactly what's needed here (64-bit key and so on)
 	 * that is quite a bit faster than using rb_tree_find_node(). 
 	 *
-	 * In the fast path memcmp() needs to be called at least once to
-	 * confirm that the correct name has been found.  If there has been
-	 * a hash value collision (very rare) the search will continue on.
+	 * For a matching key memcmp() needs to be called once to confirm
+	 * that the correct name has been found.  Very rarely there will be
+	 * a key value collision and the search will continue.
 	 */
 	for (;;) {
 		if (__predict_false(RB_SENTINEL_P(node))) {
@@ -791,7 +791,10 @@ cache_revlookup(struct vnode *vp, struct
 			}
 		}
 
-		/* Record a hit on the entry.  This is an unlocked read. */
+		/*
+		 * Record a hit on the entry.  This is an unlocked read but
+		 * even if wrong it doesn't matter too much.
+		 */
 		lrulist = atomic_load_relaxed(&ncp->nc_lrulist);
 		if (lrulist != LRU_ACTIVE) {
 			cache_activate(ncp);
@@ -905,8 +908,8 @@ cache_enter(struct vnode *dvp, struct vn
 
 	/*
 	 * With the directory lock still held, insert to the tail of the
-	 * ACTIVE LRU list (new) and with the LRU lock held take the to
-	 * opportunity to incrementally balance the lists.
+	 * ACTIVE LRU list (new) and take the opportunity to incrementally
+	 * balance the lists.
 	 */
 	mutex_enter(&cache_lru_lock);
 	ncp->nc_lrulist = LRU_ACTIVE;
@@ -916,8 +919,10 @@ cache_enter(struct vnode *dvp, struct vn
 	mutex_exit(&cache_lru_lock);
 
 	/*
-	 * Finally, insert to the vnode, and unlock.  Partially sort the
-	 * per-vnode list: dots go to back.
+	 * Finally, insert to the vnode and unlock.  With everything set up
+	 * it's safe to let cache_revlookup() see the entry.  Partially sort
+	 * the per-vnode list: dots go to back so cache_revlookup() doesn't
+	 * have to consider them.
 	 */
 	if (vp != NULL) {
 		vnode_impl_t *vi = VNODE_TO_VIMPL(vp);
@@ -987,7 +992,7 @@ nchinit(void)
 {
 
 	cache_pool = pool_cache_init(sizeof(struct namecache),
-	coherency_unit, 0, 0, "nchentry", NULL, IPL_NONE, NULL,
+	coherency_unit, 0, 0, "namecache", NULL, IPL_NONE, NULL,
 	NULL, NULL);
 	KASSERT(cache_pool != NULL);
 
@@ -1126,11 +1131,7 @@ cache_purge_children(struct vnode *dvp)
 	SDT_PROBE(vfs, namecache, purge, children, dvp, 0, 0, 0, 0);
 
 	rw_enter(&dvi->vi_nc_lock, RW_WRITER);
-	for (;;) {
-		ncp = rb_tree_iterate(&dvi->vi_nc_tree, NULL, RB_DIR_RIGHT);
-		if (ncp == NULL) {
-			break;
-		}
+	while ((ncp = RB_TREE_MIN(&dvi->vi_nc_tree)) != NULL) {
 		cache_remove(ncp, true);
 	}
 	rw_exit(&dvi->vi_nc_lock);
@@ -1210,14 +1211,14 @@ cache_purgevfs(struct mount *mp)
 }
 
 /*
- * Re-queue an entry onto the correct LRU list, after it has scored a hit.
+ * Re-queue an entry onto the tail of the active LRU list, after it has
+ * scored a hit.
  */
 static void
 cache_activate(struct namecache *ncp)
 {
 
 	mutex_enter(&cache_lru_lock);
-	/* Put on tail of ACTIVE list, since it just scored a hit. */
 	TAILQ_REMOVE(&cache_lru.list[ncp->nc_lrulist], ncp, nc_lru);
 	TAILQ_INSERT_TAIL(&cache_lru.list[LRU_ACTIVE], ncp, nc_lru);
 	cache_lru.count[ncp->nc_lrulist]--;



CVS commit: src/usr.sbin/crash

2020-03-26 Thread Andrew Doran
Module Name:src
Committed By:   ad
Date:   Fri Mar 27 00:17:08 UTC 2020

Modified Files:
src/usr.sbin/crash: crash.c

Log Message:
No need for warnx() if !LOCKDEBUG


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/usr.sbin/crash/crash.c

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

Modified files:

Index: src/usr.sbin/crash/crash.c
diff -u src/usr.sbin/crash/crash.c:1.12 src/usr.sbin/crash/crash.c:1.13
--- src/usr.sbin/crash/crash.c:1.12	Mon Mar  9 01:54:31 2020
+++ src/usr.sbin/crash/crash.c	Fri Mar 27 00:17:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: crash.c,v 1.12 2020/03/09 01:54:31 christos Exp $	*/
+/*	$NetBSD: crash.c,v 1.13 2020/03/27 00:17:08 ad Exp $	*/
 
 /*-
  * Copyright (c) 2009 The NetBSD Foundation, Inc.
@@ -31,7 +31,7 @@
 
 #include 
 #ifndef lint
-__RCSID("$NetBSD: crash.c,v 1.12 2020/03/09 01:54:31 christos Exp $");
+__RCSID("$NetBSD: crash.c,v 1.13 2020/03/27 00:17:08 ad Exp $");
 #endif /* not lint */
 
 #include 
@@ -427,17 +427,16 @@ main(int argc, char **argv)
 		errx(EXIT_FAILURE, "cannot read osrelease: %s",
 		kvm_geterr(kd));
 	}
-#ifdef LOCKDEBUG
-	if ((size_t)kvm_read(kd, nl[X_LOCKDEBUG].n_value, &ld_all,
-	sizeof(ld_all)) != sizeof(ld_all))
-		warn("Cannot read ld_all (no LOCKDEBUG kernel?): %s",
-		kvm_geterr(kd));
-#endif
 	printf("Crash version %s, image version %s.\n", osrelease, imgrelease);
 	if (strcmp(osrelease, imgrelease) != 0) {
 		printf("WARNING: versions differ, you may not be able to "
 		"examine this image.\n");
 	}
+#ifdef LOCKDEBUG
+	if ((size_t)kvm_read(kd, nl[X_LOCKDEBUG].n_value, &ld_all,
+	sizeof(ld_all)) != sizeof(ld_all))
+		printf("Kernel compiled without options LOCKDEBUG.\n");
+#endif
 
 	/*
 	 * Print the panic string, if any.



CVS commit: src/sys/arch/arm/sunxi

2020-03-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Mar 27 01:42:11 UTC 2020

Modified Files:
src/sys/arch/arm/sunxi: sunxi_rtc.c

Log Message:
Add the clock providers for the sun6i_a31, sun8i_a23, sun8i_r40, sun8i_v3,
sun8i_h3, sun50i_h5 (same as H3), and sun50i_h6 RTC blocks.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/sunxi/sunxi_rtc.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/arch/arm/sunxi/sunxi_rtc.c
diff -u src/sys/arch/arm/sunxi/sunxi_rtc.c:1.5 src/sys/arch/arm/sunxi/sunxi_rtc.c:1.6
--- src/sys/arch/arm/sunxi/sunxi_rtc.c:1.5	Thu Sep  5 23:42:26 2019
+++ src/sys/arch/arm/sunxi/sunxi_rtc.c	Fri Mar 27 01:42:10 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: sunxi_rtc.c,v 1.5 2019/09/05 23:42:26 thorpej Exp $ */
+/* $NetBSD: sunxi_rtc.c,v 1.6 2020/03/27 01:42:10 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2014-2017 Jared McNeill 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sunxi_rtc.c,v 1.5 2019/09/05 23:42:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sunxi_rtc.c,v 1.6 2020/03/27 01:42:10 thorpej Exp $");
 
 #include 
 #include 
@@ -37,6 +37,7 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_rtc.c,
 #include 
 
 #include 
+#include 
 
 #include 
 
@@ -64,6 +65,18 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_rtc.c,
 #define	 SUN7I_RTC_SECOND	__BITS(5,0)
 #define	SUN7I_RTC_BASE_YEAR	1970
 
+#define	SUN6I_LOSC_CTRL_REG	0x00
+#define	 SUN6I_LOSC_CTRL_KEY		(0x16aa << 16)
+#define	 SUN6I_LOSC_CTRL_AUTO_SWT_BYPASS __BIT(15)
+#define	 SUN6I_LOSC_CTRL_ALM_DHMS_ACC	__BIT(9)
+#define	 SUN6I_LOSC_CTRL_RTC_HMS_ACC	__BIT(8)
+#define	 SUN6I_LOSC_CTRL_RTC_YMD_ACC	__BIT(7)
+#define	 SUN6I_LOSC_CTRL_EXT_LOSC_EN	__BIT(4)
+#define	 SUN6I_LOSC_CTRL_EXT_OSC	__BIT(0)
+
+#define	SUN6I_INTOSC_CLK_PRESCAL_REG 0x08
+#define	 SUN6I_INTOSC_CLK_PRESCAL	__BITS(0,4)
+
 #define	SUN6I_RTC_YY_MM_DD_REG	0x10
 #define	 SUN6I_RTC_LEAP		__BIT(22)
 #define	 SUN6I_RTC_YEAR		__BITS(21,16)
@@ -76,14 +89,25 @@ __KERNEL_RCSID(0, "$NetBSD: sunxi_rtc.c,
 #define	 SUN6I_RTC_SECOND	__BITS(5,0)
 #define	SUN6I_RTC_BASE_YEAR	2000
 
+#define	SUN6I_RTC_LOSC_OUT_GATING_REG 0x60
+#define	 SUN6I_RTC_LOSC_OUT_EN	__BIT(0)
+
 struct sunxi_rtc_config {
 	bus_size_t	yy_mm_dd_reg;
 	uint32_t	leap, year, month, day;
 	bus_size_t	hh_mm_ss_reg;
 	uint32_t	wk_no, hour, minute, second;
 	u_int		base_year;
+
+	u_int		iosc_rate;
+	u_int		fixed_prescaler;
+	uint32_t	ext_losc_en;
+	uint32_t	auto_swt_bypass;
+	u_int		flags;
 };
 
+#define	SUNXI_RTC_F_HAS_VAR_PRESCALER	__BIT(0)
+
 static const struct sunxi_rtc_config sun4i_rtc_config = {
 	.yy_mm_dd_reg = SUN4I_RTC_YY_MM_DD_REG,
 	.leap = SUN4I_RTC_LEAP,
@@ -98,7 +122,7 @@ static const struct sunxi_rtc_config sun
 	.base_year = SUN4I_RTC_BASE_YEAR,
 };
 
-static const struct sunxi_rtc_config sun6i_rtc_config = {
+static const struct sunxi_rtc_config sun6i_a31_rtc_config = {
 	.yy_mm_dd_reg = SUN6I_RTC_YY_MM_DD_REG,
 	.leap = SUN6I_RTC_LEAP,
 	.year = SUN6I_RTC_YEAR,
@@ -110,6 +134,9 @@ static const struct sunxi_rtc_config sun
 	.minute = SUN6I_RTC_MINUTE,
 	.second = SUN6I_RTC_SECOND,
 	.base_year = SUN6I_RTC_BASE_YEAR,
+
+	.iosc_rate = 667000,
+	.flags = SUNXI_RTC_F_HAS_VAR_PRESCALER,
 };
 
 static const struct sunxi_rtc_config sun7i_rtc_config = {
@@ -126,21 +153,142 @@ static const struct sunxi_rtc_config sun
 	.base_year = SUN7I_RTC_BASE_YEAR,
 };
 
+static const struct sunxi_rtc_config sun8i_a23_rtc_config = {
+	.yy_mm_dd_reg = SUN6I_RTC_YY_MM_DD_REG,
+	.leap = SUN6I_RTC_LEAP,
+	.year = SUN6I_RTC_YEAR,
+	.month = SUN6I_RTC_MONTH,
+	.day = SUN6I_RTC_DAY,
+	.hh_mm_ss_reg = SUN6I_RTC_HH_MM_SS_REG,
+	.wk_no = SUN6I_RTC_WK_NO,
+	.hour = SUN6I_RTC_HOUR,
+	.minute = SUN6I_RTC_MINUTE,
+	.second = SUN6I_RTC_SECOND,
+	.base_year = SUN6I_RTC_BASE_YEAR,
+
+	.iosc_rate = 667000,
+	.flags = SUNXI_RTC_F_HAS_VAR_PRESCALER,
+};
+
+static const struct sunxi_rtc_config sun8i_r40_rtc_config = {
+	.yy_mm_dd_reg = SUN6I_RTC_YY_MM_DD_REG,
+	.leap = SUN6I_RTC_LEAP,
+	.year = SUN6I_RTC_YEAR,
+	.month = SUN6I_RTC_MONTH,
+	.day = SUN6I_RTC_DAY,
+	.hh_mm_ss_reg = SUN6I_RTC_HH_MM_SS_REG,
+	.wk_no = SUN6I_RTC_WK_NO,
+	.hour = SUN6I_RTC_HOUR,
+	.minute = SUN6I_RTC_MINUTE,
+	.second = SUN6I_RTC_SECOND,
+	.base_year = SUN6I_RTC_BASE_YEAR,
+
+	.iosc_rate = 1600,
+	.fixed_prescaler = 512,
+};
+
+static const struct sunxi_rtc_config sun8i_v3_rtc_config = {
+	.yy_mm_dd_reg = SUN6I_RTC_YY_MM_DD_REG,
+	.leap = SUN6I_RTC_LEAP,
+	.year = SUN6I_RTC_YEAR,
+	.month = SUN6I_RTC_MONTH,
+	.day = SUN6I_RTC_DAY,
+	.hh_mm_ss_reg = SUN6I_RTC_HH_MM_SS_REG,
+	.wk_no = SUN6I_RTC_WK_NO,
+	.hour = SUN6I_RTC_HOUR,
+	.minute = SUN6I_RTC_MINUTE,
+	.second = SUN6I_RTC_SECOND,
+	.base_year = SUN6I_RTC_BASE_YEAR,
+
+	.iosc_rate = 32000,
+};
+
+static const struct sunxi_rtc_config sun8i_h3_rtc_config = {
+	.yy_mm_dd_reg = SUN6I_RTC_YY_MM_DD_REG,
+	.leap = SUN6I_RTC_LEAP,
+	.year = SUN6I_RTC_YEAR,
+	.month = SUN6I_RTC_MONTH,
+	.day = 

CVS commit: src/sys/arch/evbarm/conf

2020-03-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Mar 27 01:43:58 UTC 2020

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64

Log Message:
Attach sunxirtc in pass4; it's required by mmcpwrseq on some boards.


To generate a diff of this commit:
cvs rdiff -u -r1.146 -r1.147 src/sys/arch/evbarm/conf/GENERIC64

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

Modified files:

Index: src/sys/arch/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.146 src/sys/arch/evbarm/conf/GENERIC64:1.147
--- src/sys/arch/evbarm/conf/GENERIC64:1.146	Wed Mar 18 10:56:38 2020
+++ src/sys/arch/evbarm/conf/GENERIC64	Fri Mar 27 01:43:58 2020
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.146 2020/03/18 10:56:38 jmcneill Exp $
+#	$NetBSD: GENERIC64,v 1.147 2020/03/27 01:43:58 thorpej Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -421,7 +421,7 @@ sun8icrypto* 	at fdt?			# Allwinner Cryp
 
 # RTC
 plrtc*		at fdt?			# ARM PrimeCell RTC
-sunxirtc*	at fdt?			# Allwinner RTC
+sunxirtc*	at fdt? pass 4		# Allwinner RTC
 tegrartc*	at fdt?			# NVIDIA Tegra RTC
 
 # SDMMC



CVS commit: src/sys/arch/arm/dts

2020-03-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Mar 27 01:59:50 UTC 2020

Added Files:
src/sys/arch/arm/dts: sun50i-h6-orangepi-lite2.dts

Log Message:
Add a more complete / correct device tree for the OrangePi Lite 2.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/dts/sun50i-h6-orangepi-lite2.dts

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

Added files:

Index: src/sys/arch/arm/dts/sun50i-h6-orangepi-lite2.dts
diff -u /dev/null src/sys/arch/arm/dts/sun50i-h6-orangepi-lite2.dts:1.1
--- /dev/null	Fri Mar 27 01:59:50 2020
+++ src/sys/arch/arm/dts/sun50i-h6-orangepi-lite2.dts	Fri Mar 27 01:59:49 2020
@@ -0,0 +1,341 @@
+// SPDX-License-Identifier: (GPL-2.0+ or MIT)
+/*
+ * Copyright (C) 2018 Jagan Teki 
+ */
+
+/*
+ * Corrected OrangePi Lite2 device tree taken from:
+ *
+ * https://github.com/armbian/build/blob/master/patch/kernel/sunxi-dev/board-h6-orangepi-lite2-fix-missing-all.patch
+ *
+ * Commit 9fadb36e18cfca774068feedcc176bd483082e83
+ */
+
+/dts-v1/;
+
+#include "../../../external/gpl2/dts/dist/arch/arm64/boot/dts/allwinner/sun50i-h6.dtsi"
+
+#include 
+
+/ {
+	model = "OrangePi Lite2";
+	compatible = "xunlong,orangepi-lite2", "allwinner,sun50i-h6";
+
+	aliases {
+		serial0 = &uart0; /* debug */
+		serial1 = &uart1; /* BT-UART */
+	};
+
+	chosen {
+		stdout-path = "serial0:115200n8";
+	};
+
+	connector {
+		compatible = "hdmi-connector";
+		type = "a";
+		ddc-supply = <®_ddc>;
+
+		port {
+			hdmi_con_in: endpoint {
+remote-endpoint = <&hdmi_out_con>;
+			};
+		};
+	};
+
+	leds {
+		compatible = "gpio-leds";
+
+		power {
+			label = "orangepi:red:power";
+			gpios = <&r_pio 0 4 GPIO_ACTIVE_HIGH>; /* PL4 */
+			default-state = "on";
+		};
+
+		status {
+			label = "orangepi:green:status";
+			gpios = <&r_pio 0 7 GPIO_ACTIVE_HIGH>; /* PL7 */
+		};
+	};
+
+	reg_ddc: ddc-io {
+		compatible = "regulator-fixed";
+		regulator-name = "ddc-io";
+		regulator-min-microvolt = <500>;
+		regulator-max-microvolt = <500>;
+		enable-active-high;
+		gpio = <&pio 7 2 GPIO_ACTIVE_HIGH>; /* PH2 */
+	};
+
+	reg_vcc5v: vcc5v {
+		/* board wide 5V supply directly from the DC jack */
+		compatible = "regulator-fixed";
+		regulator-name = "vcc-5v";
+		regulator-min-microvolt = <500>;
+		regulator-max-microvolt = <500>;
+		regulator-always-on;
+	};
+
+	reg_usb_vbus: vbus {
+		compatible = "regulator-fixed";
+		regulator-name = "usb-vbus";
+		regulator-min-microvolt = <500>;
+		regulator-max-microvolt = <500>;
+		startup-delay-us = <10>;
+		gpio = <&r_pio 0 5 GPIO_ACTIVE_HIGH>; /* PL5 USB0-DRVVBUS */
+		enable-active-high;
+	};
+
+	wifi_pwrseq: wifi_pwrseq {
+		compatible = "mmc-pwrseq-simple";
+		clocks = <&rtc 1>;
+		clock-names = "ext_clock";
+		reset-gpios = <&r_pio 1 3 GPIO_ACTIVE_LOW>; /* PM3 */
+		post-power-on-delay-ms = <200>;
+	};
+};
+
+&cpu0 {
+	cpu-supply = <®_dcdca>;
+};
+
+&de {
+	status = "okay";
+};
+
+&hdmi {
+	status = "okay";
+};
+
+&hdmi_out {
+	hdmi_out_con: endpoint {
+		remote-endpoint = <&hdmi_con_in>;
+	};
+};
+
+&mmc0 {
+	vmmc-supply = <®_cldo1>;
+	cd-gpios = <&pio 5 6 GPIO_ACTIVE_LOW>; /* PF6 */
+	bus-width = <4>;
+	status = "okay";
+};
+
+&mmc1 {
+	vmmc-supply = <®_cldo2>;
+	vqmmc-supply = <®_bldo3>;
+	mmc-pwrseq = <&wifi_pwrseq>;
+	bus-width = <4>;
+	non-removable;
+	status = "okay";
+
+	brcm: sdio-wifi@1 {
+		reg = <1>;
+		compatible = "brcm,bcm4329-fmac";
+		interrupt-parent = <&r_pio>;
+		interrupts = <1 0 IRQ_TYPE_LEVEL_LOW>;	/* PM0 */
+		interrupt-names = "host-wake";
+	};
+};
+
+&pio {
+	vcc-pc-supply = <®_bldo2>;
+	vcc-pd-supply = <®_cldo1>;
+	vcc-pg-supply = <®_bldo3>;
+};
+
+&r_i2c {
+	status = "okay";
+
+	axp805: pmic@36 {
+		compatible = "x-powers,axp805", "x-powers,axp806";
+		reg = <0x36>;
+		interrupt-parent = <&r_intc>;
+		interrupts = <0 IRQ_TYPE_LEVEL_LOW>;
+		interrupt-controller;
+		#interrupt-cells = <1>;
+		x-powers,self-working-mode;
+		vina-supply = <®_vcc5v>;
+		vinb-supply = <®_vcc5v>;
+		vinc-supply = <®_vcc5v>;
+		vind-supply = <®_vcc5v>;
+		vine-supply = <®_vcc5v>;
+		aldoin-supply = <®_vcc5v>;
+		bldoin-supply = <®_vcc5v>;
+		cldoin-supply = <®_vcc5v>;
+
+		regulators {
+			reg_aldo1: aldo1 {
+regulator-always-on;
+regulator-min-microvolt = <330>;
+regulator-max-microvolt = <330>;
+regulator-name = "vcc-pl-led-ir";
+			};
+
+			reg_aldo2: aldo2 {
+regulator-min-microvolt = <330>;
+regulator-max-microvolt = <330>;
+regulator-name = "vcc33-audio-tv-ephy-mac";
+			};
+
+			/* ALDO3 is shorted to CLDO1 */
+			reg_aldo3: aldo3 {
+regulator-always-on;
+regulator-min-microvolt = <330>;
+regulator-max-microvolt = <330>;
+regulator-name = "vcc33-io-pd-emmc-sd-usb-uart-1";
+			};
+
+			reg_bldo1: bldo1 {
+regulator-always-on;
+regulator-min-microvolt = <180>;
+regulator-max-microvolt = <180>;
+regulator-name = "vcc18-dram-bias-pll";
+			};

CVS commit: src/share/installboot/evbarm

2020-03-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Mar 27 02:01:48 UTC 2020

Modified Files:
src/share/installboot/evbarm: boards.plist

Log Message:
Add OrangePi Lite and Lite2.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/share/installboot/evbarm/boards.plist

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

Modified files:

Index: src/share/installboot/evbarm/boards.plist
diff -u src/share/installboot/evbarm/boards.plist:1.5 src/share/installboot/evbarm/boards.plist:1.6
--- src/share/installboot/evbarm/boards.plist:1.5	Mon Jan 27 07:48:59 2020
+++ src/share/installboot/evbarm/boards.plist	Fri Mar 27 02:01:48 2020
@@ -1,4 +1,4 @@
-
+
 

CVS commit: src

2020-03-26 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Fri Mar 27 04:31:18 UTC 2020

Modified Files:
src/distrib/sets/lists/base: md.evbarm
src/external/broadcom/bwfm: Makefile

Log Message:
Let xunlong,orangepi-lite2 share bwfm config with raspberrypi,3-model-b-plus;
it seem to work fine and there's no better alternative at the moment.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/distrib/sets/lists/base/md.evbarm
cvs rdiff -u -r1.7 -r1.8 src/external/broadcom/bwfm/Makefile

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

Modified files:

Index: src/distrib/sets/lists/base/md.evbarm
diff -u src/distrib/sets/lists/base/md.evbarm:1.17 src/distrib/sets/lists/base/md.evbarm:1.18
--- src/distrib/sets/lists/base/md.evbarm:1.17	Sun Mar 22 22:36:12 2020
+++ src/distrib/sets/lists/base/md.evbarm	Fri Mar 27 04:31:18 2020
@@ -1,4 +1,4 @@
-# $NetBSD: md.evbarm,v 1.17 2020/03/22 22:36:12 thorpej Exp $
+# $NetBSD: md.evbarm,v 1.18 2020/03/27 04:31:18 thorpej Exp $
 ./libdata/firmware/if_bwfm/brcmfmac43143-sdio.bin	base-firmware-root	firmware
 ./libdata/firmware/if_bwfm/brcmfmac43241b0-sdio.bin	base-firmware-root	firmware
 ./libdata/firmware/if_bwfm/brcmfmac43241b4-sdio.bin	base-firmware-root	firmware
@@ -21,6 +21,7 @@
 ./libdata/firmware/if_bwfm/brcmfmac43455-sdio.bin	base-firmware-root	firmware
 ./libdata/firmware/if_bwfm/brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt	base-firmware-root	firmware
 ./libdata/firmware/if_bwfm/brcmfmac43455-sdio.raspberrypi,4-model-b.txt	base-firmware-root	firmware
+./libdata/firmware/if_bwfm/brcmfmac43455-sdio.xunlong,orangepi-lite2.txt	base-firmware-root	firmware
 ./libdata/firmware/if_bwfm/brcmfmac43456-sdio.bin	base-firmware-root	firmware
 ./libdata/firmware/if_bwfm/brcmfmac43456-sdio.clm_blob	base-firmware-root	firmware
 ./libdata/firmware/if_bwfm/brcmfmac43456-sdio.pine64,pinebook-pro.txt	base-firmware-root	firmware

Index: src/external/broadcom/bwfm/Makefile
diff -u src/external/broadcom/bwfm/Makefile:1.7 src/external/broadcom/bwfm/Makefile:1.8
--- src/external/broadcom/bwfm/Makefile:1.7	Sun Mar 22 22:36:12 2020
+++ src/external/broadcom/bwfm/Makefile	Fri Mar 27 04:31:18 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2020/03/22 22:36:12 thorpej Exp $
+# $NetBSD: Makefile,v 1.8 2020/03/27 04:31:18 thorpej Exp $
 
 NOMAN=	# define
 
@@ -71,6 +71,11 @@ LINKS+=	${FILESDIR}/brcmfmac43430-sdio.r
 FILES+=	dist/brcmfmac43430-sdio.AP6212.txt
 LINKS+=	${FILESDIR}/brcmfmac43430-sdio.AP6212.txt \
 	${FILESDIR}/brcmfmac43430-sdio.sinovoip,bpi-m2-zero.txt
+
+# In lieu of a better option the xunlong,orangepi-lite2 has successfully
+# used the the same nvram config as the raspberrypi,3-model-b-plus.
+LINKS+=	${FILESDIR}/brcmfmac43455-sdio.raspberrypi,3-model-b-plus.txt \
+	${FILESDIR}/brcmfmac43455-sdio.xunlong,orangepi-lite2.txt
 .endif
 
 .include 



CVS commit: src/sys/arch/arm/sociox

2020-03-26 Thread Tohru Nishimura
Module Name:src
Committed By:   nisimura
Date:   Fri Mar 27 06:32:49 UTC 2020

Modified Files:
src/sys/arch/arm/sociox: if_scx.c

Log Message:
register definition mashed. from UEFI and CycloneV PDF


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/sociox/if_scx.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/arch/arm/sociox/if_scx.c
diff -u src/sys/arch/arm/sociox/if_scx.c:1.17 src/sys/arch/arm/sociox/if_scx.c:1.18
--- src/sys/arch/arm/sociox/if_scx.c:1.17	Thu Mar 26 10:38:16 2020
+++ src/sys/arch/arm/sociox/if_scx.c	Fri Mar 27 06:32:49 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_scx.c,v 1.17 2020/03/26 10:38:16 nisimura Exp $	*/
+/*	$NetBSD: if_scx.c,v 1.18 2020/03/27 06:32:49 nisimura Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -57,7 +57,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.17 2020/03/26 10:38:16 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1.18 2020/03/27 06:32:49 nisimura Exp $");
 
 #include 
 #include 
@@ -84,29 +84,31 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #include 
 #include 
 
-/* SC2A11 register block */
+/* SC2A11 register block 0x100-0x1204? */
 #define SWRESET		0x104
-#define MACADRH		0x10c
-#define MACADRL		0x110
 #define COMINIT		0x120
-#define INTRST		0x200
-#define  IRQ_RX		(1U<<1)
-#define  IRQ_TX		(1U<<0)
-#define INTREN		0x204
-#define INTR_SET	0x234
-#define INTR_CLR	0x238
-#define TXINTST		0x400
-#define TXINTEN		0x404
-#define TXINT_SET	0x428
-#define TXINT_CLR	0x42c
+#define xINTSR		0x200		/* aggregated interrupt status report */
+#define  IRQ_RX		(1U<<1)		/* top level Rx interrupt */
+#define  IRQ_TX		(1U<<0)		/* top level Rx interrupt */
+#define xINTAEN		0x204		/* INT_A enable */
+#define xINTA_SET	0x234		/* bit to set */
+#define xINTA_CLR	0x238		/* bit to clr */
+#define xINTBEN		0x23c		/* INT_B enable */
+#define xINTB_SET	0x240		/* bit to set */
+#define xINTB_CLR	0x244		/* bit to clr */
+/* 0x0c-48 *//* pkt,tls,s0,s1 SR/IE/SET/CLR */
+#define TXISR		0x400
+#define TXIEN		0x404
+#define TXI_SET		0x428
+#define TXI_CLR		0x42c
 #define  TXI_NTOWNR	(1U<<17)
 #define  TXI_TR_ERR	(1U<<16)
 #define  TXI_TXDONE	(1U<<15)
 #define  TXI_TMREXP	(1U<<14)
-#define RXINTST		0x440
-#define RXINTEN		0x444
-#define RXINT_SET	0x468
-#define RXINT_CLR	0x46c
+#define RXISR		0x440
+#define RXIEN		0x444
+#define RXI_SET		0x468
+#define RXI_CLR		0x46c
 #define  RXI_RC_ERR	(1U<<16)
 #define  RXI_PKTCNT	(1U<<15)
 #define  RXI_TMREXP	(1U<<14)
@@ -117,16 +119,22 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define H2MENG		0x210		/* DMAC host2media ucode port */
 #define M2HENG		0x21c		/* DMAC media2host ucode port */
 #define PKTENG		0x0d0		/* packet engine ucode port */
+#define CLKEN		0x100		/* clock distribution enable */
+#define  CLK_G		(1U<<5)
+#define  CLK_ALL	0x24
+#define MACADRH		0x10c		/* ??? */
+#define MACADRL		0x110		/* ??? */
 #define MCVER		0x22c		/* micro controller version */
 #define HWVER		0x230		/* hardware version */
 
-#define MACSTAT		0x1024		/* gmac status */
-#define MACDATA		0x11c0		/* gmac rd/wr data */
 #define MACCMD		0x11c4		/* gmac operation */
 #define  CMD_IOWR	(1U<<28)	/* write op */
 #define  CMD_BUSY	(1U<<31)	/* busy bit */
-#define DESCENG_INIT	0x11fc
-#define DESCENG_SRST	0x1204
+#define MACSTAT		0x1024		/* gmac status */
+#define MACDATA		0x11c0		/* gmac rd/wr data */
+#define MACINTE		0x1028		/* interrupt enable */
+#define DESC_INIT	0x11fc		/* desc engine init */
+#define DESC_SRST	0x1204		/* desc engine sw reset */
 
 /* GMAC register block. use mac_write()/mac_read() to handle */
 #define GMACMCR		0x		/* MAC configuration */
@@ -134,8 +142,8 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define  MCR_CST	(1U<<25)	/* strip CRC */
 #define  MCR_TC		(1U<<24)	/* keep RGMII PHY notified */
 #define  MCR_JE		(1U<<20)	/* ignore oversized >9018 condition */
-#define  MCR_USEMII	(1U<<15)	/* 1: RMII/MII, 0: RGMII */
-#define  MCR_SPD100	(1U<<14)	/* force speed 100 */
+#define  MCR_USEMII	(1U<<15)	/* 1: RMII/MII, 0: RGMII (_PS) */
+#define  MCR_SPD100	(1U<<14)	/* force speed 100 (_FES) */
 #define  MCR_USEFDX	(1U<<11)	/* force full duplex */
 #define  MCR_IPCKEN	(1U<<10)	/* handle checksum */
 #define  MCR_ACS	(1U<<7)		/* auto pad strip CRC */
@@ -145,19 +153,19 @@ __KERNEL_RCSID(0, "$NetBSD: if_scx.c,v 1
 #define  _MCR_HDX	0x0001a00c	/* XXX TBD */
 #define GMACAFR		0x0004		/* frame DA/SA address filter */
 #define  AFR_RA		(1U<<31)	/* receive block all on */
-#define  AFR_HPF	(1U<<10)	/* activate hash or perfect filter */
+#define  AFR_HPF	(1U<<10)	/* hash+perfect filter, or hash only */
 #define  AFR_SAF	(1U<<9)		/* source address filter */
 #define  AFR_SAIF	(1U<<8)		/* SA inverse filtering */
-#define  AFR_PCF	(3U<<6)		/* */
-#define  AFR_RB		(1U<<5)		/* reject broadcast frame */
-#define  AFR_AM		(1U<<4)		/* accept all multicast frame */
+#define