CVS commit: src/sys/arch/aarch64/aarch64

2021-10-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 21 06:06:16 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
fix gimplish


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/aarch64/aarch64/locore.S

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

Modified files:

Index: src/sys/arch/aarch64/aarch64/locore.S
diff -u src/sys/arch/aarch64/aarch64/locore.S:1.80 src/sys/arch/aarch64/aarch64/locore.S:1.81
--- src/sys/arch/aarch64/aarch64/locore.S:1.80	Thu Sep 30 21:19:16 2021
+++ src/sys/arch/aarch64/aarch64/locore.S	Thu Oct 21 06:06:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: locore.S,v 1.80 2021/09/30 21:19:16 skrll Exp $	*/
+/*	$NetBSD: locore.S,v 1.81 2021/10/21 06:06:16 skrll Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -38,7 +38,7 @@
 #include 
 #include "assym.h"
 
-RCSID("$NetBSD: locore.S,v 1.80 2021/09/30 21:19:16 skrll Exp $")
+RCSID("$NetBSD: locore.S,v 1.81 2021/10/21 06:06:16 skrll Exp $")
 
 #ifdef AARCH64_DEVICE_MEM_STRONGLY_ORDERED
 #define	MAIR_DEVICE_MEM		MAIR_DEVICE_nGnRnE
@@ -480,7 +480,7 @@ mp_vstart:
 	ldr	x0, [x0]
 	add	sp, sp, x0
 
-	/* stop using TTBR0 - CPU_DPRINT{,REG,SREG} no longer after this */
+	/* disable TTBR0 - CPU_DPRINT{,REG,SREG} no longer work after this */
 	mrs	x0, tcr_el1
 	orr	x0, x0, #TCR_EPD0
 	msr	tcr_el1, x0



CVS commit: src/sys/arch/aarch64/aarch64

2021-10-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 21 06:06:16 UTC 2021

Modified Files:
src/sys/arch/aarch64/aarch64: locore.S

Log Message:
fix gimplish


To generate a diff of this commit:
cvs rdiff -u -r1.80 -r1.81 src/sys/arch/aarch64/aarch64/locore.S

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



CVS commit: src/sys/dev/pci

2021-10-20 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Oct 21 05:37:43 UTC 2021

Modified Files:
src/sys/dev/pci: virtio.c virtio_pci.c virtiovar.h

Log Message:
virtio: reconfigure MSI-X vector on re-initialization

This may fix a problem that some interrupts, for example
link-state change of vioif(4) are not notified.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/pci/virtio_pci.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/virtiovar.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/pci

2021-10-20 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Oct 21 05:37:43 UTC 2021

Modified Files:
src/sys/dev/pci: virtio.c virtio_pci.c virtiovar.h

Log Message:
virtio: reconfigure MSI-X vector on re-initialization

This may fix a problem that some interrupts, for example
link-state change of vioif(4) are not notified.


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.31 -r1.32 src/sys/dev/pci/virtio_pci.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/pci/virtiovar.h

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

Modified files:

Index: src/sys/dev/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.50 src/sys/dev/pci/virtio.c:1.51
--- src/sys/dev/pci/virtio.c:1.50	Thu Oct 21 05:32:27 2021
+++ src/sys/dev/pci/virtio.c	Thu Oct 21 05:37:43 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.50 2021/10/21 05:32:27 yamaguchi Exp $	*/
+/*	$NetBSD: virtio.c,v 1.51 2021/10/21 05:37:43 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.50 2021/10/21 05:32:27 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.51 2021/10/21 05:37:43 yamaguchi Exp $");
 
 #include 
 #include 
@@ -93,7 +93,7 @@ virtio_reset(struct virtio_softc *sc)
 void
 virtio_reinit_start(struct virtio_softc *sc)
 {
-	int i;
+	int i, r;
 
 	virtio_set_status(sc, VIRTIO_CONFIG_DEVICE_STATUS_ACK);
 	virtio_set_status(sc, VIRTIO_CONFIG_DEVICE_STATUS_DRIVER);
@@ -112,6 +112,12 @@ virtio_reinit_start(struct virtio_softc 
 		sc->sc_ops->setup_queue(sc, vq->vq_index,
 		vq->vq_dmamap->dm_segs[0].ds_addr);
 	}
+
+	r = sc->sc_ops->setup_interrupts(sc, 1);
+	if (r != 0) {
+		printf("%s: failed to setup interrupts\n",
+		device_xname(sc->sc_dev));
+	}
 }
 
 void
@@ -1205,7 +1211,7 @@ virtio_child_attach_finish(struct virtio
 		goto fail;
 	}
 
-	r = sc->sc_ops->setup_interrupts(sc);
+	r = sc->sc_ops->setup_interrupts(sc, 0);
 	if (r != 0) {
 		aprint_error_dev(sc->sc_dev, "failed to setup interrupts\n");
 	}

Index: src/sys/dev/pci/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.31 src/sys/dev/pci/virtio_pci.c:1.32
--- src/sys/dev/pci/virtio_pci.c:1.31	Thu Oct 21 05:32:27 2021
+++ src/sys/dev/pci/virtio_pci.c	Thu Oct 21 05:37:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.31 2021/10/21 05:32:27 yamaguchi Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.32 2021/10/21 05:37:43 yamaguchi Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.31 2021/10/21 05:32:27 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.32 2021/10/21 05:37:43 yamaguchi Exp $");
 
 #include 
 #include 
@@ -112,8 +112,8 @@ static int	virtio_pci_adjust_config_regi
 static int	virtio_pci_intr(void *arg);
 static int	virtio_pci_msix_queue_intr(void *);
 static int	virtio_pci_msix_config_intr(void *);
-static int	virtio_pci_setup_interrupts_09(struct virtio_softc *);
-static int	virtio_pci_setup_interrupts_10(struct virtio_softc *);
+static int	virtio_pci_setup_interrupts_09(struct virtio_softc *, int);
+static int	virtio_pci_setup_interrupts_10(struct virtio_softc *, int);
 static int	virtio_pci_establish_msix_interrupts(struct virtio_softc *,
 		struct pci_attach_args *);
 static int	virtio_pci_establish_intx_interrupt(struct virtio_softc *,
@@ -805,7 +805,7 @@ virtio_pci_negotiate_features_10(struct 
  * -*/
 
 static int
