CVS commit: src/sys/dev/sun

2022-04-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 28 03:12:03 UTC 2022

Modified Files:
src/sys/dev/sun: cgsix.c

Log Message:
be lazy about clearing the cursor - in most cases we're about to overwrite it
anyway. Same logic as with VCONS_DONT_READ.
visible speedup in things like systat and top


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/sun/cgsix.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/sun/cgsix.c
diff -u src/sys/dev/sun/cgsix.c:1.70 src/sys/dev/sun/cgsix.c:1.71
--- src/sys/dev/sun/cgsix.c:1.70	Sat Aug  7 16:19:16 2021
+++ src/sys/dev/sun/cgsix.c	Thu Apr 28 03:12:03 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: cgsix.c,v 1.70 2021/08/07 16:19:16 thorpej Exp $ */
+/*	$NetBSD: cgsix.c,v 1.71 2022/04/28 03:12:03 macallan Exp $ */
 
 /*-
  * Copyright (c) 1998 The NetBSD Foundation, Inc.
@@ -78,7 +78,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: cgsix.c,v 1.70 2021/08/07 16:19:16 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: cgsix.c,v 1.71 2022/04/28 03:12:03 macallan Exp $");
 
 #include 
 #include 
@@ -339,6 +339,23 @@ cg6_ras_init(struct cgsix_softc *sc)
 }
 
 static void
+cg6_ras_nuke_cursor(struct rasops_info *ri)
+{
+	struct vcons_screen *scr = ri->ri_hw;
+	struct cgsix_softc *sc = scr->scr_cookie;
+	int wi, he, x, y;
+		
+	if (ri->ri_flg & RI_CURSOR) {
+		wi = ri->ri_font->fontwidth;
+		he = ri->ri_font->fontheight;
+		x = ri->ri_ccol * wi + ri->ri_xorigin;
+		y = ri->ri_crow * he + ri->ri_yorigin;
+		cg6_invert(sc, x, y, wi, he);
+		ri->ri_flg &= ~RI_CURSOR;
+	}
+}
+
+static void
 cg6_ras_copyrows(void *cookie, int src, int dst, int n)
 {
 	struct rasops_info *ri = cookie;
@@ -362,6 +379,10 @@ cg6_ras_copyrows(void *cookie, int src, 
 		n = ri->ri_rows - dst;
 	if (n <= 0)
 		return;
+	if ((ri->ri_crow >= src && ri->ri_crow < (src + n)) &&
+	   (ri->ri_flg & RI_CURSOR)) {
+		cg6_ras_nuke_cursor(ri);
+	}
 	n *= ri->ri_font->fontheight;
 	src *= ri->ri_font->fontheight;
 	dst *= ri->ri_font->fontheight;
@@ -380,6 +401,8 @@ cg6_ras_copyrows(void *cookie, int src, 
 	fbc->fbc_x3 = ri->ri_xorigin + ri->ri_emuwidth - 1;
 	fbc->fbc_y3 = ri->ri_yorigin + dst + n - 1;
 	CG6_BLIT(fbc);
+	if (ri->ri_crow >= dst && ri->ri_crow < (dst + n))
+		ri->ri_flg &= ~RI_CURSOR;
 }
 
 static void
@@ -408,6 +431,11 @@ cg6_ras_copycols(void *cookie, int row, 
 		n = ri->ri_cols - dst;
 	if (n <= 0)
 		return;
+	if (ri->ri_crow == row && 
+	   (ri->ri_ccol >= src && ri->ri_ccol < (src + n)) &&
+	   (ri->ri_flg & RI_CURSOR)) {
+		cg6_ras_nuke_cursor(ri);
+	}
 	n *= ri->ri_font->fontwidth;
 	src *= ri->ri_font->fontwidth;
 	dst *= ri->ri_font->fontwidth;
@@ -429,6 +457,9 @@ cg6_ras_copycols(void *cookie, int row, 
 	fbc->fbc_y3 = ri->ri_yorigin + row + 
 	ri->ri_font->fontheight - 1;
 	CG6_BLIT(fbc);
+	if (ri->ri_crow == row && 
+	   (ri->ri_ccol >= dst && ri->ri_ccol < (dst + n)))
+		ri->ri_flg &= ~RI_CURSOR;
 }
 
 static void
@@ -449,6 +480,11 @@ cg6_ras_erasecols(void *cookie, int row,
 		n = ri->ri_cols - col;
 	if (n <= 0)
 		return;
+
+	if (ri->ri_crow == row && 
+	   (ri->ri_ccol >= col && ri->ri_ccol < (col + n)))
+		ri->ri_flg &= ~RI_CURSOR;
+
 	n *= ri->ri_font->fontwidth;
 	col *= ri->ri_font->fontwidth;
 	row *= ri->ri_font->fontheight;
@@ -483,6 +519,9 @@ cg6_ras_eraserows(void *cookie, int row,
 	if (n <= 0)
 		return;
 
+	if (ri->ri_crow >= row && ri->ri_crow < (row + n))
+		ri->ri_flg &= ~RI_CURSOR;
+
 	CG6_WAIT_READY(fbc);
 	fbc->fbc_alu = CG6_ALU_FILL;
 	fbc->fbc_mode = GX_BLIT_SRC | GX_MODE_COLOR8;
@@ -624,7 +663,7 @@ cg6attach(struct cgsix_softc *sc, const 
 		}
 	}
 	cg6_setup_palette(sc);
-	
+
 	aa.scrdata = _screenlist;
 	aa.console = isconsole;
 	aa.accessops = _accessops;
@@ -1369,6 +1408,10 @@ cgsix_putchar(void *cookie, int row, int
 	if ((row >= 0) && (row < ri->ri_rows) && (col >= 0) && 
 	(col < ri->ri_cols)) {
 
+		if (row == ri->ri_crow && col == ri->ri_ccol) {
+			ri->ri_flg &= ~RI_CURSOR;
+		}
+
 		if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
 
 			int fg, bg, uc, i;
@@ -1438,6 +1481,10 @@ cgsix_putchar_aa(void *cookie, int row, 
 	if (!CHAR_IN_FONT(c, font))
 		return;
 
+	if (row == ri->ri_crow && col == ri->ri_ccol) {
+		ri->ri_flg &= ~RI_CURSOR;
+	}
+
 	wi = font->fontwidth;
 	he = font->fontheight;
 
@@ -1532,21 +1579,17 @@ cgsix_cursor(void *cookie, int on, int r
 	he = ri->ri_font->fontheight;
 	
 	if (sc->sc_mode == WSDISPLAYIO_MODE_EMUL) {
-		x = ri->ri_ccol * wi + ri->ri_xorigin;
-		y = ri->ri_crow * he + ri->ri_yorigin;
-		if (ri->ri_flg & RI_CURSOR) {
+		if (on) {
+			if (ri->ri_flg & RI_CURSOR) {
+cg6_ras_nuke_cursor(ri);
+			}
+			x = col * wi + ri->ri_xorigin;
+			y = row * he + ri->ri_yorigin;
 			cg6_invert(sc, x, y, wi, he);
-			ri->ri_flg &= ~RI_CURSOR;
+			ri->ri_flg |= RI_CURSOR;
 		}
 		ri->ri_crow = row;
 		ri->ri_ccol = col;
-		if (on)
-		{
-			x = ri->ri_ccol * wi + ri->ri_xorigin;
-			y = 

CVS commit: src/sys/dev/sun

2022-04-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 28 03:12:03 UTC 2022

Modified Files:
src/sys/dev/sun: cgsix.c

Log Message:
be lazy about clearing the cursor - in most cases we're about to overwrite it
anyway. Same logic as with VCONS_DONT_READ.
visible speedup in things like systat and top


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/sun/cgsix.c

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



CVS commit: src/external/mit/xorg/server/xorg-server/dix

2022-04-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 28 03:07:44 UTC 2022

Modified Files:
src/external/mit/xorg/server/xorg-server/dix: Makefile.common

Log Message:
add locations where pkgsrc installs X11 fonts to the default font path


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/mit/xorg/server/xorg-server/dix/Makefile.common

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

Modified files:

Index: src/external/mit/xorg/server/xorg-server/dix/Makefile.common
diff -u src/external/mit/xorg/server/xorg-server/dix/Makefile.common:1.2 src/external/mit/xorg/server/xorg-server/dix/Makefile.common:1.3
--- src/external/mit/xorg/server/xorg-server/dix/Makefile.common:1.2	Thu Jun 18 02:45:46 2009
+++ src/external/mit/xorg/server/xorg-server/dix/Makefile.common	Thu Apr 28 03:07:44 2022
@@ -1,7 +1,14 @@
-#	$NetBSD: Makefile.common,v 1.2 2009/06/18 02:45:46 mrg Exp $
+#	$NetBSD: Makefile.common,v 1.3 2022/04/28 03:07:44 macallan Exp $
+
+PKGFONTDIR=		/usr/pkg/share/fonts/X11
 
 X11DEFAULTFONTPATH=	${X11FONTDIR}/misc/ \
 			${X11FONTDIR}/TTF/ \
 			${X11FONTDIR}/Type1/ \
 			${X11FONTDIR}/75dpi/ \
-			${X11FONTDIR}/100dpi/
+			${X11FONTDIR}/100dpi/ \
+			${PKGFONTDIR}/misc/ \
+			${PKGFONTDIR}/TTF/ \
+			${PKGFONTDIR}/Type1/ \
+			${PKGFONTDIR}/75dpi/ \
+			${PKGFONTDIR}/100dpi/



CVS commit: src/external/mit/xorg/server/xorg-server/dix

2022-04-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Thu Apr 28 03:07:44 UTC 2022

Modified Files:
src/external/mit/xorg/server/xorg-server/dix: Makefile.common

Log Message:
add locations where pkgsrc installs X11 fonts to the default font path


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 \
src/external/mit/xorg/server/xorg-server/dix/Makefile.common

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



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

2022-04-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Apr 27 23:38:31 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: efi_machdep.c pmap.c

Log Message:
since pmap_activate_efirt() rewrites TTBR0, it is necessary to pmap_activate() 
again after pmap_deactivate_efirt() to restore the original TTBR0.

- Fix to do pmap_{de,}activate() before/after pmap_{,de}activate_efirt().
- moved kpreempt_{disable,enable}() to the caller since everything between
  arm_efirt_md_enter() and arm_efirt_md_exit() should be kpreempt disabled.

ok skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/aarch64/aarch64/efi_machdep.c
cvs rdiff -u -r1.135 -r1.136 src/sys/arch/aarch64/aarch64/pmap.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/aarch64/aarch64/efi_machdep.c
diff -u src/sys/arch/aarch64/aarch64/efi_machdep.c:1.11 src/sys/arch/aarch64/aarch64/efi_machdep.c:1.12
--- src/sys/arch/aarch64/aarch64/efi_machdep.c:1.11	Sat Apr  2 11:16:06 2022
+++ src/sys/arch/aarch64/aarch64/efi_machdep.c	Wed Apr 27 23:38:31 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: efi_machdep.c,v 1.11 2022/04/02 11:16:06 skrll Exp $ */
+/* $NetBSD: efi_machdep.c,v 1.12 2022/04/27 23:38:31 ryo Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.11 2022/04/02 11:16:06 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: efi_machdep.c,v 1.12 2022/04/27 23:38:31 ryo Exp $");
 
 #include 
 #include 
@@ -106,9 +106,12 @@ arm_efirt_md_map_range(vaddr_t va, paddr
 int
 arm_efirt_md_enter(void)
 {
-	struct lwp *l = curlwp;
+	struct lwp *l;
 	int err;
 
+	kpreempt_disable();
+	l = curlwp;
+
 	/* Save FPU state */
 	arm_efirt_state.fpu_used = fpu_used_p(l) != 0;
 	if (arm_efirt_state.fpu_used)
@@ -126,8 +129,12 @@ arm_efirt_md_enter(void)
 	if (err)
 		return err;
 
-	if (efi_userva)
+	if (efi_userva) {
+		if ((l->l_flag & LW_SYSTEM) == 0) {
+			pmap_deactivate(l);
+		}
 		pmap_activate_efirt();
+	}
 
 	return 0;
 }
@@ -137,8 +144,13 @@ arm_efirt_md_exit(void)
 {
 	struct lwp *l = curlwp;
 
-	if (efi_userva)
+	if (efi_userva) {
 		pmap_deactivate_efirt();
+		if ((l->l_flag & LW_SYSTEM) == 0) {
+			pmap_activate(l);
+		}
+	}
+
 
 	/* Disable FP access */
 	reg_cpacr_el1_write(CPACR_FPEN_NONE);
@@ -150,4 +162,6 @@ arm_efirt_md_exit(void)
 
 	/* Remove custom fault handler */
 	cpu_unset_onfault();
+
+	kpreempt_enable();
 }

