CVS commit: src/share/misc

2023-04-16 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Apr 17 00:37:04 UTC 2023

Modified Files:
src/share/misc: style

Log Message:
share/misc/style: Don't prescribe using "extern.h" for all prototypes.

That's very 80s.

No objection (or even response, amazingly enough) on tech-userlevel in
two weeks.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/share/misc/style

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



CVS commit: src/share/misc

2023-04-16 Thread David A. Holland
Module Name:src
Committed By:   dholland
Date:   Mon Apr 17 00:37:04 UTC 2023

Modified Files:
src/share/misc: style

Log Message:
share/misc/style: Don't prescribe using "extern.h" for all prototypes.

That's very 80s.

No objection (or even response, amazingly enough) on tech-userlevel in
two weeks.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/share/misc/style

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/style
diff -u src/share/misc/style:1.72 src/share/misc/style:1.73
--- src/share/misc/style:1.72	Sat Apr 15 12:22:37 2023
+++ src/share/misc/style	Mon Apr 17 00:37:04 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: style,v 1.72 2023/04/15 12:22:37 rillig Exp $ */
+/* $NetBSD: style,v 1.73 2023/04/17 00:37:04 dholland Exp $ */
 
 /*
  * The revision control tag appears first, with a blank line after it.
@@ -30,7 +30,7 @@
 #include 
 __COPYRIGHT("@(#) Copyright (c) 2008\
  The NetBSD Foundation, inc. All rights reserved.");
-__RCSID("$NetBSD: style,v 1.72 2023/04/15 12:22:37 rillig Exp $");
+__RCSID("$NetBSD: style,v 1.73 2023/04/17 00:37:04 dholland Exp $");
 
 /*
  * VERY important single-line comments look like this.
@@ -356,7 +356,8 @@ function(int a1, int a2, float fl, int a
 	 * When declaring variables in functions, multiple variables per line
 	 * are okay. If a line overflows reuse the type keyword.
 	 *
-	 * Function prototypes should go in the include file "extern.h".
+	 * Function prototypes and external data declarations should go in a
+	 * suitable include file.
 	 *
 	 * Avoid initializing variables in the declarations; move
 	 * declarations next to their first use, and initialize



CVS commit: src

2023-04-16 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Sun Apr 16 20:46:18 UTC 2023

Modified Files:
src/distrib/sets/lists/base: ad.aarch64 mi shl.mi
src/distrib/sets/lists/debug: shl.mi
src/doc: 3RDPARTY CHANGES
src/etc/mtree: NetBSD.dist.base NetBSD.dist.compat.in
src/external/mit/lua/dist: Makefile README README.import
src/external/mit/lua/dist/doc: contents.html lua.1 manual.html
readme.html
src/external/mit/lua/dist/src: Makefile lapi.c lapi.h lauxlib.c
lauxlib.h lbaselib.c lcode.c lcode.h lcorolib.c lctype.c lctype.h
ldblib.c ldebug.c ldebug.h ldo.c ldo.h ldump.c lfunc.c lfunc.h
lgc.c lgc.h linit.c liolib.c ljumptab.h llex.c llex.h llimits.h
lmathlib.c lmem.c lmem.h loadlib.c lobject.c lobject.h lopcodes.c
lopcodes.h loslib.c lparser.c lparser.h lprefix.h lstate.c lstate.h
lstring.c lstring.h lstrlib.c ltable.c ltable.h ltablib.c ltm.c
ltm.h lua.c lua.h luac.c luaconf.h lualib.h lundump.c lundump.h
lutf8lib.c lvm.c lvm.h lzio.c lzio.h
src/external/mit/lua/lib/liblua: Makefile shlib_version
src/share/mk: bsd.lua.mk
src/sys/modules/examples/luahello: luahello.lua
src/sys/modules/lua: Makefile
Removed Files:
src/external/mit/lua/dist/src: lbitlib.c

Log Message:
Resolve conflicts for lua 5.4.4 import.
Adjust various files for lua 5.4.4.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/distrib/sets/lists/base/ad.aarch64
cvs rdiff -u -r1.1314 -r1.1315 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.946 -r1.947 src/distrib/sets/lists/base/shl.mi
cvs rdiff -u -r1.303 -r1.304 src/distrib/sets/lists/debug/shl.mi
cvs rdiff -u -r1.1919 -r1.1920 src/doc/3RDPARTY
cvs rdiff -u -r1.2958 -r1.2959 src/doc/CHANGES
cvs rdiff -u -r1.246 -r1.247 src/etc/mtree/NetBSD.dist.base
cvs rdiff -u -r1.1 -r1.2 src/etc/mtree/NetBSD.dist.compat.in
cvs rdiff -u -r1.7 -r1.8 src/external/mit/lua/dist/Makefile
cvs rdiff -u -r1.8 -r1.9 src/external/mit/lua/dist/README
cvs rdiff -u -r1.2 -r1.3 src/external/mit/lua/dist/README.import
cvs rdiff -u -r1.7 -r1.8 src/external/mit/lua/dist/doc/contents.html \
src/external/mit/lua/dist/doc/lua.1 \
src/external/mit/lua/dist/doc/readme.html
cvs rdiff -u -r1.8 -r1.9 src/external/mit/lua/dist/doc/manual.html
cvs rdiff -u -r1.5 -r1.6 src/external/mit/lua/dist/src/Makefile
cvs rdiff -u -r1.12 -r1.13 src/external/mit/lua/dist/src/lapi.c \
src/external/mit/lua/dist/src/llex.c \
src/external/mit/lua/dist/src/lobject.c
cvs rdiff -u -r1.9 -r1.10 src/external/mit/lua/dist/src/lapi.h \
src/external/mit/lua/dist/src/ldebug.h \
src/external/mit/lua/dist/src/ldo.c src/external/mit/lua/dist/src/ldo.h \
src/external/mit/lua/dist/src/ldump.c \
src/external/mit/lua/dist/src/linit.c \
src/external/mit/lua/dist/src/liolib.c \
src/external/mit/lua/dist/src/lmathlib.c \
src/external/mit/lua/dist/src/lmem.c \
src/external/mit/lua/dist/src/loadlib.c \
src/external/mit/lua/dist/src/lstate.c \
src/external/mit/lua/dist/src/lstate.h \
src/external/mit/lua/dist/src/lstring.c \
src/external/mit/lua/dist/src/lstring.h \
src/external/mit/lua/dist/src/ltablib.c \
src/external/mit/lua/dist/src/ltm.c src/external/mit/lua/dist/src/lua.c
cvs rdiff -u -r1.11 -r1.12 src/external/mit/lua/dist/src/lauxlib.c \
src/external/mit/lua/dist/src/lcode.c \
src/external/mit/lua/dist/src/ldblib.c \
src/external/mit/lua/dist/src/ldebug.c \
src/external/mit/lua/dist/src/loslib.c \
src/external/mit/lua/dist/src/lparser.c \
src/external/mit/lua/dist/src/ltable.c \
src/external/mit/lua/dist/src/lua.h
cvs rdiff -u -r1.8 -r1.9 src/external/mit/lua/dist/src/lauxlib.h \
src/external/mit/lua/dist/src/lcode.h \
src/external/mit/lua/dist/src/lfunc.c \
src/external/mit/lua/dist/src/lfunc.h src/external/mit/lua/dist/src/lgc.h \
src/external/mit/lua/dist/src/llex.h src/external/mit/lua/dist/src/lmem.h \
src/external/mit/lua/dist/src/lopcodes.c \
src/external/mit/lua/dist/src/lopcodes.h \
src/external/mit/lua/dist/src/lparser.h \
src/external/mit/lua/dist/src/ltable.h \
src/external/mit/lua/dist/src/ltm.h \
src/external/mit/lua/dist/src/lundump.c \
src/external/mit/lua/dist/src/lutf8lib.c \
src/external/mit/lua/dist/src/lzio.c src/external/mit/lua/dist/src/lzio.h
cvs rdiff -u -r1.10 -r1.11 src/external/mit/lua/dist/src/lbaselib.c \
src/external/mit/lua/dist/src/lgc.c \
src/external/mit/lua/dist/src/llimits.h \
src/external/mit/lua/dist/src/lobject.h \
src/external/mit/lua/dist/src/luac.c src/external/mit/lua/dist/src/lvm.h
cvs rdiff -u -r1.7 -r0 src/external/mit/lua/dist/src/lbitlib.c
cvs rdiff -u -r1.7 -r1.8 src/external/mit/lua/dist/src/lcorolib.c \
src/external/mit/lua/dist/src/lctype.c \
src/external/mit/lua/dist/src/lctype.h \

CVS commit: src

2023-04-16 Thread Nikita
Module Name:src
Committed By:   nikita
Date:   Sun Apr 16 20:46:18 UTC 2023

Modified Files:
src/distrib/sets/lists/base: ad.aarch64 mi shl.mi
src/distrib/sets/lists/debug: shl.mi
src/doc: 3RDPARTY CHANGES
src/etc/mtree: NetBSD.dist.base NetBSD.dist.compat.in
src/external/mit/lua/dist: Makefile README README.import
src/external/mit/lua/dist/doc: contents.html lua.1 manual.html
readme.html
src/external/mit/lua/dist/src: Makefile lapi.c lapi.h lauxlib.c
lauxlib.h lbaselib.c lcode.c lcode.h lcorolib.c lctype.c lctype.h
ldblib.c ldebug.c ldebug.h ldo.c ldo.h ldump.c lfunc.c lfunc.h
lgc.c lgc.h linit.c liolib.c ljumptab.h llex.c llex.h llimits.h
lmathlib.c lmem.c lmem.h loadlib.c lobject.c lobject.h lopcodes.c
lopcodes.h loslib.c lparser.c lparser.h lprefix.h lstate.c lstate.h
lstring.c lstring.h lstrlib.c ltable.c ltable.h ltablib.c ltm.c
ltm.h lua.c lua.h luac.c luaconf.h lualib.h lundump.c lundump.h
lutf8lib.c lvm.c lvm.h lzio.c lzio.h
src/external/mit/lua/lib/liblua: Makefile shlib_version
src/share/mk: bsd.lua.mk
src/sys/modules/examples/luahello: luahello.lua
src/sys/modules/lua: Makefile
Removed Files:
src/external/mit/lua/dist/src: lbitlib.c

Log Message:
Resolve conflicts for lua 5.4.4 import.
Adjust various files for lua 5.4.4.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/distrib/sets/lists/base/ad.aarch64
cvs rdiff -u -r1.1314 -r1.1315 src/distrib/sets/lists/base/mi
cvs rdiff -u -r1.946 -r1.947 src/distrib/sets/lists/base/shl.mi
cvs rdiff -u -r1.303 -r1.304 src/distrib/sets/lists/debug/shl.mi
cvs rdiff -u -r1.1919 -r1.1920 src/doc/3RDPARTY
cvs rdiff -u -r1.2958 -r1.2959 src/doc/CHANGES
cvs rdiff -u -r1.246 -r1.247 src/etc/mtree/NetBSD.dist.base
cvs rdiff -u -r1.1 -r1.2 src/etc/mtree/NetBSD.dist.compat.in
cvs rdiff -u -r1.7 -r1.8 src/external/mit/lua/dist/Makefile
cvs rdiff -u -r1.8 -r1.9 src/external/mit/lua/dist/README
cvs rdiff -u -r1.2 -r1.3 src/external/mit/lua/dist/README.import
cvs rdiff -u -r1.7 -r1.8 src/external/mit/lua/dist/doc/contents.html \
src/external/mit/lua/dist/doc/lua.1 \
src/external/mit/lua/dist/doc/readme.html
cvs rdiff -u -r1.8 -r1.9 src/external/mit/lua/dist/doc/manual.html
cvs rdiff -u -r1.5 -r1.6 src/external/mit/lua/dist/src/Makefile
cvs rdiff -u -r1.12 -r1.13 src/external/mit/lua/dist/src/lapi.c \
src/external/mit/lua/dist/src/llex.c \
src/external/mit/lua/dist/src/lobject.c
cvs rdiff -u -r1.9 -r1.10 src/external/mit/lua/dist/src/lapi.h \
src/external/mit/lua/dist/src/ldebug.h \
src/external/mit/lua/dist/src/ldo.c src/external/mit/lua/dist/src/ldo.h \
src/external/mit/lua/dist/src/ldump.c \
src/external/mit/lua/dist/src/linit.c \
src/external/mit/lua/dist/src/liolib.c \
src/external/mit/lua/dist/src/lmathlib.c \
src/external/mit/lua/dist/src/lmem.c \
src/external/mit/lua/dist/src/loadlib.c \
src/external/mit/lua/dist/src/lstate.c \
src/external/mit/lua/dist/src/lstate.h \
src/external/mit/lua/dist/src/lstring.c \
src/external/mit/lua/dist/src/lstring.h \
src/external/mit/lua/dist/src/ltablib.c \
src/external/mit/lua/dist/src/ltm.c src/external/mit/lua/dist/src/lua.c
cvs rdiff -u -r1.11 -r1.12 src/external/mit/lua/dist/src/lauxlib.c \
src/external/mit/lua/dist/src/lcode.c \
src/external/mit/lua/dist/src/ldblib.c \
src/external/mit/lua/dist/src/ldebug.c \
src/external/mit/lua/dist/src/loslib.c \
src/external/mit/lua/dist/src/lparser.c \
src/external/mit/lua/dist/src/ltable.c \
src/external/mit/lua/dist/src/lua.h
cvs rdiff -u -r1.8 -r1.9 src/external/mit/lua/dist/src/lauxlib.h \
src/external/mit/lua/dist/src/lcode.h \
src/external/mit/lua/dist/src/lfunc.c \
src/external/mit/lua/dist/src/lfunc.h src/external/mit/lua/dist/src/lgc.h \
src/external/mit/lua/dist/src/llex.h src/external/mit/lua/dist/src/lmem.h \
src/external/mit/lua/dist/src/lopcodes.c \
src/external/mit/lua/dist/src/lopcodes.h \
src/external/mit/lua/dist/src/lparser.h \
src/external/mit/lua/dist/src/ltable.h \
src/external/mit/lua/dist/src/ltm.h \
src/external/mit/lua/dist/src/lundump.c \
src/external/mit/lua/dist/src/lutf8lib.c \
src/external/mit/lua/dist/src/lzio.c src/external/mit/lua/dist/src/lzio.h
cvs rdiff -u -r1.10 -r1.11 src/external/mit/lua/dist/src/lbaselib.c \
src/external/mit/lua/dist/src/lgc.c \
src/external/mit/lua/dist/src/llimits.h \
src/external/mit/lua/dist/src/lobject.h \
src/external/mit/lua/dist/src/luac.c src/external/mit/lua/dist/src/lvm.h
cvs rdiff -u -r1.7 -r0 src/external/mit/lua/dist/src/lbitlib.c
cvs rdiff -u -r1.7 -r1.8 src/external/mit/lua/dist/src/lcorolib.c \
src/external/mit/lua/dist/src/lctype.c \
src/external/mit/lua/dist/src/lctype.h \

CVS commit: src/lib/libc/locale

2023-04-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Apr 16 20:37:59 UTC 2023

Modified Files:
src/lib/libc/locale: newlocale.c

Log Message:
Fix parsing a locale string with multiple components.
Also check for truncation of a long locale string.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/locale/newlocale.c

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

Modified files:

Index: src/lib/libc/locale/newlocale.c
diff -u src/lib/libc/locale/newlocale.c:1.3 src/lib/libc/locale/newlocale.c:1.4
--- src/lib/libc/locale/newlocale.c:1.3	Fri Sep 13 13:13:32 2013
+++ src/lib/libc/locale/newlocale.c	Sun Apr 16 20:37:59 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: newlocale.c,v 1.3 2013/09/13 13:13:32 joerg Exp $ */
+/* $NetBSD: newlocale.c,v 1.4 2023/04/16 20:37:59 mlelstv Exp $ */
 
 /*-
  * Copyright (c)2008, 2011 Citrus Project,
@@ -27,7 +27,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: newlocale.c,v 1.3 2013/09/13 13:13:32 joerg Exp $");
+__RCSID("$NetBSD: newlocale.c,v 1.4 2023/04/16 20:37:59 mlelstv Exp $");
 
 #include "namespace.h"
 #include 
@@ -57,7 +57,10 @@ newlocale(int mask, const char *name, lo
 	if (src == NULL)
 		src = _current_locale();
 	memcpy(dst, src, sizeof(*src));
-	strlcpy([0], name, sizeof(head));
+	if (strlcpy([0], name, sizeof(head)) >= sizeof(head)) {
+		free(dst);
+		return (locale_t)NULL;
+	}
 	tokens[0] = (const char *)[0];
 	tail = strchr(tokens[0], '/');
 	if (tail == NULL) {
@@ -77,6 +80,7 @@ newlocale(int mask, const char *name, lo
 		}
 		if (howmany-- > 0) {
 			for (i = 1; i < howmany; ++i) {
+*tail++ = '\0';
 tokens[i] = (const char *)tail;
 tail = strchr(tokens[i], '/');
 if (tail == NULL) {
@@ -84,6 +88,7 @@ newlocale(int mask, const char *name, lo
 	return NULL;
 }
 			}
+			*tail++ = '\0';
 			tokens[howmany] = tail;
 			tail = strchr(tokens[howmany], '/');
 			if (tail != NULL) {



CVS commit: src/lib/libc/locale

2023-04-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Apr 16 20:37:59 UTC 2023

Modified Files:
src/lib/libc/locale: newlocale.c

Log Message:
Fix parsing a locale string with multiple components.
Also check for truncation of a long locale string.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/lib/libc/locale/newlocale.c

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



CVS commit: src/sys/dev/usb

2023-04-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Apr 16 19:26:20 UTC 2023

Modified Files:
src/sys/dev/usb: uaudio.c uaudioreg.h

Log Message:
Handle packet scheduling for high/super speed.
More UAC2 handling for input/output/feature/selector units.
Setting sample rate for UAC2 now works, still no support for clock selectors
and multipliers.
Added sysctl to set debug level.
Minor fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/sys/dev/usb/uaudio.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/usb/uaudioreg.h

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

Modified files:

Index: src/sys/dev/usb/uaudio.c
diff -u src/sys/dev/usb/uaudio.c:1.178 src/sys/dev/usb/uaudio.c:1.179
--- src/sys/dev/usb/uaudio.c:1.178	Mon Apr 10 15:14:50 2023
+++ src/sys/dev/usb/uaudio.c	Sun Apr 16 19:26:20 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: uaudio.c,v 1.178 2023/04/10 15:14:50 mlelstv Exp $	*/
+/*	$NetBSD: uaudio.c,v 1.179 2023/04/16 19:26:20 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1999, 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.178 2023/04/10 15:14:50 mlelstv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1.179 2023/04/16 19:26:20 mlelstv Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -59,6 +59,7 @@ __KERNEL_RCSID(0, "$NetBSD: uaudio.c,v 1
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -99,8 +100,12 @@ int	uaudiodebug = 0;
 #define DPRINTFN(n,x,y...)
 #endif
 
-#define UAUDIO_NCHANBUFS 6	/* number of outstanding request */
-#define UAUDIO_NFRAMES   10	/* ms of sound in each request */
+/* number of outstanding requests */
+#define UAUDIO_NCHANBUFS	6
+/* number of USB frames per request, also the number of ms */
+#define UAUDIO_NFRAMES		10
+/* number of microframes per requewst (high, super)  */
+#define UAUDIO_NFRAMES_HI	(UAUDIO_NFRAMES * USB_UFRAMES_PER_FRAME)
 
 
 #define MIX_MAX_CHAN 8