-virtio_pci_setup_interrupts_10(struct virtio_softc *sc)
+virtio_pci_setup_interrupts_10(struct virtio_softc *sc, int reinit)
 {
 	struct virtio_pci_softc * const psc = (struct virtio_pci_softc *)sc;
 	device_t self  =  sc->sc_dev;
@@ -821,7 +821,10 @@ virtio_pci_setup_interrupts_10(struct vi
 		VIRTIO_CONFIG1_CONFIG_MSIX_VECTOR, vector);
 	ret = bus_space_read_2(iot, ioh, VIRTIO_CONFIG1_CONFIG_MSIX_VECTOR);
 	if (ret != vector) {
-		aprint_error_dev(self, "can't set config msix vector\n");
+		if (reinit == 0) {
+			aprint_error_dev(self,
+			"can't set config msix vector\n");
+		}
 		return -1;
 	}
 
@@ -836,8 +839,10 @@ virtio_pci_setup_interrupts_10(struct vi
 		ret = bus_space_read_2(iot, ioh,
 			VIRTIO_CONFIG1_QUEUE_MSIX_VECTOR);
 		if (ret != vector) {
-			aprint_error_dev(self, "can't set queue %d "
-"msix vector\n", qid);
+			if (reinit == 0) {
+aprint_error_dev(self, "can't set queue %d "
+"msix vector\n", qid);
+			}
 			return -1;
 		}
 	}
@@ -846,7 +851,7 @@ virtio_pci_setup_interrupts_10(struct vi
 }
 
 static int
-virtio_pci_setup_interrupts_09(struct virtio_softc *sc)
+virtio_pci_setup_interrupts_09(struct virtio_softc *sc, int reinit)
 {
 	struct virtio_pci_softc * const psc = (struct virtio_pci_softc *)sc;
 	device_t self = sc->sc_dev;
@@ -863,7 +868,10 @@ virtio_pci_setup_interrupts_09(struct vi
 	aprint_debug_dev(sc->sc_dev, "expected=

CVS commit: src/sys/dev/pci

2021-10-20 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Oct 21 05:32:27 UTC 2021

Modified Files:
src/sys/dev/pci: virtio.c virtio_pci.c virtiovar.h

Log Message:
divide setup routine of virtio interrupts
into establishment and device configuration


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/virtio_pci.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/virtiovar.h

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

Modified files:

Index: src/sys/dev/pci/virtio.c
diff -u src/sys/dev/pci/virtio.c:1.49 src/sys/dev/pci/virtio.c:1.50
--- src/sys/dev/pci/virtio.c:1.49	Sun Feb  7 09:29:53 2021
+++ src/sys/dev/pci/virtio.c	Thu Oct 21 05:32:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: virtio.c,v 1.49 2021/02/07 09:29:53 skrll Exp $	*/
+/*	$NetBSD: virtio.c,v 1.50 2021/10/21 05:32:27 yamaguchi Exp $	*/
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.49 2021/02/07 09:29:53 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio.c,v 1.50 2021/10/21 05:32:27 yamaguchi Exp $");
 
 #include 
 #include 
@@ -1199,10 +1199,15 @@ virtio_child_attach_finish(struct virtio
 	int r;
 
 	sc->sc_finished_called = true;
+	r = sc->sc_ops->alloc_interrupts(sc);
+	if (r != 0) {
+		aprint_error_dev(sc->sc_dev, "failed to allocate interrupts\n");
+		goto fail;
+	}
+
 	r = sc->sc_ops->setup_interrupts(sc);
 	if (r != 0) {
 		aprint_error_dev(sc->sc_dev, "failed to setup interrupts\n");
-		goto fail;
 	}
 
 	KASSERT(sc->sc_soft_ih == NULL);

Index: src/sys/dev/pci/virtio_pci.c
diff -u src/sys/dev/pci/virtio_pci.c:1.30 src/sys/dev/pci/virtio_pci.c:1.31
--- src/sys/dev/pci/virtio_pci.c:1.30	Sat Aug  7 16:19:14 2021
+++ src/sys/dev/pci/virtio_pci.c	Thu Oct 21 05:32:27 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: virtio_pci.c,v 1.30 2021/08/07 16:19:14 thorpej Exp $ */
+/* $NetBSD: virtio_pci.c,v 1.31 2021/10/21 05:32:27 yamaguchi Exp $ */
 
 /*
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.30 2021/08/07 16:19:14 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: virtio_pci.c,v 1.31 2021/10/21 05:32:27 yamaguchi Exp $");
 
 #include 
 #include 
@@ -106,18 +106,19 @@ static void	virtio_pci_set_status_10(str
 static void	virtio_pci_negotiate_features_10(struct virtio_softc *, uint64_t);
 static int	virtio_pci_find_cap(struct virtio_pci_softc *psc, int cfg_type, void *buf, int buflen);
 
-static int	virtio_pci_setup_interrupts(struct virtio_softc *);
+static int	virtio_pci_alloc_interrupts(struct virtio_softc *);
 static void	virtio_pci_free_interrupts(struct virtio_softc *);
 static int	virtio_pci_adjust_config_region(struct virtio_pci_softc *psc);
 static int	virtio_pci_intr(void *arg);
 static int	virtio_pci_msix_queue_intr(void *);
 static int	virtio_pci_msix_config_intr(void *);
-static int	virtio_pci_setup_msix_vectors_09(struct virtio_softc *);
-static int	virtio_pci_setup_msix_vectors_10(struct virtio_softc *);
-static int	virtio_pci_setup_msix_interrupts(struct virtio_softc *,
+static int	virtio_pci_setup_interrupts_09(struct virtio_softc *);
+static int	virtio_pci_setup_interrupts_10(struct virtio_softc *);
+static int	virtio_pci_establish_msix_interrupts(struct virtio_softc *,
 		struct pci_attach_args *);
-static int	virtio_pci_setup_intx_interrupt(struct virtio_softc *,
+static int	virtio_pci_establish_intx_interrupt(struct virtio_softc *,
 		struct pci_attach_args *);
+static bool	virtio_pci_msix_enabled(struct virtio_pci_softc *);
 
 #define VIRTIO_MSIX_CONFIG_VECTOR_INDEX	0
 #define VIRTIO_MSIX_QUEUE_VECTOR_INDEX	1
@@ -158,8 +159,9 @@ static const struct virtio_ops virtio_pc
 	.setup_queue = virtio_pci_setup_queue_09,
 	.set_status = virtio_pci_set_status_09,
 	.neg_features = virtio_pci_negotiate_features_09,
-	.setup_interrupts = virtio_pci_setup_interrupts,
+	.alloc_interrupts = virtio_pci_alloc_interrupts,
 	.free_interrupts = virtio_pci_free_interrupts,
+	.setup_interrupts = virtio_pci_setup_interrupts_09,
 };
 
 static const struct virtio_ops virtio_pci_ops_10 = {
@@ -168,8 +170,9 @@ static const struct virtio_ops virtio_pc
 	.setup_queue = virtio_pci_setup_queue_10,
 	.set_status = virtio_pci_set_status_10,
 	.neg_features = virtio_pci_negotiate_features_10,
-	.setup_interrupts = virtio_pci_setup_interrupts,
+	.alloc_interrupts = virtio_pci_alloc_interrupts,
 	.free_interrupts = virtio_pci_free_interrupts,
+	.setup_interrupts = virtio_pci_setup_interrupts_10,
 };
 
 static int
@@ -802,7 +805,7 @@ virtio_pci_negotiate_features_10(struct 
  * -*/
 
 static int
-virtio_pci_setup_msix_vectors_10(struct virtio_softc *sc)
+virtio_pci_setup_interrupts_10(struct virtio_softc *sc)
 {
 	struct virtio_pci_softc * const psc = (struct virtio_pci_softc *)sc;
 	device_t self  =  sc->sc

CVS commit: src/sys/dev/pci

2021-10-20 Thread Shoichi YAMAGUCHI
Module Name:src
Committed By:   yamaguchi
Date:   Thu Oct 21 05:32:27 UTC 2021

Modified Files:
src/sys/dev/pci: virtio.c virtio_pci.c virtiovar.h

Log Message:
divide setup routine of virtio interrupts
into establishment and device configuration


To generate a diff of this commit:
cvs rdiff -u -r1.49 -r1.50 src/sys/dev/pci/virtio.c
cvs rdiff -u -r1.30 -r1.31 src/sys/dev/pci/virtio_pci.c
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/pci/virtiovar.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/man4

2021-10-20 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Oct 21 04:51:11 UTC 2021

Modified Files:
src/share/man/man4: pms.4

Log Message:
Add documentation for the button_region_movement_enable variable.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/share/man/man4/pms.4

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/man4/pms.4
diff -u src/share/man/man4/pms.4:1.38 src/share/man/man4/pms.4:1.39
--- src/share/man/man4/pms.4:1.38	Thu Oct  1 17:13:19 2020
+++ src/share/man/man4/pms.4	Thu Oct 21 04:51:10 2021
@@ -1,4 +1,4 @@
-.\" $NetBSD: pms.4,v 1.38 2020/10/01 17:13:19 nia Exp $
+.\" $NetBSD: pms.4,v 1.39 2021/10/21 04:51:10 blymn Exp $
 .\"
 .\" Copyright (c) 1993 Christopher G. Demetriou
 .\" All rights reserved.
@@ -170,6 +170,17 @@ event (default 32 for x and y, 2 for z).
 .It Dv hw.synaptics.movement_threshold
 Movements of less than this value (in Synaptics coordinates) are
 ignored (default 4).
+.It Dv hw.synaptics.movement_enable
+This value determines whether or not the touchpad will respond to
+touch.
+If set to 1 then the touchpad will respond to touch, if set to 0
+will not respond effectively disabling the touchpad.
+.It Dv hw.synaptics.button_region_movement_enable
+This value determines if finger movement events will be reported for
+fingers that are located in the button emulation region defined by
+.Va hw.synaptics.button_boundary
+If set to 0 (the default) finger movements will not be reported.
+If set to 1 finger movements will be reported.
 .It Dv hw.synaptics.button_boundary
 Sets the top edge of the button emulation region on a clickpad.
 Since a clickpad only reports left clicks this region is used to emulate



CVS commit: src/share/man/man4

2021-10-20 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Oct 21 04:51:11 UTC 2021

Modified Files:
src/share/man/man4: pms.4

Log Message:
Add documentation for the button_region_movement_enable variable.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/share/man/man4/pms.4

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



CVS commit: src/sys/dev/pckbport

2021-10-20 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Oct 21 04:49:28 UTC 2021

Modified Files:
src/sys/dev/pckbport: synaptics.c synapticsvar.h

Log Message:
Significant update to the synaptics touchpad driver.

* Accumulate packets for primary, secondary, finger count packets
  before handing off to pms_synaptics_process_packet.  This means
  that both primary and, possibly, secondary finger locations will
  be processed at the same time.  Previously the processing each
  packet as it arrived.

* Fix the secondary finger position reporting, there was an off by
  one in the shifts when decoding which effectively halved the
  reported position.

* For a clickpad, make the emulated button region "dead" so that finger
  movements in this region are ignored.  This makes it easier to click
  a button without accidentally repositioning the cursor.  There is a
  sysctl variable "button_region_movement_enable" that will allow
  these finger movements to be reported if this is desirable.

* Reset the finger ballistics when the number of fingers changes.  This
  stops the annoying position jumps when a second finger touch is added
  to or removed from the touchpad.

* Add a level argument to the DPRINTF macro so one can choose their
  level of debug spam via the debug sysctl variable.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pckbport/synapticsvar.h

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

Modified files:

Index: src/sys/dev/pckbport/synaptics.c
diff -u src/sys/dev/pckbport/synaptics.c:1.72 src/sys/dev/pckbport/synaptics.c:1.73
--- src/sys/dev/pckbport/synaptics.c:1.72	Tue Sep 28 06:16:13 2021
+++ src/sys/dev/pckbport/synaptics.c	Thu Oct 21 04:49:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: synaptics.c,v 1.72 2021/09/28 06:16:13 nia Exp $	*/
+/*	$NetBSD: synaptics.c,v 1.73 2021/10/21 04:49:28 blymn Exp $	*/
 
 /*
  * Copyright (c) 2005, Steve C. Woodford
@@ -48,7 +48,7 @@
 #include "opt_pms.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.72 2021/09/28 06:16:13 nia Exp $");
+__KERNEL_RCSID(0, "$NetBSD: synaptics.c,v 1.73 2021/10/21 04:49:28 blymn Exp $");
 
 #include 
 #include 
@@ -79,11 +79,14 @@ struct synaptics_packet {
 	signed short	sp_x;	/* Unscaled absolute X/Y coordinates */
 	signed short	sp_y;
 	u_char	sp_z;		/* Z (pressure) */
+	signed short	sp_sx;	/* Unscaled absolute X/Y coordinates */
+	signed short	sp_sy;  /* for secondary finger */
+	u_char	sp_sz;		/* Z (pressure) */
 	u_char	sp_w;		/* W (contact patch width) */
-	signed short	sp_sx;	/* Secondary finger unscaled absolute */
-/* X/Y coordinates */
-	signed short	sp_xy;
-	u_char	sp_finger;	/* 0 for primary, 1 for secondary */
+	u_char  sp_primary;	/* seen primary finger packet */
+	u_char  sp_secondary;	/* seen secondary finger packet */
+	u_char	sp_finger_status; /* seen extended finger packet */
+	u_char	sp_finger_count; /* number of fingers seen */
 	char	sp_left;	/* Left mouse button status */
 	char	sp_right;	/* Right mouse button status */
 	char	sp_middle;	/* Middle button status (possibly emulated) */
@@ -121,12 +124,13 @@ static int synaptics_max_speed_y = 32;
 static int synaptics_max_speed_z = 2;
 static int synaptics_movement_threshold = 4;
 static int synaptics_movement_enable = 1;
+static int synaptics_button_region_movement = 1;
 static bool synaptics_aux_mid_button_scroll = TRUE;
 static int synaptics_debug = 0;
 
-#define	DPRINTF(SC, FMT, ARGS...) do	  \
+#define	DPRINTF(LEVEL, SC, FMT, ARGS...) do	  \
 {	  \
-	if (synaptics_debug) {		  \
+	if (synaptics_debug >= LEVEL) {		  \
 		struct pms_softc *_dprintf_psc =			  \
 		container_of((SC), struct pms_softc, u.synaptics);	  \
 		device_printf(_dprintf_psc->sc_dev, FMT, ##ARGS);	  \
@@ -157,8 +161,16 @@ static int synaptics_max_speed_y_nodenum
 static int synaptics_max_speed_z_nodenum;
 static int synaptics_movement_threshold_nodenum;
 static int synaptics_movement_enable_nodenum;
+static int synaptics_button_region_movement_nodenum;
 static int synaptics_aux_mid_button_scroll_nodenum;
 
+/*
+ * This holds the processed packet data, it is global because multiple
+ * packets from the trackpad may be processed when handling multiple
+ * fingers on the trackpad to gather all the data.
+ */
+static struct synaptics_packet packet;
+
 static int
 synaptics_poll_cmd(struct pms_softc *psc, ...)
 {
@@ -490,6 +502,10 @@ pms_synaptics_enable(void *vsc)
 	(sc->flags & SYN_FLAG_HAS_ADV_GESTURE_MODE))
 		synaptics_special_write(psc, SYNAPTICS_WRITE_DELUXE_3, 0x3); 
 
+	/* Disable motion in the button region for clickpads */
+	if(sc->flags & SYN_FLAG_HAS_ONE_BUTTON_CLICKPAD)
+		synaptics_button_region_movement = 0;
+
 	sc->up_down = 0;
 	sc->prev_fingers = 0;
 	sc->gesture_start_x = sc->gesture_start_y = 0;
@@ -497,11 +513,14 @@ pms_synaptics_enable(v

CVS commit: src/sys/dev/pckbport

2021-10-20 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Thu Oct 21 04:49:28 UTC 2021

Modified Files:
src/sys/dev/pckbport: synaptics.c synapticsvar.h

Log Message:
Significant update to the synaptics touchpad driver.

* Accumulate packets for primary, secondary, finger count packets
  before handing off to pms_synaptics_process_packet.  This means
  that both primary and, possibly, secondary finger locations will
  be processed at the same time.  Previously the processing each
  packet as it arrived.

* Fix the secondary finger position reporting, there was an off by
  one in the shifts when decoding which effectively halved the
  reported position.

* For a clickpad, make the emulated button region "dead" so that finger
  movements in this region are ignored.  This makes it easier to click
  a button without accidentally repositioning the cursor.  There is a
  sysctl variable "button_region_movement_enable" that will allow
  these finger movements to be reported if this is desirable.

* Reset the finger ballistics when the number of fingers changes.  This
  stops the annoying position jumps when a second finger touch is added
  to or removed from the touchpad.

* Add a level argument to the DPRINTF macro so one can choose their
  level of debug spam via the debug sysctl variable.


To generate a diff of this commit:
cvs rdiff -u -r1.72 -r1.73 src/sys/dev/pckbport/synaptics.c
cvs rdiff -u -r1.11 -r1.12 src/sys/dev/pckbport/synapticsvar.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/arm/cortex

2021-10-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 21 04:47:57 UTC 2021

Modified Files:
src/sys/arch/arm/cortex: gic.c

Log Message:
Fix some conditionals to match gicv3 and add some comments to describe
what's going on.

Fixes PR port-evbarm/56420


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/arm/cortex/gic.c

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

Modified files:

Index: src/sys/arch/arm/cortex/gic.c
diff -u src/sys/arch/arm/cortex/gic.c:1.50 src/sys/arch/arm/cortex/gic.c:1.51
--- src/sys/arch/arm/cortex/gic.c:1.50	Sun Sep 26 13:38:50 2021
+++ src/sys/arch/arm/cortex/gic.c	Thu Oct 21 04:47:57 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: gic.c,v 1.50 2021/09/26 13:38:50 jmcneill Exp $	*/
+/*	$NetBSD: gic.c,v 1.51 2021/10/21 04:47:57 skrll Exp $	*/
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
 #define _INTR_PRIVATE
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.50 2021/09/26 13:38:50 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gic.c,v 1.51 2021/10/21 04:47:57 skrll Exp $");
 
 #include 
 #include 
@@ -331,9 +331,17 @@ armgic_irq_handler(void *tf)
 
 	ci->ci_data.cpu_nintr++;
 
-	if (ci->ci_hwpl != old_ipl) {
+	/*
+	 * Raise ci_hwpl (and PMR) to ci_cpl and IAR will tell us if the
+	 * interrupt that got us here can have its handler run or not.
+	 */
+	if (ci->ci_hwpl <= old_ipl) {
 		ci->ci_hwpl = old_ipl;
 		gicc_write(sc, GICC_PMR, armgic_ipl_to_priority(old_ipl));
+		/*
+		 * we'll get no interrupts when PMR is IPL_HIGH, so bail
+		 * early.
+		 */
 		if (old_ipl == IPL_HIGH) {
 			return;
 		}
@@ -373,11 +381,13 @@ armgic_irq_handler(void *tf)
 		 *
 		 * However, if are just raising ipl, we can just update ci_cpl.
 		 */
+
+		/* Surely we can KASSERT(ipl < ci->ci_cpl); */
 		const int ipl = is->is_ipl;
 		if (__predict_false(ipl < ci->ci_cpl)) {
 			pic_do_pending_ints(I32_bit, ipl, tf);
 			KASSERT(ci->ci_cpl == ipl);
-		} else {
+		} else if (ci->ci_cpl != ipl) {
 			KASSERTMSG(ipl > ci->ci_cpl, "ipl %d cpl %d hw-ipl %#x",
 			ipl, ci->ci_cpl,
 			gicc_read(sc, GICC_PMR));



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

2021-10-20 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Oct 21 04:47:57 UTC 2021

Modified Files:
src/sys/arch/arm/cortex: gic.c

Log Message:
Fix some conditionals to match gicv3 and add some comments to describe
what's going on.

Fixes PR port-evbarm/56420


To generate a diff of this commit:
cvs rdiff -u -r1.50 -r1.51 src/sys/arch/arm/cortex/gic.c

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



CVS commit: src/doc

2021-10-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Oct 21 02:47:17 UTC 2021

Modified Files:
src/doc: CHANGES

Log Message:
doc: pktq_rps_hash() changes.


To generate a diff of this commit:
cvs rdiff -u -r1.2841 -r1.2842 src/doc/CHANGES

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2841 src/doc/CHANGES:1.2842
--- src/doc/CHANGES:1.2841	Thu Oct 14 21:18:07 2021
+++ src/doc/CHANGES	Thu Oct 21 02:47:17 2021
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2841 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2842 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -437,6 +437,8 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	tzdata partly updated to 2021b [kre 20211001] 
 	sht4xtemp(4): Driver for the Sensirion SHT40/SHT41/SHT45 temperature
 		and humidity sensor [brad 20211003]
+	network: Make pktq_rps_hash() pluggable for each interface type.
+		[knakahara 20211011]
 	wm(4): Add Tiger Lake and newer devices (I219V 15-V9 and LM 16-19).
 		[msaitoh 20211013]
 	sgp40mox(4): Driver for the Sensirion SGP40 MOx gas sensor for air quality



CVS commit: src/doc

2021-10-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Thu Oct 21 02:47:17 UTC 2021

Modified Files:
src/doc: CHANGES

Log Message:
doc: pktq_rps_hash() changes.


To generate a diff of this commit:
cvs rdiff -u -r1.2841 -r1.2842 src/doc/CHANGES

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



CVS commit: src/sys

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Oct 21 02:34:04 UTC 2021

Modified Files:
src/sys/kern: kern_event.c
src/sys/sys: event.h

Log Message:
Allow the f_touch() filter op to return an error, specifically in
the EVENT_REGISTER case.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/kern/kern_event.c
cvs rdiff -u -r1.49 -r1.50 src/sys/sys/event.h

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

Modified files:

Index: src/sys/kern/kern_event.c
diff -u src/sys/kern/kern_event.c:1.134 src/sys/kern/kern_event.c:1.135
--- src/sys/kern/kern_event.c:1.134	Thu Oct 21 01:11:21 2021
+++ src/sys/kern/kern_event.c	Thu Oct 21 02:34:03 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_event.c,v 1.134 2021/10/21 01:11:21 thorpej Exp $	*/
+/*	$NetBSD: kern_event.c,v 1.135 2021/10/21 02:34:03 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2021 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #endif /* _KERNEL_OPT */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.134 2021/10/21 01:11:21 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.135 2021/10/21 02:34:03 thorpej Exp $");
 
 #include 
 #include 
@@ -116,7 +116,7 @@ static int	filt_timer(struct knote *, lo
 static int	filt_userattach(struct knote *);
 static void	filt_userdetach(struct knote *);
 static int	filt_user(struct knote *, long hint);
-static void	filt_usertouch(struct knote *, struct kevent *, long type);
+static int	filt_usertouch(struct knote *, struct kevent *, long type);
 
 static const struct fileops kqueueops = {
 	.fo_name = "kqueue",
@@ -476,10 +476,10 @@ filter_event(struct knote *kn, long hint
 	return rv;
 }
 
-static void
+static int
 filter_touch(struct knote *kn, struct kevent *kev, long type)
 {
-	kn->kn_fop->f_touch(kn, kev, type);
+	return kn->kn_fop->f_touch(kn, kev, type);
 }
 
 static kauth_listener_t	kqueue_listener;
@@ -1384,7 +1384,7 @@ filt_user(struct knote *kn, long hint)
 	return hookid;
 }
 
-static void
+static int
 filt_usertouch(struct knote *kn, struct kevent *kev, long type)
 {
 	int ffctrl;
@@ -1441,6 +1441,8 @@ filt_usertouch(struct knote *kn, struct 
 		panic("filt_usertouch() - invalid type (%ld)", type);
 		break;
 	}
+
+	return 0;
 }
 
 /*
@@ -1874,8 +1876,13 @@ kqueue_register(struct kqueue *kq, struc
 	if (!(kn->kn_fop->f_flags & FILTEROP_ISFD) &&
 	kn->kn_fop->f_touch != NULL) {
 		mutex_spin_enter(&kq->kq_lock);
-		filter_touch(kn, kev, EVENT_REGISTER);
+		error = filter_touch(kn, kev, EVENT_REGISTER);
 		mutex_spin_exit(&kq->kq_lock);
+		if (__predict_false(error != 0)) {
+			/* Never a new knote (which would consume newkn). */
+			KASSERT(newkn != NULL);
+			goto doneunlock;
+		}
 	} else {
 		kn->kn_sfflags = kev->fflags;
 		kn->kn_sdata = kev->data;
@@ -1887,7 +1894,7 @@ kqueue_register(struct kqueue *kq, struc
 	 * support events, and the attach routine is
 	 * broken and does not return an error.
 	 */
-done_ev_add:
+ done_ev_add:
 	rv = filter_event(kn, 0);
 	if (rv)
 		knote_activate(kn);
@@ -1904,7 +1911,7 @@ done_ev_add:
 	if ((kev->flags & EV_ENABLE)) {
 		knote_enqueue(kn);
 	}
-doneunlock:
+ doneunlock:
 	mutex_exit(&fdp->fd_lock);
  done:
 	rw_exit(&kqueue_filter_lock);
@@ -2197,7 +2204,7 @@ relock:
 kn->kn_fop->f_touch != NULL);
 		/* XXXAD should be got from f_event if !oneshot. */
 		if (touch) {
-			filter_touch(kn, kevp, EVENT_PROCESS);
+			(void)filter_touch(kn, kevp, EVENT_PROCESS);
 		} else {
 			*kevp = kn->kn_kevent;
 		}

Index: src/sys/sys/event.h
diff -u src/sys/sys/event.h:1.49 src/sys/sys/event.h:1.50
--- src/sys/sys/event.h:1.49	Wed Oct 20 03:08:18 2021
+++ src/sys/sys/event.h	Thu Oct 21 02:34:04 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: event.h,v 1.49 2021/10/20 03:08:18 thorpej Exp $	*/
+/*	$NetBSD: event.h,v 1.50 2021/10/21 02:34:04 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 1999,2000,2001 Jonathan Lemon 
@@ -230,7 +230,7 @@ struct filterops {
 	/* called when knote is DELETEd */
 	int	(*f_event)	(struct knote *, long);
 	/* called when event is triggered */
-	void	(*f_touch)	(struct knote *, struct kevent *, long);
+	int	(*f_touch)	(struct knote *, struct kevent *, long);
 };
 
 /* filterops flags */



CVS commit: src/sys

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Oct 21 02:34:04 UTC 2021

Modified Files:
src/sys/kern: kern_event.c
src/sys/sys: event.h

Log Message:
Allow the f_touch() filter op to return an error, specifically in
the EVENT_REGISTER case.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/kern/kern_event.c
cvs rdiff -u -r1.49 -r1.50 src/sys/sys/event.h

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



CVS commit: src/sys/kern

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Oct 21 01:11:21 UTC 2021

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

Log Message:
Re-factor the code that computes the EVFILT_TIMER value into its own
function.

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/sys/kern/kern_event.c

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



CVS commit: src/sys/kern

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Oct 21 01:11:21 UTC 2021

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

Log Message:
Re-factor the code that computes the EVFILT_TIMER value into its own
function.

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.133 -r1.134 src/sys/kern/kern_event.c

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

Modified files:

Index: src/sys/kern/kern_event.c
diff -u src/sys/kern/kern_event.c:1.133 src/sys/kern/kern_event.c:1.134
--- src/sys/kern/kern_event.c:1.133	Thu Oct 21 00:54:15 2021
+++ src/sys/kern/kern_event.c	Thu Oct 21 01:11:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_event.c,v 1.133 2021/10/21 00:54:15 thorpej Exp $	*/
+/*	$NetBSD: kern_event.c,v 1.134 2021/10/21 01:11:21 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2021 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #endif /* _KERNEL_OPT */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.133 2021/10/21 00:54:15 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.134 2021/10/21 01:11:21 thorpej Exp $");
 
 #include 
 #include 
@@ -1153,32 +1153,13 @@ knote_proc_exit(struct proc *p)
 
 #define	FILT_TIMER_NOSCHED	((uintptr_t)-1)
 
-static void
-filt_timerexpire(void *knx)
-{
-	struct knote *kn = knx;
-	struct kqueue *kq = kn->kn_kq;
-
-	mutex_spin_enter(&kq->kq_lock);
-	kn->kn_data++;
-	knote_activate_locked(kn);
-	if (kn->kn_sdata != FILT_TIMER_NOSCHED) {
-		KASSERT(kn->kn_sdata > 0 && kn->kn_sdata <= INT_MAX);
-		callout_schedule((callout_t *)kn->kn_hook,
-		(int)kn->kn_sdata);
-	}
-	mutex_spin_exit(&kq->kq_lock);
-}
-
 static int
-filt_timerattach(struct knote *kn)
+filt_timercompute(struct kevent *kev, uintptr_t *tticksp)
 {
-	callout_t *calloutp;
-	struct kqueue *kq;
 	struct timespec ts;
-	int tticks, flags = 0;
+	uintptr_t tticks;
 
-	if (kn->kn_sfflags & ~(NOTE_TIMER_UNITMASK | NOTE_ABSTIME)) {
+	if (kev->fflags & ~(NOTE_TIMER_UNITMASK | NOTE_ABSTIME)) {
 		return EINVAL;
 	}
 
@@ -1186,32 +1167,32 @@ filt_timerattach(struct knote *kn)
 	 * Convert the event 'data' to a timespec, then convert the
 	 * timespec to callout ticks.
 	 */
-	switch (kn->kn_sfflags & NOTE_TIMER_UNITMASK) {
+	switch (kev->fflags & NOTE_TIMER_UNITMASK) {
 	case NOTE_SECONDS:
-		ts.tv_sec = kn->kn_sdata;
+		ts.tv_sec = kev->data;
 		ts.tv_nsec = 0;
 		break;
 
 	case NOTE_MSECONDS:		/* == historical value 0 */
-		ts.tv_sec = kn->kn_sdata / 1000;
-		ts.tv_nsec = (kn->kn_sdata % 1000) * 100;
+		ts.tv_sec = kev->data / 1000;
+		ts.tv_nsec = (kev->data % 1000) * 100;
 		break;
 
 	case NOTE_USECONDS:
-		ts.tv_sec = kn->kn_sdata / 100;
-		ts.tv_nsec = (kn->kn_sdata % 100) * 1000;
+		ts.tv_sec = kev->data / 100;
+		ts.tv_nsec = (kev->data % 100) * 1000;
 		break;
 
 	case NOTE_NSECONDS:
-		ts.tv_sec = kn->kn_sdata / 10;
-		ts.tv_nsec = kn->kn_sdata % 10;
+		ts.tv_sec = kev->data / 10;
+		ts.tv_nsec = kev->data % 10;
 		break;
 
 	default:
 		return EINVAL;
 	}
 
-	if (kn->kn_sfflags & NOTE_ABSTIME) {
+	if (kev->fflags & NOTE_ABSTIME) {
 		struct timespec deadline = ts;
 
 		/*
@@ -1222,35 +1203,81 @@ filt_timerattach(struct knote *kn)
 		 */
 		nanotime(&ts);
 
+		/* Absolute timers do not repeat. */
+		kev->data = FILT_TIMER_NOSCHED;
+
 		/* If we're past the deadline, then the event will fire. */
 		if (timespeccmp(&deadline, &ts, <=)) {
-			kn->kn_data = 1;
-			return 0;
+			tticks = FILT_TIMER_NOSCHED;
+			goto out;
 		}
 
 		/* Calculate how much time is left. */
 		timespecsub(&deadline, &ts, &ts);
 	} else {
 		/* EV_CLEAR automatically set for relative timers. */
-		flags |= EV_CLEAR;
+		kev->flags |= EV_CLEAR;
 	}
 
 	tticks = tstohz(&ts);
 
 	/* if the supplied value is under our resolution, use 1 tick */
 	if (tticks == 0) {
-		if (kn->kn_sdata == 0)
+		if (kev->data == 0)
 			return EINVAL;
 		tticks = 1;
+	} else if (tticks > INT_MAX) {
+		return EINVAL;
 	}
 
-	if ((kn->kn_flags & EV_ONESHOT) != 0 ||
-	(kn->kn_sfflags & NOTE_ABSTIME) != 0) {
+	if ((kev->flags & EV_ONESHOT) != 0) {
 		/* Timer does not repeat. */
-		kn->kn_sdata = FILT_TIMER_NOSCHED;
+		kev->data = FILT_TIMER_NOSCHED;
 	} else {
 		KASSERT((uintptr_t)tticks != FILT_TIMER_NOSCHED);
-		kn->kn_sdata = tticks;
+		kev->data = tticks;
+	}
+
+ out:
+	*tticksp = tticks;
+
+	return 0;
+}
+
+static void
+filt_timerexpire(void *knx)
+{
+	struct knote *kn = knx;
+	struct kqueue *kq = kn->kn_kq;
+
+	mutex_spin_enter(&kq->kq_lock);
+	kn->kn_data++;
+	knote_activate_locked(kn);
+	if (kn->kn_sdata != FILT_TIMER_NOSCHED) {
+		KASSERT(kn->kn_sdata > 0 && kn->kn_sdata <= INT_MAX);
+		callout_schedule((callout_t *)kn->kn_hook,
+		(int)kn->kn_sdata);
+	}
+	mutex_spin_exit(&kq->kq_lock);
+}
+
+static int
+filt_timerattach(struct knote *kn)
+{
+	callout_t *calloutp;
+	struct kqueue *kq;
+	uintptr_t tticks;
+	int error;
+
+	struct kevent kev = {
+		.flags = kn->kn_flags,
+		.fflags = kn->k

CVS commit: src/sys/dev/acpi

2021-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 21 00:56:52 UTC 2021

Modified Files:
src/sys/dev/acpi: com_acpi.c

Log Message:
acpi: com: Honour the reg-shift property


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/acpi/com_acpi.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/acpi/com_acpi.c
diff -u src/sys/dev/acpi/com_acpi.c:1.42 src/sys/dev/acpi/com_acpi.c:1.43
--- src/sys/dev/acpi/com_acpi.c:1.42	Thu Mar 25 05:33:59 2021
+++ src/sys/dev/acpi/com_acpi.c	Thu Oct 21 00:56:52 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: com_acpi.c,v 1.42 2021/03/25 05:33:59 rin Exp $ */
+/* $NetBSD: com_acpi.c,v 1.43 2021/10/21 00:56:52 jmcneill Exp $ */
 
 /*
  * Copyright (c) 2002 Jared D. McNeill 
@@ -26,7 +26,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: com_acpi.c,v 1.42 2021/03/25 05:33:59 rin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: com_acpi.c,v 1.43 2021/10/21 00:56:52 jmcneill Exp $");
 
 #include 
 #include 
@@ -118,6 +118,7 @@ com_acpi_attach(device_t parent, device_
 	bus_size_t size;
 	ACPI_STATUS rv;
 	ACPI_INTEGER clock_freq;
+	ACPI_INTEGER reg_shift;
 
 	sc->sc_dev = self;
 
@@ -158,7 +159,14 @@ com_acpi_attach(device_t parent, device_
 			aprint_error_dev(self, "can't map i/o space\n");
 			goto out;
 		}
-	com_init_regs(&sc->sc_regs, iot, ioh, base);
+
+	rv = acpi_dsd_integer(aa->aa_node->ad_handle, "reg-shift",
+	®_shift);
+	if (ACPI_FAILURE(rv)) {
+		reg_shift = 0;
+	}
+
+	com_init_regs_stride(&sc->sc_regs, iot, ioh, base, reg_shift);
 
 	aprint_normal("%s", device_xname(self));
 



CVS commit: src/sys/dev/acpi

2021-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 21 00:56:52 UTC 2021

Modified Files:
src/sys/dev/acpi: com_acpi.c

Log Message:
acpi: com: Honour the reg-shift property


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/sys/dev/acpi/com_acpi.c

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



CVS commit: src/sys/kern

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Oct 21 00:54:15 UTC 2021

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

Log Message:
- Don't use a separate kqueue_timer_lock; just protect those knotes
  with the kq->kq_lock.
- Re-factor the guts of knote_activate() into knote_activate_locked(),
  and use it in a few places to avoid a few unlock-the-immediately-lock
  cycles.
- Define a FILT_TIMER_NOSCHED macro, rather than hard-coding (uintptr_t)-1
  in a bunch of difference place.

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/kern/kern_event.c

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

Modified files:

Index: src/sys/kern/kern_event.c
diff -u src/sys/kern/kern_event.c:1.132 src/sys/kern/kern_event.c:1.133
--- src/sys/kern/kern_event.c:1.132	Wed Oct 13 04:57:19 2021
+++ src/sys/kern/kern_event.c	Thu Oct 21 00:54:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_event.c,v 1.132 2021/10/13 04:57:19 thorpej Exp $	*/
+/*	$NetBSD: kern_event.c,v 1.133 2021/10/21 00:54:15 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009, 2021 The NetBSD Foundation, Inc.
@@ -63,7 +63,7 @@
 #endif /* _KERNEL_OPT */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.132 2021/10/13 04:57:19 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_event.c,v 1.133 2021/10/21 00:54:15 thorpej Exp $");
 
 #include 
 #include 
@@ -101,6 +101,7 @@ static void	kqueue_doclose(struct kqueue
 static void	knote_detach(struct knote *, filedesc_t *fdp, bool);
 static void	knote_enqueue(struct knote *);
 static void	knote_activate(struct knote *);
+static void	knote_activate_locked(struct knote *);
 
 static void	filt_kqdetach(struct knote *);
 static int	filt_kqueue(struct knote *, long hint);
@@ -273,7 +274,6 @@ static size_t		user_kfiltersz;		/* size 
  * KM_SLEEP is not).
  */
 static krwlock_t	kqueue_filter_lock;	/* lock on filter lists */
-static kmutex_t		kqueue_timer_lock;	/* for EVFILT_TIMER */
 
 #define	KQ_FLUX_WAIT(kq)	(void)cv_wait(&kq->kq_cv, &kq->kq_lock)
 #define	KQ_FLUX_WAKEUP(kq)	cv_broadcast(&kq->kq_cv)
@@ -514,7 +514,6 @@ kqueue_init(void)
 {
 
 	rw_init(&kqueue_filter_lock);
-	mutex_init(&kqueue_timer_lock, MUTEX_DEFAULT, IPL_SOFTCLOCK);
 
 	kqueue_listener = kauth_listen_scope(KAUTH_SCOPE_PROCESS,
 	kqueue_listener_cb, NULL);
@@ -877,10 +876,10 @@ knote_proc_exec(struct proc *p)
 		kq = kn->kn_kq;
 		mutex_spin_enter(&kq->kq_lock);
 		fflags = (kn->kn_fflags |= (kn->kn_sfflags & NOTE_EXEC));
-		mutex_spin_exit(&kq->kq_lock);
 		if (fflags) {
-			knote_activate(kn);
+			knote_activate_locked(kn);
 		}
+		mutex_spin_exit(&kq->kq_lock);
 	}
 
 	mutex_exit(p->p_lock);
@@ -1095,10 +1094,10 @@ knote_proc_fork(struct proc *p1, struct 
 			KASSERT(mutex_owned(&kq->kq_lock));
 		}
 		fflags = kn->kn_fflags;
-		mutex_spin_exit(&kq->kq_lock);
 		if (fflags) {
-			knote_activate(kn);
+			knote_activate_locked(kn);
 		}
+		mutex_spin_exit(&kq->kq_lock);
 	}
 
 	mutex_exit(p1->p_lock);
@@ -1141,31 +1140,34 @@ knote_proc_exit(struct proc *p)
 			kn->kn_status |= KN_DETACHED;
 			SLIST_REMOVE_HEAD(&p->p_klist, kn_selnext);
 		}
-		mutex_spin_exit(&kq->kq_lock);
 
 		/*
 		 * Always activate the knote for NOTE_EXIT regardless
 		 * of whether or not the listener cares about it.
 		 * This matches historical behavior.
 		 */
-		knote_activate(kn);
+		knote_activate_locked(kn);
+		mutex_spin_exit(&kq->kq_lock);
 	}
 }
 
+#define	FILT_TIMER_NOSCHED	((uintptr_t)-1)
+
 static void
 filt_timerexpire(void *knx)
 {
 	struct knote *kn = knx;
+	struct kqueue *kq = kn->kn_kq;
 
-	mutex_enter(&kqueue_timer_lock);
+	mutex_spin_enter(&kq->kq_lock);
 	kn->kn_data++;
-	knote_activate(kn);
-	if (kn->kn_sdata != (uintptr_t)-1) {
+	knote_activate_locked(kn);
+	if (kn->kn_sdata != FILT_TIMER_NOSCHED) {
 		KASSERT(kn->kn_sdata > 0 && kn->kn_sdata <= INT_MAX);
 		callout_schedule((callout_t *)kn->kn_hook,
 		(int)kn->kn_sdata);
 	}
-	mutex_exit(&kqueue_timer_lock);
+	mutex_spin_exit(&kq->kq_lock);
 }
 
 static int
@@ -1245,9 +1247,9 @@ filt_timerattach(struct knote *kn)
 	if ((kn->kn_flags & EV_ONESHOT) != 0 ||
 	(kn->kn_sfflags & NOTE_ABSTIME) != 0) {
 		/* Timer does not repeat. */
-		kn->kn_sdata = (uintptr_t)-1;
+		kn->kn_sdata = FILT_TIMER_NOSCHED;
 	} else {
-		KASSERT((uintptr_t)tticks != (uintptr_t)-1);
+		KASSERT((uintptr_t)tticks != FILT_TIMER_NOSCHED);
 		kn->kn_sdata = tticks;
 	}
 
@@ -1275,17 +1277,9 @@ filt_timerdetach(struct knote *kn)
 	callout_t *calloutp;
 	struct kqueue *kq = kn->kn_kq;
 
-	/*
-	 * We don't need to hold the kqueue_timer_lock here; even
-	 * if filt_timerexpire() misses our setting of EV_ONESHOT,
-	 * we are guaranteed that the callout will no longer be
-	 * scheduled even if we attempted to halt it after it already
-	 * started running, even if it rescheduled itself.
-	 */
-
-	mutex_spin_enter(&kq->kq_lock);
 	/* prevent rescheduling when we expire */
-	kn->kn_flags |= EV_ONESHOT;
+	mutex_spin

CVS commit: src/sys/kern

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Thu Oct 21 00:54:15 UTC 2021

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

Log Message:
- Don't use a separate kqueue_timer_lock; just protect those knotes
  with the kq->kq_lock.
- Re-factor the guts of knote_activate() into knote_activate_locked(),
  and use it in a few places to avoid a few unlock-the-immediately-lock
  cycles.
- Define a FILT_TIMER_NOSCHED macro, rather than hard-coding (uintptr_t)-1
  in a bunch of difference place.

NFC.


To generate a diff of this commit:
cvs rdiff -u -r1.132 -r1.133 src/sys/kern/kern_event.c

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/acpi

2021-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 21 00:09:28 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
baud_rate is signed now


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/acpi/acpi_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/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.29 src/sys/arch/arm/acpi/acpi_platform.c:1.30
--- src/sys/arch/arm/acpi/acpi_platform.c:1.29	Wed Oct 20 23:03:40 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Thu Oct 21 00:09:28 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.29 2021/10/20 23:03:40 jakllsch Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.30 2021/10/21 00:09:28 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.29 2021/10/20 23:03:40 jakllsch Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.30 2021/10/21 00:09:28 jmcneill Exp $");
 
 #include 
 #include 
@@ -91,7 +91,7 @@ __KERNEL_RCSID(0, "$NetBSD: acpi_platfor
 
 static const struct acpi_spcr_baud_rate {
 	uint8_t		id;
-	uint32_t	baud_rate;
+	int		baud_rate;
 } acpi_spcr_baud_rates[] = {
 	{ SPCR_BAUD_DEFAULT,	-1 },
 	{ SPCR_BAUD_9600,	9600 },



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

2021-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 21 00:09:28 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
baud_rate is signed now


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/arm/acpi/acpi_platform.c

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



CVS commit: src/distrib/notes/common

2021-10-20 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Wed Oct 20 23:45:09 UTC 2021

Modified Files:
src/distrib/notes/common: main

Log Message:
main: add .gz extension to .img references for consistency


To generate a diff of this commit:
cvs rdiff -u -r1.566 -r1.567 src/distrib/notes/common/main

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

Modified files:

Index: src/distrib/notes/common/main
diff -u src/distrib/notes/common/main:1.566 src/distrib/notes/common/main:1.567
--- src/distrib/notes/common/main:1.566	Wed Oct 20 23:30:30 2021
+++ src/distrib/notes/common/main	Wed Oct 20 23:45:09 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: main,v 1.566 2021/10/20 23:30:30 gutteridge Exp $
+.\"	$NetBSD: main,v 1.567 2021/10/20 23:45:09 gutteridge Exp $
 .\"
 .\" Copyright (c) 1999-2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -266,8 +266,8 @@ Many commercial and freeware programs ar
 If installing via USB, you must first uncompress the USB image, which
 is gzipped.
 .if \n[amd64] \{\
-Note the \*M architecture has two images, NetBSD-\*V-\*M-install.img and
-NetBSD-\*V-\*M-bios-install.img. The latter is intended for older
+Note the \*M architecture has two images, NetBSD-\*V-\*M-install.img.gz
+and NetBSD-\*V-\*M-bios-install.img.gz. The latter is intended for older
 hardware which is unable to boot using a hybrid MBR and GPT image.
 .\}
 .Dl $ Ic "gunzip NetBSD-\*V-\*M-install.img.gz"



CVS commit: src/distrib/notes/common

2021-10-20 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Wed Oct 20 23:45:09 UTC 2021

Modified Files:
src/distrib/notes/common: main

Log Message:
main: add .gz extension to .img references for consistency


To generate a diff of this commit:
cvs rdiff -u -r1.566 -r1.567 src/distrib/notes/common/main

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



CVS commit: src/distrib/notes/common

2021-10-20 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Wed Oct 20 23:30:30 UTC 2021

Modified Files:
src/distrib/notes/common: main

Log Message:
main: add note about amd64 now having a "bios" image, too


To generate a diff of this commit:
cvs rdiff -u -r1.565 -r1.566 src/distrib/notes/common/main

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

Modified files:

Index: src/distrib/notes/common/main
diff -u src/distrib/notes/common/main:1.565 src/distrib/notes/common/main:1.566
--- src/distrib/notes/common/main:1.565	Wed Oct 20 23:23:59 2021
+++ src/distrib/notes/common/main	Wed Oct 20 23:30:30 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: main,v 1.565 2021/10/20 23:23:59 gutteridge Exp $
+.\"	$NetBSD: main,v 1.566 2021/10/20 23:30:30 gutteridge Exp $
 .\"
 .\" Copyright (c) 1999-2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -265,6 +265,11 @@ Many commercial and freeware programs ar
 .Pp
 If installing via USB, you must first uncompress the USB image, which
 is gzipped.
+.if \n[amd64] \{\
+Note the \*M architecture has two images, NetBSD-\*V-\*M-install.img and
+NetBSD-\*V-\*M-bios-install.img. The latter is intended for older
+hardware which is unable to boot using a hybrid MBR and GPT image.
+.\}
 .Dl $ Ic "gunzip NetBSD-\*V-\*M-install.img.gz"
 Next, write the USB image to a USB stick/drive.
 Note that this will overwrite any existing data on the device that you



CVS commit: src/distrib/notes/common

2021-10-20 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Wed Oct 20 23:30:30 UTC 2021

Modified Files:
src/distrib/notes/common: main

Log Message:
main: add note about amd64 now having a "bios" image, too


To generate a diff of this commit:
cvs rdiff -u -r1.565 -r1.566 src/distrib/notes/common/main

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



CVS commit: src/distrib/notes/common

2021-10-20 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Wed Oct 20 23:23:59 UTC 2021

Modified Files:
src/distrib/notes/common: main

Log Message:
main: simplify conditional markup


To generate a diff of this commit:
cvs rdiff -u -r1.564 -r1.565 src/distrib/notes/common/main

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

Modified files:

Index: src/distrib/notes/common/main
diff -u src/distrib/notes/common/main:1.564 src/distrib/notes/common/main:1.565
--- src/distrib/notes/common/main:1.564	Thu May 27 15:47:42 2021
+++ src/distrib/notes/common/main	Wed Oct 20 23:23:59 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: main,v 1.564 2021/05/27 15:47:42 martin Exp $
+.\"	$NetBSD: main,v 1.565 2021/10/20 23:23:59 gutteridge Exp $
 .\"
 .\" Copyright (c) 1999-2012 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -257,7 +257,7 @@ and
 .Pa etc.\*[setsuffix] .
 In a typical workstation installation you will probably want
 all the installation sets.
-.ie \n[i386]:\n[amd64] \{\
+.if \n[i386]:\n[amd64] \{\
 .It
 Write the boot images
 .Pp
@@ -280,7 +280,6 @@ On Windows, you will need to use a progr
 .Lk http://sourceforge.net/projects/win32diskimager/ "Win32 Disk Imager" ,
 or
 .Lk https://www.NetBSD.org/~martin/rawrite32 Rawrite32 .
-.if \n[amd64]:\n[i386] \{\
 If you have problems writing a raw image to a floppy,
 the
 .Ic rawrite.exe
@@ -289,7 +288,6 @@ in the
 .Pa \*M/installation/misc/
 directory may be of help.
 .\}
-.\}
 .if \n[macppc] \{\
 .It
 If your \*M has a floppy drive, create the pair of boot floppies using
@@ -640,7 +638,7 @@ Changes after the release of \n[major].\
 Changes in previous
 .Nx
 releases.
-.ie \n[FOR_RELEASE] \{\
+.if \n[FOR_RELEASE] \{\
 .It Li LAST_MINUTE
 Last minute changes and notes about the release.
 .\} \" \n[FOR_RELEASE]



CVS commit: src/distrib/notes/common

2021-10-20 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Wed Oct 20 23:23:59 UTC 2021

Modified Files:
src/distrib/notes/common: main

Log Message:
main: simplify conditional markup


To generate a diff of this commit:
cvs rdiff -u -r1.564 -r1.565 src/distrib/notes/common/main

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/acpi

2021-10-20 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Oct 20 23:03:40 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
SPCR_BAUD_DEFAULT maps better to -1 than 0

Suggested by jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/acpi/acpi_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/arm/acpi/acpi_platform.c
diff -u src/sys/arch/arm/acpi/acpi_platform.c:1.28 src/sys/arch/arm/acpi/acpi_platform.c:1.29
--- src/sys/arch/arm/acpi/acpi_platform.c:1.28	Sat Aug  7 21:24:56 2021
+++ src/sys/arch/arm/acpi/acpi_platform.c	Wed Oct 20 23:03:40 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_platform.c,v 1.28 2021/08/07 21:24:56 jmcneill Exp $ */
+/* $NetBSD: acpi_platform.c,v 1.29 2021/10/20 23:03:40 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
 #include "opt_multiprocessor.h"
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.28 2021/08/07 21:24:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_platform.c,v 1.29 2021/10/20 23:03:40 jakllsch Exp $");
 
 #include 
 #include 
@@ -93,7 +93,7 @@ static const struct acpi_spcr_baud_rate 
 	uint8_t		id;
 	uint32_t	baud_rate;
 } acpi_spcr_baud_rates[] = {
-	{ SPCR_BAUD_DEFAULT,	0 },
+	{ SPCR_BAUD_DEFAULT,	-1 },
 	{ SPCR_BAUD_9600,	9600 },
 	{ SPCR_BAUD_19200,	19200 },
 	{ SPCR_BAUD_57600,	57600 },



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

2021-10-20 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Oct 20 23:03:40 UTC 2021

Modified Files:
src/sys/arch/arm/acpi: acpi_platform.c

Log Message:
SPCR_BAUD_DEFAULT maps better to -1 than 0

Suggested by jmcneill@


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/arm/acpi/acpi_platform.c

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



CVS commit: src/lib/libcrypt

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 20:29:33 UTC 2021

Modified Files:
src/lib/libcrypt: crypt.3

Log Message:
crypt.3: add a reference for Argon2


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libcrypt/crypt.3

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



CVS commit: src/lib/libcrypt

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 20:29:33 UTC 2021

Modified Files:
src/lib/libcrypt: crypt.3

Log Message:
crypt.3: add a reference for Argon2


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/lib/libcrypt/crypt.3

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

Modified files:

Index: src/lib/libcrypt/crypt.3
diff -u src/lib/libcrypt/crypt.3:1.32 src/lib/libcrypt/crypt.3:1.33
--- src/lib/libcrypt/crypt.3:1.32	Tue Oct 12 21:41:13 2021
+++ src/lib/libcrypt/crypt.3	Wed Oct 20 20:29:33 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: crypt.3,v 1.32 2021/10/12 21:41:13 wiz Exp $
+.\"	$NetBSD: crypt.3,v 1.33 2021/10/20 20:29:33 nia Exp $
 .\"
 .\" Copyright (c) 1989, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -29,7 +29,7 @@
 .\"
 .\" @(#)crypt.3	8.2 (Berkeley) 12/11/93
 .\"
-.Dd October 12, 2021
+.Dd October 20, 2021
 .Dt CRYPT 3
 .Os
 .Sh NAME
@@ -372,6 +372,15 @@ usual political silliness.
 .Xr passwd 5 ,
 .Xr passwd.conf 5
 .Rs
+.%T "Argon2: the memory-hard function for password hashing and other applications"
+.%A Alex Biryukov
+.%A Daniel Dinu
+.%A Dmitry Khovratovich
+.%D 2017
+.%I University of Luxembourg
+.%U https://www.password-hashing.net/
+.Re
+.Rs
 .%T "Mathematical Cryptology for Computer Scientists and Mathematicians"
 .%A Wayne Patterson
 .%D 1987



CVS commit: src/lib/libcrypt

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 20:21:44 UTC 2021

Modified Files:
src/lib/libcrypt: crypt-argon2.c

Log Message:
Be a little bit more eager to let Argon2 use memory.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libcrypt/crypt-argon2.c

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

Modified files:

Index: src/lib/libcrypt/crypt-argon2.c
diff -u src/lib/libcrypt/crypt-argon2.c:1.13 src/lib/libcrypt/crypt-argon2.c:1.14
--- src/lib/libcrypt/crypt-argon2.c:1.13	Wed Oct 20 16:46:33 2021
+++ src/lib/libcrypt/crypt-argon2.c	Wed Oct 20 20:21:44 2021
@@ -179,9 +179,15 @@ estimate_argon2_params(argon2_type atype
 		 */
 		max_mem /= 100;
 		if (max_mem > 3) {
-			memory = 8192;
+			memory = 32768;
+		} else if (max_mem > 15000) {
+			memory = 16384;
 		} else if (max_mem > 7000) {
+			memory = 8192;
+		} else if (max_mem > 3000) {
 			memory = 4096;
+		} else if (max_mem > 900) {
+			memory = 1024;
 		} else if (max_mem > 24) {
 			memory = 256;
 		} else {



CVS commit: src/lib/libcrypt

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 20:21:44 UTC 2021

Modified Files:
src/lib/libcrypt: crypt-argon2.c

Log Message:
Be a little bit more eager to let Argon2 use memory.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/lib/libcrypt/crypt-argon2.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/i2c

2021-10-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 20 17:52:44 UTC 2021

Modified Files:
src/sys/dev/i2c: sgp40.c

Log Message:
- fix clang compilation: add "%s" to format string
- comma is followed by space
- KNF multi-line comments
- fold long lines
- early returns, fixes a missed iic_release_bus() on error.
- foo == false -> !foo


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/sgp40.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/i2c/sgp40.c
diff -u src/sys/dev/i2c/sgp40.c:1.1 src/sys/dev/i2c/sgp40.c:1.2
--- src/sys/dev/i2c/sgp40.c:1.1	Thu Oct 14 09:54:46 2021
+++ src/sys/dev/i2c/sgp40.c	Wed Oct 20 13:52:44 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: sgp40.c,v 1.1 2021/10/14 13:54:46 brad Exp $	*/
+/*	$NetBSD: sgp40.c,v 1.2 2021/10/20 17:52:44 christos Exp $	*/
 
 /*
  * Copyright (c) 2021 Brad Spencer 
@@ -17,7 +17,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sgp40.c,v 1.1 2021/10/14 13:54:46 brad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sgp40.c,v 1.2 2021/10/20 17:52:44 christos Exp $");
 
 /*
   Driver for the Sensirion SGP40 MOx gas sensor for air quality
@@ -42,7 +42,8 @@ __KERNEL_RCSID(0, "$NetBSD: sgp40.c,v 1.
 #include 
 
 static uint8_t 	sgp40_crc(uint8_t *, size_t);
-static int  sgp40_cmdr(struct sgp40_sc *, uint16_t, uint8_t *, uint8_t, uint8_t *, size_t);
+static int  sgp40_cmdr(struct sgp40_sc *, uint16_t, uint8_t *, uint8_t,
+uint8_t *, size_t);
 static int 	sgp40_poke(i2c_tag_t, i2c_addr_t, bool);
 static int 	sgp40_match(device_t, cfdata_t, void *);
 static void 	sgp40_attach(device_t, device_t, void *);
@@ -110,9 +111,10 @@ sgp40_thread(void *aux)
 
 	VocAlgorithm_init(&voc_algorithm_params);
 
-	while (sc->sc_stopping == false) {
-		rv = cv_timedwait(&sc->sc_condvar, &sc->sc_threadmutex, mstohz(1000));
-		if (rv == EWOULDBLOCK && sc->sc_stopping == false) {
+	while (!sc->sc_stopping) {
+		rv = cv_timedwait(&sc->sc_condvar, &sc->sc_threadmutex,
+		mstohz(1000));
+		if (rv == EWOULDBLOCK && !sc->sc_stopping) {
 			sgp40_take_measurement(sc,&voc_algorithm_params);
 		}
 	}
@@ -138,35 +140,37 @@ sgp40_stop_thread(void *aux)
 	mutex_enter(&sc->sc_mutex);
 	error = iic_acquire_bus(sc->sc_tag, 0);
 	if (error) {
-		DPRINTF(sc, 2, ("%s: Could not acquire iic bus for heater off in stop thread: %d\n",
+		DPRINTF(sc, 2, ("%s: Could not acquire iic bus for heater off "
+		"in stop thread: %d\n", device_xname(sc->sc_dev), error));
+		goto out;
+	}
+	error = sgp40_cmdr(sc, SGP40_HEATER_OFF, NULL, 0, NULL, 0);
+	if (error) {
+		DPRINTF(sc, 2, ("%s: Error turning heater off: %d\n",
 		device_xname(sc->sc_dev), error));
-	} else {
-		error = sgp40_cmdr(sc, SGP40_HEATER_OFF,NULL,0,NULL,0);
-		if (error) {
-			DPRINTF(sc, 2, ("%s: Error turning heater off: %d\n",
-			device_xname(sc->sc_dev), error));
-		}
-		iic_release_bus(sc->sc_tag, 0);
 	}
+out:
+	iic_release_bus(sc->sc_tag, 0);
 	mutex_exit(&sc->sc_mutex);
 }
 
 static int
 sgp40_compute_temp_comp(int unconverted)
 {
-	/* The published algorithm for this conversion is:
-	   (temp_in_celcius + 45) * 65535 / 175
-
-	   However, this did not exactly yield the results that
-	   the example in the data sheet, so something a little
-	   different was done.
-
-	   (temp_in_celcius + 45) * 65536 / 175
-
-	   This was also scaled up by 10^2 and then scaled back to
-	   preserve some percision.  37449 is simply (65536 * 100) / 175
-	   and rounded.
-	*/
+	/*
+	 * The published algorithm for this conversion is:
+	 * (temp_in_celcius + 45) * 65535 / 175
+	 *
+	 * However, this did not exactly yield the results that
+	 * the example in the data sheet, so something a little
+	 * different was done.
+	 *
+	 * (temp_in_celcius + 45) * 65536 / 175
+	 *
+	 * This was also scaled up by 10^2 and then scaled back to
+	 * preserve some percision.  37449 is simply (65536 * 100) / 175
+	 * and rounded.
+	 */
 
 	return (((unconverted + 45) * 100) * 37449) / 1;
 }
@@ -176,19 +180,20 @@ sgp40_compute_rh_comp(int unconverted)
 {
 	int q;
 
-	/* The published algorithm for this conversion is:
-	   %rh * 65535 / 100
-
-	   However, this did not exactly yield the results that
-	   the example in the data sheet, so something a little
-	   different was done.
-
-	   %rh * 65536 / 100
-
-	   This was also scaled up by 10^2 and then scaled back to
-	   preserve some percision.  The value is also latched to 65535
-	   as an upper limit.
-	*/
+	/*
+	 * The published algorithm for this conversion is:
+	 * %rh * 65535 / 100
+	 *
+	 * However, this did not exactly yield the results that
+	 * the example in the data sheet, so something a little
+	 * different was done.
+	 *
+	 * %rh * 65536 / 100
+	 *
+	 * This was also scaled up by 10^2 and then scaled back to
+	 * preserve some percision.  The value is also latched to 65535
+	 * as an upper limit.
+	 */
 
 	q = ((unconverted * 100) * 65536) / 1;
 	if

CVS commit: src/sys/dev/i2c

2021-10-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Oct 20 17:52:44 UTC 2021

Modified Files:
src/sys/dev/i2c: sgp40.c

Log Message:
- fix clang compilation: add "%s" to format string
- comma is followed by space
- KNF multi-line comments
- fold long lines
- early returns, fixes a missed iic_release_bus() on error.
- foo == false -> !foo


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/sgp40.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/pwhash

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 17:30:29 UTC 2021

Modified Files:
src/usr.bin/pwhash: pwhash.1

Log Message:
Update remarks on default parameters for Argon2.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/pwhash/pwhash.1

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/pwhash/pwhash.1
diff -u src/usr.bin/pwhash/pwhash.1:1.10 src/usr.bin/pwhash/pwhash.1:1.11
--- src/usr.bin/pwhash/pwhash.1:1.10	Tue Oct 12 17:24:37 2021
+++ src/usr.bin/pwhash/pwhash.1	Wed Oct 20 17:30:28 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: pwhash.1,v 1.10 2021/10/12 17:24:37 nia Exp $
+.\"	$NetBSD: pwhash.1,v 1.11 2021/10/20 17:30:28 nia Exp $
 .\"	$OpenBSD: encrypt.1,v 1.16 2000/11/09 17:52:07 aaron Exp $
 .\"
 .\" Copyright (c) 1996, Jason Downs.  All rights reserved.
@@ -24,7 +24,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.Dd May 24, 2016
+.Dd October 20, 2021
 .Dt PWHASH 1
 .Os
 .Sh NAME
@@ -80,14 +80,14 @@ Following the required 
 name, three optional comma-delimited parameters may be provided,
 
 t=n Specify the number of iterations to n.
-The default is 3.
 
 m=n Specify the memory usage in KB  to n.
-The default is 4096.
 
 p=n Specify the number of threads to n.
 This is currently ignored.
-The default is 1.
+
+If unspecified, default parameters are calculated based on system
+performance and available resources.
 .It Fl s Ar salt
 Encrypt the string using DES, with the specified
 .Ar salt .



CVS commit: src/usr.bin/pwhash

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 17:30:29 UTC 2021

Modified Files:
src/usr.bin/pwhash: pwhash.1

Log Message:
Update remarks on default parameters for Argon2.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/usr.bin/pwhash/pwhash.1

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



CVS commit: src/lib/libcrypt

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 16:46:34 UTC 2021

Modified Files:
src/lib/libcrypt: crypt-argon2.c

Log Message:
crypt(3): For argon2, default to time=3.

Good enough for a 50MHz SPARC, a shark, and the spec.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libcrypt/crypt-argon2.c

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

Modified files:

Index: src/lib/libcrypt/crypt-argon2.c
diff -u src/lib/libcrypt/crypt-argon2.c:1.12 src/lib/libcrypt/crypt-argon2.c:1.13
--- src/lib/libcrypt/crypt-argon2.c:1.12	Wed Oct 20 15:35:42 2021
+++ src/lib/libcrypt/crypt-argon2.c	Wed Oct 20 16:46:33 2021
@@ -156,7 +156,7 @@ estimate_argon2_params(argon2_type atype
 	size_t max_mem_sz = sizeof(max_mem);
 	/* low values from argon2 test suite... */
 	uint32_t memory = 256;
-	uint32_t time = 2;
+	uint32_t time = 3;
 	uint32_t threads = 1;
 
 	if (*ememory < ARGON2_MIN_MEMORY) {
@@ -226,7 +226,7 @@ error:
 	*ethreads = threads;
 	return 0;
 reset:
-	time = 2;
+	time = 3;
 	memory = 256;
 	threads = 1;
 	goto error;



CVS commit: src/lib/libcrypt

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 16:46:34 UTC 2021

Modified Files:
src/lib/libcrypt: crypt-argon2.c

Log Message:
crypt(3): For argon2, default to time=3.

Good enough for a 50MHz SPARC, a shark, and the spec.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/lib/libcrypt/crypt-argon2.c

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



CVS commit: src/lib/libcrypt

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 15:35:42 UTC 2021

Modified Files:
src/lib/libcrypt: crypt-argon2.c

Log Message:
crypt(3): return 0 -> return NULL for function returning char *


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libcrypt/crypt-argon2.c

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

Modified files:

Index: src/lib/libcrypt/crypt-argon2.c
diff -u src/lib/libcrypt/crypt-argon2.c:1.11 src/lib/libcrypt/crypt-argon2.c:1.12
--- src/lib/libcrypt/crypt-argon2.c:1.11	Wed Oct 20 13:03:29 2021
+++ src/lib/libcrypt/crypt-argon2.c	Wed Oct 20 15:35:42 2021
@@ -398,7 +398,7 @@ __crypt_argon2(const char *pw, const cha
 
 	if (rc < 0) {
 		/* unable to parse input params */
-		return 0;
+		return NULL;
 	}
 
 	rc = argon2_hash(ctx.t_cost, ctx.m_cost,
@@ -409,7 +409,7 @@ __crypt_argon2(const char *pw, const cha
 	if (rc != ARGON2_OK) {
 		fprintf(stderr, "argon2: failed: %s\n",
 		argon2_error_message(rc));
-		return 0;
+		return NULL;
 	}
 
 	memcpy(rbuf, encodebuf, sizeof(encodebuf));



CVS commit: src/lib/libcrypt

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 15:35:42 UTC 2021

Modified Files:
src/lib/libcrypt: crypt-argon2.c

Log Message:
crypt(3): return 0 -> return NULL for function returning char *


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/lib/libcrypt/crypt-argon2.c

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



CVS commit: src/tests/kernel/kqueue

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 14:33:14 UTC 2021

Modified Files:
src/tests/kernel/kqueue: t_vnode.c

Log Message:
Add a test case for PR kern/56460.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/kernel/kqueue/t_vnode.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/kernel/kqueue/t_vnode.c
diff -u src/tests/kernel/kqueue/t_vnode.c:1.2 src/tests/kernel/kqueue/t_vnode.c:1.3
--- src/tests/kernel/kqueue/t_vnode.c:1.2	Wed Oct 20 03:08:19 2021
+++ src/tests/kernel/kqueue/t_vnode.c	Wed Oct 20 14:33:14 2021
@@ -671,6 +671,53 @@ ATF_TC_CLEANUP(interest, tc)
 	(void)unlink(testfile);
 }
 
+ATF_TC_WITH_CLEANUP(rename_over_self_hardlink);
+ATF_TC_HEAD(rename_over_self_hardlink, tc)
+{
+	atf_tc_set_md_var(tc, "descr", "This test case tests "
+		"renaming a file over a hard-link to itself");
+}
+ATF_TC_BODY(rename_over_self_hardlink, tc)
+{
+	struct kevent event[2], *dir_ev, *file_ev;
+	int dir_fd, file_fd;
+
+	ATF_REQUIRE((kq = kqueue()) != -1);
+
+	ATF_REQUIRE((mkdir(dir_target, 0700)) == 0);
+	ATF_REQUIRE((dir_fd = open(dir_target, O_RDONLY)) != -1);
+
+	ATF_REQUIRE((file_fd = open(file_inside1, O_RDONLY | O_CREAT,
+	0600)) != -1);
+	ATF_REQUIRE(link(file_inside1, file_inside2) == 0);
+
+	EV_SET(&event[0], dir_fd, EVFILT_VNODE, EV_ADD,
+	NOTE_WRITE | NOTE_EXTEND | NOTE_LINK, 0, NULL);
+	EV_SET(&event[1], file_fd, EVFILT_VNODE, EV_ADD,
+	NOTE_LINK | NOTE_DELETE, 0, NULL);
+	ATF_REQUIRE(kevent(kq, event, 2, NULL, 0, NULL) == 0);
+
+	ATF_REQUIRE(rename(file_inside1, file_inside2) == 0);
+
+	ATF_REQUIRE(kevent(kq, NULL, 0, event, 2, &ts) == 2);
+	ATF_REQUIRE(event[0].ident == (uintptr_t)dir_fd ||
+		event[0].ident == (uintptr_t)file_fd);
+	ATF_REQUIRE(event[1].ident == (uintptr_t)dir_fd ||
+		event[1].ident == (uintptr_t)file_fd);
+	if (event[0].ident == (uintptr_t)dir_fd) {
+		dir_ev = &event[0];
+		file_ev = &event[1];
+	} else {
+		dir_ev = &event[1];
+		file_ev = &event[0];
+	}
+	ATF_REQUIRE(dir_ev->fflags == NOTE_WRITE);
+	ATF_REQUIRE(file_ev->fflags == NOTE_LINK);
+}
+ATF_TC_CLEANUP(rename_over_self_hardlink, tc)
+{
+	cleanup();
+}
 
 ATF_TP_ADD_TCS(tp)
 {
@@ -699,6 +746,8 @@ ATF_TP_ADD_TCS(tp)
 	ATF_TP_ADD_TC(tp, dir_note_write_mv_file_out);
 	ATF_TP_ADD_TC(tp, dir_note_write_mv_file_within);
 
+	ATF_TP_ADD_TC(tp, rename_over_self_hardlink);
+
 	ATF_TP_ADD_TC(tp, open_write_read_close);
 	ATF_TP_ADD_TC(tp, interest);
 



CVS commit: src/tests/kernel/kqueue

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 14:33:14 UTC 2021

Modified Files:
src/tests/kernel/kqueue: t_vnode.c

Log Message:
Add a test case for PR kern/56460.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/tests/kernel/kqueue/t_vnode.c

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



CVS commit: src/sys/fs/tmpfs

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 14:28:21 UTC 2021

Modified Files:
src/sys/fs/tmpfs: tmpfs_rename.c

Log Message:
Move a mis-placed KASSERT().


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/tmpfs/tmpfs_rename.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/fs/tmpfs/tmpfs_rename.c
diff -u src/sys/fs/tmpfs/tmpfs_rename.c:1.11 src/sys/fs/tmpfs/tmpfs_rename.c:1.12
--- src/sys/fs/tmpfs/tmpfs_rename.c:1.11	Wed Oct 20 03:08:17 2021
+++ src/sys/fs/tmpfs/tmpfs_rename.c	Wed Oct 20 14:28:21 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: tmpfs_rename.c,v 1.11 2021/10/20 03:08:17 thorpej Exp $	*/
+/*	$NetBSD: tmpfs_rename.c,v 1.12 2021/10/20 14:28:21 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_rename.c,v 1.11 2021/10/20 03:08:17 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_rename.c,v 1.12 2021/10/20 14:28:21 thorpej Exp $");
 
 #include 
 #include 
@@ -402,11 +402,12 @@ tmpfs_gro_remove(struct mount *mp, kauth
 	KASSERT(VOP_ISLOCKED(dvp) == LK_EXCLUSIVE);
 	KASSERT(VOP_ISLOCKED(vp) == LK_EXCLUSIVE);
 
+	KASSERT((*dep)->td_node == VP_TO_TMPFS_NODE(vp));
+
 	tmpfs_dir_detach(dnode, *dep);
 	tmpfs_free_dirent(VFS_TO_TMPFS(mp), *dep);
 	tmpfs_update(dvp, TMPFS_UPDATE_MTIME | TMPFS_UPDATE_CTIME);
 
-	KASSERT((*dep)->td_node == VP_TO_TMPFS_NODE(vp));
 	*tvp_nlinkp = VP_TO_TMPFS_NODE(vp)->tn_links;
 
 	return 0;



CVS commit: src/sys/fs/tmpfs

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 14:28:21 UTC 2021

Modified Files:
src/sys/fs/tmpfs: tmpfs_rename.c

Log Message:
Move a mis-placed KASSERT().


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/fs/tmpfs/tmpfs_rename.c

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



CVS commit: src/sys/miscfs/genfs

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 13:29:06 UTC 2021

Modified Files:
src/sys/miscfs/genfs: genfs_rename.c

Log Message:
Don't use genfs_rename_knote() in the "rename foo over hard-link to itself"
case, which simply results in removing the "from" name; there are assertions
in genfs_rename_knote() that are too strong for that case.

PR kern/56460


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/miscfs/genfs/genfs_rename.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/miscfs/genfs/genfs_rename.c
diff -u src/sys/miscfs/genfs/genfs_rename.c:1.6 src/sys/miscfs/genfs/genfs_rename.c:1.7
--- src/sys/miscfs/genfs/genfs_rename.c:1.6	Wed Oct 20 03:08:18 2021
+++ src/sys/miscfs/genfs/genfs_rename.c	Wed Oct 20 13:29:06 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: genfs_rename.c,v 1.6 2021/10/20 03:08:18 thorpej Exp $	*/
+/*	$NetBSD: genfs_rename.c,v 1.7 2021/10/20 13:29:06 thorpej Exp $	*/
 
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.6 2021/10/20 03:08:18 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: genfs_rename.c,v 1.7 2021/10/20 13:29:06 thorpej Exp $");
 
 #include 
 #include 
@@ -312,10 +312,14 @@ genfs_sane_rename(const struct genfs_ren
 			fcnp->cn_namelen) == 0))
 			/* Renaming an entry over itself does nothing.  */
 			error = 0;
-		else
+		else {
 			/* XXX Can't use VOP_REMOVE because of locking.  */
 			error = genfs_rename_remove(ops, mp, cred,
 			fdvp, fcnp, fde, fvp, &tvp_new_nlink);
+			VN_KNOTE(fdvp, NOTE_WRITE);
+			VN_KNOTE(fvp,
+			tvp_new_nlink == 0 ? NOTE_DELETE : NOTE_LINK);
+		}
 		goto out;
 	}
 	KASSERT(fvp != tvp);
@@ -370,10 +374,9 @@ genfs_sane_rename(const struct genfs_ren
 		goto out;
 
 	/* Success!  */
+	genfs_rename_knote(fdvp, fvp, tdvp, tvp, tvp_new_nlink);
 
-out:	if (error == 0) {
-		genfs_rename_knote(fdvp, fvp, tdvp, tvp, tvp_new_nlink);
-	}
+out:
 	genfs_rename_exit(ops, mp, fdvp, fvp, tdvp, tvp);
 	return error;
 }



CVS commit: src/sys/miscfs/genfs

2021-10-20 Thread Jason R Thorpe
Module Name:src
Committed By:   thorpej
Date:   Wed Oct 20 13:29:06 UTC 2021

Modified Files:
src/sys/miscfs/genfs: genfs_rename.c

Log Message:
Don't use genfs_rename_knote() in the "rename foo over hard-link to itself"
case, which simply results in removing the "from" name; there are assertions
in genfs_rename_knote() that are too strong for that case.

PR kern/56460


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/miscfs/genfs/genfs_rename.c

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



CVS commit: src/lib/libcrypt

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 13:03:29 UTC 2021

Modified Files:
src/lib/libcrypt: crypt-argon2.c pw_gensalt.c

Log Message:
crypt(3): Adapt default Argon2 parameters to system performance

If the parameters are unspecified:

- Set the default memory consumption based on the amount of memory
available to userspace.

The algorithm actually slows down incredibly quickly as the "memory"
parameter is increased. We want to avoid running out of memory on low
memory systems, but increase the difficulty of bruteforcing passwords
from systems with a lot of memory. At the same time, we want to avoid
problems when concurrent logins are happening.

- Run a hashing loop for one second with steadily increasing "time"
until we settle on a value for "time". We want to use as much CPU time
as reasonable for computing the password hash without making logins
inconvenient.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libcrypt/crypt-argon2.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libcrypt/pw_gensalt.c

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

Modified files:

Index: src/lib/libcrypt/crypt-argon2.c
diff -u src/lib/libcrypt/crypt-argon2.c:1.10 src/lib/libcrypt/crypt-argon2.c:1.11
--- src/lib/libcrypt/crypt-argon2.c:1.10	Sat Oct 16 10:53:33 2021
+++ src/lib/libcrypt/crypt-argon2.c	Wed Oct 20 13:03:29 2021
@@ -24,6 +24,11 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+#include 
+#include 
+#include 
+#include 
+
 #include 
 #include  
 #include 
@@ -37,6 +42,10 @@
 #include 
 #include "crypt.h"
 
+crypt_private int
+estimate_argon2_params(argon2_type, uint32_t *,
+uint32_t *, uint32_t *);
+
 /* defaults pulled from run.c */
 #define HASHLEN		32
 #define T_COST_DEF 	3 
@@ -57,6 +66,10 @@
 #define ARGON2_ARGON2D_STR	"argon2d"
 #define ARGON2_ARGON2ID_STR	"argon2id"
 
+/*
+ * Unpadded Base64 calculations are taken from the Apache2/CC-0
+ * licensed libargon2 for compatibility
+ */
 
 /*
  * Some macros for constant-time comparisons. These work over values in
@@ -123,6 +136,103 @@ from_base64(void *dst, size_t *dst_len, 
 	return src;
 }
 
+/*
+ * Used to find default parameters that perform well on the host
+ * machine.  Inputs should dereference to either 0 (to estimate),
+ * or desired value.
+ */
+crypt_private int
+estimate_argon2_params(argon2_type atype, uint32_t *etime,
+uint32_t *ememory, uint32_t *ethreads)
+{
+	const int mib[] = { CTL_HW, HW_USERMEM64 };
+	struct timespec tp1, tp2, delta;
+	char tmp_salt[16];
+	char tmp_pwd[16];
+	uint32_t tmp_hash[32];
+	char tmp_encoded[256];
+	struct rlimit rlim;
+	uint64_t max_mem;
+	size_t max_mem_sz = sizeof(max_mem);
+	/* low values from argon2 test suite... */
+	uint32_t memory = 256;
+	uint32_t time = 2;
+	uint32_t threads = 1;
+
+	if (*ememory < ARGON2_MIN_MEMORY) {
+		/*
+		 * attempt to find a reasonble bound for memory use
+		 */
+		if (sysctl(mib, __arraycount(mib),
+		&max_mem, &max_mem_sz, NULL, 0) < 0) {
+			goto error;
+		}
+		if (getrlimit(RLIMIT_AS, &rlim) < 0)
+			goto error;
+		if (max_mem > rlim.rlim_cur && rlim.rlim_cur != RLIM_INFINITY)
+			max_mem = rlim.rlim_cur;
+
+		/*
+		 * Note that adding memory also greatly slows the algorithm.
+		 * Do we need to be concerned about memory usage during
+		 * concurrent connections?
+		 */
+		max_mem /= 100;
+		if (max_mem > 3) {
+			memory = 8192;
+		} else if (max_mem > 7000) {
+			memory = 4096;
+		} else if (max_mem > 24) {
+			memory = 256;
+		} else {
+			memory = ARGON2_MIN_MEMORY;
+		}
+	} else {
+		memory = *ememory;
+	}
+
+	if (*etime < ARGON2_MIN_TIME) {
+		/*
+		 * just fill these with random stuff since we'll immediately
+		 * discard them after calculating hashes for 1 second
+		 */
+		arc4random_buf(tmp_pwd, sizeof(tmp_pwd));
+		arc4random_buf(tmp_salt, sizeof(tmp_salt));
+
+		if (clock_gettime(CLOCK_MONOTONIC, &tp1) == -1)
+			goto error;
+		for (; delta.tv_sec < 1 && time < ARGON2_MAX_TIME; ++time) {
+			if (argon2_hash(time, memory, threads,
+			tmp_pwd, sizeof(tmp_pwd), 
+			tmp_salt, sizeof(tmp_salt), 
+			tmp_hash, sizeof(tmp_hash), 
+			tmp_encoded, sizeof(tmp_encoded), 
+			atype, ARGON2_VERSION_NUMBER) != ARGON2_OK) {
+goto reset;
+			}
+			if (clock_gettime(CLOCK_MONOTONIC, &tp2) == -1)
+break;
+			if (timespeccmp(&tp1, &tp2, >))
+break; /* broken system... */
+			timespecsub(&tp2, &tp1, &delta);
+		}
+	} else {
+		time = *etime;
+	}
+
+error:
+	*etime = time;
+	*ememory = memory;
+	*ethreads = threads;
+	return 0;
+reset:
+	time = 2;
+	memory = 256;
+	threads = 1;
+	goto error;
+}
+
+
 /* process params to argon2 */
 /* we don't force param order as input, */
 /* but we do provide the expected order to argon2 api */

Index: src/lib/libcrypt/pw_gensalt.c
diff -u src/lib/libcrypt/pw_gensalt.c:1.12 src/lib/libcrypt/pw_gensalt.c:1.13
--- src/lib/libcrypt/pw_gensalt.c:1.12	Sat Oct 16 10:53:33 2021
+++ src/lib/libcrypt/pw_

CVS commit: src/lib/libcrypt

2021-10-20 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Wed Oct 20 13:03:29 UTC 2021

Modified Files:
src/lib/libcrypt: crypt-argon2.c pw_gensalt.c

Log Message:
crypt(3): Adapt default Argon2 parameters to system performance

If the parameters are unspecified:

- Set the default memory consumption based on the amount of memory
available to userspace.

The algorithm actually slows down incredibly quickly as the "memory"
parameter is increased. We want to avoid running out of memory on low
memory systems, but increase the difficulty of bruteforcing passwords
from systems with a lot of memory. At the same time, we want to avoid
problems when concurrent logins are happening.

- Run a hashing loop for one second with steadily increasing "time"
until we settle on a value for "time". We want to use as much CPU time
as reasonable for computing the password hash without making logins
inconvenient.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/lib/libcrypt/crypt-argon2.c
cvs rdiff -u -r1.12 -r1.13 src/lib/libcrypt/pw_gensalt.c

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



CVS commit: src/sys/dev/pci

2021-10-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct 20 08:10:27 UTC 2021

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

Log Message:
Use wm_flush_desc_rings() more.

 - Use wm_flush_desc_rings() for newer than PCH_SPT, too. Same as other OSes.
   It seems that some devices has no this errata, but we don't know how to
   identify it. So just use >= PCH_SPT.
 - Use wm_flush_desc_rings() before chip reset in wm_resume(), too.


To generate a diff of this commit:
cvs rdiff -u -r1.714 -r1.715 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.714 src/sys/dev/pci/if_wm.c:1.715
--- src/sys/dev/pci/if_wm.c:1.714	Wed Oct 20 08:06:45 2021
+++ src/sys/dev/pci/if_wm.c	Wed Oct 20 08:10:26 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.714 2021/10/20 08:06:45 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.715 2021/10/20 08:10:26 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.714 2021/10/20 08:06:45 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.715 2021/10/20 08:10:26 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3293,6 +3293,10 @@ wm_resume(device_t self, const pmf_qual_
 	if (sc->sc_type >= WM_T_PCH2)
 		wm_resume_workarounds_pchlan(sc);
 	if ((ifp->if_flags & IFF_UP) == 0) {
+		/* >= PCH_SPT hardware workaround before reset. */
+		if (sc->sc_type >= WM_T_PCH_SPT)
+			wm_flush_desc_rings(sc);
+
 		wm_reset(sc);
 		/* Non-AMT based hardware can now take control from firmware */
 		if ((sc->sc_flags & WM_F_HAS_AMT) == 0)
@@ -6093,8 +6097,8 @@ wm_init_locked(struct ifnet *ifp)
 	if_statadd2(ifp, if_collisions, CSR_READ(sc, WMREG_COLC),
 	if_ierrors, CSR_READ(sc, WMREG_RXERRC));
 
-	/* PCH_SPT hardware workaround */
-	if (sc->sc_type == WM_T_PCH_SPT)
+	/* >= PCH_SPT hardware workaround before reset. */
+	if (sc->sc_type >= WM_T_PCH_SPT)
 		wm_flush_desc_rings(sc);
 
 	/* Reset the chip to a known state. */



CVS commit: src/sys/dev/pci

2021-10-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct 20 08:10:27 UTC 2021

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

Log Message:
Use wm_flush_desc_rings() more.

 - Use wm_flush_desc_rings() for newer than PCH_SPT, too. Same as other OSes.
   It seems that some devices has no this errata, but we don't know how to
   identify it. So just use >= PCH_SPT.
 - Use wm_flush_desc_rings() before chip reset in wm_resume(), too.


To generate a diff of this commit:
cvs rdiff -u -r1.714 -r1.715 src/sys/dev/pci/if_wm.c

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



CVS commit: src/sys/dev/pci

2021-10-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct 20 08:06:45 UTC 2021

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

Log Message:
Disable printf()s in wm_flush_desc_rings() because the code is verified.

 The problem was very rare, so I added those printf()s as we can see.
Last week, knakahara and I found a procedure to reproduce the problem and
verified it worked correctly.

 To reproduce the problem:

 0) Use I219 V1 to V5. Not all of them have the problem and newer than V5 may
have the problem. I used V2 for the test.
 1) Define WM_DEBUG or add printf in wm_flush_desc_rings() to see
DESCRING_STATUS_FLUSH_REQ bit.
 2) Run "iperf -s" on the DUT.
 3) Run "iperf3 -R -u -c 192.168.1.110 -w 8m -b 1g" repeatedly on another
machine. Note that kern.sbmax should be increased on both machines.
 4) run
while true; do
ifconfig wm0 down up
sleep 30
done
 5) After DESCRING_STATUS_FLUSH_REQ is set, without wm_flush_desc_rings(),
TX stalls and reboot is required to recover from it.
With wm_flush_desc_rings(), no device hang.
 6) If you can't see the DESCRING_STATUS_FLUSH_REQ is set, change the media
to 100BASE-T.

 Note that if_wm.c rev. 1.710 originally written by chuq is required for the
test. Without the change, the device becomes unrecoverable state before
wm_flush_desc_rings() and the function doesn't recover from the problem.


To generate a diff of this commit:
cvs rdiff -u -r1.713 -r1.714 src/sys/dev/pci/if_wm.c

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



CVS commit: src/sys/dev/pci

2021-10-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct 20 08:06:45 UTC 2021

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

Log Message:
Disable printf()s in wm_flush_desc_rings() because the code is verified.

 The problem was very rare, so I added those printf()s as we can see.
Last week, knakahara and I found a procedure to reproduce the problem and
verified it worked correctly.

 To reproduce the problem:

 0) Use I219 V1 to V5. Not all of them have the problem and newer than V5 may
have the problem. I used V2 for the test.
 1) Define WM_DEBUG or add printf in wm_flush_desc_rings() to see
DESCRING_STATUS_FLUSH_REQ bit.
 2) Run "iperf -s" on the DUT.
 3) Run "iperf3 -R -u -c 192.168.1.110 -w 8m -b 1g" repeatedly on another
machine. Note that kern.sbmax should be increased on both machines.
 4) run
while true; do
ifconfig wm0 down up
sleep 30
done
 5) After DESCRING_STATUS_FLUSH_REQ is set, without wm_flush_desc_rings(),
TX stalls and reboot is required to recover from it.
With wm_flush_desc_rings(), no device hang.
 6) If you can't see the DESCRING_STATUS_FLUSH_REQ is set, change the media
to 100BASE-T.

 Note that if_wm.c rev. 1.710 originally written by chuq is required for the
test. Without the change, the device becomes unrecoverable state before
wm_flush_desc_rings() and the function doesn't recover from the problem.


To generate a diff of this commit:
cvs rdiff -u -r1.713 -r1.714 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.713 src/sys/dev/pci/if_wm.c:1.714
--- src/sys/dev/pci/if_wm.c:1.713	Wed Oct 20 08:02:07 2021
+++ src/sys/dev/pci/if_wm.c	Wed Oct 20 08:06:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.713 2021/10/20 08:02:07 msaitoh Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.714 2021/10/20 08:06:45 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.713 2021/10/20 08:02:07 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.714 2021/10/20 08:06:45 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -4890,8 +4890,9 @@ wm_flush_desc_rings(struct wm_softc *sc)
 	 * the data of the next descriptor. We don't care about the data we are
 	 * about to reset the HW.
 	 */
-	device_printf(sc->sc_dev, "Need TX flush (reg = %08x, len = %u)\n",
-	preg, reg);
+#ifdef WM_DEBUG
+	device_printf(sc->sc_dev, "Need TX flush (reg = %08x)\n", preg);
+#endif
 	reg = CSR_READ(sc, WMREG_TCTL);
 	CSR_WRITE(sc, WMREG_TCTL, reg | TCTL_EN);
 
@@ -4921,7 +4922,9 @@ wm_flush_desc_rings(struct wm_softc *sc)
 	 * Mark all descriptors in the RX ring as consumed and disable the
 	 * rx ring.
 	 */
+#ifdef WM_DEBUG
 	device_printf(sc->sc_dev, "Need RX flush (reg = %08x)\n", preg);
+#endif
 	rctl = CSR_READ(sc, WMREG_RCTL);
 	CSR_WRITE(sc, WMREG_RCTL, rctl & ~RCTL_EN);
 	CSR_WRITE_FLUSH(sc);



CVS commit: src/sys/dev/pci

2021-10-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct 20 08:02:08 UTC 2021

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

Log Message:
Change DMA physical address in wm_flush_desc_rings() to match other OSes.

 - Even without this change, the workaround works with my machines.
 - Add comment.


To generate a diff of this commit:
cvs rdiff -u -r1.712 -r1.713 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.712 src/sys/dev/pci/if_wm.c:1.713
--- src/sys/dev/pci/if_wm.c:1.712	Wed Oct 20 07:04:28 2021
+++ src/sys/dev/pci/if_wm.c	Wed Oct 20 08:02:07 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.712 2021/10/20 07:04:28 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.713 2021/10/20 08:02:07 msaitoh Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.712 2021/10/20 07:04:28 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.713 2021/10/20 08:02:07 msaitoh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -4852,8 +4852,15 @@ wm_reset_phy(struct wm_softc *sc)
 }
 
 /*
- * Only used by WM_T_PCH_SPT which does not use multiqueue,
- * so it is enough to check sc->sc_queue[0] only.
+ * wm_flush_desc_rings - remove all descriptors from the descriptor rings.
+ *
+ * In i219, the descriptor rings must be emptied before resetting the HW
+ * or before changing the device state to D3 during runtime (runtime PM).
+ *
+ * Failure to do this will cause the HW to enter a unit hang state which can
+ * only be released by PCI reset on the device.
+ *
+ * I219 does not use multiqueue, so it is enough to check sc->sc_queue[0] only.
  */
 static void
 wm_flush_desc_rings(struct wm_softc *sc)
@@ -4875,7 +4882,14 @@ wm_flush_desc_rings(struct wm_softc *sc)
 	if (((preg & DESCRING_STATUS_FLUSH_REQ) == 0) || (reg == 0))
 		return;
 
-	/* TX */
+	/*
+	 * Remove all descriptors from the tx_ring.
+	 *
+	 * We want to clear all pending descriptors from the TX ring. Zeroing
+	 * happens when the HW reads the regs. We  assign the ring itself as
+	 * the data of the next descriptor. We don't care about the data we are
+	 * about to reset the HW.
+	 */
 	device_printf(sc->sc_dev, "Need TX flush (reg = %08x, len = %u)\n",
 	preg, reg);
 	reg = CSR_READ(sc, WMREG_TCTL);
@@ -4884,7 +4898,7 @@ wm_flush_desc_rings(struct wm_softc *sc)
 	txq = &sc->sc_queue[0].wmq_txq;
 	nexttx = txq->txq_next;
 	txd = &txq->txq_descs[nexttx];
-	wm_set_dma_addr(&txd->wtx_addr, WM_CDTXADDR(txq, nexttx));
+	wm_set_dma_addr(&txd->wtx_addr, txq->txq_desc_dma);
 	txd->wtx_cmdlen = htole32(WTX_CMD_IFCS | 512);
 	txd->wtx_fields.wtxu_status = 0;
 	txd->wtx_fields.wtxu_options = 0;
@@ -4903,7 +4917,10 @@ wm_flush_desc_rings(struct wm_softc *sc)
 	if ((preg & DESCRING_STATUS_FLUSH_REQ) == 0)
 		return;
 
-	/* RX */
+	/*
+	 * Mark all descriptors in the RX ring as consumed and disable the
+	 * rx ring.
+	 */
 	device_printf(sc->sc_dev, "Need RX flush (reg = %08x)\n", preg);
 	rctl = CSR_READ(sc, WMREG_RCTL);
 	CSR_WRITE(sc, WMREG_RCTL, rctl & ~RCTL_EN);



CVS commit: src/sys/dev/pci

2021-10-20 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Oct 20 08:02:08 UTC 2021

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

Log Message:
Change DMA physical address in wm_flush_desc_rings() to match other OSes.

 - Even without this change, the workaround works with my machines.
 - Add comment.


To generate a diff of this commit:
cvs rdiff -u -r1.712 -r1.713 src/sys/dev/pci/if_wm.c

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



CVS commit: src/sys/dev/pci

2021-10-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Oct 20 07:04:28 UTC 2021

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

Log Message:
Fix return value of interrupt handler, pointed out by msaitoh@n.o.

Even if stopping flag is set (and handler do nothing), the interrupt
itself should be assume to be processed when ICR is not zero.  If not,
interrupt count is not incremented correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.711 -r1.712 src/sys/dev/pci/if_wm.c

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

Modified files:

Index: src/sys/dev/pci/if_wm.c
diff -u src/sys/dev/pci/if_wm.c:1.711 src/sys/dev/pci/if_wm.c:1.712
--- src/sys/dev/pci/if_wm.c:1.711	Wed Oct 20 02:12:36 2021
+++ src/sys/dev/pci/if_wm.c	Wed Oct 20 07:04:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_wm.c,v 1.711 2021/10/20 02:12:36 knakahara Exp $	*/
+/*	$NetBSD: if_wm.c,v 1.712 2021/10/20 07:04:28 knakahara Exp $	*/
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.711 2021/10/20 02:12:36 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.712 2021/10/20 07:04:28 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -9853,7 +9853,7 @@ wm_intr_legacy(void *arg)
 
 	if (rxq->rxq_stopping) {
 		mutex_exit(rxq->rxq_lock);
-		return 0;
+		return 1;
 	}
 
 #if defined(WM_DEBUG) || defined(WM_EVENT_COUNTERS)
@@ -9877,7 +9877,7 @@ wm_intr_legacy(void *arg)
 
 	if (txq->txq_stopping) {
 		mutex_exit(txq->txq_lock);
-		return 0;
+		return 1;
 	}
 
 #if defined(WM_DEBUG) || defined(WM_EVENT_COUNTERS)
@@ -9897,7 +9897,7 @@ wm_intr_legacy(void *arg)
 
 	if (sc->sc_core_stopping) {
 		WM_CORE_UNLOCK(sc);
-		return 0;
+		return 1;
 	}
 
 	if (icr & (ICR_LSC | ICR_RXSEQ)) {
@@ -9997,7 +9997,7 @@ wm_txrxintr_msix(void *arg)
 
 	if (txq->txq_stopping) {
 		mutex_exit(txq->txq_lock);
-		return 0;
+		return 1;
 	}
 
 	WM_Q_EVCNT_INCR(txq, txdw);
@@ -10011,7 +10011,7 @@ wm_txrxintr_msix(void *arg)
 
 	if (rxq->rxq_stopping) {
 		mutex_exit(rxq->rxq_lock);
-		return 0;
+		return 1;
 	}
 
 	WM_Q_EVCNT_INCR(rxq, intr);



CVS commit: src/sys/dev/pci

2021-10-20 Thread Kengo NAKAHARA
Module Name:src
Committed By:   knakahara
Date:   Wed Oct 20 07:04:28 UTC 2021

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

Log Message:
Fix return value of interrupt handler, pointed out by msaitoh@n.o.

Even if stopping flag is set (and handler do nothing), the interrupt
itself should be assume to be processed when ICR is not zero.  If not,
interrupt count is not incremented correctly.


To generate a diff of this commit:
cvs rdiff -u -r1.711 -r1.712 src/sys/dev/pci/if_wm.c

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