Index: src/sys/arch/aarch64/aarch64/pmap.c
diff -u src/sys/arch/aarch64/aarch64/pmap.c:1.135 src/sys/arch/aarch64/aarch64/pmap.c:1.136
--- src/sys/arch/aarch64/aarch64/pmap.c:1.135	Sun Apr 17 15:20:36 2022
+++ src/sys/arch/aarch64/aarch64/pmap.c	Wed Apr 27 23:38:31 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: pmap.c,v 1.135 2022/04/17 15:20:36 skrll Exp $	*/
+/*	$NetBSD: pmap.c,v 1.136 2022/04/27 23:38:31 ryo Exp $	*/
 
 /*
  * Copyright (c) 2017 Ryo Shimizu 
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.135 2022/04/17 15:20:36 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.136 2022/04/27 23:38:31 ryo Exp $");
 
 #include "opt_arm_debug.h"
 #include "opt_cpuoptions.h"
@@ -1495,8 +1495,6 @@ pmap_protect(struct pmap *pm, vaddr_t sv
 void
 pmap_activate_efirt(void)
 {
-	kpreempt_disable();
-
 	struct cpu_info *ci = curcpu();
 	struct pmap *pm = _pmap;
 	struct pmap_asid_info * const pai = PMAP_PAI(pm, cpu_tlb_info(ci));
@@ -1577,8 +1575,6 @@ pmap_deactivate_efirt(void)
 	pm->pm_activated = false;
 
 	PMAP_COUNT(deactivate);
-
-	kpreempt_enable();
 }
 #endif
 



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

2022-04-27 Thread Ryo Shimizu
Module Name:src
Committed By:   ryo
Date:   Wed Apr 27 23:38:31 UTC 2022

Modified Files:
src/sys/arch/aarch64/aarch64: efi_machdep.c pmap.c

Log Message:
since pmap_activate_efirt() rewrites TTBR0, it is necessary to pmap_activate() 
again after pmap_deactivate_efirt() to restore the original TTBR0.

- Fix to do pmap_{de,}activate() before/after pmap_{,de}activate_efirt().
- moved kpreempt_{disable,enable}() to the caller since everything between
  arm_efirt_md_enter() and arm_efirt_md_exit() should be kpreempt disabled.

ok skrll@


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/aarch64/aarch64/efi_machdep.c
cvs rdiff -u -r1.135 -r1.136 src/sys/arch/aarch64/aarch64/pmap.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/gpio

2022-04-27 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Wed Apr 27 23:15:30 UTC 2022

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

Log Message:
I have been using this for a while and forgot to commit it.  This add
a number of KERNEL_LOCK() calls and at the very least prevents gpioiic
from panicing the system.  This may be a fix for kern/56438.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/gpio/gpio.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/gpio

2022-04-27 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Wed Apr 27 23:15:30 UTC 2022

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

Log Message:
I have been using this for a while and forgot to commit it.  This add
a number of KERNEL_LOCK() calls and at the very least prevents gpioiic
from panicing the system.  This may be a fix for kern/56438.


To generate a diff of this commit:
cvs rdiff -u -r1.70 -r1.71 src/sys/dev/gpio/gpio.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/gpio/gpio.c
diff -u src/sys/dev/gpio/gpio.c:1.70 src/sys/dev/gpio/gpio.c:1.71
--- src/sys/dev/gpio/gpio.c:1.70	Thu Mar 31 19:30:16 2022
+++ src/sys/dev/gpio/gpio.c	Wed Apr 27 23:15:30 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: gpio.c,v 1.70 2022/03/31 19:30:16 pgoyette Exp $ */
+/* $NetBSD: gpio.c,v 1.71 2022/04/27 23:15:30 brad Exp $ */
 /*	$OpenBSD: gpio.c,v 1.6 2006/01/14 12:33:49 grange Exp $	*/
 
 /*
@@ -23,7 +23,7 @@
 #endif
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.70 2022/03/31 19:30:16 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: gpio.c,v 1.71 2022/04/27 23:15:30 brad Exp $");
 
 /*
  * General Purpose Input/Output framework.
@@ -181,12 +181,14 @@ gpio_childdetached(device_t self, device
 	if (error)
 		return;
 
+	KERNEL_LOCK(1, NULL);
 	LIST_FOREACH(gdev, >sc_devs, sc_next)
 		if (gdev->sc_dev == child) {
 			LIST_REMOVE(gdev, sc_next);
 			kmem_free(gdev, sizeof(struct gpio_dev));
 			break;
 		}
+	KERNEL_UNLOCK_ONE(NULL);
 
 	mutex_enter(>sc_mtx);
 	sc->sc_attach_busy = 0;
@@ -199,8 +201,10 @@ static int
 gpio_rescan(device_t self, const char *ifattr, const int *locators)
 {
 
+	KERNEL_LOCK(1, NULL);
 	config_search(self, NULL,
 	CFARGS(.search = gpio_search));
+	KERNEL_UNLOCK_ONE(NULL);
 
 	return 0;
 }
@@ -882,6 +886,7 @@ gpio_ioctl(struct gpio_softc *sc, u_long
 		locs[GPIOCF_MASK] = ga.ga_mask;
 		locs[GPIOCF_FLAG] = ga.ga_flags;
 
+		KERNEL_LOCK(1, NULL);
 		cf = config_search(sc->sc_dev, ,
 		CFARGS(.locators = locs));
 		if (cf != NULL) {
@@ -902,6 +907,8 @@ gpio_ioctl(struct gpio_softc *sc, u_long
 #endif
 		} else
 			error = EINVAL;
+		KERNEL_UNLOCK_ONE(NULL);
+
 		mutex_enter(>sc_mtx);
 		sc->sc_attach_busy = 0;
 		cv_signal(>sc_attach);
@@ -1139,6 +1146,7 @@ gpio_ioctl_oapi(struct gpio_softc *sc, u
 		if (error)
 			return EBUSY;
 
+		KERNEL_LOCK(1, NULL);
 		attach = data;
 		LIST_FOREACH(gdev, >sc_devs, sc_next) {
 			if (strcmp(device_xname(gdev->sc_dev),
@@ -1148,11 +1156,15 @@ gpio_ioctl_oapi(struct gpio_softc *sc, u
 cv_signal(>sc_attach);
 mutex_exit(>sc_mtx);
 
-if (config_detach(gdev->sc_dev, 0) == 0)
+if (config_detach(gdev->sc_dev, 0) == 0) {
+	KERNEL_UNLOCK_ONE(NULL);
 	return 0;
+}
 break;
 			}
 		}
+		KERNEL_UNLOCK_ONE(NULL);
+
 		if (gdev == NULL) {
 			mutex_enter(>sc_mtx);
 			sc->sc_attach_busy = 0;



CVS commit: src

2022-04-27 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Wed Apr 27 23:11:25 UTC 2022

Modified Files:
src/share/man/man4: sht3xtemp.4
src/sys/dev/i2c: sht3x.c sht3xreg.h

Log Message:
After testing with a couple of more samples of the SHT3x sensor chip
it was found that the datasheet does not appear to provide enough
information to make use of the alarm and interrupt function work.  So
actually remove the dead code that was an attempt at making that all
work.  Adjust the man page to mention that this.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/sht3xtemp.4
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/sht3x.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/sht3xreg.h

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/sht3xtemp.4
diff -u src/share/man/man4/sht3xtemp.4:1.2 src/share/man/man4/sht3xtemp.4:1.3
--- src/share/man/man4/sht3xtemp.4:1.2	Sat Nov  6 19:36:12 2021
+++ src/share/man/man4/sht3xtemp.4	Wed Apr 27 23:11:25 2022
@@ -1,4 +1,4 @@
-.\" $NetBSD: sht3xtemp.4,v 1.2 2021/11/06 19:36:12 wiz Exp $
+.\" $NetBSD: sht3xtemp.4,v 1.3 2022/04/27 23:11:25 brad Exp $
 .\"
 .\" Copyright (c) 2021 Brad Spencer 
 .\"
@@ -119,3 +119,6 @@ The
 .Nm
 driver was written by
 .An Brad Spencer Aq Mt b...@anduin.eldar.org .
+.Sh BUGS
+The datasheet did not provide enough information to get the alarm
+function of the chip working.

Index: src/sys/dev/i2c/sht3x.c
diff -u src/sys/dev/i2c/sht3x.c:1.6 src/sys/dev/i2c/sht3x.c:1.7
--- src/sys/dev/i2c/sht3x.c:1.6	Thu Mar 31 19:30:16 2022
+++ src/sys/dev/i2c/sht3x.c	Wed Apr 27 23:11:25 2022
@@ -1,5 +1,5 @@
 
-/*	$NetBSD: sht3x.c,v 1.6 2022/03/31 19:30:16 pgoyette Exp $	*/
+/*	$NetBSD: sht3x.c,v 1.7 2022/04/27 23:11:25 brad Exp $	*/
 
 /*
  * Copyright (c) 2021 Brad Spencer 
@@ -18,7 +18,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: sht3x.c,v 1.6 2022/03/31 19:30:16 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sht3x.c,v 1.7 2022/04/27 23:11:25 brad Exp $");
 
 /*
   Driver for the Sensirion SHT30/SHT31/SHT35
@@ -52,18 +52,6 @@ static int 	sht3x_match(device_t, cfdata
 static void 	sht3x_attach(device_t, device_t, void *);
 static int 	sht3x_detach(device_t, int);
 static void 	sht3x_refresh(struct sysmon_envsys *, envsys_data_t *);
-#ifdef __did_not_work
-/*
- * The chip that I had would not allow the limits to actually be set
- * for reasons which are not obvious.  The chip took the command just
- * fine, but a read back of the limit registers showed that no change
- * was made, so disable limits for now.
- */
-static void	sht3x_get_limits(struct sysmon_envsys *, envsys_data_t *,
-sysmon_envsys_lim_t *, uint32_t *);
-static void	sht3x_set_limits(struct sysmon_envsys *, envsys_data_t *,
-sysmon_envsys_lim_t *, uint32_t *);
-#endif
 static int 	sht3x_verify_sysctl(SYSCTLFN_ARGS);
 static int 	sht3x_verify_sysctl_heateron(SYSCTLFN_ARGS);
 static int 	sht3x_verify_sysctl_modes(SYSCTLFN_ARGS);