@@ -133,7 +138,6 @@ struct mixerctl {
 	u_int		nranges;
 	u_int		delta;
 	u_int		mul;
-	u_int		high;
 	uint8_t		class;
 	char		ctlname[MAX_AUDIO_DEV_LEN];
 	const char	*ctlunit;
@@ -147,6 +151,7 @@ struct as_info {
 	uint8_t		attributes; /* Copy of bmAttributes of
  * usb_audio_streaming_endpoint_descriptor
  */
+	uint8_t		terminal;	/* connected Terminal ID */
 	struct usbd_interface *	ifaceh;
 	const usb_interface_descriptor_t *idesc;
 	const usb_endpoint_descriptor_audio_t *edesc;
@@ -177,12 +182,14 @@ struct chan {
 	int	altidx;		/* currently used altidx */
 
 	int	curchanbuf;
+	u_int	nframes;	/* UAUDIO_NFRAMES or UAUDIO_NFRAMES_HI */
+	u_int	nchanbufs;	/* 1..UAUDIO_NCHANBUFS */
 	struct chanbuf {
 		struct chan	*chan;
 		struct usbd_xfer *xfer;
 		u_char		*buffer;
-		uint16_t	sizes[UAUDIO_NFRAMES];
-		uint16_t	offsets[UAUDIO_NFRAMES];
+		uint16_t	sizes[UAUDIO_NFRAMES_HI];
+		uint16_t	offsets[UAUDIO_NFRAMES_HI];
 		uint16_t	size;
 	} chanbufs[UAUDIO_NCHANBUFS];
 
@@ -223,9 +230,13 @@ struct uaudio_softc {
 	int		sc_nratectls;	/* V2 sample rates */
 	int		sc_ratectls[AUFMT_MAX_FREQUENCIES];
 	int		sc_ratemode[AUFMT_MAX_FREQUENCIES];
+	int		sc_playclock;
+	int		sc_recclock;
 	struct audio_format *sc_formats;
 	int		sc_nformats;
+	uint8_t		sc_clock[256];	/* map terminals to clocks */
 	u_int		sc_channel_config;
+	u_int		sc_usb_frames_per_second;
 	char		sc_dying;
 	struct audio_device sc_adev;
 };
@@ -244,7 +255,7 @@ struct io_terminal {
 		const union usb_audio_output_terminal *ot;
 		const struct usb_audio_mixer_unit *mu;
 		const struct usb_audio_selector_unit *su;
-		const struct usb_audio_feature_unit *fu;
+		const union usb_audio_feature_unit *fu;
 		const struct usb_audio_processing_unit *pu;
 		const struct usb_audio_extension_unit *eu;
 		const struct usb_audio_clksrc_unit *cu;
@@ -254,6 +265,7 @@ struct io_terminal {
 	struct terminal_list **inputs; /* list of source input terminals */
 	struct terminal_list *output; /* list of destination output terminals */
 	int direct;		/* directly connected to an output terminal */
+	uint8_t clock;
 };
 
 #define UAC_OUTPUT	0
@@ -286,7 +298,7 @@ Static const usb_interface_descriptor_t 
 
 Static void	uaudio_mixer_add_ctl(struct uaudio_softc *, struct mixerctl *);
 Static char	*uaudio_id_name
-	(struct uaudio_softc *, const struct io_terminal *, int);
+	(struct uaudio_softc *, const struct io_terminal *, uint8_t);
 #ifdef UAUDIO_DEBUG
 Static void	uaudio_dump_cluster
 	(struct uaudio_softc *, const union usb_audio_cluster *);
@@ -307,7 +319,7 @@ Static const char *uaudio_get_terminal_n
 Static int	uaudio_determine_class
 	(const struct io_terminal *, struct mixerctl *);
 Static const char *uaudio_feature_name
-	(const struct io_terminal *, struct mixerctl *);
+	(const struct io_terminal *, uint8_t, int);
 Static void	uaudio_add_feature
 	(struct uaudio_softc *, const struct io_terminal *, int);
 Static void	uaudio_add_processing_updown
@@ -348,6 +360,7 @@ Static void	

CVS commit: src/sys/dev/usb

2023-04-16 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Apr 16 19:26:20 UTC 2023

Modified Files:
src/sys/dev/usb: uaudio.c uaudioreg.h

Log Message:
Handle packet scheduling for high/super speed.
More UAC2 handling for input/output/feature/selector units.
Setting sample rate for UAC2 now works, still no support for clock selectors
and multipliers.
Added sysctl to set debug level.
Minor fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.178 -r1.179 src/sys/dev/usb/uaudio.c
cvs rdiff -u -r1.18 -r1.19 src/sys/dev/usb/uaudioreg.h

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



CVS commit: src/sys/dev/virtio

2023-04-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 16 18:37:16 UTC 2023

Modified Files:
src/sys/dev/virtio: viocon.c

Log Message:
viocon(4): Show error in assertion failure.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/virtio/viocon.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/virtio/viocon.c
diff -u src/sys/dev/virtio/viocon.c:1.8 src/sys/dev/virtio/viocon.c:1.9
--- src/sys/dev/virtio/viocon.c:1.8	Thu Mar 23 03:55:11 2023
+++ src/sys/dev/virtio/viocon.c	Sun Apr 16 18:37:16 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: viocon.c,v 1.8 2023/03/23 03:55:11 yamaguchi Exp $	*/
+/*	$NetBSD: viocon.c,v 1.9 2023/04/16 18:37:16 riastradh Exp $	*/
 /*	$OpenBSD: viocon.c,v 1.8 2021/11/05 11:38:29 mpi Exp $	*/
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: viocon.c,v 1.8 2023/03/23 03:55:11 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: viocon.c,v 1.9 2023/04/16 18:37:16 riastradh Exp $");
 
 #include 
 #include 
@@ -377,7 +377,7 @@ viocon_rx_fill(struct viocon_port *vp)
 		virtio_enqueue_commit(vsc, vq, slot, 0);
 		ndone++;
 	}
-	KASSERT(r == 0 || r == EAGAIN);
+	KASSERTMSG(r == 0 || r == EAGAIN, "r=%d", r);
 	if (ndone > 0)
 		virtio_notify(vsc, vq);
 }
@@ -453,9 +453,9 @@ vioconstart(struct tty *tp)
 			SET(tp->t_state, TS_BUSY);
 			break;
 		}
-		KASSERT(ret == 0);
+		KASSERTMSG(ret == 0, "ret=%d", ret);
 		ret = virtio_enqueue_reserve(vsc, vq, slot, 1);
-		KASSERT(ret == 0);
+		KASSERTMSG(ret == 0, "ret=%d", ret);
 		buf = vp->vp_tx_buf + slot * BUFSIZE;
 		cnt = q_to_b(>t_outq, buf, BUFSIZE);
 		bus_dmamap_sync(virtio_dmat(vsc), vp->vp_dmamap,



CVS commit: src/sys/dev/virtio

2023-04-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 16 18:37:16 UTC 2023

Modified Files:
src/sys/dev/virtio: viocon.c

Log Message:
viocon(4): Show error in assertion failure.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/dev/virtio/viocon.c

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



CVS commit: src/sys/dev/pci

2023-04-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 16 17:57:08 UTC 2023

Modified Files:
src/sys/dev/pci: virtio_pci.c

Log Message:
virtio@pci: Fix assertion on detach.

If the child never attached in the first place, it's OK for it to not
have detached.

XXX This should not be a set of flags; this should be a state
enumeration, because some flags make no sense, like FINISHED|FAILED.

XXX This should not be asserted separately in each bus; there should
be a single place in virtio.c to assert this, uniformly in all buses.

PR kern/57357

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/pci/virtio_pci.c

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

Modified files:

Index: src/sys/dev/pci/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.40 src/sys/dev/pci/virtio_pci.c:1.41
--- src/sys/dev/pci/virtio_pci.c:1.40	Fri Mar 31 07:34:26 2023
+++ src/sys/dev/pci/virtio_pci.c	Sun Apr 16 17:57:08 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.40 2023/03/31 07:34:26 yamaguchi Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.41 2023/04/16 17:57:08 riastradh Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.40 2023/03/31 07:34:26 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.41 2023/04/16 17:57:08 riastradh Exp $");
 
 #include 
 #include 
@@ -333,8 +333,11 @@ virtio_pci_detach(device_t self, int fla
 	if (r != 0)
 		return r;
 
-	/* Check that child detached properly */
-	KASSERT(ISSET(sc->sc_child_flags, VIRTIO_CHILD_DETACHED));
+	/* Check that child never attached, or detached properly */
+	KASSERTMSG(!ISSET(sc->sc_child_flags,
+		(VIRTIO_CHILD_ATTACH_FINISHED|VIRTIO_CHILD_ATTACH_FAILED)) ||
+	ISSET(sc->sc_child_flags, VIRTIO_CHILD_DETACHED),
+	"%s: child flags %x", device_xname(self), sc->sc_child_flags);
 	KASSERT(sc->sc_vqs == NULL);
 	KASSERT(psc->sc_ihs_num == 0);
 



CVS commit: src/sys/dev/pci

2023-04-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 16 17:57:08 UTC 2023

Modified Files:
src/sys/dev/pci: virtio_pci.c

Log Message:
virtio@pci: Fix assertion on detach.

If the child never attached in the first place, it's OK for it to not
have detached.

XXX This should not be a set of flags; this should be a state
enumeration, because some flags make no sense, like FINISHED|FAILED.

XXX This should not be asserted separately in each bus; there should
be a single place in virtio.c to assert this, uniformly in all buses.

PR kern/57357

XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/dev/pci/virtio_pci.c

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



CVS commit: src/sys/dev/ic

2023-04-16 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Sun Apr 16 17:16:45 UTC 2023

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

Log Message:
Do not create the sysctl tree if the initial setup of the chip fails.


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

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

Modified files:

Index: src/sys/dev/ic/bmx280.c
diff -u src/sys/dev/ic/bmx280.c:1.1 src/sys/dev/ic/bmx280.c:1.2
--- src/sys/dev/ic/bmx280.c:1.1	Sat Dec  3 01:04:43 2022
+++ src/sys/dev/ic/bmx280.c	Sun Apr 16 17:16:45 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: bmx280.c,v 1.1 2022/12/03 01:04:43 brad Exp $	*/
+/*	$NetBSD: bmx280.c,v 1.2 2023/04/16 17:16:45 brad Exp $	*/
 
 /*
  * Copyright (c) 2022 Brad Spencer 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.1 2022/12/03 01:04:43 brad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bmx280.c,v 1.2 2023/04/16 17:16:45 brad Exp $");
 
 /*
  * Common driver for the Bosch BMP280/BME280 temperature, humidity (sometimes) and
@@ -444,11 +444,6 @@ bmx280_attach(struct bmx280_sc *sc)
 		sc->sc_has_humidity = true;
 	}
 
-	if ((error = bmx280_sysctl_init(sc)) != 0) {
-		aprint_error_dev(sc->sc_dev, "Can't setup sysctl tree (%d)\n", error);
-		goto out;
-	}
-
 	uint8_t raw_blob_tp[24];
 	reg = BMX280_REGISTER_DIG_T1;
 	error = (*(sc->sc_func_read_register))(sc, reg, raw_blob_tp, 24);
@@ -500,6 +495,11 @@ bmx280_attach(struct bmx280_sc *sc)
 		goto out;
 	}
 
+	if ((error = bmx280_sysctl_init(sc)) != 0) {
+		aprint_error_dev(sc->sc_dev, "Can't setup sysctl tree (%d)\n", error);
+		goto out;
+	}
+
 	for (i = 0; i < sc->sc_numsensors; i++) {
 		if (sc->sc_has_humidity == false &&
 		bmx280_sensors[i].type == ENVSYS_SRELHUMIDITY) {



CVS commit: src/sys/dev/ic

2023-04-16 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Sun Apr 16 17:16:45 UTC 2023

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

Log Message:
Do not create the sysctl tree if the initial setup of the chip fails.


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

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



CVS commit: src/sys

2023-04-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Apr 16 16:55:02 UTC 2023

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64
src/sys/dev/acpi: files.acpi
Added Files:
src/sys/dev/acpi: dwcwdt_acpi.c

Log Message:
DesignWare watchdog ACPI attach glue


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/sys/arch/evbarm/conf/GENERIC64
cvs rdiff -u -r0 -r1.1 src/sys/dev/acpi/dwcwdt_acpi.c
cvs rdiff -u -r1.126 -r1.127 src/sys/dev/acpi/files.acpi

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.210 src/sys/arch/evbarm/conf/GENERIC64:1.211
--- src/sys/arch/evbarm/conf/GENERIC64:1.210	Sat Feb 25 08:19:35 2023
+++ src/sys/arch/evbarm/conf/GENERIC64	Sun Apr 16 16:55:01 2023
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.210 2023/02/25 08:19:35 skrll Exp $
+#	$NetBSD: GENERIC64,v 1.211 2023/04/16 16:55:01 jmcneill Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -162,6 +162,7 @@ tegratimer*	at fdt?			# Timers
 applewdog*	at fdt?			# Apple watchdog
 bcmpmwdog*	at fdt?			# Broadcom BCM283x watchdog
 dwcwdt* 	at fdt?			# DesignWare watchdog
+dwcwdt*		at acpi?
 mesongxwdt*	at fdt?			# Amlogic Meson GX watchdog
 sbsawdt*	at acpi?		# ARM SBSA-compliant watchdog
 sunxiwdt*	at fdt?			# Allwinner watchdog

Index: src/sys/dev/acpi/files.acpi
diff -u src/sys/dev/acpi/files.acpi:1.126 src/sys/dev/acpi/files.acpi:1.127
--- src/sys/dev/acpi/files.acpi:1.126	Thu May 26 02:16:44 2022
+++ src/sys/dev/acpi/files.acpi	Sun Apr 16 16:55:01 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: files.acpi,v 1.126 2022/05/26 02:16:44 mrg Exp $
+#	$NetBSD: files.acpi,v 1.127 2023/04/16 16:55:01 jmcneill Exp $
 
 defflag	opt_acpi.h	ACPIVERBOSE ACPI_DEBUG ACPI_ACTIVATE_DEV
 			ACPI_DSDT_OVERRIDE ACPI_SCANPCI ACPI_BREAKPOINT
@@ -308,4 +308,8 @@ file	dev/acpi/igpio_acpi.c		igpio_acpi
 attach	dwcmmc at acpinodebus with dwcmmc_acpi
 file	dev/acpi/dwcmmc_acpi.c		dwcmmc_acpi
 
+# DesignWare Watchdog
+attach	dwcwdt at acpinodebus with dwcwdt_acpi
+file	dev/acpi/dwcwdt_acpi.c		dwcwdt_acpi
+
 include	"dev/acpi/wmi/files.wmi"

Added files:

Index: src/sys/dev/acpi/dwcwdt_acpi.c
diff -u /dev/null src/sys/dev/acpi/dwcwdt_acpi.c:1.1
--- /dev/null	Sun Apr 16 16:55:02 2023
+++ src/sys/dev/acpi/dwcwdt_acpi.c	Sun Apr 16 16:55:01 2023
@@ -0,0 +1,100 @@
+/* $NetBSD: dwcwdt_acpi.c,v 1.1 2023/04/16 16:55:01 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2023 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: dwcwdt_acpi.c,v 1.1 2023/04/16 16:55:01 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+#include 
+#include 
+
+static const struct device_compatible_entry compat_data[] = {
+	{ .compat = "snps,dw-wdt" },
+	DEVICE_COMPAT_EOL
+};
+
+static int
+dwcwdt_acpi_match(device_t parent, cfdata_t cf, void *aux)
+{
+	struct acpi_attach_args *aa = aux;
+
+	return acpi_compatible_match(aa, compat_data);
+}
+
+static void
+dwcwdt_acpi_attach(device_t parent, device_t self, void *aux)
+{
+	struct dwcwdt_softc * const sc = device_private(self);
+	struct acpi_attach_args *aa = aux;
+	ACPI_HANDLE handle = aa->aa_node->ad_handle;
+	struct acpi_resources res;
+	struct acpi_mem *mem;
+	ACPI_INTEGER ival;
+	ACPI_STATUS rv;
+
+	rv = acpi_resource_parse(sc->sc_dev, handle, "_CRS",
+	, _resource_parse_ops_default);
+	if (ACPI_FAILURE(rv)) {
+		return;
+	}
+
+	mem = acpi_res_mem(, 0);
+	if (mem == NULL) {
+		aprint_error_dev(self, "couldn't find mem resource\n");
+		goto done;
+	}
+
+	sc->sc_dev = self;
+	sc->sc_bst = 

CVS commit: src/sys

2023-04-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Apr 16 16:55:02 UTC 2023

Modified Files:
src/sys/arch/evbarm/conf: GENERIC64
src/sys/dev/acpi: files.acpi
Added Files:
src/sys/dev/acpi: dwcwdt_acpi.c

Log Message:
DesignWare watchdog ACPI attach glue


To generate a diff of this commit:
cvs rdiff -u -r1.210 -r1.211 src/sys/arch/evbarm/conf/GENERIC64
cvs rdiff -u -r0 -r1.1 src/sys/dev/acpi/dwcwdt_acpi.c
cvs rdiff -u -r1.126 -r1.127 src/sys/dev/acpi/files.acpi

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



CVS commit: src/sys

2023-04-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Apr 16 16:51:38 UTC 2023

Modified Files:
src/sys/conf: files
src/sys/dev/fdt: dwcwdt_fdt.c files.fdt
Added Files:
src/sys/dev/ic: dwc_wdt.c dwc_wdt_var.h

Log Message:
Separate DesignWare watchdog driver and FDT glue.


To generate a diff of this commit:
cvs rdiff -u -r1.1306 -r1.1307 src/sys/conf/files
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/dwcwdt_fdt.c
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/fdt/files.fdt
cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/dwc_wdt.c src/sys/dev/ic/dwc_wdt_var.h

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

Modified files:

Index: src/sys/conf/files
diff -u src/sys/conf/files:1.1306 src/sys/conf/files:1.1307
--- src/sys/conf/files:1.1306	Wed Dec 28 18:19:44 2022
+++ src/sys/conf/files	Sun Apr 16 16:51:38 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: files,v 1.1306 2022/12/28 18:19:44 jakllsch Exp $
+#	$NetBSD: files,v 1.1307 2023/04/16 16:51:38 jmcneill Exp $
 #	@(#)files.newconf	7.5 (Berkeley) 5/10/93
 
 version 	20171118
@@ -799,6 +799,10 @@ file	dev/ic/dwc_gmac.c		awge
 device	eqos: arp, ether, ifnet, mii
 file	dev/ic/dwc_eqos.c		eqos
 
+# Synopsys DesignWare Watchdog
+device	dwcwdt: sysmon_wdog
+file	dev/ic/dwc_wdt.c		dwcwdt
+
 # 8390-family Ethernet controllers
 #
 define	dp8390nic

Index: src/sys/dev/fdt/dwcwdt_fdt.c
diff -u src/sys/dev/fdt/dwcwdt_fdt.c:1.5 src/sys/dev/fdt/dwcwdt_fdt.c:1.6
--- src/sys/dev/fdt/dwcwdt_fdt.c:1.5	Wed Jan 27 03:10:21 2021
+++ src/sys/dev/fdt/dwcwdt_fdt.c	Sun Apr 16 16:51:38 2023
@@ -1,7 +1,7 @@
-/* $NetBSD: dwcwdt_fdt.c,v 1.5 2021/01/27 03:10:21 thorpej Exp $ */
+/* $NetBSD: dwcwdt_fdt.c,v 1.6 2023/04/16 16:51:38 jmcneill Exp $ */
 
 /*-
- * Copyright (c) 2018 Jared McNeill 
+ * Copyright (c) 2018, 2023 Jared McNeill 
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: dwcwdt_fdt.c,v 1.5 2021/01/27 03:10:21 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: dwcwdt_fdt.c,v 1.6 2023/04/16 16:51:38 jmcneill Exp $");
 
 #include 
 #include 
@@ -38,133 +38,17 @@ __KERNEL_RCSID(0, "$NetBSD: dwcwdt_fdt.c
 #include 
 
 #include 
+#include 
 
 #include 
 
-#define	WDT_CR0x00
-#define	 WDT_CR_RST_PULSE_LENGTH	__BITS(4,2)
-#define	 WDT_CR_RESP_MODE		__BIT(1)
-#define	 WDT_CR_WDT_EN			__BIT(0)
-
-#define	WDT_TORR			0x04
-#define	 WDT_TORR_TIMEOUT_PERIOD	__BITS(3,0)
-
-#define	WDT_CCVR			0x08
-
-#define	WDT_CRR0x0c
-#define	 WDT_CRR_CNT_RESTART		__BITS(7,0)
-#define	  WDT_CRR_CNT_RESTART_MAGIC	0x76
-
-#define	WDT_STAT			0x10
-#define	 WDT_STAT_WDT_STATUS		__BIT(0)
-
-#define	WDT_EOI0x14
-#define	 WDT_EOI_WDT_INT_CLR		__BIT(0)
-
-static const uint32_t wdt_torr[] = {
-	0x,
-	0x0001,
-	0x0003,
-	0x0007,
-	0x000f,
-	0x001f,
-	0x003f,
-	0x007f,
-	0x00ff,
-	0x01ff,
-	0x03ff,
-	0x07ff,
-	0x0fff,
-	0x1fff,
-	0x3fff,
-	0x7fff,
-};
-
-#define	DWCWDT_PERIOD_DEFAULT		15
-
 static const struct device_compatible_entry compat_data[] = {
 	{ .compat = "snps,dw-wdt" },
 	DEVICE_COMPAT_EOL
 };
 
-struct dwcwdt_softc {
-	device_t sc_dev;
-	bus_space_tag_t sc_bst;
-	bus_space_handle_t sc_bsh;
-	struct sysmon_wdog sc_smw;
-	u_int sc_clkrate;
-};
-
-#define RD4(sc, reg) \
-	bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
-#define WR4(sc, reg, val) \
-	bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
-
 static int
-dwcwdt_map_period(struct dwcwdt_softc *sc, u_int period,
-u_int *aperiod)
-{
-	int i;
-
-	if (period == 0)
-		return -1;
-
-	for (i = 0; i < __arraycount(wdt_torr); i++) {
-		const u_int ms = (u_int)uint64_t)wdt_torr[i] + 1) * 1000) / sc->sc_clkrate);
-		if (ms >= period * 1000) {
-			*aperiod = ms / 1000;
-			return i;
-		}
-	}
-
-	return -1;
-}
-
-static int
-dwcwdt_tickle(struct sysmon_wdog *smw)
-{
-	struct dwcwdt_softc * const sc = smw->smw_cookie;
-	const uint32_t crr =
-	__SHIFTIN(WDT_CRR_CNT_RESTART_MAGIC, WDT_CRR_CNT_RESTART);
-
-	WR4(sc, WDT_CRR, crr);
-
-	return 0;
-}
-
-static int
-dwcwdt_setmode(struct sysmon_wdog *smw)
-{
-	struct dwcwdt_softc * const sc = smw->smw_cookie;
-	uint32_t cr, torr;
-	int intv;
-
-	if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) {
-		/* Watchdog can only be disarmed by a reset */
-		return EIO;
-	}
-
-	if (smw->smw_period == WDOG_PERIOD_DEFAULT)
-		smw->smw_period = DWCWDT_PERIOD_DEFAULT;
-
-	intv = dwcwdt_map_period(sc, smw->smw_period,
-	>sc_smw.smw_period);
-	if (intv == -1)
-		return EINVAL;
-
-	torr = __SHIFTIN(intv, WDT_TORR_TIMEOUT_PERIOD);
-	WR4(sc, WDT_TORR, torr);
-	dwcwdt_tickle(smw);
-	cr = RD4(sc, WDT_CR);
-	cr &= ~WDT_CR_RESP_MODE;
-	cr |= WDT_CR_WDT_EN;
-	WR4(sc, WDT_CR, cr);
-
-	return 0;
-}
-
-static int
-dwcwdt_match(device_t parent, cfdata_t cf, void *aux)
+dwcwdt_fdt_match(device_t parent, cfdata_t cf, void *aux)
 {
 	struct fdt_attach_args * 

CVS commit: src/sys

2023-04-16 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Apr 16 16:51:38 UTC 2023

Modified Files:
src/sys/conf: files
src/sys/dev/fdt: dwcwdt_fdt.c files.fdt
Added Files:
src/sys/dev/ic: dwc_wdt.c dwc_wdt_var.h

Log Message:
Separate DesignWare watchdog driver and FDT glue.


To generate a diff of this commit:
cvs rdiff -u -r1.1306 -r1.1307 src/sys/conf/files
cvs rdiff -u -r1.5 -r1.6 src/sys/dev/fdt/dwcwdt_fdt.c
cvs rdiff -u -r1.67 -r1.68 src/sys/dev/fdt/files.fdt
cvs rdiff -u -r0 -r1.1 src/sys/dev/ic/dwc_wdt.c src/sys/dev/ic/dwc_wdt_var.h

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



CVS commit: src/sys/arch

2023-04-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 16 14:01:51 UTC 2023

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c genassym.cf locore.S
pmap.c pmap_machdep.c
src/sys/arch/aarch64/include: asan.h vmparam.h
src/sys/arch/arm/include/arm32: vmparam.h
src/sys/arch/evbarm/fdt: platform.h

Log Message:
Rename VM_KERNEL_IO_ADDRESS to VM_KERNEL_IO_BASE to match RISC-V

It's less letters, matches other similar variables and will help with
sharing code between the two architectures.

NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/aarch64/aarch64/aarch64_machdep.c
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.147 -r1.148 src/sys/arch/aarch64/aarch64/pmap.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/pmap_machdep.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/aarch64/include/asan.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/include/vmparam.h
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/arm/include/arm32/vmparam.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/evbarm/fdt/platform.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/arch/aarch64/aarch64/aarch64_machdep.c
diff -u src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.67 src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.68
--- src/sys/arch/aarch64/aarch64/aarch64_machdep.c:1.67	Fri Apr  7 08:55:29 2023
+++ src/sys/arch/aarch64/aarch64/aarch64_machdep.c	Sun Apr 16 14:01:51 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: aarch64_machdep.c,v 1.67 2023/04/07 08:55:29 skrll Exp $ */
+/* $NetBSD: aarch64_machdep.c,v 1.68 2023/04/16 14:01:51 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.67 2023/04/07 08:55:29 skrll Exp $");
+__KERNEL_RCSID(1, "$NetBSD: aarch64_machdep.c,v 1.68 2023/04/16 14:01:51 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -356,7 +356,7 @@ initarm_common(vaddr_t kvm_base, vsize_t
 	module_end,
 #endif
 	VM_KERNEL_VM_BASE,
-	VM_KERNEL_IO_ADDRESS,
+	VM_KERNEL_IO_BASE,
 	VM_MAX_KERNEL_ADDRESS);
 
 #ifdef DDB

Index: src/sys/arch/aarch64/aarch64/genassym.cf
diff -u src/sys/arch/aarch64/aarch64/genassym.cf:1.38 src/sys/arch/aarch64/aarch64/genassym.cf:1.39
--- src/sys/arch/aarch64/aarch64/genassym.cf:1.38	Sat Jun 25 13:24:34 2022
+++ src/sys/arch/aarch64/aarch64/genassym.cf	Sun Apr 16 14:01:51 2023
@@ -1,4 +1,4 @@
-# $NetBSD: genassym.cf,v 1.38 2022/06/25 13:24:34 jmcneill Exp $
+# $NetBSD: genassym.cf,v 1.39 2023/04/16 14:01:51 skrll Exp $
 #-
 # Copyright (c) 2014 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -69,7 +69,7 @@ define	__HAVE_FAST_SOFTINTS	1
 define	MAXCPUS			MAXCPUS
 define	VM_MIN_KERNEL_ADDRESS	VM_MIN_KERNEL_ADDRESS
 define	VM_MAX_KERNEL_ADDRESS	VM_MAX_KERNEL_ADDRESS
-define	VM_KERNEL_IO_ADDRESS	VM_KERNEL_IO_ADDRESS
+define	VM_KERNEL_IO_BASE	VM_KERNEL_IO_BASE
 define	VM_KERNEL_IO_SIZE	VM_KERNEL_IO_SIZE
 define	AARCH64_DIRECTMAP_START	AARCH64_DIRECTMAP_START
 define	AARCH64_DIRECTMAP_MASK	AARCH64_DIRECTMAP_MASK

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.91 src/sys/arch/aarch64/aarch64/locore.S:1.92
--- src/sys/arch/aarch64/aarch64/locore.S:1.91	Thu Feb 23 14:54:57 2023
+++ src/sys/arch/aarch64/aarch64/locore.S	Sun Apr 16 14:01:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.91 2023/02/23 14:54:57 riastradh Exp $	*/
+/*	$NetBSD: locore.S,v 1.92 2023/04/16 14:01:51 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.91 2023/02/23 14:54:57 riastradh Exp $")
+RCSID("$NetBSD: locore.S,v 1.92 2023/04/16 14:01:51 skrll Exp $")
 
 #ifdef AARCH64_DEVICE_MEM_NONPOSTED
 #define	MAIR_DEVICE_MEM		MAIR_DEVICE_nGnRnE
@@ -1037,7 +1037,7 @@ sctlr_pac:
 	0)
 
 .L_devmap_addr:
-	.quad	VM_KERNEL_IO_ADDRESS
+	.quad	VM_KERNEL_IO_BASE
 
 	.data
 

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.147 src/sys/arch/aarch64/aarch64/pmap.c:1.148
--- src/sys/arch/aarch64/aarch64/pmap.c:1.147	Sun Oct 30 14:08:09 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Sun Apr 16 14:01:51 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.147 2022/10/30 14:08:09 riastradh Exp $	*/
+/*	$NetBSD: pmap.c,v 1.148 2023/04/16 14:01:51 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.147 2022/10/30 14:08:09 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.148 2023/04/16 14:01:51 skrll Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -375,8 +375,8 @@ pmap_devmap_bootstrap(vaddr_t l0pt, cons
 		table[i].pd_va);
 		va = table[i].pd_va;
 

CVS commit: src/sys/arch

2023-04-16 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sun Apr 16 14:01:51 UTC 2023

Modified Files:
src/sys/arch/aarch64/aarch64: aarch64_machdep.c genassym.cf locore.S
pmap.c pmap_machdep.c
src/sys/arch/aarch64/include: asan.h vmparam.h
src/sys/arch/arm/include/arm32: vmparam.h
src/sys/arch/evbarm/fdt: platform.h

Log Message:
Rename VM_KERNEL_IO_ADDRESS to VM_KERNEL_IO_BASE to match RISC-V

It's less letters, matches other similar variables and will help with
sharing code between the two architectures.

NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 src/sys/arch/aarch64/aarch64/aarch64_machdep.c
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/aarch64/aarch64/genassym.cf
cvs rdiff -u -r1.91 -r1.92 src/sys/arch/aarch64/aarch64/locore.S
cvs rdiff -u -r1.147 -r1.148 src/sys/arch/aarch64/aarch64/pmap.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/aarch64/aarch64/pmap_machdep.c
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/aarch64/include/asan.h
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/aarch64/include/vmparam.h
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/arm/include/arm32/vmparam.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/evbarm/fdt/platform.h

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



CVS commit: src/sys/kern

2023-04-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 16 11:18:25 UTC 2023

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

Log Message:
autoconf(9): Assert alldevs_lock held in config_unit_nextfree.

The one caller, config_unit_alloc, guarantees it through
config_alldevs_enter/exit.


To generate a diff of this commit:
cvs rdiff -u -r1.308 -r1.309 src/sys/kern/subr_autoconf.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_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.308 src/sys/kern/subr_autoconf.c:1.309
--- src/sys/kern/subr_autoconf.c:1.308	Sun Apr 16 11:14:58 2023
+++ src/sys/kern/subr_autoconf.c	Sun Apr 16 11:18:25 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.308 2023/04/16 11:14:58 riastradh Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.309 2023/04/16 11:18:25 riastradh Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.308 2023/04/16 11:14:58 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.309 2023/04/16 11:18:25 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1483,6 +1483,8 @@ config_unit_nextfree(cfdriver_t cd, cfda
 {
 	int unit = cf->cf_unit;
 
+	KASSERT(mutex_owned(_lock));
+
 	if (unit < 0)
 		return -1;
 	if (cf->cf_fstate == FSTATE_STAR) {



CVS commit: src/sys/kern

2023-04-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 16 11:18:25 UTC 2023

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

Log Message:
autoconf(9): Assert alldevs_lock held in config_unit_nextfree.

The one caller, config_unit_alloc, guarantees it through
config_alldevs_enter/exit.


To generate a diff of this commit:
cvs rdiff -u -r1.308 -r1.309 src/sys/kern/subr_autoconf.c

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



CVS commit: src/sys/kern

2023-04-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 16 11:14:58 UTC 2023

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

Log Message:
autoconf(9): Avoid potential ABA bug in config_makeroom.

When we unlock alldevs_lock to allocate a new cd_devs array nsp,
other threads may have:

1. freed the old one (osp),
2. done some other memory allocation,
3. allocated a new _larger_ array whose address happens to concide
   with osp (e.g., in (2) the page was recycled for a different pool
   cache), and
4. updated cd_devs back to osp but increased cd_ndevs.

In that case, the memory may be corrupted: we try to copy the wrong
number of device_t pointers into nsp and we free osp with the wrong
(stale) length.

Avoid this by checking whether cd_ndevs has changed too -- if not,
osp might have been recycled but at least the lengths we're about to
copy and free are still correct so there's no harm in an ABA
situation.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.307 -r1.308 src/sys/kern/subr_autoconf.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_autoconf.c
diff -u src/sys/kern/subr_autoconf.c:1.307 src/sys/kern/subr_autoconf.c:1.308
--- src/sys/kern/subr_autoconf.c:1.307	Wed Feb 22 17:00:16 2023
+++ src/sys/kern/subr_autoconf.c	Sun Apr 16 11:14:58 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: subr_autoconf.c,v 1.307 2023/02/22 17:00:16 riastradh Exp $ */
+/* $NetBSD: subr_autoconf.c,v 1.308 2023/04/16 11:14:58 riastradh Exp $ */
 
 /*
  * Copyright (c) 1996, 2000 Christopher G. Demetriou
@@ -77,7 +77,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.307 2023/02/22 17:00:16 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: subr_autoconf.c,v 1.308 2023/04/16 11:14:58 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_ddb.h"
@@ -1357,7 +1357,7 @@ config_makeroom(int n, struct cfdriver *
 		 * If another thread moved the array while we did
 		 * not hold alldevs_lock, try again.
 		 */
-		if (cd->cd_devs != osp) {
+		if (cd->cd_devs != osp || cd->cd_ndevs != ondevs) {
 			mutex_exit(_lock);
 			kmem_free(nsp, sizeof(device_t) * nndevs);
 			mutex_enter(_lock);



CVS commit: src/sys/kern

2023-04-16 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun Apr 16 11:14:58 UTC 2023

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

Log Message:
autoconf(9): Avoid potential ABA bug in config_makeroom.

When we unlock alldevs_lock to allocate a new cd_devs array nsp,
other threads may have:

1. freed the old one (osp),
2. done some other memory allocation,
3. allocated a new _larger_ array whose address happens to concide
   with osp (e.g., in (2) the page was recycled for a different pool
   cache), and
4. updated cd_devs back to osp but increased cd_ndevs.

In that case, the memory may be corrupted: we try to copy the wrong
number of device_t pointers into nsp and we free osp with the wrong
(stale) length.

Avoid this by checking whether cd_ndevs has changed too -- if not,
osp might have been recycled but at least the lengths we're about to
copy and free are still correct so there's no harm in an ABA
situation.

XXX pullup-8
XXX pullup-9
XXX pullup-10


To generate a diff of this commit:
cvs rdiff -u -r1.307 -r1.308 src/sys/kern/subr_autoconf.c

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