CVS commit: src/sys/sys

2021-07-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul 22 04:46:29 UTC 2021

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

Log Message:
Minor shuffle to bring  and  in before
any  headers and for the COHERENCY_UNIT and CACHE_LINE_SIZE
defaults to be provided after the  includes, but before the
 includes.

COHERENCY_UNIT and CACHE_LINE_SIZE are used by a few  filss.

I checked a handful of kernel builds produce the same binary before and
after this change.  I'll check more.


To generate a diff of this commit:
cvs rdiff -u -r1.699 -r1.700 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.699 src/sys/sys/param.h:1.700
--- src/sys/sys/param.h:1.699	Wed Jul 21 07:39:58 2021
+++ src/sys/sys/param.h	Thu Jul 22 04:46:29 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.699 2021/07/21 07:39:58 ozaki-r Exp $	*/
+/*	$NetBSD: param.h,v 1.700 2021/07/22 04:46:29 skrll Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -138,6 +138,22 @@
 #define	MIN(a,b)	((/*CONSTCOND*/(a)<(b))?(a):(b))
 #define	MAX(a,b)	((/*CONSTCOND*/(a)>(b))?(a):(b))
 
+/* Machine type dependent parameters. */
+#include 
+#include 
+
+/*
+ * Coherency unit: assumed cache line size.  See also MIN_LWP_ALIGNMENT.
+ * The MD code depends on the current values of these constants. Don't
+ * change them without coordinating.
+ */
+#ifndef COHERENCY_UNIT
+#define	COHERENCY_UNIT		64
+#endif
+#ifndef CACHE_LINE_SIZE
+#define	CACHE_LINE_SIZE		64
+#endif
+
 /* More types and definitions used throughout the kernel. */
 #ifdef _KERNEL
 #include 
@@ -173,10 +189,6 @@
 /* Signals. */
 #include 
 
-/* Machine type dependent parameters. */
-#include 
-#include 
-
 #define	DEV_BSHIFT	9			/* log2(DEV_BSIZE) */
 #define	DEV_BSIZE	(1 << DEV_BSHIFT)	/* 512 */
 
@@ -200,19 +212,6 @@
 #define	dbtob(x)	((x) << DEV_BSHIFT)
 #define	btodb(x)	((x) >> DEV_BSHIFT)
 
-/*
- * Coherency unit: assumed cache line size.  See also MIN_LWP_ALIGNMENT.
- * The MD code depends on the current values of these constants. Don't
- * change them without coordinating.
- */
-#ifndef COHERENCY_UNIT
-#define	COHERENCY_UNIT		64
-#endif
-#ifndef CACHE_LINE_SIZE
-#define	CACHE_LINE_SIZE		64
-#endif
-
-
 #ifndef MAXCPUS
 #define	MAXCPUS			32
 #endif



CVS commit: src/sys/sys

2021-07-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Jul 22 04:46:29 UTC 2021

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

Log Message:
Minor shuffle to bring  and  in before
any  headers and for the COHERENCY_UNIT and CACHE_LINE_SIZE
defaults to be provided after the  includes, but before the
 includes.

COHERENCY_UNIT and CACHE_LINE_SIZE are used by a few  filss.

I checked a handful of kernel builds produce the same binary before and
after this change.  I'll check more.


To generate a diff of this commit:
cvs rdiff -u -r1.699 -r1.700 src/sys/sys/param.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/alpha

2021-07-21 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jul 22 01:39:18 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: fp_complete.c machdep.c
src/sys/arch/alpha/include: cpu.h fpu.h

Log Message:
Various minor cleanups and bug fixes to the FP software completion code:
- Use __CTASSERT() instead of rolling our own compile-time assertion
  using cpp.
- Use __BIT()  instead of rolling our own.
- Improve some comments.
- Define a default FP_C and FPCR value that is self-consistent, and
  initialize it properly at process creation time.
- Fix signal information when the trap shadow cannot be resolved.
- Use defined constants rather than magic numbers for the exception
  summary bits.
- Add a machdep sysctl to enable FP software-completion debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/alpha/alpha/fp_complete.c
cvs rdiff -u -r1.374 -r1.375 src/sys/arch/alpha/alpha/machdep.c
cvs rdiff -u -r1.102 -r1.103 src/sys/arch/alpha/include/cpu.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/alpha/include/fpu.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/alpha/alpha/fp_complete.c
diff -u src/sys/arch/alpha/alpha/fp_complete.c:1.24 src/sys/arch/alpha/alpha/fp_complete.c:1.25
--- src/sys/arch/alpha/alpha/fp_complete.c:1.24	Tue Sep  1 08:22:36 2020
+++ src/sys/arch/alpha/alpha/fp_complete.c	Thu Jul 22 01:39:18 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fp_complete.c,v 1.24 2020/09/01 08:22:36 thorpej Exp $ */
+/* $NetBSD: fp_complete.c,v 1.25 2021/07/22 01:39:18 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2001 Ross Harvey
@@ -33,9 +33,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include "opt_ddb.h"
+
 #include 			/* RCS ID & Copyright macro defns */
 
-__KERNEL_RCSID(0, "$NetBSD: fp_complete.c,v 1.24 2020/09/01 08:22:36 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fp_complete.c,v 1.25 2021/07/22 01:39:18 thorpej Exp $");
 
 #include 
 #include 