@@ -1181,9 +1169,6 @@ sht3x_attach(device_t parent, device_t s
 
 		sc->sc_sensors[i].units = sht3x_sensors[i].type;
 		sc->sc_sensors[i].state = ENVSYS_SINVALID;
-#ifdef __did_not_work
-		sc->sc_sensors[i].flags |= ENVSYS_FMONLIMITS;
-#endif
 
 		DPRINTF(sc, 2, ("%s: registering sensor %d (%s)\n", __func__, i,
 		sc->sc_sensors[i].desc));
@@ -1200,10 +1185,6 @@ sht3x_attach(device_t parent, device_t s
 	sc->sc_sme->sme_name = device_xname(sc->sc_dev);
 	sc->sc_sme->sme_cookie = sc;
 	sc->sc_sme->sme_refresh = sht3x_refresh;
-#ifdef __did_not_work
-	sc->sc_sme->sme_get_limits = sht3x_get_limits;
-	sc->sc_sme->sme_set_limits = sht3x_set_limits;
-#endif
 
 	DPRINTF(sc, 2, ("sht3x_attach: registering with envsys\n"));
 
@@ -1370,38 +1351,6 @@ sht3x_parse_data(struct sht3x_sc *sc, en
 	return 0;
 }
 
-#ifdef __did_not_work
-/*
- * These are the the same as above except solved for the raw tick rather than
- * temperature or humidity.  These are needed for setting the alert limits, but
- * since that did not work, disable these too for now.
- */
-static uint16_t
-sht3x_compute_raw_from_temp(uint32_t temp)
-{
-	uint64_t i1;
-	uint32_t tempc;
-
-	tempc = temp - 27215;
-	tempc = tempc / 100;
-
-	i1 = (13107 * tempc) + 589815;
-	return (uint16_t)(i1 / 35);
-}
-
-static uint16_t
-sht3x_compute_raw_from_rh(uint32_t mrh)
-{
-	uint64_t i1;
-	uint32_t rh;
-
-	rh = mrh / 100;
-
-	i1 = 13107 * rh;
-	return (uint16_t)(i1 / 20);
-}
-#endif
-
 static int
 sht3x_refresh_periodic(struct sysmon_envsys *sme, envsys_data_t *edata)
 {
@@ -1478,419 +1427,6 @@ sht3x_refresh(struct sysmon_envsys *sme,
 	mutex_exit(>sc_mutex);
 }
 
-#ifdef __did_not_work
-static void
-sht3x_get_limits(struct sysmon_envsys *sme, envsys_data_t *edata,
-sysmon_envsys_lim_t *limits, uint32_t *props)
-{
-	struct sht3x_sc *sc = sme->sme_cookie;
-	uint16_t rawlimitshigh, rawlimitslow;
-	uint16_t templimithigh, rhlimithigh,
-	templimitlow, rhlimitlow;
-	uint8_t 

CVS commit: src

2022-04-27 Thread Brad Spencer
Module Name:src
Committed By:   brad
Date:   Wed Apr 27 23:11:25 UTC 2022

Modified Files:
src/share/man/man4: sht3xtemp.4
src/sys/dev/i2c: sht3x.c sht3xreg.h

Log Message:
After testing with a couple of more samples of the SHT3x sensor chip
it was found that the datasheet does not appear to provide enough
information to make use of the alarm and interrupt function work.  So
actually remove the dead code that was an attempt at making that all
work.  Adjust the man page to mention that this.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/share/man/man4/sht3xtemp.4
cvs rdiff -u -r1.6 -r1.7 src/sys/dev/i2c/sht3x.c
cvs rdiff -u -r1.1 -r1.2 src/sys/dev/i2c/sht3xreg.h

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



CVS commit: src/lib/libcurses

2022-04-27 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Apr 27 22:04:04 UTC 2022

Modified Files:
src/lib/libcurses: move.c

Log Message:
Fix for PR 56243
clear the past EOL flags when moving the cursor - they are no longer
valid as move cannot put the cursor past the EOL.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/move.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/libcurses/move.c
diff -u src/lib/libcurses/move.c:1.23 src/lib/libcurses/move.c:1.24
--- src/lib/libcurses/move.c:1.23	Tue Oct 19 06:41:03 2021
+++ src/lib/libcurses/move.c	Wed Apr 27 22:04:04 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: move.c,v 1.23 2021/10/19 06:41:03 blymn Exp $	*/
+/*	$NetBSD: move.c,v 1.24 2022/04/27 22:04:04 blymn Exp $	*/
 
 /*
  * Copyright (c) 1981, 1993, 1994
@@ -34,7 +34,7 @@
 #if 0
 static char sccsid[] = "@(#)move.c	8.2 (Berkeley) 5/4/94";
 #else
-__RCSID("$NetBSD: move.c,v 1.23 2021/10/19 06:41:03 blymn Exp $");
+__RCSID("$NetBSD: move.c,v 1.24 2022/04/27 22:04:04 blymn Exp $");
 #endif
 #endif/* not lint */
 
@@ -68,6 +68,10 @@ wmove(WINDOW *win, int y, int x)
 	if (x >= win->maxx || y >= win->maxy)
 		return ERR;
 
+	/* clear the EOL flags for both where we were and where we are going */
+	win->alines[win->cury]->flags &= ~ __ISPASTEOL;
+	win->alines[y]->flags &= ~ __ISPASTEOL;
+
 	win->curx = x;
 	win->cury = y;
 



CVS commit: src/lib/libcurses

2022-04-27 Thread Brett Lymn
Module Name:src
Committed By:   blymn
Date:   Wed Apr 27 22:04:04 UTC 2022

Modified Files:
src/lib/libcurses: move.c

Log Message:
Fix for PR 56243
clear the past EOL flags when moving the cursor - they are no longer
valid as move cannot put the cursor past the EOL.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/lib/libcurses/move.c

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



Re: CVS commit: src/sys/lib/libsa

2022-04-27 Thread Christos Zoulas
In article <20220427144850.61383f...@cvs.netbsd.org>,
Rin Okuyama  wrote:
>-=-=-=-=-=-
>
>Module Name:   src
>Committed By:  rin
>Date:  Wed Apr 27 14:48:50 UTC 2022
>
>Modified Files:
>   src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c
>
>Log Message:
>Revert previous at the moment.
>
>This is wrong reasoning; 68020 and above (incl. 040 and 060) support
>32-bit displacements for PC relative addressing (via "fully extension
>addressing mode" with null index register).
>
>I've still not figured out what goes wrong with amiga/boot(8) when
>compiled without -l option for gas(1)...

But that was a nice change :-)

christos



CVS commit: src/sys/nfs

2022-04-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 27 17:38:52 UTC 2022

Modified Files:
src/sys/nfs: nfs_serv.c nfs_srvsubs.c nfs_var.h

Log Message:
As VOP_GETATTR() needs a shared lock at least move the preopattr lookup
inside nfs_namei() where we may lock the start directory without violating
the lock order.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.15 -r1.16 src/sys/nfs/nfs_srvsubs.c
cvs rdiff -u -r1.95 -r1.96 src/sys/nfs/nfs_var.h

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

Modified files:

Index: src/sys/nfs/nfs_serv.c
diff -u src/sys/nfs/nfs_serv.c:1.182 src/sys/nfs/nfs_serv.c:1.183
--- src/sys/nfs/nfs_serv.c:1.182	Thu Sep 16 20:17:47 2021
+++ src/sys/nfs/nfs_serv.c	Wed Apr 27 17:38:52 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs_serv.c,v 1.182 2021/09/16 20:17:47 andvar Exp $	*/
+/*	$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $	*/
 
 /*
  * Copyright (c) 1989, 1993
@@ -55,7 +55,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.182 2021/09/16 20:17:47 andvar Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_serv.c,v 1.183 2022/04/27 17:38:52 hannken Exp $");
 
 #include 
 #include 
@@ -422,7 +422,8 @@ nfsrv_lookup(struct nfsrv_descript *nfsd
 	nd.ni_cnd.cn_nameiop = LOOKUP;
 	nd.ni_cnd.cn_flags = LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag);
+		, NULL, NULL,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), pubflag);
 
 	if (!error && pubflag) {
 		if (nd.ni_vp->v_type == VDIR && nfs_pub.np_index != NULL &&
@@ -1447,10 +1448,8 @@ nfsrv_create(struct nfsrv_descript *nfsd
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp && v3) {
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		nfsm_reply(NFSX_WCCDATA(v3));
 		nfsm_srvwcc_data(dirfor_ret, , diraft_ret, );
@@ -1689,9 +1688,8 @@ nfsrv_mknod(struct nfsrv_descript *nfsd,
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp)
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
+		, _ret, ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		nfsm_reply(NFSX_WCCDATA(1));
 		nfsm_srvwcc_data(dirfor_ret, , diraft_ret, );
@@ -1845,14 +1843,8 @@ nfsrv_remove(struct nfsrv_descript *nfsd
 	nd.ni_cnd.cn_nameiop = DELETE;
 	nd.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (error == 0 && dirp && v3) {
-		if (nd.ni_dvp == nd.ni_vp)
-			vn_lock(dirp, LK_SHARED | LK_RETRY);
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-		if (nd.ni_dvp == nd.ni_vp)
-			VOP_UNLOCK(dirp);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (!error) {
 		vp = nd.ni_vp;
 		if (vp->v_type == VDIR) {
@@ -1944,14 +1936,8 @@ nfsrv_rename(struct nfsrv_descript *nfsd
 	fromnd.ni_cnd.cn_nameiop = DELETE;
 	fromnd.ni_cnd.cn_flags = LOCKPARENT;
 	error = nfs_namei(, , len, slp, nam, ,
-		, , lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (error == 0 && fdirp && v3) {
-		if (fromnd.ni_dvp == fromnd.ni_vp)
-			vn_lock(fdirp, LK_SHARED | LK_RETRY);
-		fdirfor_ret = VOP_GETATTR(fdirp, , cred);
-		if (fromnd.ni_dvp == fromnd.ni_vp)
-			VOP_UNLOCK(fdirp);
-	}
+		, , (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		fromnd.ni_cnd.cn_nameiop = 0;
 		nfsm_reply(2 * NFSX_WCCDATA(v3));
@@ -2021,10 +2007,8 @@ nfsrv_rename(struct nfsrv_descript *nfsd
 	tond.ni_cnd.cn_nameiop = RENAME;
 	tond.ni_cnd.cn_flags = LOCKPARENT | LOCKLEAF | NOCACHE;
 	error = nfs_namei(, , len2, slp, nam, ,
-		, , lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (tdirp && v3) {
-		tdirfor_ret = VOP_GETATTR(tdirp, , cred);
-	}
+		, , (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error) {
 		VFS_RENAMELOCK_EXIT(localfs);
 		VOP_ABORTOP(fromnd.ni_dvp, _cnd);
@@ -2218,10 +2202,8 @@ nfsrv_link(struct nfsrv_descript *nfsd, 
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp && v3) {
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
 	if (error)
 		goto out1;
 	xp = nd.ni_vp;
@@ -2310,10 +2292,8 @@ nfsrv_symlink(struct nfsrv_descript *nfs
 	nd.ni_cnd.cn_nameiop = CREATE;
 	nd.ni_cnd.cn_flags = LOCKPARENT;
 	error = nfs_namei(, , len, slp, nam, , ,
-		, lwp, (nfsd->nd_flag & ND_KERBAUTH), false);
-	if (dirp && v3) {
-		dirfor_ret = VOP_GETATTR(dirp, , cred);
-	}
+		, (v3 ? _ret : NULL), ,
+		lwp, 

CVS commit: src/sys/nfs

2022-04-27 Thread Juergen Hannken-Illjes
Module Name:src
Committed By:   hannken
Date:   Wed Apr 27 17:38:52 UTC 2022

Modified Files:
src/sys/nfs: nfs_serv.c nfs_srvsubs.c nfs_var.h

Log Message:
As VOP_GETATTR() needs a shared lock at least move the preopattr lookup
inside nfs_namei() where we may lock the start directory without violating
the lock order.


To generate a diff of this commit:
cvs rdiff -u -r1.182 -r1.183 src/sys/nfs/nfs_serv.c
cvs rdiff -u -r1.15 -r1.16 src/sys/nfs/nfs_srvsubs.c
cvs rdiff -u -r1.95 -r1.96 src/sys/nfs/nfs_var.h

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



CVS commit: [netbsd-8] src/doc

2022-04-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 27 16:56:09 UTC 2022

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Ticket #1739


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.125 -r1.1.2.126 src/doc/CHANGES-8.3

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-8.3
diff -u src/doc/CHANGES-8.3:1.1.2.125 src/doc/CHANGES-8.3:1.1.2.126
--- src/doc/CHANGES-8.3:1.1.2.125	Fri Mar 18 13:27:22 2022
+++ src/doc/CHANGES-8.3	Wed Apr 27 16:56:09 2022
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-8.3,v 1.1.2.125 2022/03/18 13:27:22 martin Exp $
+# $NetBSD: CHANGES-8.3,v 1.1.2.126 2022/04/27 16:56:09 martin Exp $
 
 A complete list of changes from the NetBSD 8.2 release to the NetBSD 8.3
 release:
@@ -2559,3 +2559,11 @@ usr.sbin/puffs/mount_9p/node.c			1.30,1.
 	check returned type from T_READ request.
 	[ozaki-r, ticket #1738]
 
+lib/libquota/quota_oldfiles.c			1.10
+sys/ufs/ufs/ufs_quota1.c			1.25
+usr.sbin/quotaon/quotaon.c			1.31
+
+	Fix quota1 user+group quota, quotaoff live lock and quotaon/off
+	verbose output.  Avoids possibly corrupted quota data.
+	[hannken, ticket #1739]
+



CVS commit: [netbsd-8] src/doc

2022-04-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 27 16:56:09 UTC 2022

Modified Files:
src/doc [netbsd-8]: CHANGES-8.3

Log Message:
Ticket #1739


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.125 -r1.1.2.126 src/doc/CHANGES-8.3

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



CVS commit: [netbsd-8] src

2022-04-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 27 16:55:18 UTC 2022

Modified Files:
src/lib/libquota [netbsd-8]: quota_oldfiles.c
src/sys/ufs/ufs [netbsd-8]: ufs_quota1.c
src/usr.sbin/quotaon [netbsd-8]: quotaon.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1739):

usr.sbin/quotaon/quotaon.c: revision 1.31
lib/libquota/quota_oldfiles.c: revision 1.10
sys/ufs/ufs/ufs_quota1.c: revision 1.25

Fix default quota file names, both user and group quota used the
same default name "QUOTAFILENAME, names[USRQUOTA])" resulting in
diagnostic assertion and possibly corrupted quota data.

Keep flag "UFS_QUOTA" set until the last quota is closed.
Prevents a live lock when dqrele() finds a struct with "dq_cnt == 1"
and flag "DQ_MOD" and cannot sync as flag UFS_QUOTA is unset.

As the quota type comes from the kernel and is only valid when
quota is on get the type before quota_off and after quota_on.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.26.1 src/lib/libquota/quota_oldfiles.c
cvs rdiff -u -r1.22.10.1 -r1.22.10.2 src/sys/ufs/ufs/ufs_quota1.c
cvs rdiff -u -r1.30 -r1.30.24.1 src/usr.sbin/quotaon/quotaon.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/libquota/quota_oldfiles.c
diff -u src/lib/libquota/quota_oldfiles.c:1.9 src/lib/libquota/quota_oldfiles.c:1.9.26.1
--- src/lib/libquota/quota_oldfiles.c:1.9	Fri Feb 24 18:00:09 2012
+++ src/lib/libquota/quota_oldfiles.c	Wed Apr 27 16:55:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_oldfiles.c,v 1.9 2012/02/24 18:00:09 njoly Exp $	*/
+/*	$NetBSD: quota_oldfiles.c,v 1.9.26.1 2022/04/27 16:55:18 martin Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -33,7 +33,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: quota_oldfiles.c,v 1.9 2012/02/24 18:00:09 njoly Exp $");
+__RCSID("$NetBSD: quota_oldfiles.c,v 1.9.26.1 2022/04/27 16:55:18 martin Exp $");
 
 #include 
 #include 
@@ -255,7 +255,7 @@ __quota_oldfiles_defquotafile(struct quo
 
 	(void)snprintf(buf, maxlen, "%s/%s.%s",
 		   qh->qh_mountpoint,
-		   QUOTAFILENAME, names[USRQUOTA]);
+		   QUOTAFILENAME, names[idtype]);
 }
 
 const char *

Index: src/sys/ufs/ufs/ufs_quota1.c
diff -u src/sys/ufs/ufs/ufs_quota1.c:1.22.10.1 src/sys/ufs/ufs/ufs_quota1.c:1.22.10.2
--- src/sys/ufs/ufs/ufs_quota1.c:1.22.10.1	Fri Jan  1 13:19:57 2021
+++ src/sys/ufs/ufs/ufs_quota1.c	Wed Apr 27 16:55:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota1.c,v 1.22.10.1 2021/01/01 13:19:57 martin Exp $	*/
+/*	$NetBSD: ufs_quota1.c,v 1.22.10.2 2022/04/27 16:55:18 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22.10.1 2021/01/01 13:19:57 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22.10.2 2022/04/27 16:55:18 martin Exp $");
 
 #include 
 #include 
@@ -435,7 +435,6 @@ quota1_handle_cmd_quotaoff(struct lwp *l
 		return (0);
 	}
 	ump->umq1_qflags[type] |= QTF_CLOSING;
-	ump->um_flags &= ~UFS_QUOTA;
 	mutex_exit();
 	/*
 	 * Search vnodes associated with this mount point,
@@ -472,6 +471,8 @@ quota1_handle_cmd_quotaoff(struct lwp *l
 		if (ump->um_quotas[i] != NULLVP)
 			break;
 	ump->umq1_qflags[type] &= ~QTF_CLOSING;
+	if (i == MAXQUOTAS)
+		ump->um_flags &= ~UFS_QUOTA;
 	cv_broadcast();
 	mutex_exit();
 	kauth_cred_free(cred);

Index: src/usr.sbin/quotaon/quotaon.c
diff -u src/usr.sbin/quotaon/quotaon.c:1.30 src/usr.sbin/quotaon/quotaon.c:1.30.24.1
--- src/usr.sbin/quotaon/quotaon.c:1.30	Sat Apr  7 05:07:33 2012
+++ src/usr.sbin/quotaon/quotaon.c	Wed Apr 27 16:55:18 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotaon.c,v 1.30 2012/04/07 05:07:33 christos Exp $	*/
+/*	$NetBSD: quotaon.c,v 1.30.24.1 2022/04/27 16:55:18 martin Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quotaon.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: quotaon.c,v 1.30 2012/04/07 05:07:33 christos Exp $");
+__RCSID("$NetBSD: quotaon.c,v 1.30.24.1 2022/04/27 16:55:18 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -217,12 +217,14 @@ quotaonoff(struct fstab *fs, struct quot
 int warn_on_enxio, const char *fsspec)
 {
 	const char *mode = (offmode == 1) ? "off" : "on";
+	const char *type;
 
 	if (strcmp(fs->fs_file, "/") && readonly(fs, fsspec)) {
 		return 1;
 	}
 
 	if (offmode) {
+		type = quota_idtype_getname(qh, idtype);
 		if (quota_quotaoff(qh, idtype)) {
 			if (warn_on_enxio || errno != ENXIO) {
 warn("quota%s for %s", mode, fs->fs_file);
@@ -236,11 +238,12 @@ quotaonoff(struct fstab *fs, struct quot
 			}
 			return 1;
 		}
+		type = quota_idtype_getname(qh, idtype);
 	}
 
 	if (vflag) {
 		printf("%s: %s quotas turned %s\n",
-		fs->fs_file, quota_idtype_getname(qh, idtype), mode);
+		fs->fs_file, type, mode);
 	}
 	return 0;
 }



CVS commit: [netbsd-8] src

2022-04-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 27 16:55:18 UTC 2022

Modified Files:
src/lib/libquota [netbsd-8]: quota_oldfiles.c
src/sys/ufs/ufs [netbsd-8]: ufs_quota1.c
src/usr.sbin/quotaon [netbsd-8]: quotaon.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1739):

usr.sbin/quotaon/quotaon.c: revision 1.31
lib/libquota/quota_oldfiles.c: revision 1.10
sys/ufs/ufs/ufs_quota1.c: revision 1.25

Fix default quota file names, both user and group quota used the
same default name "QUOTAFILENAME, names[USRQUOTA])" resulting in
diagnostic assertion and possibly corrupted quota data.

Keep flag "UFS_QUOTA" set until the last quota is closed.
Prevents a live lock when dqrele() finds a struct with "dq_cnt == 1"
and flag "DQ_MOD" and cannot sync as flag UFS_QUOTA is unset.

As the quota type comes from the kernel and is only valid when
quota is on get the type before quota_off and after quota_on.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.26.1 src/lib/libquota/quota_oldfiles.c
cvs rdiff -u -r1.22.10.1 -r1.22.10.2 src/sys/ufs/ufs/ufs_quota1.c
cvs rdiff -u -r1.30 -r1.30.24.1 src/usr.sbin/quotaon/quotaon.c

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



CVS commit: [netbsd-9] src/doc

2022-04-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 27 16:54:20 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Ticket #1440


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.86 -r1.1.2.87 src/doc/CHANGES-9.3

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



CVS commit: [netbsd-9] src/doc

2022-04-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 27 16:54:20 UTC 2022

Modified Files:
src/doc [netbsd-9]: CHANGES-9.3

Log Message:
Ticket #1440


To generate a diff of this commit:
cvs rdiff -u -r1.1.2.86 -r1.1.2.87 src/doc/CHANGES-9.3

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-9.3
diff -u src/doc/CHANGES-9.3:1.1.2.86 src/doc/CHANGES-9.3:1.1.2.87
--- src/doc/CHANGES-9.3:1.1.2.86	Mon Apr 25 12:39:27 2022
+++ src/doc/CHANGES-9.3	Wed Apr 27 16:54:20 2022
@@ -1,4 +1,4 @@
-# $NetBSD: CHANGES-9.3,v 1.1.2.86 2022/04/25 12:39:27 martin Exp $
+# $NetBSD: CHANGES-9.3,v 1.1.2.87 2022/04/27 16:54:20 martin Exp $
 
 A complete list of changes from the NetBSD 9.2 release to the NetBSD 9.3
 release:
@@ -1553,3 +1553,11 @@ xsrc/external/mit/xinit/dist/startx.cpp	
 	Do not attempt to trap SIGKILL.
 	[nia, ticket #1439]
 
+lib/libquota/quota_oldfiles.c			1.10
+sys/ufs/ufs/ufs_quota1.c			1.25
+usr.sbin/quotaon/quotaon.c			1.31
+
+	Fix quota1 user+group quota, quotaoff live lock and quotaon/off
+	verbose output.  Avoids possibly corrupted quota data.
+	[hannken, ticket #1440]
+



CVS commit: [netbsd-9] src

2022-04-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 27 16:53:32 UTC 2022

Modified Files:
src/lib/libquota [netbsd-9]: quota_oldfiles.c
src/sys/ufs/ufs [netbsd-9]: ufs_quota1.c
src/usr.sbin/quotaon [netbsd-9]: quotaon.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1440):

usr.sbin/quotaon/quotaon.c: revision 1.31
lib/libquota/quota_oldfiles.c: revision 1.10
sys/ufs/ufs/ufs_quota1.c: revision 1.25

Fix default quota file names, both user and group quota used the
same default name "QUOTAFILENAME, names[USRQUOTA])" resulting in
diagnostic assertion and possibly corrupted quota data.

Keep flag "UFS_QUOTA" set until the last quota is closed.
Prevents a live lock when dqrele() finds a struct with "dq_cnt == 1"
and flag "DQ_MOD" and cannot sync as flag UFS_QUOTA is unset.

As the quota type comes from the kernel and is only valid when
quota is on get the type before quota_off and after quota_on.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.36.1 src/lib/libquota/quota_oldfiles.c
cvs rdiff -u -r1.22.22.1 -r1.22.22.2 src/sys/ufs/ufs/ufs_quota1.c
cvs rdiff -u -r1.30 -r1.30.34.1 src/usr.sbin/quotaon/quotaon.c

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



CVS commit: [netbsd-9] src

2022-04-27 Thread Martin Husemann
Module Name:src
Committed By:   martin
Date:   Wed Apr 27 16:53:32 UTC 2022

Modified Files:
src/lib/libquota [netbsd-9]: quota_oldfiles.c
src/sys/ufs/ufs [netbsd-9]: ufs_quota1.c
src/usr.sbin/quotaon [netbsd-9]: quotaon.c

Log Message:
Pull up following revision(s) (requested by hannken in ticket #1440):

usr.sbin/quotaon/quotaon.c: revision 1.31
lib/libquota/quota_oldfiles.c: revision 1.10
sys/ufs/ufs/ufs_quota1.c: revision 1.25

Fix default quota file names, both user and group quota used the
same default name "QUOTAFILENAME, names[USRQUOTA])" resulting in
diagnostic assertion and possibly corrupted quota data.

Keep flag "UFS_QUOTA" set until the last quota is closed.
Prevents a live lock when dqrele() finds a struct with "dq_cnt == 1"
and flag "DQ_MOD" and cannot sync as flag UFS_QUOTA is unset.

As the quota type comes from the kernel and is only valid when
quota is on get the type before quota_off and after quota_on.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.9.36.1 src/lib/libquota/quota_oldfiles.c
cvs rdiff -u -r1.22.22.1 -r1.22.22.2 src/sys/ufs/ufs/ufs_quota1.c
cvs rdiff -u -r1.30 -r1.30.34.1 src/usr.sbin/quotaon/quotaon.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/libquota/quota_oldfiles.c
diff -u src/lib/libquota/quota_oldfiles.c:1.9 src/lib/libquota/quota_oldfiles.c:1.9.36.1
--- src/lib/libquota/quota_oldfiles.c:1.9	Fri Feb 24 18:00:09 2012
+++ src/lib/libquota/quota_oldfiles.c	Wed Apr 27 16:53:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: quota_oldfiles.c,v 1.9 2012/02/24 18:00:09 njoly Exp $	*/
+/*	$NetBSD: quota_oldfiles.c,v 1.9.36.1 2022/04/27 16:53:32 martin Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -33,7 +33,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: quota_oldfiles.c,v 1.9 2012/02/24 18:00:09 njoly Exp $");
+__RCSID("$NetBSD: quota_oldfiles.c,v 1.9.36.1 2022/04/27 16:53:32 martin Exp $");
 
 #include 
 #include 
@@ -255,7 +255,7 @@ __quota_oldfiles_defquotafile(struct quo
 
 	(void)snprintf(buf, maxlen, "%s/%s.%s",
 		   qh->qh_mountpoint,
-		   QUOTAFILENAME, names[USRQUOTA]);
+		   QUOTAFILENAME, names[idtype]);
 }
 
 const char *

Index: src/sys/ufs/ufs/ufs_quota1.c
diff -u src/sys/ufs/ufs/ufs_quota1.c:1.22.22.1 src/sys/ufs/ufs/ufs_quota1.c:1.22.22.2
--- src/sys/ufs/ufs/ufs_quota1.c:1.22.22.1	Fri Jan  1 13:17:08 2021
+++ src/sys/ufs/ufs/ufs_quota1.c	Wed Apr 27 16:53:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs_quota1.c,v 1.22.22.1 2021/01/01 13:17:08 martin Exp $	*/
+/*	$NetBSD: ufs_quota1.c,v 1.22.22.2 2022/04/27 16:53:32 martin Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993, 1995
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22.22.1 2021/01/01 13:17:08 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ufs_quota1.c,v 1.22.22.2 2022/04/27 16:53:32 martin Exp $");
 
 #include 
 #include 
@@ -435,7 +435,6 @@ quota1_handle_cmd_quotaoff(struct lwp *l
 		return (0);
 	}
 	ump->umq1_qflags[type] |= QTF_CLOSING;
-	ump->um_flags &= ~UFS_QUOTA;
 	mutex_exit();
 	/*
 	 * Search vnodes associated with this mount point,
@@ -472,6 +471,8 @@ quota1_handle_cmd_quotaoff(struct lwp *l
 		if (ump->um_quotas[i] != NULLVP)
 			break;
 	ump->umq1_qflags[type] &= ~QTF_CLOSING;
+	if (i == MAXQUOTAS)
+		ump->um_flags &= ~UFS_QUOTA;
 	cv_broadcast();
 	mutex_exit();
 	kauth_cred_free(cred);

Index: src/usr.sbin/quotaon/quotaon.c
diff -u src/usr.sbin/quotaon/quotaon.c:1.30 src/usr.sbin/quotaon/quotaon.c:1.30.34.1
--- src/usr.sbin/quotaon/quotaon.c:1.30	Sat Apr  7 05:07:33 2012
+++ src/usr.sbin/quotaon/quotaon.c	Wed Apr 27 16:53:32 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: quotaon.c,v 1.30 2012/04/07 05:07:33 christos Exp $	*/
+/*	$NetBSD: quotaon.c,v 1.30.34.1 2022/04/27 16:53:32 martin Exp $	*/
 
 /*
  * Copyright (c) 1980, 1990, 1993
@@ -42,7 +42,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 19
 #if 0
 static char sccsid[] = "@(#)quotaon.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: quotaon.c,v 1.30 2012/04/07 05:07:33 christos Exp $");
+__RCSID("$NetBSD: quotaon.c,v 1.30.34.1 2022/04/27 16:53:32 martin Exp $");
 #endif
 #endif /* not lint */
 
@@ -217,12 +217,14 @@ quotaonoff(struct fstab *fs, struct quot
 int warn_on_enxio, const char *fsspec)
 {
 	const char *mode = (offmode == 1) ? "off" : "on";
+	const char *type;
 
 	if (strcmp(fs->fs_file, "/") && readonly(fs, fsspec)) {
 		return 1;
 	}
 
 	if (offmode) {
+		type = quota_idtype_getname(qh, idtype);
 		if (quota_quotaoff(qh, idtype)) {
 			if (warn_on_enxio || errno != ENXIO) {
 warn("quota%s for %s", mode, fs->fs_file);
@@ -236,11 +238,12 @@ quotaonoff(struct fstab *fs, struct quot
 			}
 			return 1;
 		}
+		type = quota_idtype_getname(qh, idtype);
 	}
 
 	if (vflag) {
 		printf("%s: %s quotas turned %s\n",
-		fs->fs_file, quota_idtype_getname(qh, idtype), mode);
+		fs->fs_file, type, mode);
 	}
 	return 0;
 }



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 14:50:35 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Revert previous.

On 2022/04/27 21:10, Rin Okuyama wrote:
> Module Name:  src
> Committed By: rin
> Date: Wed Apr 27 12:10:47 UTC 2022
>
> Modified Files:
>   src/sys/arch/amiga/stand/bootblock/boot: Makefile
>
> Log Message:
> Sprinkle SA_HARDCODED_SECSIZE; now everything fits into
> +/-32KB range visible for PC relative addressing mode.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amiga/stand/bootblock/boot/Makefile
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/amiga/stand/bootblock/boot/Makefile

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/amiga/stand/bootblock/boot/Makefile
diff -u src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.58 src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.59
--- src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.58	Wed Apr 27 12:10:47 2022
+++ src/sys/arch/amiga/stand/bootblock/boot/Makefile	Wed Apr 27 14:50:35 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.58 2022/04/27 12:10:47 rin Exp $
+#	$NetBSD: Makefile,v 1.59 2022/04/27 14:50:35 rin Exp $
 
 .include 
 .include 		# for HOST_SH
@@ -50,7 +50,7 @@ SOBJS += libstubs.o
 OBJS+=	$(SOBJS) $(COBJS)
 
 #XX#DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER -DDYNAMIC_CRC_TABLE -DNOBYFOUR -UBYFOUR 
-DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER -DSA_HARDCODED_SECSIZE
+DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER 
 DEFS += -D__INTERNAL_LIBSA_CREAD
 DEFS += -DSERCONSOLE
 SOBJS += cread.o



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 14:50:35 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Revert previous.

On 2022/04/27 21:10, Rin Okuyama wrote:
> Module Name:  src
> Committed By: rin
> Date: Wed Apr 27 12:10:47 UTC 2022
>
> Modified Files:
>   src/sys/arch/amiga/stand/bootblock/boot: Makefile
>
> Log Message:
> Sprinkle SA_HARDCODED_SECSIZE; now everything fits into
> +/-32KB range visible for PC relative addressing mode.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amiga/stand/bootblock/boot/Makefile
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/amiga/stand/bootblock/boot/Makefile

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



CVS commit: src/sys/lib/libsa

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 14:48:50 UTC 2022

Modified Files:
src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c

Log Message:
Revert previous at the moment.

This is wrong reasoning; 68020 and above (incl. 040 and 060) support
32-bit displacements for PC relative addressing (via "fully extension
addressing mode" with null index register).

I've still not figured out what goes wrong with amiga/boot(8) when
compiled without -l option for gas(1)...

On 2022/04/27 20:48, Rin Okuyama wrote:
> Module Name:  src
> Committed By: rin
> Date: Wed Apr 27 11:48:26 UTC 2022
>
> Modified Files:
>   src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c
>
> Log Message:
> Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
> used instead of secsize obtained by SAIOSECSIZE ioctl.
>
> This hack avoids divdi3 and friends from being linked, in order to
> support variable secsize.
>
> This is useful for amiga/boot(8); it is loaded by firmware into
> unpredictable address, and therefore all symbols should be
> addressable by PC relative mode with only 16-bit displacements.
>
> See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
> more details.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c
> cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c
> cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/lib/libsa/ext2fs.c
cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libsa/minixfs3.c
cvs rdiff -u -r1.84 -r1.85 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.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/lib/libsa/ext2fs.c
diff -u src/sys/lib/libsa/ext2fs.c:1.32 src/sys/lib/libsa/ext2fs.c:1.33
--- src/sys/lib/libsa/ext2fs.c:1.32	Wed Apr 27 11:48:26 2022
+++ src/sys/lib/libsa/ext2fs.c	Wed Apr 27 14:48:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.c,v 1.32 2022/04/27 11:48:26 rin Exp $	*/
+/*	$NetBSD: ext2fs.c,v 1.33 2022/04/27 14:48:50 rin Exp $	*/
 
 /*
  * Copyright (c) 1997 Manuel Bouyer.
@@ -415,9 +415,15 @@ read_sblock(struct open_file *f, struct 
 	struct ext2fs ext2fs;
 	size_t buf_size;
 	int rc;
+	u_int secsize;
+
+	secsize = 0;
+	rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, );
+	if (rc != 0 || secsize == 0)
+		secsize = DEV_BSIZE;
 
 	rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
-	SBOFF / GETSECSIZE(f), SBSIZE, sbbuf, _size);
+	SBOFF / secsize, SBSIZE, sbbuf, _size);
 	if (rc)
 		return rc;
 

Index: src/sys/lib/libsa/minixfs3.c
diff -u src/sys/lib/libsa/minixfs3.c:1.11 src/sys/lib/libsa/minixfs3.c:1.12
--- src/sys/lib/libsa/minixfs3.c:1.11	Wed Apr 27 11:48:26 2022
+++ src/sys/lib/libsa/minixfs3.c	Wed Apr 27 14:48:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: minixfs3.c,v 1.11 2022/04/27 11:48:26 rin Exp $	*/
+/*	$NetBSD: minixfs3.c,v 1.12 2022/04/27 14:48:50 rin Exp $	*/
 
 /*-
  * Copyright (c) 2012
@@ -449,6 +449,7 @@ read_sblock(struct open_file *f, struct 
 	static uint8_t sbbuf[MINBSIZE];
 	size_t buf_size;
 	int rc;
+	u_int secsize;
 
 	/* We must read amount multiple of sector size, hence we can't
 	 * read SBSIZE and read MINBSIZE.
@@ -456,8 +457,13 @@ read_sblock(struct open_file *f, struct 
 	if (SBSIZE > MINBSIZE)
 		return EINVAL;
 
+	secsize = 0;
+	rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, );
+	if (rc != 0 || secsize == 0)
+		secsize = DEV_BSIZE;
+
 	rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
-	SUPER_BLOCK_OFF / GETSECSIZE(f), MINBSIZE, sbbuf, _size);
+	SUPER_BLOCK_OFF / secsize, MINBSIZE, sbbuf, _size);
 	if (rc)
 		return rc;
 

Index: src/sys/lib/libsa/stand.h
diff -u src/sys/lib/libsa/stand.h:1.84 src/sys/lib/libsa/stand.h:1.85
--- src/sys/lib/libsa/stand.h:1.84	Wed Apr 27 11:48:26 2022
+++ src/sys/lib/libsa/stand.h	Wed Apr 27 14:48:50 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: stand.h,v 1.84 2022/04/27 11:48:26 rin Exp $	*/
+/*	$NetBSD: stand.h,v 1.85 2022/04/27 14:48:50 rin Exp $	*/
 
 /*
  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
@@ -64,7 +64,6 @@
 #ifndef _LIBSA_STAND_H_
 #define	_LIBSA_STAND_H_
 
-#include 
 #include 
 #include 
 #include 
@@ -321,22 +320,4 @@ void	bzero(void *, size_t);
 
 int	atoi(const char *);
 
-#if !defined(SA_HARDCODED_SECSIZE)
-#define	GETSECSIZE(f)	getsecsize(f)
-static inline u_int
-getsecsize(struct open_file *f)
-{
-	int rc;
-	u_int secsize = 0;
-
-	rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, );
-	if (rc != 0 || secsize == 0)
-		secsize = DEV_BSIZE;
-
-	return secsize;
-}
-#else
-#define	GETSECSIZE(f)	DEV_BSIZE
-#endif
-
 #endif /* _LIBSA_STAND_H_ */
Index: src/sys/lib/libsa/ufs.c
diff -u src/sys/lib/libsa/ufs.c:1.84 src/sys/lib/libsa/ufs.c:1.85
--- src/sys/lib/libsa/ufs.c:1.84	Wed Apr 27 11:48:26 

CVS commit: src/sys/lib/libsa

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 14:48:50 UTC 2022

Modified Files:
src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c

Log Message:
Revert previous at the moment.

This is wrong reasoning; 68020 and above (incl. 040 and 060) support
32-bit displacements for PC relative addressing (via "fully extension
addressing mode" with null index register).

I've still not figured out what goes wrong with amiga/boot(8) when
compiled without -l option for gas(1)...

On 2022/04/27 20:48, Rin Okuyama wrote:
> Module Name:  src
> Committed By: rin
> Date: Wed Apr 27 11:48:26 UTC 2022
>
> Modified Files:
>   src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c
>
> Log Message:
> Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
> used instead of secsize obtained by SAIOSECSIZE ioctl.
>
> This hack avoids divdi3 and friends from being linked, in order to
> support variable secsize.
>
> This is useful for amiga/boot(8); it is loaded by firmware into
> unpredictable address, and therefore all symbols should be
> addressable by PC relative mode with only 16-bit displacements.
>
> See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
> more details.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c
> cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c
> cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.c
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/lib/libsa/ext2fs.c
cvs rdiff -u -r1.11 -r1.12 src/sys/lib/libsa/minixfs3.c
cvs rdiff -u -r1.84 -r1.85 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.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/amiga/stand/bootblock/boot

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 12:10:47 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Sprinkle SA_HARDCODED_SECSIZE; now everything fits into
+/-32KB range visible for PC relative addressing mode.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amiga/stand/bootblock/boot/Makefile

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/amiga/stand/bootblock/boot/Makefile
diff -u src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.57 src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.58
--- src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.57	Thu Feb 25 03:42:14 2021
+++ src/sys/arch/amiga/stand/bootblock/boot/Makefile	Wed Apr 27 12:10:47 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.57 2021/02/25 03:42:14 rin Exp $
+#	$NetBSD: Makefile,v 1.58 2022/04/27 12:10:47 rin Exp $
 
 .include 
 .include 		# for HOST_SH
@@ -50,7 +50,7 @@ SOBJS += libstubs.o
 OBJS+=	$(SOBJS) $(COBJS)
 
 #XX#DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER -DDYNAMIC_CRC_TABLE -DNOBYFOUR -UBYFOUR 
-DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER 
+DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER -DSA_HARDCODED_SECSIZE
 DEFS += -D__INTERNAL_LIBSA_CREAD
 DEFS += -DSERCONSOLE
 SOBJS += cread.o



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 12:10:47 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Sprinkle SA_HARDCODED_SECSIZE; now everything fits into
+/-32KB range visible for PC relative addressing mode.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amiga/stand/bootblock/boot/Makefile

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



CVS commit: src/sys/lib/libsa

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 11:48:26 UTC 2022

Modified Files:
src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c

Log Message:
Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize.

This is useful for amiga/boot(8); it is loaded by firmware into
unpredictable address, and therefore all symbols should be
addressable by PC relative mode with only 16-bit displacements.

See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
more details.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c
cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c
cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.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/lib/libsa/ext2fs.c
diff -u src/sys/lib/libsa/ext2fs.c:1.31 src/sys/lib/libsa/ext2fs.c:1.32
--- src/sys/lib/libsa/ext2fs.c:1.31	Sun Apr 24 06:48:15 2022
+++ src/sys/lib/libsa/ext2fs.c	Wed Apr 27 11:48:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ext2fs.c,v 1.31 2022/04/24 06:48:15 mlelstv Exp $	*/
+/*	$NetBSD: ext2fs.c,v 1.32 2022/04/27 11:48:26 rin Exp $	*/
 
 /*
  * Copyright (c) 1997 Manuel Bouyer.
@@ -415,15 +415,9 @@ read_sblock(struct open_file *f, struct 
 	struct ext2fs ext2fs;
 	size_t buf_size;
 	int rc;
-	u_int secsize;
-
-	secsize = 0;
-	rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, );
-	if (rc != 0 || secsize == 0)
-		secsize = DEV_BSIZE;
 
 	rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
-	SBOFF / secsize, SBSIZE, sbbuf, _size);
+	SBOFF / GETSECSIZE(f), SBSIZE, sbbuf, _size);
 	if (rc)
 		return rc;
 

Index: src/sys/lib/libsa/minixfs3.c
diff -u src/sys/lib/libsa/minixfs3.c:1.10 src/sys/lib/libsa/minixfs3.c:1.11
--- src/sys/lib/libsa/minixfs3.c:1.10	Sun Apr 24 06:48:15 2022
+++ src/sys/lib/libsa/minixfs3.c	Wed Apr 27 11:48:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: minixfs3.c,v 1.10 2022/04/24 06:48:15 mlelstv Exp $	*/
+/*	$NetBSD: minixfs3.c,v 1.11 2022/04/27 11:48:26 rin Exp $	*/
 
 /*-
  * Copyright (c) 2012
@@ -449,7 +449,6 @@ read_sblock(struct open_file *f, struct 
 	static uint8_t sbbuf[MINBSIZE];
 	size_t buf_size;
 	int rc;
-	u_int secsize;
 
 	/* We must read amount multiple of sector size, hence we can't
 	 * read SBSIZE and read MINBSIZE.
@@ -457,13 +456,8 @@ read_sblock(struct open_file *f, struct 
 	if (SBSIZE > MINBSIZE)
 		return EINVAL;
 
-	secsize = 0;
-	rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, );
-	if (rc != 0 || secsize == 0)
-		secsize = DEV_BSIZE;
-
 	rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
-	SUPER_BLOCK_OFF / secsize, MINBSIZE, sbbuf, _size);
+	SUPER_BLOCK_OFF / GETSECSIZE(f), MINBSIZE, sbbuf, _size);
 	if (rc)
 		return rc;
 

Index: src/sys/lib/libsa/stand.h
diff -u src/sys/lib/libsa/stand.h:1.83 src/sys/lib/libsa/stand.h:1.84
--- src/sys/lib/libsa/stand.h:1.83	Mon May 17 08:50:36 2021
+++ src/sys/lib/libsa/stand.h	Wed Apr 27 11:48:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: stand.h,v 1.83 2021/05/17 08:50:36 mrg Exp $	*/
+/*	$NetBSD: stand.h,v 1.84 2022/04/27 11:48:26 rin Exp $	*/
 
 /*
  * Copyright (c) 1999 Christopher G. Demetriou.  All rights reserved.
@@ -64,6 +64,7 @@
 #ifndef _LIBSA_STAND_H_
 #define	_LIBSA_STAND_H_
 
+#include 
 #include 
 #include 
 #include 
@@ -320,4 +321,22 @@ void	bzero(void *, size_t);
 
 int	atoi(const char *);
 
+#if !defined(SA_HARDCODED_SECSIZE)
+#define	GETSECSIZE(f)	getsecsize(f)
+static inline u_int
+getsecsize(struct open_file *f)
+{
+	int rc;
+	u_int secsize = 0;
+
+	rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, );
+	if (rc != 0 || secsize == 0)
+		secsize = DEV_BSIZE;
+
+	return secsize;
+}
+#else
+#define	GETSECSIZE(f)	DEV_BSIZE
+#endif
+
 #endif /* _LIBSA_STAND_H_ */
Index: src/sys/lib/libsa/ufs.c
diff -u src/sys/lib/libsa/ufs.c:1.83 src/sys/lib/libsa/ufs.c:1.84
--- src/sys/lib/libsa/ufs.c:1.83	Sun Apr 24 06:52:59 2022
+++ src/sys/lib/libsa/ufs.c	Wed Apr 27 11:48:26 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: ufs.c,v 1.83 2022/04/24 06:52:59 mlelstv Exp $	*/
+/*	$NetBSD: ufs.c,v 1.84 2022/04/27 11:48:26 rin Exp $	*/
 
 /*-
  * Copyright (c) 1993
@@ -594,21 +594,15 @@ ffs_find_superblock(struct open_file *f,
 	struct file *fp = (struct file *)f->f_fsdata;
 	int rc;
 	size_t buf_size;
-	u_int secsize;
 #ifdef LIBSA_FFSv2
 	static daddr_t sblock_try[] = SBLOCKSEARCH;
 	int i;
 #endif
 
-	secsize = 0;
-	rc = DEV_IOCTL(f->f_dev)(f, SAIOSECSIZE, );
-	if (rc != 0 || secsize == 0)
-		secsize = DEV_BSIZE;
-
 #ifdef LIBSA_FFSv2
 	for (i = 0; sblock_try[i] != -1; i++) {
 		rc = DEV_STRATEGY(f->f_dev)(f->f_devdata, F_READ,
-		sblock_try[i] / secsize, SBLOCKSIZE, fs, _size);
+		sblock_try[i] / GETSECSIZE(f), SBLOCKSIZE, fs, _size);
 		if (rc)
 			return rc;
 		if (buf_size != SBLOCKSIZE)
@@ -623,7 +617,7 @@ 

CVS commit: src/sys/lib/libsa

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 11:48:26 UTC 2022

Modified Files:
src/sys/lib/libsa: ext2fs.c minixfs3.c stand.h ufs.c

Log Message:
Introduce SA_HARDCODED_SECSIZE hack, by which hardcoded DEV_BSIZE is
used instead of secsize obtained by SAIOSECSIZE ioctl.

This hack avoids divdi3 and friends from being linked, in order to
support variable secsize.

This is useful for amiga/boot(8); it is loaded by firmware into
unpredictable address, and therefore all symbols should be
addressable by PC relative mode with only 16-bit displacements.

See sys/arch/amiga/stand/bootblock/{boot/bbstart.s,elf2bb,txlt} for
more details.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/lib/libsa/ext2fs.c
cvs rdiff -u -r1.10 -r1.11 src/sys/lib/libsa/minixfs3.c
cvs rdiff -u -r1.83 -r1.84 src/sys/lib/libsa/stand.h src/sys/lib/libsa/ufs.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

2022-04-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 27 08:06:20 UTC 2022

Modified Files:
src/sys/arch/arm/apple: files.apple
src/sys/arch/evbarm/conf: GENERIC64
Added Files:
src/sys/arch/arm/apple: apple_mbox.c apple_mbox.h apple_rtkit.c
apple_rtkit.h

Log Message:
Add support for the mailbox that provides a communications channel with
additional cores integrated in Apple Silicon.

Also, add an implementation for the protocol to communicate with
coprocessors running firmware based Apple's RTKit OS.

>From OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/apple/apple_mbox.c \
src/sys/arch/arm/apple/apple_mbox.h src/sys/arch/arm/apple/apple_rtkit.c \
src/sys/arch/arm/apple/apple_rtkit.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/apple/files.apple
cvs rdiff -u -r1.197 -r1.198 src/sys/arch/evbarm/conf/GENERIC64

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

Modified files:

Index: src/sys/arch/arm/apple/files.apple
diff -u src/sys/arch/arm/apple/files.apple:1.4 src/sys/arch/arm/apple/files.apple:1.5
--- src/sys/arch/arm/apple/files.apple:1.4	Wed Apr 27 07:59:18 2022
+++ src/sys/arch/arm/apple/files.apple	Wed Apr 27 08:06:20 2022
@@ -1,11 +1,9 @@
-#	$NetBSD: files.apple,v 1.4 2022/04/27 07:59:18 skrll Exp $
+#	$NetBSD: files.apple,v 1.5 2022/04/27 08:06:20 skrll Exp $
 #
 # Configuration info for Apple Silicon SoCs
 #
 #
 
-file	arch/arm/apple/apple_platform.c		soc_apple
-
 # IOMMU
 device	appledart
 attach	appledart at fdt with apple_dart
@@ -16,6 +14,11 @@ device	appleintc: pic, pic_splfuncs
 attach	appleintc at fdt with apple_intc
 file	arch/arm/apple/apple_intc.c		apple_intc
 
+# Mailbox
+device	applembox
+attach	applembox at fdt with apple_mbox
+file	arch/arm/apple/apple_mbox.c		apple_mbox
+
 # PCIe controller
 device	applepcie: pcibus, pcihost_fdt
 attach	applepcie at fdt with apple_pcie
@@ -39,3 +42,6 @@ file	arch/arm/apple/apple_wdog.c		apple_
 
 # SOC parameters
 defflag	opt_soc.hSOC_APPLE
+
+file	arch/arm/apple/apple_platform.c		soc_apple
+file	arch/arm/apple/apple_rtkit.c		soc_apple & apple_mbox

Index: src/sys/arch/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.197 src/sys/arch/evbarm/conf/GENERIC64:1.198
--- src/sys/arch/evbarm/conf/GENERIC64:1.197	Wed Apr 27 07:59:18 2022
+++ src/sys/arch/evbarm/conf/GENERIC64	Wed Apr 27 08:06:20 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.197 2022/04/27 07:59:18 skrll Exp $
+#	$NetBSD: GENERIC64,v 1.198 2022/04/27 08:06:20 skrll Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -200,6 +200,9 @@ tegrafuse*	at fdt? pass 4		# NVIDIA Tegr
 # Power management controller
 tegrapmc*	at fdt? pass 4		# NVIDIA Tegra PMC
 
+# Mailbox controller
+applembox*	at fdt? pass 2		# Apple Mailbox
+
 # Clock and Reset controller
 bcmcprman*	at fdt? pass 1		# Broadcom BCM283x Clock Manager
 bcmaux* 	at fdt? pass 1		# Broadcom BCM283x Aux Periph Clocks

Added files:

Index: src/sys/arch/arm/apple/apple_mbox.c
diff -u /dev/null src/sys/arch/arm/apple/apple_mbox.c:1.1
--- /dev/null	Wed Apr 27 08:06:20 2022
+++ src/sys/arch/arm/apple/apple_mbox.c	Wed Apr 27 08:06:20 2022
@@ -0,0 +1,310 @@
+/*	$NetBSD: apple_mbox.c,v 1.1 2022/04/27 08:06:20 skrll Exp $	*/
+/*	$OpenBSD: apple_mbox.c,v 1.2 2022/01/04 20:55:48 kettenis Exp $	*/
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 2021 Mark Kettenis 
+ *
+ * Permission to use, copy, modify, and 

CVS commit: src/sys/arch

2022-04-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 27 08:06:20 UTC 2022

Modified Files:
src/sys/arch/arm/apple: files.apple
src/sys/arch/evbarm/conf: GENERIC64
Added Files:
src/sys/arch/arm/apple: apple_mbox.c apple_mbox.h apple_rtkit.c
apple_rtkit.h

Log Message:
Add support for the mailbox that provides a communications channel with
additional cores integrated in Apple Silicon.

Also, add an implementation for the protocol to communicate with
coprocessors running firmware based Apple's RTKit OS.

>From OpenBSD.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/apple/apple_mbox.c \
src/sys/arch/arm/apple/apple_mbox.h src/sys/arch/arm/apple/apple_rtkit.c \
src/sys/arch/arm/apple/apple_rtkit.h
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/arm/apple/files.apple
cvs rdiff -u -r1.197 -r1.198 src/sys/arch/evbarm/conf/GENERIC64

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



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

2022-04-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 27 08:03:06 UTC 2022

Modified Files:
src/sys/arch/arm/apple: apple_pcie.c

Log Message:
Sync with OpenBSD

- port initialisation and device power up. Latter requires the SMC
  GPIO controller which is WIP.

While here
- improve the MSI vector search algorithm; and
- spinkle some BITS(3)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/apple/apple_pcie.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/apple

2022-04-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 27 08:03:06 UTC 2022

Modified Files:
src/sys/arch/arm/apple: apple_pcie.c

Log Message:
Sync with OpenBSD

- port initialisation and device power up. Latter requires the SMC
  GPIO controller which is WIP.

While here
- improve the MSI vector search algorithm; and
- spinkle some BITS(3)


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/arm/apple/apple_pcie.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/apple/apple_pcie.c
diff -u src/sys/arch/arm/apple/apple_pcie.c:1.5 src/sys/arch/arm/apple/apple_pcie.c:1.6
--- src/sys/arch/arm/apple/apple_pcie.c:1.5	Tue Sep 14 01:33:19 2021
+++ src/sys/arch/arm/apple/apple_pcie.c	Wed Apr 27 08:03:06 2022
@@ -1,4 +1,5 @@
-/* $NetBSD: apple_pcie.c,v 1.5 2021/09/14 01:33:19 jmcneill Exp $ */
+/* $NetBSD: apple_pcie.c,v 1.6 2022/04/27 08:03:06 skrll Exp $ */
+/*	$OpenBSD: aplpcie.c,v 1.13 2022/04/06 18:59:26 naddy Exp $	*/
 
 /*-
  * Copyright (c) 2021 Jared McNeill 
@@ -26,8 +27,25 @@
  * SUCH DAMAGE.
  */
 
+/*
+ * Copyright (c) 2021 Mark Kettenis 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+
 #include 
-__KERNEL_RCSID(0, "$NetBSD: apple_pcie.c,v 1.5 2021/09/14 01:33:19 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apple_pcie.c,v 1.6 2022/04/27 08:03:06 skrll Exp $");
 
 #include 
 #include 
@@ -46,17 +64,44 @@ __KERNEL_RCSID(0, "$NetBSD: apple_pcie.c
 #include 
 #include 
 
-#define	PCIE_MSI_CTRL		0x0124
-#define	 PCIE_MSI_CTRL_EN	(1U << 0)
-#define	 PCIE_MSI_CTRL_32	(5U << 4)
-#define	PCIE_MSI_REMAP		0x0128
-#define	PCIE_MSI_DOORBELL	0x0168
+#define PCIE_CORE_LANE_CONF(port)	(0x84000 + (port) * 0x4000)
+#define  PCIE_CORE_LANE_CONF_REFCLK0REQ	__BIT(0)
+#define  PCIE_CORE_LANE_CONF_REFCLK1REQ	__BIT(1)
+#define  PCIE_CORE_LANE_CONF_REFCLK0ACK	__BIT(2)
+#define  PCIE_CORE_LANE_CONF_REFCLK1ACK	__BIT(3)
+#define  PCIE_CORE_LANE_CONF_REFCLK0EN	__BIT(9)
+#define  PCIE_CORE_LANE_CONF_REFCLK1EN	__BIT(10)
+#define PCIE_CORE_LANE_CTRL(port)	(0x84004 + (port) * 0x4000)
+#define  PCIE_CORE_LANE_CTRL_CFGACC	__BIT(15)
+
+#define PCIE_PORT_LTSSM_CTRL		0x0080
+#define  PCIE_PORT_LTSSM_CTRL_START	__BIT(0)
+#define	PCIE_PORT_MSI_CTRL		0x0124
+#define	 PCIE_PORT_MSI_CTRL_EN		__BIT(0)
+#define	 PCIE_PORT_MSI_CTRL_32		__SHIFTIN(5U, __BITS(7,4))
+#define	PCIE_PORT_MSI_REMAP		0x0128
+#define	PCIE_PORT_MSI_DOORBELL		0x0168
+#define PCIE_PORT_LINK_STAT		0x0208
+#define  PCIE_PORT_LINK_STAT_UP		__BIT(0)
+#define PCIE_PORT_APPCLK		0x0800
+#define  PCIE_PORT_APPCLK_EN		__BIT(0)
+#define  PCIE_PORT_APPCLK_CGDIS		__BIT(8)
+#define PCIE_PORT_STAT			0x0804
+#define  PCIE_PORT_STAT_READY		__BIT(0)
+#define PCIE_PORT_REFCLK		0x0810
+#define  PCIE_PORT_REFCLK_EN		__BIT(0)
+#define  PCIE_PORT_REFCLK_CGDIS		__BIT(8)
+#define PCIE_PORT_PERST			0x0814
+#define  PCIE_PORT_PERST_DIS		__BIT(0)
 
 extern struct bus_space arm_generic_bs_tag;
 
 struct apple_pcie_softc {
 	struct pcihost_softc	sc_pcihost;
 
+	bus_space_tag_t		sc_rc_bst;
+	bus_space_handle_t	sc_rc_bsh;
+
 	int			sc_phandle;
 	struct arm_pci_msi	sc_msi;
 	u_int			sc_msi_start;
@@ -81,6 +126,176 @@ static const struct device_compatible_en
 	DEVICE_COMPAT_EOL
 };
 
+#define RREAD4(sc, reg)		\
+(bus_space_read_4((sc)->sc_rc_bst, (sc)->sc_rc_bsh, (reg)))
+#define RWRITE4(sc, reg, val)	\
+bus_space_write_4((sc)->sc_rc_bst, (sc)->sc_rc_bsh, (reg), (val))
+#define RSET4(sc, reg, bits)\
+RWRITE4((sc), (reg), RREAD4((sc), (reg)) | (bits))
+#define RCLR4(sc, reg, bits)\
+RWRITE4((sc), (reg), RREAD4((sc), (reg)) & ~(bits))
+
+
+static void
+apple_pcie_setup_port(struct apple_pcie_softc *sc, int phandle)
+{
+	const bus_space_tag_t bst = sc->sc_pcihost.sc_bst;
+	const device_t dev = sc->sc_pcihost.sc_dev;
+	const int parent = sc->sc_pcihost.sc_phandle;
+	char regname[sizeof("portX")];
+	bus_space_handle_t bsh;
+	bus_addr_t addr;
+	bus_size_t size;
+	int error;
+	int timo;
+	int len;
+
+	const u_int *reg = fdtbus_get_prop(phandle, "reg", );
+	if (len != 5 * sizeof(uint32_t)) {
+		aprint_error(": couldn't get port number\n");
+	}
+
+	u_int portno = __SHIFTOUT(be32toh(reg[0]), __BITS(13,11));
+	snprintf(regname, sizeof(regname), "port%u", 

CVS commit: src/sys/arch

2022-04-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 27 07:59:18 UTC 2022

Modified Files:
src/sys/arch/arm/apple: files.apple
src/sys/arch/evbarm/conf: GENERIC64
Added Files:
src/sys/arch/arm/apple: apple_pinctrl.c

Log Message:
Add a driver for the Apple GPIO controller found in Apple silicon.

Derived from the OpenBSD driver.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/apple/apple_pinctrl.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/apple/files.apple
cvs rdiff -u -r1.196 -r1.197 src/sys/arch/evbarm/conf/GENERIC64

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

Modified files:

Index: src/sys/arch/arm/apple/files.apple
diff -u src/sys/arch/arm/apple/files.apple:1.3 src/sys/arch/arm/apple/files.apple:1.4
--- src/sys/arch/arm/apple/files.apple:1.3	Wed Apr 27 07:55:42 2022
+++ src/sys/arch/arm/apple/files.apple	Wed Apr 27 07:59:18 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.apple,v 1.3 2022/04/27 07:55:42 skrll Exp $
+#	$NetBSD: files.apple,v 1.4 2022/04/27 07:59:18 skrll Exp $
 #
 # Configuration info for Apple Silicon SoCs
 #
@@ -21,6 +21,12 @@ device	applepcie: pcibus, pcihost_fdt
 attach	applepcie at fdt with apple_pcie
 file	arch/arm/apple/apple_pcie.c		apple_pcie
 
+# GPIO controller
+# : gpiobus?
+device	applepinctrl
+attach	applepinctrl at fdt with apple_pinctrl
+file	arch/arm/apple/apple_pinctrl.c		apple_pinctrl
+
 # Power domain controller
 device	applepmgr
 attach	applepmgr at fdt with apple_pmgr

Index: src/sys/arch/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.196 src/sys/arch/evbarm/conf/GENERIC64:1.197
--- src/sys/arch/evbarm/conf/GENERIC64:1.196	Wed Apr 27 07:55:42 2022
+++ src/sys/arch/evbarm/conf/GENERIC64	Wed Apr 27 07:59:18 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.196 2022/04/27 07:55:42 skrll Exp $
+#	$NetBSD: GENERIC64,v 1.197 2022/04/27 07:59:18 skrll Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -223,6 +223,7 @@ sunxigmacclk*	at fdt? pass 2		# Allwinne
 tegra210car*	at fdt? pass 3		# NVIDIA Tegra CAR (T210)
 
 # GPIO controller
+applepinctrl*	at fdt?			# Apple GPIO
 bcmgpio*	at fdt? pass 3		# Broadcom BCM283x GPIO
 imxgpio*	at fdt? pass 3		# IMX GPIO
 mesonpinctrl*	at fdt? pass 2		# Amlogic Meson GPIO

Added files:

Index: src/sys/arch/arm/apple/apple_pinctrl.c
diff -u /dev/null src/sys/arch/arm/apple/apple_pinctrl.c:1.1
--- /dev/null	Wed Apr 27 07:59:18 2022
+++ src/sys/arch/arm/apple/apple_pinctrl.c	Wed Apr 27 07:59:18 2022
@@ -0,0 +1,299 @@
+/*	$NetBSD: apple_pinctrl.c,v 1.1 2022/04/27 07:59:18 skrll Exp $	*/
+/*	$OpenBSD: aplpinctrl.c,v 1.4 2022/04/06 18:59:26 naddy Exp $	*/
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * Copyright (c) 2021 Mark Kettenis 
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS 

CVS commit: src/sys/arch

2022-04-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 27 07:59:18 UTC 2022

Modified Files:
src/sys/arch/arm/apple: files.apple
src/sys/arch/evbarm/conf: GENERIC64
Added Files:
src/sys/arch/arm/apple: apple_pinctrl.c

Log Message:
Add a driver for the Apple GPIO controller found in Apple silicon.

Derived from the OpenBSD driver.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/apple/apple_pinctrl.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/apple/files.apple
cvs rdiff -u -r1.196 -r1.197 src/sys/arch/evbarm/conf/GENERIC64

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



CVS commit: src/sys/arch

2022-04-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 27 07:55:42 UTC 2022

Modified Files:
src/sys/arch/arm/apple: files.apple
src/sys/arch/evbarm/conf: GENERIC64
Added Files:
src/sys/arch/arm/apple: apple_pmgr.c

Log Message:
Add support for the power domain controller found in Apple silicon
machines.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/apple/apple_pmgr.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/apple/files.apple
cvs rdiff -u -r1.195 -r1.196 src/sys/arch/evbarm/conf/GENERIC64

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

Modified files:

Index: src/sys/arch/arm/apple/files.apple
diff -u src/sys/arch/arm/apple/files.apple:1.2 src/sys/arch/arm/apple/files.apple:1.3
--- src/sys/arch/arm/apple/files.apple:1.2	Mon Jan  3 08:44:10 2022
+++ src/sys/arch/arm/apple/files.apple	Wed Apr 27 07:55:42 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: files.apple,v 1.2 2022/01/03 08:44:10 skrll Exp $
+#	$NetBSD: files.apple,v 1.3 2022/04/27 07:55:42 skrll Exp $
 #
 # Configuration info for Apple Silicon SoCs
 #
@@ -21,6 +21,11 @@ device	applepcie: pcibus, pcihost_fdt
 attach	applepcie at fdt with apple_pcie
 file	arch/arm/apple/apple_pcie.c		apple_pcie
 
+# Power domain controller
+device	applepmgr
+attach	applepmgr at fdt with apple_pmgr
+file	arch/arm/apple/apple_pmgr.c		apple_pmgr
+
 # Watchdog timer
 device	applewdog: sysmon_wdog
 attach	applewdog at fdt with apple_wdog

Index: src/sys/arch/evbarm/conf/GENERIC64
diff -u src/sys/arch/evbarm/conf/GENERIC64:1.195 src/sys/arch/evbarm/conf/GENERIC64:1.196
--- src/sys/arch/evbarm/conf/GENERIC64:1.195	Mon Mar 21 09:20:04 2022
+++ src/sys/arch/evbarm/conf/GENERIC64	Wed Apr 27 07:55:42 2022
@@ -1,5 +1,5 @@
 #
-#	$NetBSD: GENERIC64,v 1.195 2022/03/21 09:20:04 jmcneill Exp $
+#	$NetBSD: GENERIC64,v 1.196 2022/04/27 07:55:42 skrll Exp $
 #
 #	GENERIC ARM (aarch64) kernel
 #
@@ -363,6 +363,9 @@ rkpmic* 	at iic?			# Rockchip Power Mana
 rkreg*		at rkpmic?
 tcagpio*	at iic?
 
+# Power Domain controllers
+applepmgr* 	at fdt? pass 0
+
 # Random number generators
 amdccp* 	at fdt?			# AMD Cryptograhic Coprocessor RNG
 amdccp* 	at acpi?

Added files:

Index: src/sys/arch/arm/apple/apple_pmgr.c
diff -u /dev/null src/sys/arch/arm/apple/apple_pmgr.c:1.1
--- /dev/null	Wed Apr 27 07:55:42 2022
+++ src/sys/arch/arm/apple/apple_pmgr.c	Wed Apr 27 07:55:42 2022
@@ -0,0 +1,153 @@
+/* $NetBSD: apple_pmgr.c,v 1.1 2022/04/27 07:55:42 skrll Exp $ */
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Nick Hudson
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: apple_pmgr.c,v 1.1 2022/04/27 07:55:42 skrll Exp $");
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+#include 
+
+/*
+ * Power manager registers
+ */
+#define PMGR_PS_TARGET_MASK	__BITS(3, 0)
+#define PMGR_PS_ACTUAL_MASK	__BITS(7, 4)
+#define  PMGR_PS_ACTIVE		0xf
+#define  PMGR_PS_PWRGATE	0x0
+
+struct apple_pmgr_softc {
+	device_t sc_dev;
+	bus_space_tag_t sc_bst;
+	bus_space_handle_t sc_bsh;
+};
+
+#define PMGR_READ(sc, reg) \
+	bus_space_read_4((sc)->sc_bst, (sc)->sc_bsh, (reg))
+#define	PMGR_WRITE(sc, reg, val) \
+	bus_space_write_4((sc)->sc_bst, (sc)->sc_bsh, (reg), (val))
+
+
+static const struct device_compatible_entry compat_data[] = {
+	{ .compat = "apple,pmgr" },
+	DEVICE_COMPAT_EOL
+};
+
+static void
+apple_pmgr_enable(device_t dev, const uint32_t *data, bool enable)
+{
+	struct apple_pmgr_softc * const sc = device_private(dev);
+	const uint32_t pstate = enable ? 

CVS commit: src/sys/arch

2022-04-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 27 07:55:42 UTC 2022

Modified Files:
src/sys/arch/arm/apple: files.apple
src/sys/arch/evbarm/conf: GENERIC64
Added Files:
src/sys/arch/arm/apple: apple_pmgr.c

Log Message:
Add support for the power domain controller found in Apple silicon
machines.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/arch/arm/apple/apple_pmgr.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/arm/apple/files.apple
cvs rdiff -u -r1.195 -r1.196 src/sys/arch/evbarm/conf/GENERIC64

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



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

2022-04-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 27 07:53:24 UTC 2022

Modified Files:
src/sys/arch/arm/apple: apple_dart.c

Log Message:
Sync with OpenBSD

- Use subpage feature
- Catch up with new device tree bindings
- Skip locked DARTs
- Use bypass mode for USB3 DARTs

Other changes from me
- Sprinkle BITS(3)
- Improve interrupt error handling


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/apple/apple_dart.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/apple/apple_dart.c
diff -u src/sys/arch/arm/apple/apple_dart.c:1.3 src/sys/arch/arm/apple/apple_dart.c:1.4
--- src/sys/arch/arm/apple/apple_dart.c:1.3	Mon Sep  6 14:03:17 2021
+++ src/sys/arch/arm/apple/apple_dart.c	Wed Apr 27 07:53:24 2022
@@ -1,4 +1,5 @@
-/* $NetBSD: apple_dart.c,v 1.3 2021/09/06 14:03:17 jmcneill Exp $ */
+/* $NetBSD: apple_dart.c,v 1.4 2022/04/27 07:53:24 skrll Exp $ */
+/*	$OpenBSD: apldart.c,v 1.10 2022/02/27 17:36:52 kettenis Exp $	*/
 
 /*-
  * Copyright (c) 2021 Mark Kettenis 
@@ -20,7 +21,7 @@
 //#define APPLE_DART_DEBUG
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: apple_dart.c,v 1.3 2021/09/06 14:03:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apple_dart.c,v 1.4 2022/04/27 07:53:24 skrll Exp $");
 
 #include 
 #include 
@@ -34,37 +35,78 @@ __KERNEL_RCSID(0, "$NetBSD: apple_dart.c
 #include 
 
 #include 
+/*
+ * This driver largely ignores stream IDs and simply uses a single
+ * translation table for all the devices that it serves.  This is good
+ * enough for the PCIe host bridge that serves the on-board devices on
+ * the current generation Apple Silicon Macs as these only have a
+ * single PCIe device behind each DART.
+ */
 
 /*
  * DART registers
  */
+#define	DART_PARAMS2		0x0004
+#define	 DART_PARAMS2_BYPASS_SUPPORT	__BIT(0)
 #define	DART_TLB_OP		0x0020
-#define	 DART_TLB_OP_FLUSH	__BIT(20)
-#define	 DART_TLB_OP_BUSY	__BIT(2)
+#define	 DART_TLB_OP_BUSY		__BIT(2)
+#define	 DART_TLB_OP_FLUSH		__BIT(20)
 #define	DART_TLB_OP_SIDMASK	0x0034
 #define	DART_ERR_STATUS		0x0040
+#define	 DART_ERR_FLAG		__BIT(31)
+#define	 DART_ERR_STREAM_MASK	__BITS(27, 24)
+#define	 DART_ERR_CODE_MASK	__BITS(11, 0)
+#define	 DART_ERR_READ_FAULT	__BIT(4)
+#define	 DART_ERR_WRITE_FAULT	__BIT(3)
+#define	 DART_ERR_NOPTE		__BIT(2)
+#define	 DART_ERR_NOPMD		__BIT(1)
+#define	 DART_ERR_NOTTBR	__BIT(0)
 #define	DART_ERR_ADDRL		0x0050
 #define	DART_ERR_ADDRH		0x0054
-#define	DART_CONFIG(sid)	(0x0100 + (sid) * 0x4)
-#define	 DART_CONFIG_TXEN	__BIT(7)
+#define	DART_CONFIG		0x0060
+#define	 DART_CONFIG_LOCK		__BIT(15)
+#define	DART_TCR(sid)		(0x0100 + (sid) * 0x4)
+#define	 DART_TCR_TRANSLATE_ENABLE	__BIT(7)
+#define	 DART_TCR_BYPASS_DART		__BIT(8)
+#define	 DART_TCR_BYPASS_DAPF		__BIT(12)
 #define	DART_TTBR(sid, idx)	(0x0200 + (sid) * 0x10 + (idx) * 0x4)
-#define	 DART_TTBR_VALID	__BIT(31)
-#define	 DART_TTBR_SHIFT	12
+#define	 DART_TTBR_VALID		__BIT(31)
+#define	 DART_TTBR_SHIFT		12
+
+#define	DART_NUM_STREAMS	16
+#define	DART_ALL_STREAMS	((1 << DART_NUM_STREAMS) - 1)
 
 #define	DART_APERTURE_START	0x0010
 #define	DART_APERTURE_SIZE	0x3fe0
 #define	DART_PAGE_SIZE		16384
 #define	DART_PAGE_MASK		(DART_PAGE_SIZE - 1)
 
-#define	DART_L1_TABLE		0xb
+/*
+ * Some hardware (e.g. bge(4)) will always use (aligned) 64-bit memory
+ * access.  To make sure this doesn't fault, round the subpage limits
+ * down and up accordingly.
+ */
+#define DART_OFFSET_MASK	7
+
+#define	DART_L1_TABLE		0x3
 #define	DART_L2_INVAL		0x0
-#define	DART_L2_PAGE		0x3
+#define	DART_L2_VALID		__BIT(0)
+#define	DART_L2_FULL_PAGE	__BIT(1)
+
+#define	DART_L2_START_MASK	__BITS(63, 52)
+#define	DART_L2_END_MASK	__BITS(51, 40)
+#define	DART_L2_SUBPAGE(addr)	__SHIFTOUT((addr), __BITS(13, 2))
+#define	DART_L2_START(addr)	__SHIFTIN(DART_L2_SUBPAGE(addr), DART_L2_START_MASK)
+#define	DART_L2_END(addr)	__SHIFTIN(DART_L2_SUBPAGE(addr), DART_L2_END_MASK)
 
 #define	DART_ROUND_PAGE(pa)	(((pa) + DART_PAGE_MASK) & ~DART_PAGE_MASK)
 #define	DART_TRUNC_PAGE(pa)	((pa) & ~DART_PAGE_MASK)
+#define	DART_ROUND_OFFSET(pa)	(((pa) + DART_OFFSET_MASK) & ~DART_OFFSET_MASK)
+#define	DART_TRUNC_OFFSET(pa)	((pa) & ~DART_OFFSET_MASK)
 
 static const struct device_compatible_entry compat_data[] = {
 	{ .compat = "apple,dart-m1",		.value = 16 },
+	{ .compat = "apple,t8103-dart",		.value = 16 },
 	DEVICE_COMPAT_EOL
 };
 
@@ -188,14 +230,42 @@ apple_dart_intr(void *priv)
 	uint32_t status;
 
 	status = DART_READ(sc, DART_ERR_STATUS);
-	addr = DART_READ(sc, DART_ERR_ADDRL);
-	addr |= (uint64_t)DART_READ(sc, DART_ERR_ADDRH) << 32;
+	addr  = __SHIFTIN(DART_READ(sc, DART_ERR_ADDRL), __BITS(31, 0));
+	addr |= __SHIFTIN(DART_READ(sc, DART_ERR_ADDRH), __BITS(63, 32));
 	DART_WRITE(sc, DART_ERR_STATUS, status);
 
+	if ((status & DART_ERR_FLAG) == 0)
+		return 1;
+
+#ifdef APPLE_DART_DEBUG
+	printf("%s: status %#"PRIx32"\n", __func__, status);
+	printf("%s: 

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

2022-04-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Apr 27 07:53:24 UTC 2022

Modified Files:
src/sys/arch/arm/apple: apple_dart.c

Log Message:
Sync with OpenBSD

- Use subpage feature
- Catch up with new device tree bindings
- Skip locked DARTs
- Use bypass mode for USB3 DARTs

Other changes from me
- Sprinkle BITS(3)
- Improve interrupt error handling


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/arm/apple/apple_dart.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/x86/pci

2022-04-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Apr 27 06:59:26 UTC 2022

Modified Files:
src/sys/arch/x86/pci: amdsmn.c

Log Message:
Rename for AMD F15/6X device. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/pci/amdsmn.c

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

Modified files:

Index: src/sys/arch/x86/pci/amdsmn.c
diff -u src/sys/arch/x86/pci/amdsmn.c:1.12 src/sys/arch/x86/pci/amdsmn.c:1.13
--- src/sys/arch/x86/pci/amdsmn.c:1.12	Sat Aug  7 16:19:07 2021
+++ src/sys/arch/x86/pci/amdsmn.c	Wed Apr 27 06:59:25 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: amdsmn.c,v 1.12 2021/08/07 16:19:07 thorpej Exp $	*/
+/*	$NetBSD: amdsmn.c,v 1.13 2022/04/27 06:59:25 msaitoh Exp $	*/
 
 /*-
  * Copyright (c) 2017, 2019 Conrad Meyer 
@@ -29,7 +29,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.12 2021/08/07 16:19:07 thorpej Exp $ ");
+__KERNEL_RCSID(0, "$NetBSD: amdsmn.c,v 1.13 2022/04/27 06:59:25 msaitoh Exp $ ");
 
 /*
  * Driver for the AMD Family 15h (model 60+) and 17h CPU
@@ -73,7 +73,7 @@ static const struct pciid {
 	uint8_t		amdsmn_data_reg;
 } amdsmn_ids[] = {
 	{
-		.amdsmn_deviceid = PCI_PRODUCT_AMD_F15_60_RC,
+		.amdsmn_deviceid = PCI_PRODUCT_AMD_F15_6X_RC,
 		.amdsmn_addr_reg = F15H_SMN_ADDR_REG,
 		.amdsmn_data_reg = F15H_SMN_DATA_REG,
 	},



CVS commit: src/sys/arch/x86/pci

2022-04-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Apr 27 06:59:26 UTC 2022

Modified Files:
src/sys/arch/x86/pci: amdsmn.c

Log Message:
Rename for AMD F15/6X device. No functional change.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/x86/pci/amdsmn.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

2022-04-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Apr 27 06:58:17 UTC 2022

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.1436 -r1.1437 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1435 -r1.1436 src/sys/dev/pci/pcidevs_data.h

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

diffs are larger than 1MB and have been omitted


CVS commit: src/sys/dev/pci

2022-04-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Apr 27 06:58:17 UTC 2022

Modified Files:
src/sys/dev/pci: pcidevs.h pcidevs_data.h

Log Message:
Regen.


To generate a diff of this commit:
cvs rdiff -u -r1.1436 -r1.1437 src/sys/dev/pci/pcidevs.h
cvs rdiff -u -r1.1435 -r1.1436 src/sys/dev/pci/pcidevs_data.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

2022-04-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Apr 27 06:57:48 UTC 2022

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Update some AMD devices:

 - Rename AMD 15h/6xh devices.
 - Add some devices.
 - Use OHCI for OHCI device.
 - Use EHCI for EHCI device.
 - and some minor changes.


To generate a diff of this commit:
cvs rdiff -u -r1.1453 -r1.1454 src/sys/dev/pci/pcidevs

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/pcidevs
diff -u src/sys/dev/pci/pcidevs:1.1453 src/sys/dev/pci/pcidevs:1.1454
--- src/sys/dev/pci/pcidevs:1.1453	Fri Apr 22 07:34:55 2022
+++ src/sys/dev/pci/pcidevs	Wed Apr 27 06:57:48 2022
@@ -1,4 +1,4 @@
-$NetBSD: pcidevs,v 1.1453 2022/04/22 07:34:55 skrll Exp $
+$NetBSD: pcidevs,v 1.1454 2022/04/27 06:57:48 msaitoh Exp $
 
 /*
  * Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -1071,18 +1071,19 @@ product AMD F16_HB		0x1538	Family16h Hos
 product AMD F16_30_RC		0x1566	Family16h Root Complex
 product AMD F16_30_IOMMU	0x1567	Family16h IOMMU
 product AMD F16_30_HB		0x156b	Family16h Host Bridge
-product AMD F15_60_PF_0		0x1570	Family15h Processor Function 0
-product AMD F15_60_PF_1		0x1571	Family15h Processor Function 1
-product AMD F15_60_PF_2		0x1572	Family15h Processor Function 2
-product AMD F15_60_PF_3		0x1573	Family15h Processor Function 3
-product AMD F15_60_PF_4		0x1574	Family15h Processor Function 4
-product AMD F15_60_PF_5		0x1575	Family15h Processor Function 5
-product AMD F15_60_RC		0x1576	Family15h Root Complex
-product AMD F15_60_IOMMU	0x1577	Family15h IOMMU
-product AMD F15_60_PSP		0x1578	Family15h PSP
-product AMD F15_60_AC		0x157a	Family15h Audio Controller
-product AMD F15_60_HB		0x157b	Family15h Host Bridge
-product AMD F15_60_RP		0x157c	Family15h Root Port
+product AMD F15_6X_PF_0		0x1570	15h/6xh Processor Function 0
+product AMD F15_6X_PF_1		0x1571	15h/6xh Processor Function 1
+product AMD F15_6X_PF_2		0x1572	15h/6xh Processor Function 2
+product AMD F15_6X_PF_3		0x1573	15h/6xh Processor Function 3
+product AMD F15_6X_PF_4		0x1574	15h/6xh Processor Function 4
+product AMD F15_6X_PF_5		0x1575	15h/6xh Processor Function 5
+product AMD F15_6X_RC		0x1576	15h/6xh Root Complex
+product AMD F15_6X_IOMMU	0x1577	15h/6xh IOMMU
+product AMD F15_6X_PSP		0x1578	15h/6xh PSP
+product AMD F15_6X_HDA		0x157a	15h/6xh Audio Controller
+product AMD F15_6X_HB		0x157b	15h/6xh Host Bridge
+product AMD F15_6X_RP		0x157c	15h/6xh Root Port
+product AMD F15_6X_HB_2		0x157d	15h/6xh Host Bridge
 product AMD F16_30_HT		0x1580	Family16h HyperTransport Configuration
 product AMD F16_30_ADDR		0x1581	Family16h Address Map Configuration
 product AMD F16_30_DRAM		0x1582	Family16h DRAM Configuration
@@ -1101,9 +1102,10 @@ product AMD F17_1X_PCIE_1	0x15d3	Family1
 product AMD F17_1X_PCIE_2	0x15db	Family17h/1xh PCIe
 product AMD F17_1X_PCIE_3	0x15dc	Family17h/1xh PCIe
 product AMD F17_1X_PSP		0x15df	Family17h/1xh Platform Security Processor
-product AMD F17_1X_XHCI_1	0x15e0	Family17h/1xh xHCI
-product AMD F17_1X_XHCI_2	0x15e1	Family17h/1xh xHCI
-product AMD F17_1X_HDAUDIO	0x15e3	Family17h/1xh HD Audio Controller
+product AMD F17_1X_XHCI_1	0x15e0	Family17h/1xh USB 3.1 xHCI
+product AMD F17_1X_XHCI_2	0x15e1	Family17h/1xh USB 3.1 xHCI
+product AMD F17_1X_ACP		0x15e2	17h/1xh I2S Audio
+product AMD F17_1X_HDA		0x15e3	Family17h/1xh HD Audio Controller
 product AMD F17_1X_DF_0		0x15e8	Family17h/1xh Data Fabric
 product AMD F17_1X_DF_1		0x15e9	Family17h/1xh Data Fabric
 product AMD F17_1X_DF_2		0x15ea	Family17h/1xh Data Fabric
@@ -1207,7 +1209,7 @@ product AMD PBC756_USB		0x740c	AMD756 US
 product AMD PBC766_ISA		0x7410	AMD766 South Bridge
 product AMD PBC766_IDE		0x7411	AMD766 IDE Controller
 product AMD PBC766_PMC		0x7413	AMD766 Power Management Controller
-product AMD PBC766_USB		0x7414	AMD766 USB Host Controller
+product AMD PBC766_OHCI		0x7414	AMD766 USB OHCI
 product AMD PBC768_ISA		0x7440	AMD768 PCI-ISA/LPC Bridge
 product AMD PBC768_IDE		0x7441	AMD768 EIDE Controller
 product AMD PBC768_PMC		0x7443	AMD768 Power Management Controller
@@ -1252,15 +1254,17 @@ product AMD HUDSON_XHCI		0x7812	Hudson U
 product AMD FCH_SDHC		0x7813	FCH SD Flash Controller
 product AMD FCH_XHCI		0x7814	FCH USB xHCI Controller
 product AMD KERNCZ_SATA_1	0x7900	FCH SATA
-product AMD KERNCZ_AHCI_1	0x7901	FCH AHCI
+product AMD KERNCZ_AHCI_1	0x7901	FCH SATA AHCI
 product AMD KERNCZ_RAID_1	0x7902	FCH RAID
 product AMD KERNCZ_RAID_2	0x7903	FCH RAID
-product AMD KERNCZ_AHCI_2	0x7904	FCH AHCI
+product AMD KERNCZ_AHCI_2	0x7904	FCH SATA AHCI
 product AMD KERNCZ_SD		0x7906	FCH SD
-product AMD KERNCZ_EHCI		0x7908	FCH USB2
+product AMD KERNCZ_EHCI		0x7908	FCH EHCI
 product AMD KERNCZ_SMB		0x790b	X370/X399 SMBus Controller
 product AMD KERNCZ_LPC		0x790e	FCH LPC
 product AMD KERNCZ_XHCI		0x7914	FCH xHCI
+product AMD KERNCZ_AHCI_RAID_1	0x7916	FCH SATA AHCI RAID
+product AMD KERNCZ_AHCI_RAID_2	0x7917	FCH 

CVS commit: src/sys/dev/pci

2022-04-27 Thread SAITOH Masanobu
Module Name:src
Committed By:   msaitoh
Date:   Wed Apr 27 06:57:48 UTC 2022

Modified Files:
src/sys/dev/pci: pcidevs

Log Message:
Update some AMD devices:

 - Rename AMD 15h/6xh devices.
 - Add some devices.
 - Use OHCI for OHCI device.
 - Use EHCI for EHCI device.
 - and some minor changes.


To generate a diff of this commit:
cvs rdiff -u -r1.1453 -r1.1454 src/sys/dev/pci/pcidevs

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