@@ -51,6 +53,30 @@ __KERNEL_RCSID(0, "$NetBSD: fp_complete.
 
 #include 
 
+/*
+ * Validate our assumptions about bit positions.
+ */
+__CTASSERT(ALPHA_AESR_INV == (FP_X_INV << 1));
+__CTASSERT(ALPHA_AESR_DZE == (FP_X_DZ  << 1));
+__CTASSERT(ALPHA_AESR_OVF == (FP_X_OFL << 1));
+__CTASSERT(ALPHA_AESR_UNF == (FP_X_UFL << 1));
+__CTASSERT(ALPHA_AESR_INE == (FP_X_IMP << 1));
+__CTASSERT(ALPHA_AESR_IOV == (FP_X_IOV << 1));
+
+__CTASSERT(IEEE_TRAP_ENABLE_INV == (FP_X_INV << 1));
+__CTASSERT(IEEE_TRAP_ENABLE_DZE == (FP_X_DZ  << 1));
+__CTASSERT(IEEE_TRAP_ENABLE_OVF == (FP_X_OFL << 1));
+__CTASSERT(IEEE_TRAP_ENABLE_UNF == (FP_X_UFL << 1));
+__CTASSERT(IEEE_TRAP_ENABLE_INE == (FP_X_IMP << 1));
+
+__CTASSERT((uint64_t)FP_X_IMP << (61 - 3) == FPCR_INED);
+__CTASSERT((uint64_t)FP_X_UFL << (61 - 3) == FPCR_UNFD);
+__CTASSERT((uint64_t)FP_X_OFL << (49 - 0) == FPCR_OVFD);
+__CTASSERT((uint64_t)FP_X_DZ  << (49 - 0) == FPCR_DZED);
+__CTASSERT((uint64_t)FP_X_INV << (49 - 0) == FPCR_INVD);
+
+__CTASSERT(FP_C_ALLBITS == MDLWP_FP_C);
+
 #define	TSWINSIZE 4	/* size of trap shadow window in uint32_t units */
 
 /*	Set Name		Opcodes			AARM C.* Symbols  */
@@ -351,11 +377,12 @@ fp_c_to_fpcr_1(uint64_t fpcr, uint64_t f
 	 * it is necessary to initially set a sticky bit.
 	 */
 
-	fpcr &= FPCR_DYN(3);
+	fpcr &= FPCR_DYN_RM;
 
 	/*
-	 * enable traps = case where flag bit is clear OR program wants a trap
-	 * enables = ~flags | mask
+	 * enable traps = case where flag bit is clear AND program wants a trap
+	 *
+	 * enables = ~flags & mask
 	 * disables = ~(~flags | mask)
 	 * disables = flags & ~mask. Thank you, Augustus De Morgan (1806-1871)
 	 */
@@ -364,18 +391,6 @@ fp_c_to_fpcr_1(uint64_t fpcr, uint64_t f
 	fpcr |= (disables & (FP_X_IMP | FP_X_UFL)) << (61 - 3);
 	fpcr |= (disables & (FP_X_OFL | FP_X_DZ | FP_X_INV)) << (49 - 0);
 
-#	if !(FP_X_INV == 1 && FP_X_DZ == 2 && FP_X_OFL == 4 &&		\
-	FP_X_UFL == 8 && FP_X_IMP == 16 && FP_X_IOV == 32 &&	\
-	FP_X_UFL << (61 - 3) == FPCR_UNFD &&			\
-	FP_X_IMP << (61 - 3) == FPCR_INED &&			\
-	FP_X_OFL << (49 - 0) == FPCR_OVFD)
-#		error "Assertion failed"
-	/*
-	 * We don't care about the other built-in bit numbers because they
-	 * have been architecturally specified.
-	 */
-#	endif
-
 	fpcr |= fp_c & FP_C_MIRRORED << (FPCR_MIR_START - FP_C_MIR_START);
 	fpcr |= (fp_c & IEEE_MAP_DMZ) << 36;
 	if (fp_c & FP_C_MIRRORED)
@@ -407,6 +422,11 @@ alpha_write_fp_c(struct lwp *l, uint64_t
 		alpha_pal_wrfen(1);
 		fp_c_to_fpcr(l);
 		alpha_pal_wrfen(0);
+	} else {
+		struct pcb *pcb = l->l_addr;
+
+		pcb->pcb_fp.fpr_cr =
+		fp_c_to_fpcr_1(pcb->pcb_fp.fpr_cr, l->l_md.md_flags);
 	}
 	kpreempt_enable();
 }
@@ -502,12 +522,47 @@ float64_unk(float64 a, float64 b)
  */
 
 static void
+print_fp_instruction(alpha_instruction *pc, struct lwp *l, uint32_t bits)
+{
+#if defined(DDB)
+	char buf[32];
+	struct alpha_print_instruction_context ctx = {
+		.insn.bits = bits,
+		.pc = (unsigned long)pc,
+		.buf = buf,

CVS commit: src/sys/arch/alpha

2021-07-21 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jul 22 01:39:18 UTC 2021

Modified Files:
src/sys/arch/alpha/alpha: fp_complete.c machdep.c
src/sys/arch/alpha/include: cpu.h fpu.h

Log Message:
Various minor cleanups and bug fixes to the FP software completion code:
- Use __CTASSERT() instead of rolling our own compile-time assertion
  using cpp.
- Use __BIT()  instead of rolling our own.
- Improve some comments.
- Define a default FP_C and FPCR value that is self-consistent, and
  initialize it properly at process creation time.
- Fix signal information when the trap shadow cannot be resolved.
- Use defined constants rather than magic numbers for the exception
  summary bits.
- Add a machdep sysctl to enable FP software-completion debugging.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/arch/alpha/alpha/fp_complete.c
cvs rdiff -u -r1.374 -r1.375 src/sys/arch/alpha/alpha/machdep.c
cvs rdiff -u -r1.102 -r1.103 src/sys/arch/alpha/include/cpu.h
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/alpha/include/fpu.h

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



CVS commit: src/share/man/man9

2021-07-21 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Jul 22 01:38:45 UTC 2021

Modified Files:
src/share/man/man9: module.9

Log Message:
module_hold() returns void, not int

XXX module_hold() and module_rele() should probably not be exposed, since
XXX they really aren't MP-safe.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/share/man/man9/module.9

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

Modified files:

Index: src/share/man/man9/module.9
diff -u src/share/man/man9/module.9:1.52 src/share/man/man9/module.9:1.53
--- src/share/man/man9/module.9:1.52	Sun Apr  7 22:32:10 2019
+++ src/share/man/man9/module.9	Thu Jul 22 01:38:45 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: module.9,v 1.52 2019/04/07 22:32:10 pgoyette Exp $
+.\"	$NetBSD: module.9,v 1.53 2021/07/22 01:38:45 pgoyette Exp $
 .\"
 .\" Copyright (c) 2010 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -27,7 +27,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 8, 2019
+.Dd July 21, 2021
 .Dt MODULE 9
 .Os
 .Sh NAME
@@ -61,7 +61,7 @@
 .Fn module_unload "const char *name"
 .Ft void
 .Fn module_init_class "modclass_t class"
-.Ft int
+.Ft void
 .Fn module_hold "module_t *module"
 .Ft void
 .Fn module_rele "module_t *module"



CVS commit: src/share/man/man9

2021-07-21 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Thu Jul 22 01:38:45 UTC 2021

Modified Files:
src/share/man/man9: module.9

Log Message:
module_hold() returns void, not int

XXX module_hold() and module_rele() should probably not be exposed, since
XXX they really aren't MP-safe.


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 src/share/man/man9/module.9

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



CVS commit: src/sys/arch/alpha/include

2021-07-21 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jul 22 01:31:55 UTC 2021

Modified Files:
src/sys/arch/alpha/include: proc.h

Log Message:
Use __BITS() to define MDLWP_FP_C.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/alpha/include/proc.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/alpha/include

2021-07-21 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Jul 22 01:31:55 UTC 2021

Modified Files:
src/sys/arch/alpha/include: proc.h

Log Message:
Use __BITS() to define MDLWP_FP_C.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/alpha/include/proc.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/alpha/include/proc.h
diff -u src/sys/arch/alpha/include/proc.h:1.22 src/sys/arch/alpha/include/proc.h:1.23
--- src/sys/arch/alpha/include/proc.h:1.22	Fri May 16 19:18:21 2014
+++ src/sys/arch/alpha/include/proc.h	Thu Jul 22 01:31:55 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: proc.h,v 1.22 2014/05/16 19:18:21 matt Exp $ */
+/* $NetBSD: proc.h,v 1.23 2021/07/22 01:31:55 thorpej Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -61,7 +61,7 @@ struct mdlwp {
  * 	C99 API's, the use of the MDLWP_FP_C bits is defined variously in
  * 	ieeefp.h and fpu.h.
  */
-#define	MDLWP_FP_C	0x007e	/* Extended FP_C Quadword bits */
+#define	MDLWP_FP_C	__BITS(1,22)	/* Extended FP_C Quadword bits */
 #define	MDLWP_FPACTIVE	__BIT(63)	/* FPU is active on LWP's PCU CPU */
 
 /*



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

2021-07-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul 22 00:47:56 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: acpi_fdt.c files.fdt

Log Message:
Expose SMBIOS tables using sysctl machdep.dmi.*, same as x86.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/fdt/acpi_fdt.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/fdt/files.fdt

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



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

2021-07-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Jul 22 00:47:56 UTC 2021

Modified Files:
src/sys/arch/arm/fdt: acpi_fdt.c files.fdt

Log Message:
Expose SMBIOS tables using sysctl machdep.dmi.*, same as x86.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/arm/fdt/acpi_fdt.c
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/arm/fdt/files.fdt

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/fdt/acpi_fdt.c
diff -u src/sys/arch/arm/fdt/acpi_fdt.c:1.19 src/sys/arch/arm/fdt/acpi_fdt.c:1.20
--- src/sys/arch/arm/fdt/acpi_fdt.c:1.19	Sat Apr 24 23:36:26 2021
+++ src/sys/arch/arm/fdt/acpi_fdt.c	Thu Jul 22 00:47:55 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_fdt.c,v 1.19 2021/04/24 23:36:26 thorpej Exp $ */
+/* $NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015-2017 Jared McNeill 
@@ -30,7 +30,7 @@
 #include "opt_efi.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.19 2021/04/24 23:36:26 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v 1.20 2021/07/22 00:47:55 jmcneill Exp $");
 
 #include 
 #include 
@@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_fdt.c,v
 
 #include 
 #include 
+#include 
 
 #include 
 
@@ -61,6 +62,7 @@ static void	acpi_fdt_attach(device_t, de
 
 static void	acpi_fdt_poweroff(device_t);
 
+static void	acpi_fdt_smbios_init(device_t);
 static void	acpi_fdt_sysctl_init(void);
 
 extern struct arm32_bus_dma_tag acpi_coherent_dma_tag;
@@ -89,18 +91,24 @@ acpi_fdt_match(device_t parent, cfdata_t
 static void
 acpi_fdt_attach(device_t parent, device_t self, void *aux)
 {
+	extern void platform_init(void); /* XXX */
 	struct fdt_attach_args * const faa = aux;
 	struct acpibus_attach_args aa;
 
 	aprint_naive("\n");
 	aprint_normal("\n");
 
+	acpi_fdt_smbios_init(self);
+	platform_init();
+
 	fdtbus_register_power_controller(self, faa->faa_phandle,
 	_fdt_power_funcs);
 
 	if (!acpi_probe())
 		panic("ACPI subsystem failed to initialize");
 
+	platform_init();
+
 	memset(, 0, sizeof(aa));
 #if NPCI > 0
 	aa.aa_pciflags =
@@ -133,26 +141,64 @@ acpi_fdt_poweroff(device_t dev)
 }
 
 static void
+acpi_fdt_smbios_init(device_t dev)
+{
+	struct smb3hdr *sh;
+	uint8_t *ptr;
+
+	const int chosen = OF_finddevice("/chosen");
+	if (chosen >= 0) {
+		of_getprop_uint64(chosen, "netbsd,smbios-table", _table);
+	}
+	if (smbios_table == 0) {
+		return;
+	}
+
+	sh = AcpiOsMapMemory(smbios_table, sizeof(*sh));
+	if (sh == NULL) {
+		return;
+	}
+	if (!smbios3_check_header((uint8_t *)sh)) {
+		AcpiOsUnmapMemory(sh, sizeof(*sh));
+		return;
+	}
+
+	ptr = AcpiOsMapMemory(sh->addr, sh->size);
+	if (ptr != NULL) {
+		smbios_entry.addr = ptr;
+		smbios_entry.len = sh->size;
+		smbios_entry.rev = sh->eprev;
+		smbios_entry.mjr = sh->majrev;
+		smbios_entry.min = sh->minrev;
+		smbios_entry.doc = sh->docrev;
+		smbios_entry.count = UINT16_MAX;
+
+		device_printf(dev, "SMBIOS rev. %d.%d.%d @ 0x%lx\n",
+		sh->majrev, sh->minrev, sh->docrev, (u_long)sh->addr);
+	}
+	AcpiOsUnmapMemory(sh, sizeof(*sh));
+}
+
+static void
 acpi_fdt_sysctl_init(void)
 {
 	const struct sysctlnode *rnode;
 	int error;
 
-	const int chosen = OF_finddevice("/chosen");
-	if (chosen >= 0)
-		of_getprop_uint64(chosen, "netbsd,smbios-table", _table);
+	if (smbios_table == 0) {
+		return;
+	}
 
 	error = sysctl_createv(NULL, 0, NULL, ,
 	CTLFLAG_PERMANENT, CTLTYPE_NODE, "machdep", NULL,
 	NULL, 0, NULL, 0, CTL_MACHDEP, CTL_EOL);
-	if (error)
+	if (error) {
 		return;
-
-	if (smbios_table != 0) {
-		(void)sysctl_createv(NULL, 0, , NULL,
-		CTLFLAG_PERMANENT | CTLFLAG_READONLY | CTLFLAG_HEX, CTLTYPE_QUAD,
-		"smbios", SYSCTL_DESCR("SMBIOS table pointer"),
-		NULL, 0, _table, sizeof(smbios_table),
-		CTL_CREATE, CTL_EOL);
 	}
+
+	(void)sysctl_createv(NULL, 0, , NULL,
+	CTLFLAG_PERMANENT | CTLFLAG_READONLY | CTLFLAG_HEX, CTLTYPE_QUAD,
+	"smbios", SYSCTL_DESCR("SMBIOS table pointer"),
+	NULL, 0, _table, sizeof(smbios_table),
+	CTL_CREATE, CTL_EOL);
 }

Index: src/sys/arch/arm/fdt/files.fdt
diff -u src/sys/arch/arm/fdt/files.fdt:1.33 src/sys/arch/arm/fdt/files.fdt:1.34
--- src/sys/arch/arm/fdt/files.fdt:1.33	Mon Apr 26 14:44:16 2021
+++ src/sys/arch/arm/fdt/files.fdt	Thu Jul 22 00:47:55 2021
@@ -1,4 +1,4 @@
-# $NetBSD: files.fdt,v 1.33 2021/04/26 14:44:16 thorpej Exp $
+# $NetBSD: files.fdt,v 1.34 2021/07/22 00:47:55 jmcneill Exp $
 
 include	"dev/pckbport/files.pckbport"
 
@@ -75,6 +75,7 @@ file	arch/arm/fdt/pmu_fdt.c			pmu_fdt
 attach	genfb at fdt with plfb_fdt: fdt_display_timing
 file	arch/arm/fdt/plfb_fdt.c			plfb_fdt
 
-device	acpifdt: acpibus
+device	acpifdt: acpibus, smbios
 attach	acpifdt at fdt with acpi_fdt
 file	arch/arm/fdt/acpi_fdt.c			acpi_fdt
+file	dev/smbios_platform.c			acpi_fdt



CVS commit: src/sys

2021-07-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jul 21 23:26:15 UTC 2021

Modified Files:
src/sys/arch/x86/conf: files.x86
Added Files:
src/sys/dev: smbios_platform.c
Removed Files:
src/sys/arch/x86/x86: platform.c

Log Message:
x86's platform.c no longer has any x86 specific code in it, so move it to
dev/smbios_platform.c to let other ports use it


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r1.17 -r0 src/sys/arch/x86/x86/platform.c
cvs rdiff -u -r0 -r1.1 src/sys/dev/smbios_platform.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/x86/conf/files.x86
diff -u src/sys/arch/x86/conf/files.x86:1.121 src/sys/arch/x86/conf/files.x86:1.122
--- src/sys/arch/x86/conf/files.x86:1.121	Wed Jul 21 23:16:08 2021
+++ src/sys/arch/x86/conf/files.x86	Wed Jul 21 23:26:15 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.x86,v 1.121 2021/07/21 23:16:08 jmcneill Exp $
+#	$NetBSD: files.x86,v 1.122 2021/07/21 23:26:15 jmcneill Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPDEBUG MPBIOS_SCANPCI
@@ -103,7 +103,7 @@ file	arch/x86/x86/idt.c		machdep
 file	arch/x86/x86/ipi.c		machdep & !xenpv
 file	arch/x86/x86/mtrr_i686.c	mtrr & !xenpv
 file 	arch/x86/x86/patch.c		machdep & !xenpv
-file	arch/x86/x86/platform.c		machdep
+file	dev/smbios_platform.c		machdep
 file 	arch/x86/x86/pmap.c		machdep
 file 	arch/x86/x86/x86_tlb.c		machdep
 file	arch/x86/x86/procfs_machdep.c	procfs

Added files:

Index: src/sys/dev/smbios_platform.c
diff -u /dev/null src/sys/dev/smbios_platform.c:1.1
--- /dev/null	Wed Jul 21 23:26:15 2021
+++ src/sys/dev/smbios_platform.c	Wed Jul 21 23:26:15 2021
@@ -0,0 +1,321 @@
+/* $NetBSD: smbios_platform.c,v 1.1 2021/07/21 23:26:15 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2007 Jared D. 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION OR CONTRIBUTORS
+ * 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 "isa.h"
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: smbios_platform.c,v 1.1 2021/07/21 23:26:15 jmcneill Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#if NISA > 0
+#include 
+#endif
+
+#include 
+
+static int platform_dminode = CTL_EOL;
+
+void		platform_init(void);	/* XXX */
+static void	platform_add(struct smbtable *, const char *, int);
+static void	platform_add_word(struct smbtable *, const char *, uint16_t,
+const char *);
+static void	platform_add_date(struct smbtable *, const char *, int);
+static void	platform_add_uuid(struct smbtable *, const char *,
+  const uint8_t *);
+static int	platform_dmi_sysctl(SYSCTLFN_PROTO);
+
+/* list of private DMI sysctl nodes */
+static const char *platform_private_nodes[] = {
+	"chassis-serial",
+	"board-serial",
+	"system-serial",
+	"system-uuid",
+	NULL
+};
+
+void
+platform_init(void)
+{
+	struct smbtable smbios;
+	struct smbios_sys *psys;
+	struct smbios_struct_bios *pbios;
+	struct smbios_board *pboard;
+	struct smbios_chassis *pchassis;
+	struct smbios_processor *pproc;
+	struct smbios_slot *pslot;
+	int nisa, nother;
+
+	smbios.cookie = 0;
+	if (smbios_find_table(SMBIOS_TYPE_SYSTEM, )) {
+		psys = smbios.tblhdr;
+
+		platform_add(, "system-vendor", psys->vendor);
+		platform_add(, "system-product", psys->product);
+		platform_add(, "system-version", psys->version);
+		platform_add(, "system-serial", psys->serial);
+		platform_add_uuid(, "system-uuid", psys->uuid);
+	}
+
+	smbios.cookie = 0;
+	if (smbios_find_table(SMBIOS_TYPE_BIOS, )) {
+		pbios = smbios.tblhdr;
+
+		platform_add(, "bios-vendor", pbios->vendor);
+		platform_add(, "bios-version", 

CVS commit: src/sys

2021-07-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jul 21 23:26:15 UTC 2021

Modified Files:
src/sys/arch/x86/conf: files.x86
Added Files:
src/sys/dev: smbios_platform.c
Removed Files:
src/sys/arch/x86/x86: platform.c

Log Message:
x86's platform.c no longer has any x86 specific code in it, so move it to
dev/smbios_platform.c to let other ports use it


To generate a diff of this commit:
cvs rdiff -u -r1.121 -r1.122 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r1.17 -r0 src/sys/arch/x86/x86/platform.c
cvs rdiff -u -r0 -r1.1 src/sys/dev/smbios_platform.c

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



CVS commit: src/sys

2021-07-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jul 21 23:16:09 UTC 2021

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot2.c
src/sys/arch/x86/conf: files.x86
src/sys/arch/x86/x86: bios32.c platform.c x86_ipmi.c
src/sys/conf: files
src/sys/dev: files.dev
Added Files:
src/sys/arch/x86/include: smbios_machdep.h
src/sys/dev: smbios.c smbiosvar.h
Removed Files:
src/sys/arch/x86/include: smbiosvar.h

Log Message:
Separate MI smbios interface from MD specific code.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/lib/exec_multiboot2.c
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/include/smbios_machdep.h
cvs rdiff -u -r1.6 -r0 src/sys/arch/x86/include/smbiosvar.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/x86/bios32.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/x86/platform.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/x86/x86_ipmi.c
cvs rdiff -u -r1.1286 -r1.1287 src/sys/conf/files
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/files.dev
cvs rdiff -u -r0 -r1.1 src/sys/dev/smbios.c src/sys/dev/smbiosvar.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/i386/stand/lib/exec_multiboot2.c
diff -u src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.4 src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.5
--- src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.4	Thu May 14 08:34:20 2020
+++ src/sys/arch/i386/stand/lib/exec_multiboot2.c	Wed Jul 21 23:16:08 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_multiboot2.c,v 1.4 2020/05/14 08:34:20 msaitoh Exp $ */
+/* $NetBSD: exec_multiboot2.c,v 1.5 2021/07/21 23:16:08 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -34,7 +34,8 @@
 
 #include 
 #include 
-#include 
+#include 
+#include 
 
 #include  
 #include  

Index: src/sys/arch/x86/conf/files.x86
diff -u src/sys/arch/x86/conf/files.x86:1.120 src/sys/arch/x86/conf/files.x86:1.121
--- src/sys/arch/x86/conf/files.x86:1.120	Tue Oct 27 08:57:11 2020
+++ src/sys/arch/x86/conf/files.x86	Wed Jul 21 23:16:08 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.x86,v 1.120 2020/10/27 08:57:11 ryo Exp $
+#	$NetBSD: files.x86,v 1.121 2021/07/21 23:16:08 jmcneill Exp $
 
 # options for MP configuration through the MP spec
 defflag opt_mpbios.h MPBIOS MPDEBUG MPBIOS_SCANPCI
@@ -30,7 +30,7 @@ define	cpufeaturebus {}
 define  ioapicbus { [apid = -1] }
 
 # BIOS32 routines
-define	bios32
+define	bios32: smbios
 file	arch/x86/x86/bios32.c		bios32 needs-flag
 
 #

Index: src/sys/arch/x86/x86/bios32.c
diff -u src/sys/arch/x86/x86/bios32.c:1.4 src/sys/arch/x86/x86/bios32.c:1.5
--- src/sys/arch/x86/x86/bios32.c:1.4	Fri Dec 27 09:45:26 2019
+++ src/sys/arch/x86/x86/bios32.c	Wed Jul 21 23:16:09 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: bios32.c,v 1.4 2019/12/27 09:45:26 msaitoh Exp $	*/
+/*	$NetBSD: bios32.c,v 1.5 2021/07/21 23:16:09 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -86,7 +86,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.4 2019/12/27 09:45:26 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1.5 2021/07/21 23:16:09 jmcneill Exp $");
 
 #include 
 #include 
@@ -97,7 +97,8 @@ __KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1
 
 #include 
 #include 
-#include 
+#include 
+#include 
 #include 
 
 #include 
@@ -110,11 +111,8 @@ __KERNEL_RCSID(0, "$NetBSD: bios32.c,v 1
 #define	BIOS32_END	(BIOS32_START + BIOS32_SIZE - 0x10)
 
 struct bios32_entry bios32_entry;
-struct smbios_entry smbios_entry;
 
-static int smbios2_check_header(const uint8_t *);
 static void smbios2_map_kva(const uint8_t *);
-static int smbios3_check_header(const uint8_t *);
 static void smbios3_map_kva(const uint8_t *);
 
 /*
@@ -241,32 +239,6 @@ bios32_service(uint32_t service, bios32_
 	return 1;
 }
 
-static int
-smbios2_check_header(const uint8_t *p)
-{
-	const struct smbhdr *sh = (const struct smbhdr *)p;
-	uint8_t chksum;
-	int i;
-
-	if (sh->sig != BIOS32_MAKESIG('_', 'S', 'M', '_'))
-		return 0;
-	i = sh->len;
-	for (chksum = 0; i--; )
-		chksum += p[i];
-	if (chksum != 0)
-		return 0;
-	p += 0x10;
-	if (p[0] != '_' || p[1] != 'D' || p[2] != 'M' ||
-	p[3] != 'I' || p[4] != '_')
-		return 0;
-	for (chksum = 0, i = 0xf; i--; )
-		chksum += p[i];
-	if (chksum != 0)
-		return 0;
-
-	return 1;
-}
-
 static void
 smbios2_map_kva(const uint8_t *p)
 {
@@ -300,27 +272,6 @@ smbios2_map_kva(const uint8_t *p)
 	sh->majrev, sh->minrev, (u_long)sh->addr, sh->count);
 }
 
-static int
-smbios3_check_header(const uint8_t *p)
-{
-	const struct smb3hdr *sh = (const struct smb3hdr *)p;
-	uint8_t chksum;
-	int i;
-
-	if (p[0] != '_' || p[1] != 'S' || p[2] != 'M' ||
-	p[3] != '3' || p[4] != '_')
-		return 0;
-	i = sh->len;
-	for (chksum = 0; i--; )
-		chksum += p[i];
-	if (chksum != 0)
-		return 0;
-	if (sh->eprev != SMBIOS3_EPREV_3_0)
-		return 0;
-
-	return 1;
-}

CVS commit: src/sys

2021-07-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jul 21 23:16:09 UTC 2021

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot2.c
src/sys/arch/x86/conf: files.x86
src/sys/arch/x86/x86: bios32.c platform.c x86_ipmi.c
src/sys/conf: files
src/sys/dev: files.dev
Added Files:
src/sys/arch/x86/include: smbios_machdep.h
src/sys/dev: smbios.c smbiosvar.h
Removed Files:
src/sys/arch/x86/include: smbiosvar.h

Log Message:
Separate MI smbios interface from MD specific code.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/lib/exec_multiboot2.c
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/x86/conf/files.x86
cvs rdiff -u -r0 -r1.1 src/sys/arch/x86/include/smbios_machdep.h
cvs rdiff -u -r1.6 -r0 src/sys/arch/x86/include/smbiosvar.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/x86/x86/bios32.c
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/x86/x86/platform.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/x86/x86/x86_ipmi.c
cvs rdiff -u -r1.1286 -r1.1287 src/sys/conf/files
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/files.dev
cvs rdiff -u -r0 -r1.1 src/sys/dev/smbios.c src/sys/dev/smbiosvar.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/raidframe

2021-07-21 Thread Greg Oster
Module Name:src
Committed By:   oster
Date:   Wed Jul 21 23:10:12 UTC 2021

Modified Files:
src/sys/dev/raidframe: rf_shutdown.c

Log Message:
Remove commented line that is a duplicate of a real line.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/raidframe/rf_shutdown.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/raidframe/rf_shutdown.c
diff -u src/sys/dev/raidframe/rf_shutdown.c:1.20 src/sys/dev/raidframe/rf_shutdown.c:1.21
--- src/sys/dev/raidframe/rf_shutdown.c:1.20	Wed Dec 17 20:51:34 2008
+++ src/sys/dev/raidframe/rf_shutdown.c	Wed Jul 21 23:10:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: rf_shutdown.c,v 1.20 2008/12/17 20:51:34 cegger Exp $	*/
+/*	$NetBSD: rf_shutdown.c,v 1.21 2021/07/21 23:10:12 oster Exp $	*/
 /*
  * rf_shutdown.c
  */
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: rf_shutdown.c,v 1.20 2008/12/17 20:51:34 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rf_shutdown.c,v 1.21 2021/07/21 23:10:12 oster Exp $");
 
 #include 
 
@@ -71,8 +71,6 @@ _rf_ShutdownCreate(RF_ShutdownList_t **l
  * Have to directly allocate memory here, since we start up before
  * and shutdown after RAIDframe internal allocation system.
  */
-	/* 	ent = (RF_ShutdownList_t *) malloc(sizeof(RF_ShutdownList_t),
-		M_RAIDFRAME, M_WAITOK); */
 	ent = (RF_ShutdownList_t *) malloc(sizeof(RF_ShutdownList_t),
 	   M_RAIDFRAME, M_WAITOK);
 	ent->cleanup = cleanup;



CVS commit: src/sys/dev/raidframe

2021-07-21 Thread Greg Oster
Module Name:src
Committed By:   oster
Date:   Wed Jul 21 23:10:12 UTC 2021

Modified Files:
src/sys/dev/raidframe: rf_shutdown.c

Log Message:
Remove commented line that is a duplicate of a real line.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/raidframe/rf_shutdown.c

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



CVS commit: src/usr.bin/xlint/lint1

2021-07-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jul 21 21:24:45 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: move assignments to $$ at the end of the action

They are closely related to return statements.

While here, add some more remarks from reviewing the grammar.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.333 -r1.334 src/usr.bin/xlint/lint1/cgram.y

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

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.333 src/usr.bin/xlint/lint1/cgram.y:1.334
--- src/usr.bin/xlint/lint1/cgram.y:1.333	Wed Jul 21 21:17:57 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Jul 21 21:24:45 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.333 2021/07/21 21:17:57 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.334 2021/07/21 21:24:45 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.333 2021/07/21 21:17:57 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.334 2021/07/21 21:24:45 rillig Exp $");
 #endif
 
 #include 
@@ -375,12 +375,12 @@ identifier_sym:			/* helper for struct/u
 /* K ???, C90 ???, C99 6.4.2.1, C11 ??? */
 identifier:
 	  T_NAME {
+		cgram_debug("name '%s'", $1->sb_name);
 		$$ = $1;
-		cgram_debug("name '%s'", $$->sb_name);
 	  }
 	| T_TYPENAME {
+		cgram_debug("typename '%s'", $1->sb_name);
 		$$ = $1;
-		cgram_debug("typename '%s'", $$->sb_name);
 	  }
 	;
 
@@ -543,9 +543,9 @@ gcc_statement_expr_item:
 			/* XXX: do that only on the last name */
 			if ($1->tn_op == NAME)
 $1->tn_sym->s_used = true;
-			$$ = $1;
 			expr($1, false, false, false, false);
 			seen_fallthrough = false;
+			$$ = $1;
 		}
 	  }
 	;
@@ -615,6 +615,7 @@ unary_expression:
 	  }
 	/* K ---, C90 ---, C99 ---, C11 6.5.3 */
 	| T_ALIGNOF T_LPAREN type_name T_RPAREN {
+		/* TODO: c11ism */
 		$$ = build_alignof($3);
 	  }
 	;
@@ -736,6 +737,7 @@ declaration:			/* C99 6.7 */
 		}
 	  }
 	| begin_type_declmods end_type notype_init_declarators T_SEMI
+	/* ^^ There is no check for the missing type-specifier. */
 	| begin_type_declaration_specifiers end_type T_SEMI {
 		if (dcs->d_scl == TYPEDEF) {
 			/* typedef declares no type name */
@@ -777,6 +779,7 @@ begin_type_specifier_qualifier_list:	/* 
 	  begin_type_typespec {
 		add_type($1);
 	  }
+	  /* TODO: shift/reduce conflict for type_attribute */
 	| type_attribute begin_type_specifier_qualifier_list
 	| begin_type_qualifier_list type_specifier {
 		add_type($2);
@@ -834,6 +837,7 @@ type_attribute:			/* See C11 6.7 declara
 	  } gcc_attribute_spec_list {
 	attron = false;
 	  } T_RPAREN T_RPAREN
+	  /* TODO: c11ism */
 	| T_ALIGNAS T_LPAREN align_as T_RPAREN
 	| T_PACKED {
 		addpacked();
@@ -949,6 +953,7 @@ struct_declaration_list:	/* C99 6.7.2.1 
 
 struct_declaration:		/* C99 6.7.2.1 */
 	  begin_type_qualifier_list end_type {
+		/* ^^ There is no check for the missing type-specifier. */
 		/* too late, i know, but getsym() compensates it */
 		symtyp = FMEMBER;
 	  } notype_struct_declarators type_attribute_opt T_SEMI {
@@ -1475,12 +1480,14 @@ parameter_type_list:
 /* XXX: C99 6.7.5 defines the same name, but it looks completely different. */
 parameter_declaration:
 	  begin_type_declmods end_type {
+		/* ^^ There is no check for the missing type-specifier. */
 		$$ = declare_argument(abstract_name(), false);
 	  }
 	| begin_type_declaration_specifiers end_type {
 		$$ = declare_argument(abstract_name(), false);
 	  }
 	| begin_type_declmods end_type notype_param_declarator {
+		/* ^^ There is no check for the missing type-specifier. */
 		$$ = declare_argument($3, false);
 	  }
 	/*
@@ -1494,6 +1501,7 @@ parameter_declaration:
 		$$ = declare_argument($3, false);
 	  }
 	| begin_type_declmods end_type abstract_declarator {
+		/* ^^ There is no check for the missing type-specifier. */
 		$$ = declare_argument($3, false);
 	  }
 	| begin_type_declaration_specifiers end_type abstract_declarator {
@@ -1509,6 +1517,7 @@ initializer:			/* C99 6.7.8 "Initializat
 		/* XXX: Empty braces are not covered by C99 6.7.8. */
 	  }
 	| init_lbrace initializer_list comma_opt init_rbrace
+	  /* XXX: What is this error handling for? */
 	| error
 	;
 
@@ -1940,9 +1949,11 @@ function_definition:		/* C99 6.9.1 */
 
 func_declarator:
 	  begin_type end_type notype_declarator {
+		/* ^^ There is no check for the missing type-specifier. */
 		$$ = $3;
 	  }
 	| begin_type_declmods end_type notype_declarator {
+		/* ^^ There is no check for the missing type-specifier. */
 		$$ = $3;
 	  }
 	| begin_type_declaration_specifiers end_type type_declarator {



CVS commit: src/usr.bin/xlint/lint1

2021-07-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jul 21 21:24:45 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: move assignments to $$ at the end of the action

They are closely related to return statements.

While here, add some more remarks from reviewing the grammar.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.333 -r1.334 src/usr.bin/xlint/lint1/cgram.y

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



CVS commit: src

2021-07-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jul 21 21:17:57 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: decl_struct_member.c
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: rename grammar rules for specifier-qualifier-list

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/decl_struct_member.c
cvs rdiff -u -r1.332 -r1.333 src/usr.bin/xlint/lint1/cgram.y

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/decl_struct_member.c
diff -u src/tests/usr.bin/xlint/lint1/decl_struct_member.c:1.9 src/tests/usr.bin/xlint/lint1/decl_struct_member.c:1.10
--- src/tests/usr.bin/xlint/lint1/decl_struct_member.c:1.9	Thu Jul 15 21:00:05 2021
+++ src/tests/usr.bin/xlint/lint1/decl_struct_member.c	Wed Jul 21 21:17:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: decl_struct_member.c,v 1.9 2021/07/15 21:00:05 rillig Exp $	*/
+/*	$NetBSD: decl_struct_member.c,v 1.10 2021/07/21 21:17:57 rillig Exp $	*/
 # 3 "decl_struct_member.c"
 
 struct multi_attributes {
@@ -8,7 +8,7 @@ struct multi_attributes {
 	int deprecated;
 };
 
-struct cover_begin_type_noclass_declspecs {
+struct cover_begin_type_specifier_qualifier_list {
 	int m1;
 	__attribute__((deprecated)) int m2;
 	const int m3;
@@ -24,7 +24,7 @@ struct cover_begin_type_typespec {
 	number m2;
 };
 
-struct cover_begin_type_noclass_declmods {
+struct cover_begin_type_qualifier_list {
 	const m1;
 	const volatile m2;
 };

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.332 src/usr.bin/xlint/lint1/cgram.y:1.333
--- src/usr.bin/xlint/lint1/cgram.y:1.332	Wed Jul 21 21:11:19 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Jul 21 21:17:57 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.332 2021/07/21 21:11:19 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.333 2021/07/21 21:17:57 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.332 2021/07/21 21:11:19 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.333 2021/07/21 21:17:57 rillig Exp $");
 #endif
 
 #include 
@@ -773,21 +773,21 @@ begin_type_declmods:		/* see C99 6.7 */
 	| begin_type_declmods declmod
 	;
 
-begin_type_noclass_declspecs:
+begin_type_specifier_qualifier_list:	/* see C11 6.7.2.1 */
 	  begin_type_typespec {
 		add_type($1);
 	  }
-	| type_attribute begin_type_noclass_declspecs
-	| begin_type_noclass_declmods type_specifier {
+	| type_attribute begin_type_specifier_qualifier_list
+	| begin_type_qualifier_list type_specifier {
 		add_type($2);
 	  }
-	| begin_type_noclass_declspecs T_QUAL {
+	| begin_type_specifier_qualifier_list T_QUAL {
 		add_qualifier($2);
 	  }
-	| begin_type_noclass_declspecs notype_type_specifier {
+	| begin_type_specifier_qualifier_list notype_type_specifier {
 		add_type($2);
 	  }
-	| begin_type_noclass_declspecs type_attribute
+	| begin_type_specifier_qualifier_list type_attribute
 	;
 
 begin_type_typespec:
@@ -799,11 +799,11 @@ begin_type_typespec:
 	  }
 	;
 
-begin_type_noclass_declmods:
+begin_type_qualifier_list:
 	  begin_type T_QUAL {
 		add_qualifier($2);
 	  }
-	| begin_type_noclass_declmods T_QUAL {
+	| begin_type_qualifier_list T_QUAL {
 		add_qualifier($2);
 	  }
 	;
@@ -948,25 +948,25 @@ struct_declaration_list:	/* C99 6.7.2.1 
 	;
 
 struct_declaration:		/* C99 6.7.2.1 */
-	  begin_type_noclass_declmods end_type {
+	  begin_type_qualifier_list end_type {
 		/* too late, i know, but getsym() compensates it */
 		symtyp = FMEMBER;
 	  } notype_struct_declarators type_attribute_opt T_SEMI {
 		symtyp = FVFT;
 		$$ = $4;
 	  }
-	| begin_type_noclass_declspecs end_type {
+	| begin_type_specifier_qualifier_list end_type {
 		symtyp = FMEMBER;
 	  } type_struct_declarators type_attribute_opt T_SEMI {
 		symtyp = FVFT;
 		$$ = $4;
 	  }
-	| begin_type_noclass_declmods end_type type_attribute_opt T_SEMI {
+	| begin_type_qualifier_list end_type type_attribute_opt T_SEMI {
 		/* syntax error '%s' */
 		error(249, "member without type");
 		$$ = NULL;
 	  }
-	| begin_type_noclass_declspecs end_type type_attribute_opt T_SEMI {
+	| begin_type_specifier_qualifier_list end_type type_attribute_opt T_SEMI {
 		symtyp = FVFT;
 		if (!Sflag)
 			/* anonymous struct/union members is a C9X feature */
@@ -1363,16 +1363,16 @@ type_name:			/* C99 6.7.6 */
 	;
 
 abstract_declaration:
-	  begin_type_noclass_declmods end_type {
+	  begin_type_qualifier_list end_type {
 		$$ = declare_1_abstract(abstract_name());
 	  }
-	| begin_type_noclass_declspecs end_type {
+	| begin_type_specifier_qualifier_list end_type {
 		$$ = declare_1_abstract(abstract_name());
 	  }
-	| begin_type_noclass_declmods end_type abstract_declarator {
+	| begin_type_qualifier_list end_type abstract_declarator {
 		$$ = declare_1_abstract($3);
 	  }

CVS commit: src

2021-07-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jul 21 21:17:57 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: decl_struct_member.c
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: rename grammar rules for specifier-qualifier-list

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.bin/xlint/lint1/decl_struct_member.c
cvs rdiff -u -r1.332 -r1.333 src/usr.bin/xlint/lint1/cgram.y

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



CVS commit: src/usr.bin/xlint/lint1

2021-07-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jul 21 21:11:19 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: remove unnecessary assertion for type qualifier

If there is any new type qualifier that lint should support (such as
_Atomic from C11), the obvious place is to look in the grammar rule
type_qualifier, so there is no need to have an assertion.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.331 -r1.332 src/usr.bin/xlint/lint1/cgram.y

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

Modified files:

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.331 src/usr.bin/xlint/lint1/cgram.y:1.332
--- src/usr.bin/xlint/lint1/cgram.y:1.331	Wed Jul 21 21:04:00 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Jul 21 21:11:19 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.331 2021/07/21 21:04:00 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.332 2021/07/21 21:11:19 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.331 2021/07/21 21:04:00 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.332 2021/07/21 21:11:19 rillig Exp $");
 #endif
 
 #include 
@@ -1109,13 +1109,10 @@ enumerator:			/* C99 6.7.2.2 */
 type_qualifier:			/* C99 6.7.3 */
 	  T_QUAL {
 		$$ = xcalloc(1, sizeof(*$$));
-		if ($1 == CONST) {
+		if ($1 == CONST)
 			$$->p_const = true;
-		} else if ($1 == VOLATILE) {
+		if ($1 == VOLATILE)
 			$$->p_volatile = true;
-		} else {
-			lint_assert($1 == RESTRICT || $1 == THREAD);
-		}
 	  }
 	;
 



CVS commit: src/usr.bin/xlint/lint1

2021-07-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jul 21 21:11:19 UTC 2021

Modified Files:
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: remove unnecessary assertion for type qualifier

If there is any new type qualifier that lint should support (such as
_Atomic from C11), the obvious place is to look in the grammar rule
type_qualifier, so there is no need to have an assertion.

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.331 -r1.332 src/usr.bin/xlint/lint1/cgram.y

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



CVS commit: src

2021-07-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jul 21 21:04:00 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: gcc_stmt_asm.c
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: rename ignore_up_to_rparen to match the grammar rule

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c
cvs rdiff -u -r1.330 -r1.331 src/usr.bin/xlint/lint1/cgram.y

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

Modified files:

Index: src/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c
diff -u src/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c:1.2 src/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c:1.3
--- src/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c:1.2	Thu Jul 15 21:00:05 2021
+++ src/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c	Wed Jul 21 21:04:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gcc_stmt_asm.c,v 1.2 2021/07/15 21:00:05 rillig Exp $	*/
+/*	$NetBSD: gcc_stmt_asm.c,v 1.3 2021/07/21 21:04:00 rillig Exp $	*/
 # 3 "gcc_stmt_asm.c"
 
 /*
@@ -38,5 +38,5 @@ syntax_error(void)
 }
 
 __asm__(
-/* cover ignore_up_to_rparen at EOF */
+/* cover read_until_rparen at EOF */
 /* expect+1: error: syntax error '' [249] */

Index: src/usr.bin/xlint/lint1/cgram.y
diff -u src/usr.bin/xlint/lint1/cgram.y:1.330 src/usr.bin/xlint/lint1/cgram.y:1.331
--- src/usr.bin/xlint/lint1/cgram.y:1.330	Tue Jul 20 19:44:36 2021
+++ src/usr.bin/xlint/lint1/cgram.y	Wed Jul 21 21:04:00 2021
@@ -1,5 +1,5 @@
 %{
-/* $NetBSD: cgram.y,v 1.330 2021/07/20 19:44:36 rillig Exp $ */
+/* $NetBSD: cgram.y,v 1.331 2021/07/21 21:04:00 rillig Exp $ */
 
 /*
  * Copyright (c) 1996 Christopher G. Demetriou.  All Rights Reserved.
@@ -35,7 +35,7 @@
 
 #include 
 #if defined(__RCSID) && !defined(lint)
-__RCSID("$NetBSD: cgram.y,v 1.330 2021/07/20 19:44:36 rillig Exp $");
+__RCSID("$NetBSD: cgram.y,v 1.331 2021/07/21 21:04:00 rillig Exp $");
 #endif
 
 #include 
@@ -67,7 +67,7 @@ int	mem_block_level;
 static int olwarn = LWARN_BAD;
 
 static	void	cgram_declare(sym_t *, bool, sbuf_t *);
-static	void	ignore_up_to_rparen(void);
+static	void	read_until_rparen(void);
 static	sym_t	*symbolrename(sym_t *, sbuf_t *);
 
 
@@ -1854,7 +1854,7 @@ asm_statement:			/* GCC extension */
 
 read_until_rparen:		/* helper for 'asm_statement' */
 	  /* empty */ {
-		ignore_up_to_rparen();
+		read_until_rparen();
 	  }
 	;
 
@@ -2104,7 +2104,7 @@ cgram_declare(sym_t *decl, bool initflg,
  * unmatched right paren
  */
 static void
-ignore_up_to_rparen(void)
+read_until_rparen(void)
 {
 	int	level;
 



CVS commit: src

2021-07-21 Thread Roland Illig
Module Name:src
Committed By:   rillig
Date:   Wed Jul 21 21:04:00 UTC 2021

Modified Files:
src/tests/usr.bin/xlint/lint1: gcc_stmt_asm.c
src/usr.bin/xlint/lint1: cgram.y

Log Message:
lint: rename ignore_up_to_rparen to match the grammar rule

No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/usr.bin/xlint/lint1/gcc_stmt_asm.c
cvs rdiff -u -r1.330 -r1.331 src/usr.bin/xlint/lint1/cgram.y

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



CVS commit: src/lib/libm

2021-07-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Wed Jul 21 12:05:02 UTC 2021

Modified Files:
src/lib/libm: Makefile

Log Message:
libm: build fma(3), fmaf(3), fmal(3) on alpha

Alpha has no hardware-assisted fused multiply-add, so the fallback
C implementation must be used. A basic smoke test shows the
implementation works for
"x * x - 1.0f" vs "fmaf(x, x, -1.0f)" with "volatile float x = 1.0008f;"


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/lib/libm/Makefile

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

Modified files:

Index: src/lib/libm/Makefile
diff -u src/lib/libm/Makefile:1.213 src/lib/libm/Makefile:1.214
--- src/lib/libm/Makefile:1.213	Sun Apr 25 23:43:20 2021
+++ src/lib/libm/Makefile	Wed Jul 21 12:05:02 2021
@@ -1,4 +1,4 @@
-#  $NetBSD: Makefile,v 1.213 2021/04/25 23:43:20 christos Exp $
+#  $NetBSD: Makefile,v 1.214 2021/07/21 12:05:02 tnn Exp $
 #
 #  @(#)Makefile 5.1beta 93/09/24
 #
@@ -71,6 +71,7 @@ COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 .PATH: ${.CURDIR}/arch/alpha
 ARCH_SRCS = s_copysign.S s_copysignf.S lrint.S
 COMMON_SRCS+= fenv.c
+COMMON_SRCS+= s_fma.c s_fmaf.c s_fmal.c
 COPTS+=	-mfloat-ieee -mieee-with-inexact -mfp-trap-mode=sui -mtrap-precision=i
 
 .elif (${LIBC_MACHINE_CPU} == "arm")



CVS commit: src/lib/libm

2021-07-21 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Wed Jul 21 12:05:02 UTC 2021

Modified Files:
src/lib/libm: Makefile

Log Message:
libm: build fma(3), fmaf(3), fmal(3) on alpha

Alpha has no hardware-assisted fused multiply-add, so the fallback
C implementation must be used. A basic smoke test shows the
implementation works for
"x * x - 1.0f" vs "fmaf(x, x, -1.0f)" with "volatile float x = 1.0008f;"


To generate a diff of this commit:
cvs rdiff -u -r1.213 -r1.214 src/lib/libm/Makefile

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



CVS commit: src/sys/sys

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 07:39:58 UTC 2021

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

Log Message:
Bump the version for ALTQ/CBQ changes

Welcome to 9.99.87


To generate a diff of this commit:
cvs rdiff -u -r1.698 -r1.699 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.698 src/sys/sys/param.h:1.699
--- src/sys/sys/param.h:1.698	Mon Jul 19 19:13:33 2021
+++ src/sys/sys/param.h	Wed Jul 21 07:39:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: param.h,v 1.698 2021/07/19 19:13:33 christos Exp $	*/
+/*	$NetBSD: param.h,v 1.699 2021/07/21 07:39:58 ozaki-r Exp $	*/
 
 /*-
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -67,7 +67,7 @@
  *	2.99.9		(299000900)
  */
 
-#define	__NetBSD_Version__	999008600	/* NetBSD 9.99.86 */
+#define	__NetBSD_Version__	999008700	/* NetBSD 9.99.87 */
 
 #define __NetBSD_Prereq__(M,m,p) (M) * 1) + \
 (m) * 100) + (p) * 100) <= __NetBSD_Version__)



CVS commit: src/sys/sys

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 07:39:58 UTC 2021

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

Log Message:
Bump the version for ALTQ/CBQ changes

Welcome to 9.99.87


To generate a diff of this commit:
cvs rdiff -u -r1.698 -r1.699 src/sys/sys/param.h

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



CVS commit: src/sys/altq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 07:34:44 UTC 2021

Modified Files:
src/sys/altq: altq_cbq.c altq_rmclass.c

Log Message:
altq: fix CBQ with RED and/or pf


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/altq/altq_cbq.c
cvs rdiff -u -r1.28 -r1.29 src/sys/altq/altq_rmclass.c

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



CVS commit: src/sys/altq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 07:34:44 UTC 2021

Modified Files:
src/sys/altq: altq_cbq.c altq_rmclass.c

Log Message:
altq: fix CBQ with RED and/or pf


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/altq/altq_cbq.c
cvs rdiff -u -r1.28 -r1.29 src/sys/altq/altq_rmclass.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/altq/altq_cbq.c
diff -u src/sys/altq/altq_cbq.c:1.35 src/sys/altq/altq_cbq.c:1.36
--- src/sys/altq/altq_cbq.c:1.35	Wed Jul 21 06:33:30 2021
+++ src/sys/altq/altq_cbq.c	Wed Jul 21 07:34:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_cbq.c,v 1.35 2021/07/21 06:33:30 ozaki-r Exp $	*/
+/*	$NetBSD: altq_cbq.c,v 1.36 2021/07/21 07:34:44 ozaki-r Exp $	*/
 /*	$KAME: altq_cbq.c,v 1.21 2005/04/13 03:44:24 suz Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.35 2021/07/21 06:33:30 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.36 2021/07/21 07:34:44 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq.h"
@@ -306,6 +306,7 @@ cbq_remove_altq(struct pf_altq *a)
 	return (0);
 }
 
+#define NSEC_TO_PSEC(s)	((uint64_t)(s) * 1000 * 1000)
 int
 cbq_add_queue(struct pf_altq *a)
 {
@@ -384,7 +385,7 @@ cbq_add_queue(struct pf_altq *a)
 	 */
 	if ((opts->flags & CBQCLF_ROOTCLASS) != 0) {
 		error = rmc_init(cbqp->ifnp.ifq_, >ifnp,
-		opts->ps_per_byte, cbqrestart, a->qlimit, RM_MAXQUEUED,
+		NSEC_TO_PSEC(opts->ns_per_byte), cbqrestart, a->qlimit, RM_MAXQUEUED,
 		opts->maxidle, opts->minidle, opts->offtime,
 		opts->flags);
 		if (error != 0)
@@ -392,7 +393,7 @@ cbq_add_queue(struct pf_altq *a)
 		cl = cbqp->ifnp.root_;
 	} else {
 		cl = rmc_newclass(a->priority,
-  >ifnp, opts->ps_per_byte,
+  >ifnp, NSEC_TO_PSEC(opts->ns_per_byte),
   rmc_delay_action, a->qlimit, parent, borrow,
   opts->maxidle, opts->minidle, opts->offtime,
   opts->pktsize, opts->flags);

Index: src/sys/altq/altq_rmclass.c
diff -u src/sys/altq/altq_rmclass.c:1.28 src/sys/altq/altq_rmclass.c:1.29
--- src/sys/altq/altq_rmclass.c:1.28	Wed Jul 21 06:49:25 2021
+++ src/sys/altq/altq_rmclass.c	Wed Jul 21 07:34:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_rmclass.c,v 1.28 2021/07/21 06:49:25 ozaki-r Exp $	*/
+/*	$NetBSD: altq_rmclass.c,v 1.29 2021/07/21 07:34:44 ozaki-r Exp $	*/
 /*	$KAME: altq_rmclass.c,v 1.19 2005/04/13 03:44:25 suz Exp $	*/
 
 /*
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.28 2021/07/21 06:49:25 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.29 2021/07/21 07:34:44 ozaki-r Exp $");
 
 /* #ident "@(#)rm_class.c  1.48 97/12/05 SMI" */
 
@@ -287,7 +287,7 @@ rmc_newclass(int pri, struct rm_ifdat *i
 		if (flags & RMCF_CLEARDSCP)
 			red_flags |= RIOF_CLEARDSCP;
 #endif
-		red_pkttime = nsecPerByte * pktsize  / 1000;
+		red_pkttime = PSEC_TO_NSEC(psecPerByte) * pktsize  / 1000;
 
 		if (flags & RMCF_RED) {
 			cl->red_ = red_alloc(0, 0,



CVS commit: src/sys/altq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:49:26 UTC 2021

Modified Files:
src/sys/altq: altq_rmclass.c

Log Message:
altq, cbq: apply tweaks for PPP to only PPP interfaces


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/altq/altq_rmclass.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/altq/altq_rmclass.c
diff -u src/sys/altq/altq_rmclass.c:1.27 src/sys/altq/altq_rmclass.c:1.28
--- src/sys/altq/altq_rmclass.c:1.27	Wed Jul 21 06:47:33 2021
+++ src/sys/altq/altq_rmclass.c	Wed Jul 21 06:49:25 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_rmclass.c,v 1.27 2021/07/21 06:47:33 ozaki-r Exp $	*/
+/*	$NetBSD: altq_rmclass.c,v 1.28 2021/07/21 06:49:25 ozaki-r Exp $	*/
 /*	$KAME: altq_rmclass.c,v 1.19 2005/04/13 03:44:25 suz Exp $	*/
 
 /*
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.27 2021/07/21 06:47:33 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.28 2021/07/21 06:49:25 ozaki-r Exp $");
 
 /* #ident "@(#)rm_class.c  1.48 97/12/05 SMI" */
 
@@ -62,6 +62,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_rmclass
 #include 
 
 #include 
+#include 
 #ifdef ALTQ3_COMPAT
 #include 
 #include 
@@ -1291,32 +1292,32 @@ rmc_update_class_util(struct rm_ifdat *i
 #else
 	pkt_time = ifd->curlen_[ifd->qo_] * ifd->ns_per_byte_ / 1000;
 #endif
-#if 1 /* ALTQ4PPP */
-	if (TS_LT(nowp, >ifnow_)) {
-		int iftime;
+	if (ifd->ifq_->altq_ifp->if_type == IFT_PPP) {
+		if (TS_LT(nowp, >ifnow_)) {
+			int iftime;
 
-		/*
-		 * make sure the estimated completion time does not go
-		 * too far.  it can happen when the link layer supports
-		 * data compression or the interface speed is set to
-		 * a much lower value.
-		 */
-		TS_DELTA(>ifnow_, nowp, iftime);
-		if (iftime+pkt_time < ifd->maxiftime_) {
-			TS_ADD_DELTA(>ifnow_, pkt_time, >ifnow_);
+			/*
+			 * make sure the estimated completion time does not go
+			 * too far.  it can happen when the link layer supports
+			 * data compression or the interface speed is set to
+			 * a much lower value.
+			 */
+			TS_DELTA(>ifnow_, nowp, iftime);
+			if (iftime+pkt_time < ifd->maxiftime_) {
+TS_ADD_DELTA(>ifnow_, pkt_time, >ifnow_);
+			} else {
+TS_ADD_DELTA(nowp, ifd->maxiftime_, >ifnow_);
+			}
 		} else {
-			TS_ADD_DELTA(nowp, ifd->maxiftime_, >ifnow_);
+			TS_ADD_DELTA(nowp, pkt_time, >ifnow_);
 		}
 	} else {
-		TS_ADD_DELTA(nowp, pkt_time, >ifnow_);
-	}
-#else
-	if (TS_LT(nowp, >ifnow_)) {
-		TS_ADD_DELTA(>ifnow_, pkt_time, >ifnow_);
-	} else {
-		TS_ADD_DELTA(nowp, pkt_time, >ifnow_);
+		if (TS_LT(nowp, >ifnow_)) {
+			TS_ADD_DELTA(>ifnow_, pkt_time, >ifnow_);
+		} else {
+			TS_ADD_DELTA(nowp, pkt_time, >ifnow_);
+		}
 	}
-#endif
 
 	while (cl != NULL) {
 		TS_DELTA(>ifnow_, >last_, idle);



CVS commit: src/sys/altq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:49:26 UTC 2021

Modified Files:
src/sys/altq: altq_rmclass.c

Log Message:
altq, cbq: apply tweaks for PPP to only PPP interfaces


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/altq/altq_rmclass.c

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



CVS commit: src/usr.sbin/altq/altqstat

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:48:28 UTC 2021

Modified Files:
src/usr.sbin/altq/altqstat: qdisc_cbq.c

Log Message:
altqstat, cbq: follow uint64_t changes

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/altq/altqstat/qdisc_cbq.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/altq/altqstat/qdisc_cbq.c
diff -u src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.10 src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.11
--- src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.10	Wed Jul 21 06:45:10 2021
+++ src/usr.sbin/altq/altqstat/qdisc_cbq.c	Wed Jul 21 06:48:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: qdisc_cbq.c,v 1.10 2021/07/21 06:45:10 ozaki-r Exp $	*/
+/*	$NetBSD: qdisc_cbq.c,v 1.11 2021/07/21 06:48:28 ozaki-r Exp $	*/
 /*	$KAME: qdisc_cbq.c,v 1.7 2003/09/17 14:27:37 kjc Exp $	*/
 /*
  * Copyright (C) 1999-2000
@@ -105,9 +105,9 @@ cbq_stat_loop(int fd, const char *ifname
 
 			printf("\tpriority: %d depth: %d",
 			   sp->priority, sp->depth);
-			printf(" offtime: %ld [ns] wrr_allot: %d bytes\n",
+			printf(" offtime: %"PRIi64" [ns] wrr_allot: %d bytes\n",
 			   sp->offtime, sp->wrr_allot);
-			printf("\tpsPerByte: %ld", sp->ps_per_byte);
+			printf("\tpsPerByte: %"PRIu64, sp->ps_per_byte);
 			printf("\t(%sbps)", rate2str(flow_bps));
 			if (lp->handle != NULL_CLASS_HANDLE) {
 printf(",\tMeasured: %s [bps]\n",
@@ -139,7 +139,7 @@ cbq_stat_loop(int fd, const char *ifname
 			   sp->maxidle >> RM_FILTER_GAIN,
 			   sp->minidle / RM_POWER);
 #else
-			printf("\tAvgIdle: %ld [ns],\t(maxidle: %ld minidle: %ld [ns])\n",
+			printf("\tAvgIdle: %"PRIi64" [ns],\t(maxidle: %"PRIi64" minidle: %"PRIi64" [ns])\n",
 			   sp->avgidle, sp->maxidle, sp->minidle);
 #endif
 		}



CVS commit: src/usr.sbin/altq/altqstat

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:48:28 UTC 2021

Modified Files:
src/usr.sbin/altq/altqstat: qdisc_cbq.c

Log Message:
altqstat, cbq: follow uint64_t changes

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/altq/altqstat/qdisc_cbq.c

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



CVS commit: src/sys/altq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:47:33 UTC 2021

Modified Files:
src/sys/altq: altq_cbq.h altq_rmclass.c altq_rmclass.h

Log Message:
altq, cbq: change long to uint64_t for ILP32 archs

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/altq/altq_cbq.h
cvs rdiff -u -r1.26 -r1.27 src/sys/altq/altq_rmclass.c
cvs rdiff -u -r1.11 -r1.12 src/sys/altq/altq_rmclass.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/altq/altq_cbq.h
diff -u src/sys/altq/altq_cbq.h:1.10 src/sys/altq/altq_cbq.h:1.11
--- src/sys/altq/altq_cbq.h:1.10	Wed Jul 21 06:41:22 2021
+++ src/sys/altq/altq_cbq.h	Wed Jul 21 06:47:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_cbq.h,v 1.10 2021/07/21 06:41:22 ozaki-r Exp $	*/
+/*	$NetBSD: altq_cbq.h,v 1.11 2021/07/21 06:47:33 ozaki-r Exp $	*/
 /*	$KAME: altq_cbq.h,v 1.12 2003/10/03 05:05:15 kjc Exp $	*/
 
 /*
@@ -81,15 +81,15 @@ typedef struct _cbq_class_stats_ {
 
 	/* other static class parameters useful for debugging */
 	int		priority;
-	long		maxidle;
-	long		minidle;
-	long		offtime;
+	int64_t		maxidle;
+	int64_t		minidle;
+	int64_t		offtime;
 	int		qmax;
-	u_long		ps_per_byte;
+	uint64_t	ps_per_byte;
 	int		wrr_allot;
 
 	int		qcnt;		/* # packets in queue */
-	long		avgidle;
+	int64_t		avgidle;
 
 	/* red and rio related info */
 	int		qtype;
@@ -112,7 +112,7 @@ struct cbq_interface {
 
 typedef struct cbq_class_spec {
 	u_int		priority;
-	u_long		pico_sec_per_byte;
+	uint64_t	pico_sec_per_byte;
 	u_int		maxq;
 	u_int		maxidle;
 	int		minidle;

Index: src/sys/altq/altq_rmclass.c
diff -u src/sys/altq/altq_rmclass.c:1.26 src/sys/altq/altq_rmclass.c:1.27
--- src/sys/altq/altq_rmclass.c:1.26	Wed Jul 21 06:41:22 2021
+++ src/sys/altq/altq_rmclass.c	Wed Jul 21 06:47:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_rmclass.c,v 1.26 2021/07/21 06:41:22 ozaki-r Exp $	*/
+/*	$NetBSD: altq_rmclass.c,v 1.27 2021/07/21 06:47:33 ozaki-r Exp $	*/
 /*	$KAME: altq_rmclass.c,v 1.19 2005/04/13 03:44:25 suz Exp $	*/
 
 /*
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.26 2021/07/21 06:41:22 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.27 2021/07/21 06:47:33 ozaki-r Exp $");
 
 /* #ident "@(#)rm_class.c  1.48 97/12/05 SMI" */
 
@@ -194,7 +194,7 @@ static void	rmc_root_overlimit(struct rm
  * 	offtime = offtime * (8.0 / nsecPerByte);
  */
 struct rm_class *
-rmc_newclass(int pri, struct rm_ifdat *ifd, u_long psecPerByte,
+rmc_newclass(int pri, struct rm_ifdat *ifd, uint64_t psecPerByte,
 void (*action)(rm_class_t *, rm_class_t *), int maxq,
 struct rm_class *parent, struct rm_class *borrow, u_int maxidle,
 int minidle, u_int offtime, int pktsize, int flags)
@@ -253,18 +253,18 @@ rmc_newclass(int pri, struct rm_ifdat *i
 	cl->flags_ = flags;
 
 #if 1 /* minidle is also scaled in ALTQ */
-	cl->minidle_ = ((long)minidle * (long)psecPerByte) / 8;
+	cl->minidle_ = ((int64_t)minidle * (int64_t)psecPerByte) / 8;
 	if (cl->minidle_ > 0)
 		cl->minidle_ = 0;
 #else
 	cl->minidle_ = minidle;
 #endif
-	cl->maxidle_ = ((long)maxidle * (long)psecPerByte) / 8;
+	cl->maxidle_ = ((int64_t)maxidle * (int64_t)psecPerByte) / 8;
 	if (cl->maxidle_ == 0)
 		cl->maxidle_ = 1;
 #if 1 /* offtime is also scaled in ALTQ */
 	cl->avgidle_ = cl->maxidle_;
-	cl->offtime_ = (((long)offtime * (long)psecPerByte) / 8) >> RM_FILTER_GAIN;
+	cl->offtime_ = (((int64_t)offtime * (int64_t)psecPerByte) / 8) >> RM_FILTER_GAIN;
 	if (cl->offtime_ == 0)
 		cl->offtime_ = 1;
 #else
@@ -347,7 +347,7 @@ rmc_newclass(int pri, struct rm_ifdat *i
 }
 
 int
-rmc_modclass(struct rm_class *cl, u_long psecPerByte, int maxq, u_int maxidle,
+rmc_modclass(struct rm_class *cl, uint64_t psecPerByte, int maxq, u_int maxidle,
 int minidle, u_int offtime, int pktsize)
 {
 	struct rm_ifdat	*ifd;
@@ -365,18 +365,18 @@ rmc_modclass(struct rm_class *cl, u_long
 	qlimit(cl->q_) = maxq;
 
 #if 1 /* minidle is also scaled in ALTQ */
-	cl->minidle_ = ((long)minidle * (long)psecPerByte) / 8;
+	cl->minidle_ = ((int64_t)minidle * (int64_t)psecPerByte) / 8;
 	if (cl->minidle_ > 0)
 		cl->minidle_ = 0;
 #else
 	cl->minidle_ = minidle;
 #endif
-	cl->maxidle_ = ((long)maxidle * (long)psecPerByte) / 8;
+	cl->maxidle_ = ((int64_t)maxidle * (int64_t)psecPerByte) / 8;
 	if (cl->maxidle_ == 0)
 		cl->maxidle_ = 1;
 #if 1 /* offtime is also scaled in ALTQ */
 	cl->avgidle_ = cl->maxidle_;
-	cl->offtime_ = (((long)offtime * (long)psecPerByte) / 8) >> RM_FILTER_GAIN;
+	cl->offtime_ = (((int64_t)offtime * (int64_t)psecPerByte) / 8) >> RM_FILTER_GAIN;
 	if (cl->offtime_ == 0)
 		cl->offtime_ = 1;
 #else
@@ -661,7 +661,7 @@ rmc_delete_class(struct rm_ifdat *ifd, s
  */
 
 int
-rmc_init(struct ifaltq *ifq, struct rm_ifdat *ifd, u_long psecPerByte,
+rmc_init(struct ifaltq *ifq, struct rm_ifdat *ifd, uint64_t psecPerByte,
 void (*restart)(struct ifaltq 

CVS commit: src/sys/altq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:47:33 UTC 2021

Modified Files:
src/sys/altq: altq_cbq.h altq_rmclass.c altq_rmclass.h

Log Message:
altq, cbq: change long to uint64_t for ILP32 archs

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/altq/altq_cbq.h
cvs rdiff -u -r1.26 -r1.27 src/sys/altq/altq_rmclass.c
cvs rdiff -u -r1.11 -r1.12 src/sys/altq/altq_rmclass.h

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



CVS commit: src/usr.sbin/altq/altqstat

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:45:10 UTC 2021

Modified Files:
src/usr.sbin/altq/altqstat: qdisc_cbq.c

Log Message:
altqstat: follow changes of types of variables

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/altq/altqstat/qdisc_cbq.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/altq/altqstat/qdisc_cbq.c
diff -u src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.9 src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.10
--- src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.9	Wed Jul 21 06:42:07 2021
+++ src/usr.sbin/altq/altqstat/qdisc_cbq.c	Wed Jul 21 06:45:10 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: qdisc_cbq.c,v 1.9 2021/07/21 06:42:07 ozaki-r Exp $	*/
+/*	$NetBSD: qdisc_cbq.c,v 1.10 2021/07/21 06:45:10 ozaki-r Exp $	*/
 /*	$KAME: qdisc_cbq.c,v 1.7 2003/09/17 14:27:37 kjc Exp $	*/
 /*
  * Copyright (C) 1999-2000
@@ -105,7 +105,7 @@ cbq_stat_loop(int fd, const char *ifname
 
 			printf("\tpriority: %d depth: %d",
 			   sp->priority, sp->depth);
-			printf(" offtime: %d [us] wrr_allot: %d bytes\n",
+			printf(" offtime: %ld [ns] wrr_allot: %d bytes\n",
 			   sp->offtime, sp->wrr_allot);
 			printf("\tpsPerByte: %ld", sp->ps_per_byte);
 			printf("\t(%sbps)", rate2str(flow_bps));
@@ -139,7 +139,7 @@ cbq_stat_loop(int fd, const char *ifname
 			   sp->maxidle >> RM_FILTER_GAIN,
 			   sp->minidle / RM_POWER);
 #else
-			printf("\tAvgIdle: %d [us],\t(maxidle: %d minidle: %d [us])\n",
+			printf("\tAvgIdle: %ld [ns],\t(maxidle: %ld minidle: %ld [ns])\n",
 			   sp->avgidle, sp->maxidle, sp->minidle);
 #endif
 		}



CVS commit: src/usr.sbin/altq/altqstat

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:45:10 UTC 2021

Modified Files:
src/usr.sbin/altq/altqstat: qdisc_cbq.c

Log Message:
altqstat: follow changes of types of variables

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/altq/altqstat/qdisc_cbq.c

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



CVS commit: src/usr.sbin/altq/altqstat

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:42:07 UTC 2021

Modified Files:
src/usr.sbin/altq/altqstat: qdisc_cbq.c

Log Message:
altqstat: show raw values of avgidle, maxidle and minidle

The values are sometimes small and cooked values of them can be less
informative such as 0 or -1.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/altq/altqstat/qdisc_cbq.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/altq/altqstat/qdisc_cbq.c
diff -u src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.8 src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.9
--- src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.8	Wed Jul 21 06:38:57 2021
+++ src/usr.sbin/altq/altqstat/qdisc_cbq.c	Wed Jul 21 06:42:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: qdisc_cbq.c,v 1.8 2021/07/21 06:38:57 ozaki-r Exp $	*/
+/*	$NetBSD: qdisc_cbq.c,v 1.9 2021/07/21 06:42:07 ozaki-r Exp $	*/
 /*	$KAME: qdisc_cbq.c,v 1.7 2003/09/17 14:27:37 kjc Exp $	*/
 /*
  * Copyright (C) 1999-2000
@@ -133,10 +133,15 @@ cbq_stat_loop(int fd, const char *ifname
 
 			printf("\tQCount: %d,\t(qmax: %d)\n",
 			   sp->qcnt, sp->qmax);
+#if 0
 			printf("\tAvgIdle: %d [us],\t(maxidle: %d minidle: %d [us])\n",
 			   sp->avgidle >> RM_FILTER_GAIN,
 			   sp->maxidle >> RM_FILTER_GAIN,
 			   sp->minidle / RM_POWER);
+#else
+			printf("\tAvgIdle: %d [us],\t(maxidle: %d minidle: %d [us])\n",
+			   sp->avgidle, sp->maxidle, sp->minidle);
+#endif
 		}
 
 		/* swap the buffer pointers */



CVS commit: src/usr.sbin/altq/altqstat

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:42:07 UTC 2021

Modified Files:
src/usr.sbin/altq/altqstat: qdisc_cbq.c

Log Message:
altqstat: show raw values of avgidle, maxidle and minidle

The values are sometimes small and cooked values of them can be less
informative such as 0 or -1.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/altq/altqstat/qdisc_cbq.c

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



CVS commit: src/sys/altq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:41:22 UTC 2021

Modified Files:
src/sys/altq: altq_cbq.h altq_rmclass.c altq_rmclass.h

Log Message:
altq, cbq: treat time in nanoseconds

Time granularity in microseconds is sometimes not enough to provide
accurate bandwidth control; actual bandwidth on a capped class
can exceed its limit considerably in some cases.

Treating time in nanoseconds requires the following changes:
- Use timespec instead of timeval
- Use nanotime(9) instead of microtime(9)
- Change the type of some variables, especially *idle, to long


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/altq/altq_cbq.h
cvs rdiff -u -r1.25 -r1.26 src/sys/altq/altq_rmclass.c
cvs rdiff -u -r1.10 -r1.11 src/sys/altq/altq_rmclass.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/altq/altq_cbq.h
diff -u src/sys/altq/altq_cbq.h:1.9 src/sys/altq/altq_cbq.h:1.10
--- src/sys/altq/altq_cbq.h:1.9	Wed Jul 21 06:33:30 2021
+++ src/sys/altq/altq_cbq.h	Wed Jul 21 06:41:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_cbq.h,v 1.9 2021/07/21 06:33:30 ozaki-r Exp $	*/
+/*	$NetBSD: altq_cbq.h,v 1.10 2021/07/21 06:41:22 ozaki-r Exp $	*/
 /*	$KAME: altq_cbq.h,v 1.12 2003/10/03 05:05:15 kjc Exp $	*/
 
 /*
@@ -81,15 +81,15 @@ typedef struct _cbq_class_stats_ {
 
 	/* other static class parameters useful for debugging */
 	int		priority;
-	int		maxidle;
-	int		minidle;
-	int		offtime;
+	long		maxidle;
+	long		minidle;
+	long		offtime;
 	int		qmax;
 	u_long		ps_per_byte;
 	int		wrr_allot;
 
 	int		qcnt;		/* # packets in queue */
-	int		avgidle;
+	long		avgidle;
 
 	/* red and rio related info */
 	int		qtype;

Index: src/sys/altq/altq_rmclass.c
diff -u src/sys/altq/altq_rmclass.c:1.25 src/sys/altq/altq_rmclass.c:1.26
--- src/sys/altq/altq_rmclass.c:1.25	Wed Jul 21 06:33:30 2021
+++ src/sys/altq/altq_rmclass.c	Wed Jul 21 06:41:22 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_rmclass.c,v 1.25 2021/07/21 06:33:30 ozaki-r Exp $	*/
+/*	$NetBSD: altq_rmclass.c,v 1.26 2021/07/21 06:41:22 ozaki-r Exp $	*/
 /*	$KAME: altq_rmclass.c,v 1.19 2005/04/13 03:44:25 suz Exp $	*/
 
 /*
@@ -38,7 +38,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.25 2021/07/21 06:33:30 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_rmclass.c,v 1.26 2021/07/21 06:41:22 ozaki-r Exp $");
 
 /* #ident "@(#)rm_class.c  1.48 97/12/05 SMI" */
 
@@ -86,7 +86,7 @@ __KERNEL_RCSID(0, "$NetBSD: altq_rmclass
  * Local routines.
  */
 
-static int	rmc_satisfied(struct rm_class *, struct timeval *);
+static int	rmc_satisfied(struct rm_class *, struct timespec *);
 static void	rmc_wrr_set_weights(struct rm_ifdat *);
 static void	rmc_depth_compute(struct rm_class *);
 static void	rmc_depth_recompute(rm_class_t *);
@@ -99,8 +99,8 @@ static void	_rmc_dropq(rm_class_t *);
 static mbuf_t	*_rmc_getq(rm_class_t *);
 static mbuf_t	*_rmc_pollq(rm_class_t *);
 
-static int	rmc_under_limit(struct rm_class *, struct timeval *);
-static void	rmc_tl_satisfied(struct rm_ifdat *, struct timeval *);
+static int	rmc_under_limit(struct rm_class *, struct timespec *);
+static void	rmc_tl_satisfied(struct rm_ifdat *, struct timespec *);
 static void	rmc_drop_action(struct rm_class *);
 static void	rmc_restart(struct rm_class *);
 static void	rmc_root_overlimit(struct rm_class *, struct rm_class *);
@@ -253,18 +253,18 @@ rmc_newclass(int pri, struct rm_ifdat *i
 	cl->flags_ = flags;
 
 #if 1 /* minidle is also scaled in ALTQ */
-	cl->minidle_ = (minidle * (int)PSEC_TO_NSEC(psecPerByte)) / 8;
+	cl->minidle_ = ((long)minidle * (long)psecPerByte) / 8;
 	if (cl->minidle_ > 0)
 		cl->minidle_ = 0;
 #else
 	cl->minidle_ = minidle;
 #endif
-	cl->maxidle_ = (maxidle * PSEC_TO_NSEC(psecPerByte)) / 8;
+	cl->maxidle_ = ((long)maxidle * (long)psecPerByte) / 8;
 	if (cl->maxidle_ == 0)
 		cl->maxidle_ = 1;
 #if 1 /* offtime is also scaled in ALTQ */
 	cl->avgidle_ = cl->maxidle_;
-	cl->offtime_ = ((offtime * PSEC_TO_NSEC(psecPerByte)) / 8) >> RM_FILTER_GAIN;
+	cl->offtime_ = (((long)offtime * (long)psecPerByte) / 8) >> RM_FILTER_GAIN;
 	if (cl->offtime_ == 0)
 		cl->offtime_ = 1;
 #else
@@ -365,18 +365,18 @@ rmc_modclass(struct rm_class *cl, u_long
 	qlimit(cl->q_) = maxq;
 
 #if 1 /* minidle is also scaled in ALTQ */
-	cl->minidle_ = (minidle * PSEC_TO_NSEC(psecPerByte)) / 8;
+	cl->minidle_ = ((long)minidle * (long)psecPerByte) / 8;
 	if (cl->minidle_ > 0)
 		cl->minidle_ = 0;
 #else
 	cl->minidle_ = minidle;
 #endif
-	cl->maxidle_ = (maxidle * PSEC_TO_NSEC(psecPerByte)) / 8;
+	cl->maxidle_ = ((long)maxidle * (long)psecPerByte) / 8;
 	if (cl->maxidle_ == 0)
 		cl->maxidle_ = 1;
 #if 1 /* offtime is also scaled in ALTQ */
 	cl->avgidle_ = cl->maxidle_;
-	cl->offtime_ = ((offtime * PSEC_TO_NSEC(psecPerByte)) / 8) >> RM_FILTER_GAIN;
+	cl->offtime_ = (((long)offtime * (long)psecPerByte) / 8) >> RM_FILTER_GAIN;
 	if (cl->offtime_ == 0)
 		

CVS commit: src/sys/altq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:41:22 UTC 2021

Modified Files:
src/sys/altq: altq_cbq.h altq_rmclass.c altq_rmclass.h

Log Message:
altq, cbq: treat time in nanoseconds

Time granularity in microseconds is sometimes not enough to provide
accurate bandwidth control; actual bandwidth on a capped class
can exceed its limit considerably in some cases.

Treating time in nanoseconds requires the following changes:
- Use timespec instead of timeval
- Use nanotime(9) instead of microtime(9)
- Change the type of some variables, especially *idle, to long


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/altq/altq_cbq.h
cvs rdiff -u -r1.25 -r1.26 src/sys/altq/altq_rmclass.c
cvs rdiff -u -r1.10 -r1.11 src/sys/altq/altq_rmclass.h

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



CVS commit: src/usr.sbin/altq/altqstat

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:38:57 UTC 2021

Modified Files:
src/usr.sbin/altq/altqstat: qdisc_cbq.c

Log Message:
altqstat: adopt ps_per_byte

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/altq/altqstat/qdisc_cbq.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/altq/altqstat/qdisc_cbq.c
diff -u src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.7 src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.8
--- src/usr.sbin/altq/altqstat/qdisc_cbq.c:1.7	Sat Oct 28 11:43:02 2006
+++ src/usr.sbin/altq/altqstat/qdisc_cbq.c	Wed Jul 21 06:38:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: qdisc_cbq.c,v 1.7 2006/10/28 11:43:02 peter Exp $	*/
+/*	$NetBSD: qdisc_cbq.c,v 1.8 2021/07/21 06:38:57 ozaki-r Exp $	*/
 /*	$KAME: qdisc_cbq.c,v 1.7 2003/09/17 14:27:37 kjc Exp $	*/
 /*
  * Copyright (C) 1999-2000
@@ -100,14 +100,14 @@ cbq_stat_loop(int fd, const char *ifname
 			printf("Class %d on Interface %s: %s\n",
 			sp->handle, ifname, clnames[i]);
 
-			flow_bps = 8.0 / (double)sp->ns_per_byte
-			* 1000*1000*1000;
+			flow_bps = 8.0 / (double)sp->ps_per_byte
+			* 1000*1000*1000*1000;
 
 			printf("\tpriority: %d depth: %d",
 			   sp->priority, sp->depth);
 			printf(" offtime: %d [us] wrr_allot: %d bytes\n",
 			   sp->offtime, sp->wrr_allot);
-			printf("\tnsPerByte: %d", sp->ns_per_byte);
+			printf("\tpsPerByte: %ld", sp->ps_per_byte);
 			printf("\t(%sbps)", rate2str(flow_bps));
 			if (lp->handle != NULL_CLASS_HANDLE) {
 printf(",\tMeasured: %s [bps]\n",



CVS commit: src/usr.sbin/altq/altqstat

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:38:57 UTC 2021

Modified Files:
src/usr.sbin/altq/altqstat: qdisc_cbq.c

Log Message:
altqstat: adopt ps_per_byte

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/usr.sbin/altq/altqstat/qdisc_cbq.c

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



CVS commit: src/usr.sbin/altq/libaltq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:36:33 UTC 2021

Modified Files:
src/usr.sbin/altq/libaltq: qop_cbq.c qop_cbq.h

Log Message:
libaltq, cbq: convert ns_per_byte to ps_per_byte

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/altq/libaltq/qop_cbq.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/altq/libaltq/qop_cbq.h

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/altq/libaltq/qop_cbq.c
diff -u src/usr.sbin/altq/libaltq/qop_cbq.c:1.11 src/usr.sbin/altq/libaltq/qop_cbq.c:1.12
--- src/usr.sbin/altq/libaltq/qop_cbq.c:1.11	Wed Jul 14 08:32:13 2021
+++ src/usr.sbin/altq/libaltq/qop_cbq.c	Wed Jul 21 06:36:33 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: qop_cbq.c,v 1.11 2021/07/14 08:32:13 ozaki-r Exp $	*/
+/*	$NetBSD: qop_cbq.c,v 1.12 2021/07/21 06:36:33 ozaki-r Exp $	*/
 /*	$KAME: qop_cbq.c,v 1.7 2002/05/31 06:03:35 kjc Exp $	*/
 /*
  * Copyright (c) Sun Microsystems, Inc. 1993-1998 All rights reserved.
@@ -78,8 +78,12 @@ static int cbq_delete_filter(struct fltr
 #define CTL_PBANDWIDTH	2
 #define NS_PER_MS	(100.0)
 #define NS_PER_SEC	(NS_PER_MS*1000.0)
+#define PS_PER_MS	(10.0)
+#define PS_PER_SEC	(PS_PER_MS*1000.0)
 #define RM_FILTER_GAIN	5
 
+#define PSEC_TO_USEC(ps)	((ps) / 1000.0 / 1000.0)
+
 #define CBQ_DEVICE	"/dev/altq/cbq"
 
 static int cbq_fd = -1;
@@ -484,8 +488,8 @@ qop_cbq_add_if(struct ifinfo **rp, const
 	if ((cbq_ifinfo = calloc(1, sizeof(*cbq_ifinfo))) == NULL)
 		return (QOPERR_NOMEM);
 
-	cbq_ifinfo->nsPerByte =
-		(1.0 / (double)bandwidth) * NS_PER_SEC * 8;
+	cbq_ifinfo->psPerByte =
+		(1.0 / (double)bandwidth) * PS_PER_SEC * 8;
 	cbq_ifinfo->is_wrr = is_wrr;
 	cbq_ifinfo->is_efficient = efficient;
 	cbq_ifinfo->no_control = no_control;
@@ -768,7 +772,7 @@ cbq_class_spec(struct ifinfo *ifinfo, u_
 {
 	struct cbq_ifinfo *cbq_ifinfo = ifinfo->private;
 	double  maxq, maxidle_s, maxidle, minidle,
-			lofftime, nsPerByte, ptime, cptime;
+			lofftime, psPerByte, ptime, cptime;
 	double		z = (double)(1 << RM_FILTER_GAIN);
 	double  g = (1.0 - 1.0 / z);
 	double  f;
@@ -792,22 +796,12 @@ cbq_class_spec(struct ifinfo *ifinfo, u_
 	else if (max_pkt_size > ifinfo->ifmtu)
 		max_pkt_size = ifinfo->ifmtu;
 
-nsPerByte = cbq_ifinfo->nsPerByte / f;
-	ptime = (double) av_pkt_size * (double)cbq_ifinfo->nsPerByte;
+psPerByte = cbq_ifinfo->psPerByte / f;
+	ptime = (double) av_pkt_size * (double)cbq_ifinfo->psPerByte;
 	cptime = ptime * (1.0 - f) / f;
-#if 1 /* ALTQ */
-	if (nsPerByte * (double)max_pkt_size > (double)INT_MAX) {
-		/*
-		 * this causes integer overflow in kernel!
-		 * (bandwidth < 6Kbps when max_pkt_size=1500)
-		 */
-		if (bandwidth != 0)
-			LOG(LOG_WARNING, 0, "warning: class is too slow!!");
-		nsPerByte = (double)(INT_MAX / max_pkt_size);
-	}
-#endif
+
 	if (maxburst == 0) {  /* use default */
-		if (cptime > 10.0 * NS_PER_MS)
+		if (cptime > 10.0 * PS_PER_MS)
 			maxburst = 4;
 		else
 			maxburst = 16;
@@ -823,9 +817,9 @@ cbq_class_spec(struct ifinfo *ifinfo, u_
 		"cbq_flowspec: maxburst=%d,minburst=%d,pkt_size=%d",
 		maxburst, minburst, av_pkt_size);
 		LOG(LOG_DEBUG, 0,
-		"  nsPerByte=%.2f ns, link's nsPerByte=%.2f, f=%.3f",
-		nsPerByte, cbq_ifinfo->nsPerByte, f);
-		packet_time = av_pkt_size * (int)nsPerByte / 1000;
+		"  psPerByte=%.2f ps, link's psPerByte=%.2f, f=%.3f",
+		psPerByte, cbq_ifinfo->psPerByte, f);
+		packet_time = av_pkt_size * (int)PSEC_TO_USEC(psPerByte);
 		LOG(LOG_DEBUG, 0,
 		"  packet time=%d [us]\n", packet_time);
 		if (maxburst * packet_time < 2) {
@@ -845,21 +839,21 @@ cbq_class_spec(struct ifinfo *ifinfo, u_
 	else
 		maxidle = ptime * maxidle_s;
 	if (IsDebug(DEBUG_ALTQ))
-		LOG(LOG_DEBUG, 0, "  maxidle=%.2f us", maxidle/1000.0);
+		LOG(LOG_DEBUG, 0, "  maxidle=%.2f us", PSEC_TO_USEC(maxidle));
 	if (minburst)
 		lofftime = cptime * (1.0 + 1.0/(1.0 - g) * (1.0 - gtom) / gtom);
 	else
 		lofftime = cptime;
-	minidle = -((double)max_pkt_size * (double)nsPerByte);
+	minidle = -((double)max_pkt_size * (double)psPerByte);
 	if (IsDebug(DEBUG_ALTQ))
 		LOG(LOG_DEBUG, 0, "  lofftime=%.2f us minidle=%.2f us",
-		lofftime/1000.0, minidle/1000.0);
+		PSEC_TO_USEC(lofftime), PSEC_TO_USEC(minidle));
 
-	maxidle = ((maxidle * 8.0) / nsPerByte) * pow(2, RM_FILTER_GAIN);
+	maxidle = ((maxidle * 8.0) / psPerByte) * pow(2, RM_FILTER_GAIN);
 #if 1 /* ALTQ */
 	/* also scale lofftime and minidle */
- 	lofftime = (lofftime * 8.0) / nsPerByte * pow(2, RM_FILTER_GAIN);
-	minidle = ((minidle * 8.0) / nsPerByte) * pow(2, RM_FILTER_GAIN);
+	lofftime = (lofftime * 8.0) / psPerByte * pow(2, RM_FILTER_GAIN);
+	minidle = ((minidle * 8.0) / psPerByte) * pow(2, RM_FILTER_GAIN);
 #endif
 	maxidle = maxidle / 1000.0;
 	lofftime = lofftime / 1000.0;
@@ -872,7 +866,7 @@ cbq_class_spec(struct ifinfo *ifinfo, u_
 		else
 			maxq = 

CVS commit: src/usr.sbin/altq/libaltq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:36:33 UTC 2021

Modified Files:
src/usr.sbin/altq/libaltq: qop_cbq.c qop_cbq.h

Log Message:
libaltq, cbq: convert ns_per_byte to ps_per_byte

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/usr.sbin/altq/libaltq/qop_cbq.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/altq/libaltq/qop_cbq.h

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



CVS commit: src/sys

2021-07-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jul 21 06:35:46 UTC 2021

Modified Files:
src/sys/compat/common: tty_60.c
src/sys/dev/audio: alaw.c audiobell.c linear.c mulaw.c
src/sys/dev/hid: hidkbdmap.c
src/sys/dev/usb: usbroothub.c
src/sys/kern: subr_cprng.c subr_psref.c sys_futex.c vfs_cache.c
src/sys/netatalk: at_print.c
src/sys/uvm: uvm_mmap.c
src/sys/uvm/pmap: pmap_pvt.c

Log Message:
need  for COHERENCY_UNIT

Minor KNF along the way.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/compat/common/tty_60.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/audio/alaw.c src/sys/dev/audio/linear.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/audio/audiobell.c \
src/sys/dev/audio/mulaw.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/hid/hidkbdmap.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/usb/usbroothub.c
cvs rdiff -u -r1.40 -r1.41 src/sys/kern/subr_cprng.c
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/subr_psref.c
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/sys_futex.c
cvs rdiff -u -r1.149 -r1.150 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.1 -r1.2 src/sys/netatalk/at_print.c
cvs rdiff -u -r1.175 -r1.176 src/sys/uvm/uvm_mmap.c
cvs rdiff -u -r1.10 -r1.11 src/sys/uvm/pmap/pmap_pvt.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/tty_60.c
diff -u src/sys/compat/common/tty_60.c:1.10 src/sys/compat/common/tty_60.c:1.11
--- src/sys/compat/common/tty_60.c:1.10	Wed Jun 24 17:47:52 2020
+++ src/sys/compat/common/tty_60.c	Wed Jul 21 06:35:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tty_60.c,v 1.10 2020/06/24 17:47:52 jdolecek Exp $	*/
+/*	$NetBSD: tty_60.c,v 1.11 2021/07/21 06:35:44 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,12 +30,13 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tty_60.c,v 1.10 2020/06/24 17:47:52 jdolecek Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tty_60.c,v 1.11 2021/07/21 06:35:44 skrll Exp $");
 
 #if defined(_KERNEL_OPT)
 #include "opt_compat_netbsd.h"
 #endif
 
+#include 
 #include 
 
 #include 

Index: src/sys/dev/audio/alaw.c
diff -u src/sys/dev/audio/alaw.c:1.3 src/sys/dev/audio/alaw.c:1.4
--- src/sys/dev/audio/alaw.c:1.3	Sat Jan 11 04:06:13 2020
+++ src/sys/dev/audio/alaw.c	Wed Jul 21 06:35:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: alaw.c,v 1.3 2020/01/11 04:06:13 isaki Exp $	*/
+/*	$NetBSD: alaw.c,v 1.4 2021/07/21 06:35:44 skrll Exp $	*/
 
 /*
  * Copyright (C) 2018 Tetsuya Isaki. All rights reserved.
@@ -26,8 +26,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: alaw.c,v 1.3 2020/01/11 04:06:13 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: alaw.c,v 1.4 2021/07/21 06:35:44 skrll Exp $");
 
+#include 
 #include 
 #include 
 #include 
Index: src/sys/dev/audio/linear.c
diff -u src/sys/dev/audio/linear.c:1.3 src/sys/dev/audio/linear.c:1.4
--- src/sys/dev/audio/linear.c:1.3	Sat Jan 11 04:06:13 2020
+++ src/sys/dev/audio/linear.c	Wed Jul 21 06:35:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linear.c,v 1.3 2020/01/11 04:06:13 isaki Exp $	*/
+/*	$NetBSD: linear.c,v 1.4 2021/07/21 06:35:44 skrll Exp $	*/
 
 /*
  * Copyright (C) 2017 Tetsuya Isaki. All rights reserved.
@@ -27,8 +27,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linear.c,v 1.3 2020/01/11 04:06:13 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linear.c,v 1.4 2021/07/21 06:35:44 skrll Exp $");
 
+#include 
 #include 
 #include 
 #include 

Index: src/sys/dev/audio/audiobell.c
diff -u src/sys/dev/audio/audiobell.c:1.4 src/sys/dev/audio/audiobell.c:1.5
--- src/sys/dev/audio/audiobell.c:1.4	Sat Mar 20 04:56:52 2021
+++ src/sys/dev/audio/audiobell.c	Wed Jul 21 06:35:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiobell.c,v 1.4 2021/03/20 04:56:52 isaki Exp $	*/
+/*	$NetBSD: audiobell.c,v 1.5 2021/07/21 06:35:44 skrll Exp $	*/
 
 /*
  * Copyright (c) 1999 Richard Earnshaw
@@ -30,9 +30,11 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include 
-__KERNEL_RCSID(0, "$NetBSD: audiobell.c,v 1.4 2021/03/20 04:56:52 isaki Exp $");
+#include 
+__KERNEL_RCSID(0, "$NetBSD: audiobell.c,v 1.5 2021/07/21 06:35:44 skrll Exp $");
 
+#include 
+#include 
 #include 
 #include 
 #include 
Index: src/sys/dev/audio/mulaw.c
diff -u src/sys/dev/audio/mulaw.c:1.4 src/sys/dev/audio/mulaw.c:1.5
--- src/sys/dev/audio/mulaw.c:1.4	Sat Sep 12 06:09:16 2020
+++ src/sys/dev/audio/mulaw.c	Wed Jul 21 06:35:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: mulaw.c,v 1.4 2020/09/12 06:09:16 isaki Exp $	*/
+/*	$NetBSD: mulaw.c,v 1.5 2021/07/21 06:35:44 skrll Exp $	*/
 
 /*
  * Copyright (C) 2017 Tetsuya Isaki. All rights reserved.
@@ -27,8 +27,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: mulaw.c,v 1.4 2020/09/12 06:09:16 isaki Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mulaw.c,v 1.5 2021/07/21 06:35:44 skrll Exp $");
 
+#include 
 #include 
 #include 
 #include 

Index: src/sys/dev/hid/hidkbdmap.c
diff -u src/sys/dev/hid/hidkbdmap.c:1.13 

CVS commit: src/sys

2021-07-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jul 21 06:35:46 UTC 2021

Modified Files:
src/sys/compat/common: tty_60.c
src/sys/dev/audio: alaw.c audiobell.c linear.c mulaw.c
src/sys/dev/hid: hidkbdmap.c
src/sys/dev/usb: usbroothub.c
src/sys/kern: subr_cprng.c subr_psref.c sys_futex.c vfs_cache.c
src/sys/netatalk: at_print.c
src/sys/uvm: uvm_mmap.c
src/sys/uvm/pmap: pmap_pvt.c

Log Message:
need  for COHERENCY_UNIT

Minor KNF along the way.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/compat/common/tty_60.c
cvs rdiff -u -r1.3 -r1.4 src/sys/dev/audio/alaw.c src/sys/dev/audio/linear.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/audio/audiobell.c \
src/sys/dev/audio/mulaw.c
cvs rdiff -u -r1.13 -r1.14 src/sys/dev/hid/hidkbdmap.c
cvs rdiff -u -r1.9 -r1.10 src/sys/dev/usb/usbroothub.c
cvs rdiff -u -r1.40 -r1.41 src/sys/kern/subr_cprng.c
cvs rdiff -u -r1.14 -r1.15 src/sys/kern/subr_psref.c
cvs rdiff -u -r1.11 -r1.12 src/sys/kern/sys_futex.c
cvs rdiff -u -r1.149 -r1.150 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.1 -r1.2 src/sys/netatalk/at_print.c
cvs rdiff -u -r1.175 -r1.176 src/sys/uvm/uvm_mmap.c
cvs rdiff -u -r1.10 -r1.11 src/sys/uvm/pmap/pmap_pvt.c

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



CVS commit: src/sys/external/bsd/drm2/linux

2021-07-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jul 21 06:34:52 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/linux: linux_rcu.c

Log Message:
need  for COHERENCY_UNIT


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/linux/linux_rcu.c

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



CVS commit: src/sys/external/bsd/drm2/linux

2021-07-21 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Jul 21 06:34:52 UTC 2021

Modified Files:
src/sys/external/bsd/drm2/linux: linux_rcu.c

Log Message:
need  for COHERENCY_UNIT


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/external/bsd/drm2/linux/linux_rcu.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/external/bsd/drm2/linux/linux_rcu.c
diff -u src/sys/external/bsd/drm2/linux/linux_rcu.c:1.4 src/sys/external/bsd/drm2/linux/linux_rcu.c:1.5
--- src/sys/external/bsd/drm2/linux/linux_rcu.c:1.4	Mon Aug 27 15:07:59 2018
+++ src/sys/external/bsd/drm2/linux/linux_rcu.c	Wed Jul 21 06:34:52 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: linux_rcu.c,v 1.4 2018/08/27 15:07:59 riastradh Exp $	*/
+/*	$NetBSD: linux_rcu.c,v 1.5 2021/07/21 06:34:52 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,8 +30,9 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: linux_rcu.c,v 1.4 2018/08/27 15:07:59 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: linux_rcu.c,v 1.5 2021/07/21 06:34:52 skrll Exp $");
 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/sys/altq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:33:30 UTC 2021

Modified Files:
src/sys/altq: altq_cbq.c altq_cbq.h altq_rmclass.c altq_rmclass.h

Log Message:
altq, cbq: convert ns_per_byte to ps_per_byte

Also the type of variables of it is changed to u_long from int.

This change provides fine-grain resolution of bandwidth.  For example
750 Mbps was treated as 800 Mbps internally because bandwidth was
represented as nanoseconds per byte.  Converting the representation
to picoseconds per byte enables to treat 750 Mbps as-is.

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/altq/altq_cbq.c
cvs rdiff -u -r1.8 -r1.9 src/sys/altq/altq_cbq.h
cvs rdiff -u -r1.24 -r1.25 src/sys/altq/altq_rmclass.c
cvs rdiff -u -r1.9 -r1.10 src/sys/altq/altq_rmclass.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/altq/altq_cbq.c
diff -u src/sys/altq/altq_cbq.c:1.34 src/sys/altq/altq_cbq.c:1.35
--- src/sys/altq/altq_cbq.c:1.34	Wed Jul 14 08:31:15 2021
+++ src/sys/altq/altq_cbq.c	Wed Jul 21 06:33:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_cbq.c,v 1.34 2021/07/14 08:31:15 ozaki-r Exp $	*/
+/*	$NetBSD: altq_cbq.c,v 1.35 2021/07/21 06:33:30 ozaki-r Exp $	*/
 /*	$KAME: altq_cbq.c,v 1.21 2005/04/13 03:44:24 suz Exp $	*/
 
 /*
@@ -32,7 +32,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.34 2021/07/14 08:31:15 ozaki-r Exp $");
+__KERNEL_RCSID(0, "$NetBSD: altq_cbq.c,v 1.35 2021/07/21 06:33:30 ozaki-r Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_altq.h"
@@ -226,7 +226,7 @@ get_class_stats(class_stats_t *statsp, s
 	statsp->minidle		= cl->minidle_;
 	statsp->offtime		= cl->offtime_;
 	statsp->qmax		= qlimit(cl->q_);
-	statsp->ns_per_byte	= cl->ns_per_byte_;
+	statsp->ps_per_byte	= cl->ps_per_byte_;
 	statsp->wrr_allot	= cl->w_allotment_;
 	statsp->qcnt		= qlen(cl->q_);
 	statsp->avgidle		= cl->avgidle_;
@@ -384,7 +384,7 @@ cbq_add_queue(struct pf_altq *a)
 	 */
 	if ((opts->flags & CBQCLF_ROOTCLASS) != 0) {
 		error = rmc_init(cbqp->ifnp.ifq_, >ifnp,
-		opts->ns_per_byte, cbqrestart, a->qlimit, RM_MAXQUEUED,
+		opts->ps_per_byte, cbqrestart, a->qlimit, RM_MAXQUEUED,
 		opts->maxidle, opts->minidle, opts->offtime,
 		opts->flags);
 		if (error != 0)
@@ -392,7 +392,7 @@ cbq_add_queue(struct pf_altq *a)
 		cl = cbqp->ifnp.root_;
 	} else {
 		cl = rmc_newclass(a->priority,
-  >ifnp, opts->ns_per_byte,
+  >ifnp, opts->ps_per_byte,
   rmc_delay_action, a->qlimit, parent, borrow,
   opts->maxidle, opts->minidle, opts->offtime,
   opts->pktsize, opts->flags);
@@ -681,7 +681,7 @@ cbq_modify_class(struct cbq_modify_class
 	if ((cl = clh_to_clp(cbqp, acp->cbq_class_handle)) == NULL)
 		return (EINVAL);
 
-	if (rmc_modclass(cl, acp->cbq_class.nano_sec_per_byte,
+	if (rmc_modclass(cl, acp->cbq_class.pico_sec_per_byte,
 			 acp->cbq_class.maxq, acp->cbq_class.maxidle,
 			 acp->cbq_class.minidle, acp->cbq_class.offtime,
 			 acp->cbq_class.pktsize) < 0)
@@ -724,7 +724,7 @@ cbq_class_create(cbq_state_t *cbqp, stru
 	 */
 	if ((spec->flags & CBQCLF_ROOTCLASS) != 0) {
 		error = rmc_init(cbqp->ifnp.ifq_, >ifnp,
-		spec->nano_sec_per_byte, cbqrestart, spec->maxq,
+		spec->pico_sec_per_byte, cbqrestart, spec->maxq,
 		RM_MAXQUEUED, spec->maxidle, spec->minidle, spec->offtime,
 		spec->flags);
 		if (error)
@@ -732,7 +732,7 @@ cbq_class_create(cbq_state_t *cbqp, stru
 		cl = cbqp->ifnp.root_;
 	} else {
 		cl = rmc_newclass(spec->priority,
-  >ifnp, spec->nano_sec_per_byte,
+  >ifnp, spec->pico_sec_per_byte,
   rmc_delay_action, spec->maxq, parent, borrow,
   spec->maxidle, spec->minidle, spec->offtime,
   spec->pktsize, spec->flags);

Index: src/sys/altq/altq_cbq.h
diff -u src/sys/altq/altq_cbq.h:1.8 src/sys/altq/altq_cbq.h:1.9
--- src/sys/altq/altq_cbq.h:1.8	Thu Oct 12 19:59:08 2006
+++ src/sys/altq/altq_cbq.h	Wed Jul 21 06:33:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_cbq.h,v 1.8 2006/10/12 19:59:08 peter Exp $	*/
+/*	$NetBSD: altq_cbq.h,v 1.9 2021/07/21 06:33:30 ozaki-r Exp $	*/
 /*	$KAME: altq_cbq.h,v 1.12 2003/10/03 05:05:15 kjc Exp $	*/
 
 /*
@@ -85,7 +85,7 @@ typedef struct _cbq_class_stats_ {
 	int		minidle;
 	int		offtime;
 	int		qmax;
-	int		ns_per_byte;
+	u_long		ps_per_byte;
 	int		wrr_allot;
 
 	int		qcnt;		/* # packets in queue */
@@ -112,7 +112,7 @@ struct cbq_interface {
 
 typedef struct cbq_class_spec {
 	u_int		priority;
-	u_int		nano_sec_per_byte;
+	u_long		pico_sec_per_byte;
 	u_int		maxq;
 	u_int		maxidle;
 	int		minidle;

Index: src/sys/altq/altq_rmclass.c
diff -u src/sys/altq/altq_rmclass.c:1.24 src/sys/altq/altq_rmclass.c:1.25
--- src/sys/altq/altq_rmclass.c:1.24	Tue Jul 13 08:23:39 2021
+++ src/sys/altq/altq_rmclass.c	Wed Jul 21 06:33:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: altq_rmclass.c,v 1.24 2021/07/13 08:23:39 ozaki-r Exp $	*/
+/*	$NetBSD: altq_rmclass.c,v 1.25 2021/07/21 

CVS commit: src/sys/altq

2021-07-21 Thread Ryota Ozaki
Module Name:src
Committed By:   ozaki-r
Date:   Wed Jul 21 06:33:30 UTC 2021

Modified Files:
src/sys/altq: altq_cbq.c altq_cbq.h altq_rmclass.c altq_rmclass.h

Log Message:
altq, cbq: convert ns_per_byte to ps_per_byte

Also the type of variables of it is changed to u_long from int.

This change provides fine-grain resolution of bandwidth.  For example
750 Mbps was treated as 800 Mbps internally because bandwidth was
represented as nanoseconds per byte.  Converting the representation
to picoseconds per byte enables to treat 750 Mbps as-is.

PR kern/56319


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/altq/altq_cbq.c
cvs rdiff -u -r1.8 -r1.9 src/sys/altq/altq_cbq.h
cvs rdiff -u -r1.24 -r1.25 src/sys/altq/altq_rmclass.c
cvs rdiff -u -r1.9 -r1.10 src/sys/altq/altq_rmclass.h

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



CVS commit: src/tests/dev/audio

2021-07-21 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed Jul 21 06:18:32 UTC 2021

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

Log Message:
Add AUDIO_SETINFO_gain_balance test.
The test checks whether AUDIO_SETINFO can change the gain and the balance
at the same time (if MD driver has the capability).  See PR kern/56308.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.13 src/tests/dev/audio/audiotest.c:1.14
--- src/tests/dev/audio/audiotest.c:1.13	Tue Oct 13 09:00:17 2020
+++ src/tests/dev/audio/audiotest.c	Wed Jul 21 06:18:32 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audiotest.c,v 1.13 2020/10/13 09:00:17 rin Exp $	*/
+/*	$NetBSD: audiotest.c,v 1.14 2021/07/21 06:18:32 isaki Exp $	*/
 
 /*
  * Copyright (C) 2019 Tetsuya Isaki. All rights reserved.
@@ -26,7 +26,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: audiotest.c,v 1.13 2020/10/13 09:00:17 rin Exp $");
+__RCSID("$NetBSD: audiotest.c,v 1.14 2021/07/21 06:18:32 isaki Exp $");
 
 #include 
 #include 
@@ -5573,6 +5573,294 @@ DEF(AUDIO_SETINFO_gain)
 	XP_SYS_EQ(0, r);
 }
 
+/*
+ * Look if there are any (non-zero) gain values that can be changed.
+ * If any gain can be set, it is set to gain[0].
+ * If another gain can be set, it is set to gain[1], otherwise gain[1] = -1.
+ * This is for AUDIO_SETINFO_gain_balance.
+ */
+static void
+get_changeable_gain(int fd, int *gain, const char *dir, int offset)
+{
+	struct audio_info ai;
+	int *ai_gain;
+	int hi;
+	int lo;
+	int r;
+
+	/* A hack to handle ai.{play,record}.gain in the same code.. */
+	ai_gain = (int *)(((char *)) + offset);
+
+	/* Try to set the maximum gain */
+	AUDIO_INITINFO();
+	*ai_gain = AUDIO_MAX_GAIN;
+	r = IOCTL(fd, AUDIO_SETINFO, , "%s.gain=%d", dir, *ai_gain);
+	XP_SYS_EQ(0, r);
+	/* Get again.  The value you set is not always used as is. */
+	AUDIO_INITINFO();
+	r = IOCTL(fd, AUDIO_GETINFO, , "");
+	XP_SYS_EQ(0, r);
+	hi = *ai_gain;
+
+	/* Look for next configurable value. */
+	for (lo = hi - 1; lo >= 0; lo--) {
+		AUDIO_INITINFO();
+		*ai_gain = lo;
+		r = IOCTL(fd, AUDIO_SETINFO, , "%s.gain=%d", dir, *ai_gain);
+		XP_SYS_EQ(0, r);
+		/* Get again */
+		r = IOCTL(fd, AUDIO_GETINFO, , "");
+		XP_SYS_EQ(0, r);
+		if (*ai_gain != hi) {
+			lo = *ai_gain;
+			break;
+		}
+	}
+
+	/* Now gain is lo(=gain[0]). */
+
+	/*
+	 * hi  lo
+	 * --- ---
+	 *  <0  <0  : not available.
+	 * >=0  <0  : available but not changeable.
+	 * >=0 >=0 (hi!=lo) : available and changeable.
+	 */
+	if (hi < 0) {
+		gain[0] = -1;
+		gain[1] = -1;
+		DPRINTF("  > %s.gain cannot be set\n", dir);
+	} else if (lo < 0) {
+		gain[0] = hi;
+		gain[1] = -1;
+		DPRINTF("  > %s.gain can only be set %d\n", dir, gain[0]);
+	} else {
+		gain[0] = lo;
+		gain[1] = hi;
+		DPRINTF("  > %s.gain can be set %d, %d\n",
+		dir, gain[0], gain[1]);
+	}
+}
+
+/*
+ * Look if there are any balance values that can be changed.
+ * If any balance value can be set, it is set to balance[0].
+ * If another balance value can be set, it is set to balance[1],
+ * otherwise balance[1] = -1.
+ * This is for AUDIO_SETINFO_gain_balance.
+ */
+static void
+get_changeable_balance(int fd, int *balance, const char *dir, int offset)
+{
+	struct audio_info ai;
+	u_char *ai_balance;
+	u_char left;
+	u_char right;
+	int r;
+
+	/* A hack to handle ai.{play,record}.balance in the same code.. */
+	ai_balance = ((u_char *)) + offset;
+
+	/* Look for the right side configurable value. */
+	AUDIO_INITINFO();
+	*ai_balance = AUDIO_RIGHT_BALANCE;
+	r = IOCTL(fd, AUDIO_SETINFO, , "%s.balance=%d", dir, *ai_balance);
+	XP_SYS_EQ(0, r);
+	/* Get again.  The value you set is not always used as is. */
+	r = IOCTL(fd, AUDIO_GETINFO, , "");
+	XP_SYS_EQ(0, r);
+	right = *ai_balance;
+
+	/* Look for the left side configurable value. */
+	AUDIO_INITINFO();
+	*ai_balance = AUDIO_LEFT_BALANCE;
+	r = IOCTL(fd, AUDIO_SETINFO, , "%s.balance=%d", dir, *ai_balance);
+	XP_SYS_EQ(0, r);
+	/* Get again */
+	r = IOCTL(fd, AUDIO_GETINFO, , "");
+	XP_SYS_EQ(0, r);
+	left = *ai_balance;
+
+	/* Now balance is the left(=balance[0]). */
+
+	if (left == right) {
+		/* The driver has no balance feature. */
+		balance[0] = left;
+		balance[1] = -1;
+		DPRINTF("  > %s.balance can only be set %d\n",
+		dir, balance[0]);
+	} else {
+		balance[0] = left;
+		balance[1] = right;
+		DPRINTF("  > %s.balance can be set %d, %d\n",
+		dir, balance[0], balance[1]);
+	}
+}
+
+/*
+ * Check whether gain and balance can be set at the same time.
+ * PR kern/56308
+ */
+DEF(AUDIO_SETINFO_gain_balance)
+{
+	struct audio_info oai;
+	struct audio_info ai;
+	int i;
+	int mode;
+	int fd;
+	int r;
+	int pgain[2];
+	int pbalance[2];
+	int rgain[2];
+	int rbalance[2];
+	bool ptest;
+	bool rtest;
+
+	TEST("AUDIO_SETINFO_gain_balance");
+
+	

CVS commit: src/tests/dev/audio

2021-07-21 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed Jul 21 06:18:32 UTC 2021

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

Log Message:
Add AUDIO_SETINFO_gain_balance test.
The test checks whether AUDIO_SETINFO can change the gain and the balance
at the same time (if MD driver has the capability).  See PR kern/56308.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.



CVS commit: src/sys/dev/audio

2021-07-21 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed Jul 21 06:14:58 UTC 2021

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

Log Message:
AUDIO_SETINFO: fix a bug that the gain and the balance could not be set
at the same time.  Fix PR kern/56308.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 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.104 src/sys/dev/audio/audio.c:1.105
--- src/sys/dev/audio/audio.c:1.104	Tue Jun  8 09:46:04 2021
+++ src/sys/dev/audio/audio.c	Wed Jul 21 06:14:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: audio.c,v 1.104 2021/06/08 09:46:04 riastradh Exp $	*/
+/*	$NetBSD: audio.c,v 1.105 2021/07/21 06:14:58 isaki Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -138,7 +138,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.104 2021/06/08 09:46:04 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: audio.c,v 1.105 2021/07/21 06:14:58 isaki Exp $");
 
 #ifdef _KERNEL_OPT
 #include "audio.h"
@@ -7418,59 +7418,46 @@ audio_hw_setinfo(struct audio_softc *sc,
 		}
 	}
 
-	/* Backup play.{gain,balance} */
+	/* play.{gain,balance} */
 	if (SPECIFIED(newpi->gain) || SPECIFIED_CH(newpi->balance)) {
 		au_get_gain(sc, >sc_outports, , );
 		if (oldai) {
 			oldpi->gain = pgain;
 			oldpi->balance = pbalance;
 		}
+
+		if (SPECIFIED(newpi->gain))
+			pgain = newpi->gain;
+		if (SPECIFIED_CH(newpi->balance))
+			pbalance = newpi->balance;
+		error = au_set_gain(sc, >sc_outports, pgain, pbalance);
+		if (error) {
+			audio_printf(sc,
+			"setting play.gain=%d/balance=%d failed: "
+			"errno=%d\n",
+			pgain, pbalance, error);
+			goto abort;
+		}
 	}
-	/* Backup record.{gain,balance} */
+
+	/* record.{gain,balance} */
 	if (SPECIFIED(newri->gain) || SPECIFIED_CH(newri->balance)) {
 		au_get_gain(sc, >sc_inports, , );
 		if (oldai) {
 			oldri->gain = rgain;
 			oldri->balance = rbalance;
 		}
-	}
-	if (SPECIFIED(newpi->gain)) {
-		error = au_set_gain(sc, >sc_outports,
-		newpi->gain, pbalance);
-		if (error) {
-			audio_printf(sc,
-			"setting play.gain=%d failed: errno=%d\n",
-			newpi->gain, error);
-			goto abort;
-		}
-	}
-	if (SPECIFIED(newri->gain)) {
-		error = au_set_gain(sc, >sc_inports,
-		newri->gain, rbalance);
-		if (error) {
-			audio_printf(sc,
-			"setting record.gain=%d failed: errno=%d\n",
-			newri->gain, error);
-			goto abort;
-		}
-	}
-	if (SPECIFIED_CH(newpi->balance)) {
-		error = au_set_gain(sc, >sc_outports,
-		pgain, newpi->balance);
-		if (error) {
-			audio_printf(sc,
-			"setting play.balance=%d failed: errno=%d\n",
-			newpi->balance, error);
-			goto abort;
-		}
-	}
-	if (SPECIFIED_CH(newri->balance)) {
-		error = au_set_gain(sc, >sc_inports,
-		rgain, newri->balance);
+
+		if (SPECIFIED(newri->gain))
+			rgain = newri->gain;
+		if (SPECIFIED_CH(newri->balance))
+			rbalance = newri->balance;
+		error = au_set_gain(sc, >sc_inports, rgain, rbalance);
 		if (error) {
 			audio_printf(sc,
-			"setting record.balance=%d failed: errno=%d\n",
-			newri->balance, error);
+			"setting record.gain=%d/balance=%d failed: "
+			"errno=%d\n",
+			rgain, rbalance, error);
 			goto abort;
 		}
 	}



CVS commit: src/sys/dev/audio

2021-07-21 Thread Tetsuya Isaki
Module Name:src
Committed By:   isaki
Date:   Wed Jul 21 06:14:58 UTC 2021

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

Log Message:
AUDIO_SETINFO: fix a bug that the gain and the balance could not be set
at the same time.  Fix PR kern/56308.


To generate a diff of this commit:
cvs rdiff -u -r1.104 -r1.105 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.