CVS commit: src/sys/arch/macppc/dev

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 28 00:59:10 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fcu.c

Log Message:
check temperatures a bit more often
while there, explain why the delay is variable


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/fcu.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/macppc/dev/fcu.c
diff -u src/sys/arch/macppc/dev/fcu.c:1.2 src/sys/arch/macppc/dev/fcu.c:1.3
--- src/sys/arch/macppc/dev/fcu.c:1.2	Tue Jul 27 23:38:42 2021
+++ src/sys/arch/macppc/dev/fcu.c	Wed Jul 28 00:59:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.2 2021/07/27 23:38:42 macallan Exp $ */
+/* $NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.2 2021/07/27 23:38:42 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.3 2021/07/28 00:59:10 macallan Exp $");
 
 #include 
 #include 
@@ -490,7 +490,13 @@ fcu_adjust(void *cookie)
 		sc->sc_pwm = FALSE;
 		for (i = 0; i < FCU_ZONE_COUNT; i++)
 			fancontrol_adjust_zone(>sc_zones[i]);
-		kpause("fanctrl", true, mstohz(sc->sc_pwm ? 1000 : 5000), NULL);
+		/*
+		 * take a shorter nap if we're in the proccess of adjusting a
+		 * PWM fan, which relies on measuring speed and then changing
+		 * its duty cycle until we're reasonable close to the target
+		 * speed
+		 */
+		kpause("fanctrl", true, mstohz(sc->sc_pwm ? 1000 : 2000), NULL);
 	}
 	kthread_exit(0);
 }



CVS commit: src/sys/arch/macppc/dev

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 28 00:59:10 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fcu.c

Log Message:
check temperatures a bit more often
while there, explain why the delay is variable


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/macppc/dev/fcu.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/macppc/dev

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 28 00:36:00 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fancontrol.c

Log Message:
adjust comments, break a long line
NFC


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

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Wed Jul 28 00:36:00 UTC 2021

Modified Files:
src/sys/arch/macppc/dev: fancontrol.c

Log Message:
adjust comments, break a long line
NFC


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/fancontrol.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/macppc/dev/fancontrol.c
diff -u src/sys/arch/macppc/dev/fancontrol.c:1.1 src/sys/arch/macppc/dev/fancontrol.c:1.2
--- src/sys/arch/macppc/dev/fancontrol.c:1.1	Tue Jul 27 23:38:42 2021
+++ src/sys/arch/macppc/dev/fancontrol.c	Wed Jul 28 00:36:00 2021
@@ -1,7 +1,7 @@
-/* $NetBSD: fancontrol.c,v 1.1 2021/07/27 23:38:42 macallan Exp $ */
+/* $NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $ */
 
 /*-
- * Copyright (c) 2018 Michael Lorenz
+ * Copyright (c) 2021 Michael Lorenz
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.1 2021/07/27 23:38:42 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fancontrol.c,v 1.2 2021/07/28 00:36:00 macallan Exp $");
 
 #include 
 #include 
@@ -66,11 +66,12 @@ fancontrol_adjust_zone(fancontrol_zone_t
 	if (diff < 0) diff = 0;
 	diff = (100 * diff) / (z->Tmax - z->Tmin);
 
-	/* now adjust each fan to the new duty cycle */
+	/* now adjust each fan to the new speed */
 	for (i = 0; i < z->nfans; i++) {
 		step = (z->fans[i].max_rpm - z->fans[i].min_rpm) / 100;
 		speed = z->fans[i].min_rpm + diff * step;
-		DPRINTF("diff %d base %d %d sp %d\n", diff, z->fans[i].min_rpm, z->fans[i].max_rpm, speed);
+		DPRINTF("diff %d base %d %d sp %d\n",
+		diff, z->fans[i].min_rpm, z->fans[i].max_rpm, speed);
 		z->set_rpm(z->cookie, z->fans[i].num, speed);
 	}
 	return 0;



CVS commit: src/sys/arch/macppc

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jul 27 23:38:42 UTC 2021

Modified Files:
src/sys/arch/macppc/conf: files.macppc
src/sys/arch/macppc/dev: fcu.c
Added Files:
src/sys/arch/macppc/dev: fancontrol.c fancontrolvar.h

Log Message:
first step towards abstracting thermal zone management out of the fcu driver
( and eventually, the smu driver )
todo:
- add sysctl()s to set zone parameters
- handle envsys
- adapt smu


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r0 -r1.1 src/sys/arch/macppc/dev/fancontrol.c \
src/sys/arch/macppc/dev/fancontrolvar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/fcu.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/macppc/conf/files.macppc
diff -u src/sys/arch/macppc/conf/files.macppc:1.120 src/sys/arch/macppc/conf/files.macppc:1.121
--- src/sys/arch/macppc/conf/files.macppc:1.120	Tue Jul 27 20:23:41 2021
+++ src/sys/arch/macppc/conf/files.macppc	Tue Jul 27 23:38:42 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.macppc,v 1.120 2021/07/27 20:23:41 macallan Exp $
+#	$NetBSD: files.macppc,v 1.121 2021/07/27 23:38:42 macallan Exp $
 #
 # macppc-specific configuration info
 
@@ -176,7 +176,11 @@ device zstty: tty
 attach zstty at zsc
 file dev/ic/z8530tty.czstty needs-flag
 
-device smu { }
+define fancontrol
+file arch/macppc/dev/fancontrol.c		fancontrol
+defflag	opt_fancontrol.h	FANCONTROL_DEBUG
+
+device smu { } : fancontrol
 attach smu at mainbus
 file arch/macppc/dev/smu.c			smu needs-flag
 defflag	opt_smu.h	SMU_DEBUG
@@ -328,6 +332,6 @@ file	arch/macppc/dev/lmu.clmu
 defflag opt_lmu.h LMU_DEBUG
 
 # Apple Fan Control Unit found in some G5
-device	fcu: sysmon_envsys
+device	fcu: sysmon_envsys, fancontrol
 attach	fcu at iic
 file	arch/macppc/dev/fcu.cfcu	needs-flag

Index: src/sys/arch/macppc/dev/fcu.c
diff -u src/sys/arch/macppc/dev/fcu.c:1.1 src/sys/arch/macppc/dev/fcu.c:1.2
--- src/sys/arch/macppc/dev/fcu.c:1.1	Tue Jul 27 20:23:41 2021
+++ src/sys/arch/macppc/dev/fcu.c	Tue Jul 27 23:38:42 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: fcu.c,v 1.1 2021/07/27 20:23:41 macallan Exp $ */
+/* $NetBSD: fcu.c,v 1.2 2021/07/27 23:38:42 macallan Exp $ */
 
 /*-
  * Copyright (c) 2018 Michael Lorenz
@@ -27,7 +27,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.1 2021/07/27 20:23:41 macallan Exp $");
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.2 2021/07/27 23:38:42 macallan Exp $");
 
 #include 
 #include 
@@ -42,6 +42,8 @@ __KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.1 
 
 #include 
 
+#include 
+
 //#define FCU_DEBUG
 #ifdef FCU_DEBUG
 #define DPRINTF printf
@@ -58,14 +60,6 @@ __KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.1 
 #define FCU_PWM_ACTIVE	0x2d
 #define FCU_PWMREAD(x)	0x30 + (x)*2
 
-#define FCU_MAX_FANS 10
-
-typedef struct _fcu_zone {
-	bool (*filter)(const envsys_data_t *);
-	int nfans;
-	int fans[FCU_MAX_FANS];
-	int threshold;
-} fcu_zone_t; 
 
 typedef struct _fcu_fan {
 	int target;
@@ -86,15 +80,15 @@ struct fcu_softc {
 	i2c_addr_t	sc_addr;
 
 	struct sysmon_envsys *sc_sme;
-	envsys_data_t	sc_sensors[32];
-	int		sc_nsensors;
-	fcu_zone_t	sc_zones[FCU_ZONE_COUNT];
-	fcu_fan_t	sc_fans[FCU_MAX_FANS];
-	int		sc_nfans;
-	lwp_t		*sc_thread;
-	bool		sc_dying, sc_pwm;
-	uint8_t		sc_eeprom0[160];
-	uint8_t		sc_eeprom1[160];
+	envsys_data_t		sc_sensors[32];
+	int			sc_nsensors;
+	fancontrol_zone_t	sc_zones[FCU_ZONE_COUNT];
+	fcu_fan_t		sc_fans[FANCONTROL_MAX_FANS];
+	int			sc_nfans;
+	lwp_t			*sc_thread;
+	bool			sc_dying, sc_pwm;
+	uint8_t			sc_eeprom0[160];
+	uint8_t			sc_eeprom1[160];
 };
 
 static int	fcu_match(device_t, cfdata_t, void *);
@@ -106,8 +100,8 @@ static bool is_cpu(const envsys_data_t *
 static bool is_case(const envsys_data_t *);
 static bool is_drive(const envsys_data_t *);
 
-static void fcu_set_fan_rpm(struct fcu_softc *, fcu_fan_t *, int);
-static void fcu_adjust_zone(struct fcu_softc *, int);
+static int fcu_set_rpm(void *, int, int);
+static int fcu_get_rpm(void *, int);
 static void fcu_adjust(void *);
 
 CFATTACH_DECL_NEW(fcu, sizeof(struct fcu_softc),
@@ -160,14 +154,29 @@ fcu_attach(device_t parent, device_t sel
 		have_eeprom1 = 0;
 
 	/* init zones */
+	sc->sc_zones[FCU_ZONE_CPU].name = "CPUs";
 	sc->sc_zones[FCU_ZONE_CPU].filter = is_cpu;
-	sc->sc_zones[FCU_ZONE_CPU].threshold = 50;
+	sc->sc_zones[FCU_ZONE_CPU].cookie = sc;
+	sc->sc_zones[FCU_ZONE_CPU].get_rpm = fcu_get_rpm;
+	sc->sc_zones[FCU_ZONE_CPU].set_rpm = fcu_set_rpm;
+	sc->sc_zones[FCU_ZONE_CPU].Tmin = 50;
+	sc->sc_zones[FCU_ZONE_CPU].Tmax = 85;
 	sc->sc_zones[FCU_ZONE_CPU].nfans = 0;
+	sc->sc_zones[FCU_ZONE_CASE].name = "Slots";
 	sc->sc_zones[FCU_ZONE_CASE].filter = is_case;
-	sc->sc_zones[FCU_ZONE_CASE].threshold = 50;
+	sc->sc_zones[FCU_ZONE_CASE].Tmin = 50;
+	sc->sc_zones[FCU_ZONE_CASE].cookie = sc;
+	sc->sc_zones[FCU_ZONE_CASE].get_rpm = fcu_get_rpm;
+	

CVS commit: src/sys/arch/macppc

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jul 27 23:38:42 UTC 2021

Modified Files:
src/sys/arch/macppc/conf: files.macppc
src/sys/arch/macppc/dev: fcu.c
Added Files:
src/sys/arch/macppc/dev: fancontrol.c fancontrolvar.h

Log Message:
first step towards abstracting thermal zone management out of the fcu driver
( and eventually, the smu driver )
todo:
- add sysctl()s to set zone parameters
- handle envsys
- adapt smu


To generate a diff of this commit:
cvs rdiff -u -r1.120 -r1.121 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r0 -r1.1 src/sys/arch/macppc/dev/fancontrol.c \
src/sys/arch/macppc/dev/fancontrolvar.h
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/macppc/dev/fcu.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/evbarm/ifpga

2021-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 27 21:13:41 UTC 2021

Modified Files:
src/sys/arch/evbarm/ifpga: plcom_ifpga.c plmmc_ifpga.c

Log Message:
KNF and remove #include 

Fixes the build - prompted by cjep.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/evbarm/ifpga/plcom_ifpga.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/ifpga/plmmc_ifpga.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/evbarm/ifpga/plcom_ifpga.c
diff -u src/sys/arch/evbarm/ifpga/plcom_ifpga.c:1.17 src/sys/arch/evbarm/ifpga/plcom_ifpga.c:1.18
--- src/sys/arch/evbarm/ifpga/plcom_ifpga.c:1.17	Tue Oct 23 09:15:36 2018
+++ src/sys/arch/evbarm/ifpga/plcom_ifpga.c	Tue Jul 27 21:13:41 2021
@@ -1,4 +1,4 @@
-/*  $NetBSD: plcom_ifpga.c,v 1.17 2018/10/23 09:15:36 jmcneill Exp $ */
+/*  $NetBSD: plcom_ifpga.c,v 1.18 2021/07/27 21:13:41 skrll Exp $ */
 
 /*
  * Copyright (c) 2001 ARM Ltd
@@ -32,18 +32,17 @@
 /* Interface to plcom (PL010) serial driver. */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: plcom_ifpga.c,v 1.17 2018/10/23 09:15:36 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plcom_ifpga.c,v 1.18 2021/07/27 21:13:41 skrll Exp $");
 
+#include 
 #include 
+
+#include 
 #include 
 #include 
-#include 
-#include 
-
 #include 
 
 #include 
-#include 
 
 #include 
 #include 

Index: src/sys/arch/evbarm/ifpga/plmmc_ifpga.c
diff -u src/sys/arch/evbarm/ifpga/plmmc_ifpga.c:1.1 src/sys/arch/evbarm/ifpga/plmmc_ifpga.c:1.2
--- src/sys/arch/evbarm/ifpga/plmmc_ifpga.c:1.1	Tue Jan 27 16:34:34 2015
+++ src/sys/arch/evbarm/ifpga/plmmc_ifpga.c	Tue Jul 27 21:13:41 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: plmmc_ifpga.c,v 1.1 2015/01/27 16:34:34 jmcneill Exp $ */
+/* $NetBSD: plmmc_ifpga.c,v 1.2 2021/07/27 21:13:41 skrll Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill 
@@ -27,18 +27,17 @@
  */
 #include 
 
-__KERNEL_RCSID(0, "$NetBSD: plmmc_ifpga.c,v 1.1 2015/01/27 16:34:34 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: plmmc_ifpga.c,v 1.2 2021/07/27 21:13:41 skrll Exp $");
 
+#include 
 #include 
+
+#include 
 #include 
 #include 
-#include 
-#include 
-
 #include 
 
 #include 
-#include 
 
 #include 
 #include 



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

2021-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 27 21:13:41 UTC 2021

Modified Files:
src/sys/arch/evbarm/ifpga: plcom_ifpga.c plmmc_ifpga.c

Log Message:
KNF and remove #include 

Fixes the build - prompted by cjep.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/evbarm/ifpga/plcom_ifpga.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbarm/ifpga/plmmc_ifpga.c

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



CVS commit: src/sys

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jul 27 20:23:42 UTC 2021

Modified Files:
src/sys/arch/macppc/conf: files.macppc
src/sys/dev/i2c: files.i2c
Added Files:
src/sys/arch/macppc/dev: fcu.c
Removed Files:
src/sys/dev/i2c: fcu.c

Log Message:
move the fcu driver into arch/macppc where it belongs


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r0 -r1.1 src/sys/arch/macppc/dev/fcu.c
cvs rdiff -u -r1.13 -r0 src/sys/dev/i2c/fcu.c
cvs rdiff -u -r1.115 -r1.116 src/sys/dev/i2c/files.i2c

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/macppc/conf/files.macppc
diff -u src/sys/arch/macppc/conf/files.macppc:1.119 src/sys/arch/macppc/conf/files.macppc:1.120
--- src/sys/arch/macppc/conf/files.macppc:1.119	Fri Jun 18 22:24:51 2021
+++ src/sys/arch/macppc/conf/files.macppc	Tue Jul 27 20:23:41 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.macppc,v 1.119 2021/06/18 22:24:51 macallan Exp $
+#	$NetBSD: files.macppc,v 1.120 2021/07/27 20:23:41 macallan Exp $
 #
 # macppc-specific configuration info
 
@@ -326,3 +326,8 @@ device	lmu: sysmon_envsys
 attach	lmu at iic
 file	arch/macppc/dev/lmu.clmu
 defflag opt_lmu.h LMU_DEBUG
+
+# Apple Fan Control Unit found in some G5
+device	fcu: sysmon_envsys
+attach	fcu at iic
+file	arch/macppc/dev/fcu.cfcu	needs-flag

Index: src/sys/dev/i2c/files.i2c
diff -u src/sys/dev/i2c/files.i2c:1.115 src/sys/dev/i2c/files.i2c:1.116
--- src/sys/dev/i2c/files.i2c:1.115	Mon Jan  4 22:09:35 2021
+++ src/sys/dev/i2c/files.i2c	Tue Jul 27 20:23:41 2021
@@ -1,4 +1,4 @@
-#	$NetBSD: files.i2c,v 1.115 2021/01/04 22:09:35 thorpej Exp $
+#	$NetBSD: files.i2c,v 1.116 2021/07/27 20:23:41 macallan Exp $
 
 obsolete defflag	opt_i2cbus.h		I2C_SCAN
 define	i2cbus { }
@@ -305,11 +305,6 @@ device	em3027rtc: sysmon_envsys
 attach	em3027rtc at iic
 file	dev/i2c/em3027.c			em3027rtc
 
-# Apple Fan Control Unit found in some G5
-device	fcu: sysmon_envsys
-attach	fcu at iic
-file	dev/i2c/fcu.cfcu	needs-flag
-
 # Analog Devices AD7417 thermometer and ADC
 device	adadc: sysmon_envsys
 attach	adadc at iic

Added files:

Index: src/sys/arch/macppc/dev/fcu.c
diff -u /dev/null src/sys/arch/macppc/dev/fcu.c:1.1
--- /dev/null	Tue Jul 27 20:23:42 2021
+++ src/sys/arch/macppc/dev/fcu.c	Tue Jul 27 20:23:41 2021
@@ -0,0 +1,493 @@
+/* $NetBSD: fcu.c,v 1.1 2021/07/27 20:23:41 macallan Exp $ */
+
+/*-
+ * Copyright (c) 2018 Michael Lorenz
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+__KERNEL_RCSID(0, "$NetBSD: fcu.c,v 1.1 2021/07/27 20:23:41 macallan Exp $");
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include 
+
+#include 
+
+#include 
+
+//#define FCU_DEBUG
+#ifdef FCU_DEBUG
+#define DPRINTF printf
+#else
+#define DPRINTF if (0) printf
+#endif
+
+/* FCU registers, from OpenBSD's fcu.c */
+#define FCU_FAN_FAIL	0x0b		/* fans states in bits 0<1-6>7 */
+#define FCU_FAN_ACTIVE	0x0d
+#define FCU_FANREAD(x)	0x11 + (x)*2
+#define FCU_FANSET(x)	0x10 + (x)*2
+#define FCU_PWM_FAIL	0x2b
+#define FCU_PWM_ACTIVE	0x2d
+#define FCU_PWMREAD(x)	0x30 + (x)*2
+
+#define FCU_MAX_FANS 10
+
+typedef struct _fcu_zone {
+	bool (*filter)(const envsys_data_t *);
+	int nfans;
+	int fans[FCU_MAX_FANS];
+	int threshold;
+} fcu_zone_t; 
+
+typedef struct _fcu_fan {
+	int target;
+	int reg;
+	int base_rpm, max_rpm;
+	int step;
+	int duty;	/* for pwm fans */
+} fcu_fan_t;
+
+#define FCU_ZONE_CPU		0
+#define FCU_ZONE_CASE		1
+#define FCU_ZONE_DRIVEBAY	2
+#define FCU_ZONE_COUNT		3
+
+struct fcu_softc {
+	

CVS commit: src/sys

2021-07-27 Thread Michael Lorenz
Module Name:src
Committed By:   macallan
Date:   Tue Jul 27 20:23:42 UTC 2021

Modified Files:
src/sys/arch/macppc/conf: files.macppc
src/sys/dev/i2c: files.i2c
Added Files:
src/sys/arch/macppc/dev: fcu.c
Removed Files:
src/sys/dev/i2c: fcu.c

Log Message:
move the fcu driver into arch/macppc where it belongs


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/sys/arch/macppc/conf/files.macppc
cvs rdiff -u -r0 -r1.1 src/sys/arch/macppc/dev/fcu.c
cvs rdiff -u -r1.13 -r0 src/sys/dev/i2c/fcu.c
cvs rdiff -u -r1.115 -r1.116 src/sys/dev/i2c/files.i2c

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



CVS commit: src/tests/usr.sbin/execsnoop

2021-07-27 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Tue Jul 27 15:29:22 UTC 2021

Modified Files:
src/tests/usr.sbin/execsnoop: t_execsnoop.sh

Log Message:
Show the stderr from execsnoop so that we can see why it fails on arm.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.sbin/execsnoop/t_execsnoop.sh

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

Modified files:

Index: src/tests/usr.sbin/execsnoop/t_execsnoop.sh
diff -u src/tests/usr.sbin/execsnoop/t_execsnoop.sh:1.9 src/tests/usr.sbin/execsnoop/t_execsnoop.sh:1.10
--- src/tests/usr.sbin/execsnoop/t_execsnoop.sh:1.9	Tue Jul 27 11:05:39 2021
+++ src/tests/usr.sbin/execsnoop/t_execsnoop.sh	Tue Jul 27 15:29:22 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_execsnoop.sh,v 1.9 2021/07/27 11:05:39 skrll Exp $
+# $NetBSD: t_execsnoop.sh,v 1.10 2021/07/27 15:29:22 gson Exp $
 #
 # Copyright (c) 2020 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -27,7 +27,8 @@
 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 # POSSIBILITY OF SUCH DAMAGE.
 #
-tmp="execsnoop.out"
+stdout="execsnoop.out"
+stderr="execsnoop.stderr"
 
 atf_test_case basic cleanup
 basic_head() {
@@ -38,7 +39,7 @@ basic_head() {
 
 basic_body() {
 	n=10
-	atf_check -s exit:0 -o ignore -e empty -x "execsnoop > $tmp &"
+	atf_check -s exit:0 -o ignore -e empty -x "execsnoop >$stdout 2>$stderr &"
 	sleep 5
 
 	while [ $n -gt 0 ]; do
@@ -48,7 +49,9 @@ basic_body() {
 
 	sleep 5
 
-	if [ ! $(cat $tmp | grep "whoami" | wc -l) -eq 10 ]; then
+	cat $stderr >&2
+
+	if [ ! $(cat $stdout | grep "whoami" | wc -l) -eq 10 ]; then
 		atf_fail "execsnoop does not work"
 	fi
 



CVS commit: src/tests/usr.sbin/execsnoop

2021-07-27 Thread Andreas Gustafsson
Module Name:src
Committed By:   gson
Date:   Tue Jul 27 15:29:22 UTC 2021

Modified Files:
src/tests/usr.sbin/execsnoop: t_execsnoop.sh

Log Message:
Show the stderr from execsnoop so that we can see why it fails on arm.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/tests/usr.sbin/execsnoop/t_execsnoop.sh

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



CVS commit: src/doc

2021-07-27 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Tue Jul 27 12:40:07 UTC 2021

Modified Files:
src/doc: CHANGES

Log Message:
Tie the maximum file lock per unprivilegied uid to kern.maxfiles


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

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

Modified files:

Index: src/doc/CHANGES
diff -u src/doc/CHANGES:1.2815 src/doc/CHANGES:1.2816
--- src/doc/CHANGES:1.2815	Fri Jul  9 17:07:29 2021
+++ src/doc/CHANGES	Tue Jul 27 12:40:07 2021
@@ -1,4 +1,4 @@
-# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2815 $>
+# LIST OF CHANGES FROM LAST RELEASE:			<$Revision: 1.2816 $>
 #
 #
 # [Note: This file does not mention every change made to the NetBSD source tree.
@@ -387,3 +387,5 @@ Changes from NetBSD 9.0 to NetBSD 10.0:
 	acpi(4): Updated ACPICA to 20210604. [christos 20210706]
 	hp300: Add support of multiple rd(4) disks on all punits for HPDisk.
 		[tsutsui 20210709]
+	kernel: Tie the maximum file lock per unprivilegied uid to 
+		kern.maxfiles [manu 20210727]



CVS commit: src/doc

2021-07-27 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Tue Jul 27 12:40:07 UTC 2021

Modified Files:
src/doc: CHANGES

Log Message:
Tie the maximum file lock per unprivilegied uid to kern.maxfiles


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

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



CVS commit: src/tests/usr.sbin/execsnoop

2021-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 27 11:05:39 UTC 2021

Modified Files:
src/tests/usr.sbin/execsnoop: t_execsnoop.sh

Log Message:
PR/53417 appears fixed now so remove atf_expect_fail (for Arm).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.sbin/execsnoop/t_execsnoop.sh

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



CVS commit: src/tests/usr.sbin/execsnoop

2021-07-27 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue Jul 27 11:05:39 UTC 2021

Modified Files:
src/tests/usr.sbin/execsnoop: t_execsnoop.sh

Log Message:
PR/53417 appears fixed now so remove atf_expect_fail (for Arm).


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/tests/usr.sbin/execsnoop/t_execsnoop.sh

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

Modified files:

Index: src/tests/usr.sbin/execsnoop/t_execsnoop.sh
diff -u src/tests/usr.sbin/execsnoop/t_execsnoop.sh:1.8 src/tests/usr.sbin/execsnoop/t_execsnoop.sh:1.9
--- src/tests/usr.sbin/execsnoop/t_execsnoop.sh:1.8	Sun Jul 25 15:51:32 2021
+++ src/tests/usr.sbin/execsnoop/t_execsnoop.sh	Tue Jul 27 11:05:39 2021
@@ -1,4 +1,4 @@
-# $NetBSD: t_execsnoop.sh,v 1.8 2021/07/25 15:51:32 gson Exp $
+# $NetBSD: t_execsnoop.sh,v 1.9 2021/07/27 11:05:39 skrll Exp $
 #
 # Copyright (c) 2020 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -37,11 +37,6 @@ basic_head() {
 }
 
 basic_body() {
-	case `uname -p` in
-	*arm*)
-		atf_expect_fail "PR kern/53417" ;;
-	esac
-
 	n=10
 	atf_check -s exit:0 -o ignore -e empty -x "execsnoop > $tmp &"
 	sleep 5



CVS commit: src

2021-07-27 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Tue Jul 27 09:32:55 UTC 2021

Modified Files:
src/lib/libc/sys: fcntl.2 flock.2
src/share/man/man7: sysctl.7
src/sys/kern: vfs_lockf.c

Log Message:
Tie the maximum file lock per unprivilegied uid to kern.maxfiles

This makes the limit simple to raise at run time. While there, document
that fcntl(2) and flock(2) may return ENOMEM when this limit is reached.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/lib/libc/sys/fcntl.2
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/sys/flock.2
cvs rdiff -u -r1.152 -r1.153 src/share/man/man7/sysctl.7
cvs rdiff -u -r1.73 -r1.74 src/sys/kern/vfs_lockf.c

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

Modified files:

Index: src/lib/libc/sys/fcntl.2
diff -u src/lib/libc/sys/fcntl.2:1.45 src/lib/libc/sys/fcntl.2:1.46
--- src/lib/libc/sys/fcntl.2:1.45	Fri Sep 27 07:20:07 2019
+++ src/lib/libc/sys/fcntl.2	Tue Jul 27 09:32:55 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: fcntl.2,v 1.45 2019/09/27 07:20:07 wiz Exp $
+.\"	$NetBSD: fcntl.2,v 1.46 2021/07/27 09:32:55 manu Exp $
 .\"
 .\" Copyright (c) 1983, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -549,6 +549,17 @@ The argument
 is
 .Dv F_GETPATH
 and insufficient memory is available.
+.Pp
+The argument
+.Fa cmd
+is
+.Dv F_GETLK ,
+.Dv F_SETLK ,
+or
+.Dv F_SETLKW ,
+and the file lock limit for the current unprivilegied user
+has been reached. It can be modifed using sysctl
+.Li kern.maxfiles .
 .It Bq Er ERANGE
 The argument
 .Fa cmd

Index: src/lib/libc/sys/flock.2
diff -u src/lib/libc/sys/flock.2:1.22 src/lib/libc/sys/flock.2:1.23
--- src/lib/libc/sys/flock.2:1.22	Sat Oct 15 21:35:50 2011
+++ src/lib/libc/sys/flock.2	Tue Jul 27 09:32:55 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: flock.2,v 1.22 2011/10/15 21:35:50 rmind Exp $
+.\"	$NetBSD: flock.2,v 1.23 2021/07/27 09:32:55 manu Exp $
 .\"
 .\" Copyright (c) 1983, 1991, 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -137,6 +137,10 @@ does not include exactly one of
 .Dv LOCK_SH ,
 or
 .Dv LOCK_UN .
+.It Bq Eq ENOMEM
+The file lock limit for the current unprivilegied user 
+has been reached. It can be modifed using sysctl
+.Li kern.maxfiles .
 .It Bq Er EOPNOTSUPP
 The argument
 .Fa fd

Index: src/share/man/man7/sysctl.7
diff -u src/share/man/man7/sysctl.7:1.152 src/share/man/man7/sysctl.7:1.153
--- src/share/man/man7/sysctl.7:1.152	Tue Jul 13 16:56:43 2021
+++ src/share/man/man7/sysctl.7	Tue Jul 27 09:32:55 2021
@@ -1,4 +1,4 @@
-.\"	$NetBSD: sysctl.7,v 1.152 2021/07/13 16:56:43 nia Exp $
+.\"	$NetBSD: sysctl.7,v 1.153 2021/07/27 09:32:55 manu Exp $
 .\"
 .\" Copyright (c) 1993
 .\"	The Regents of the University of California.  All rights reserved.
@@ -756,6 +756,11 @@ Memory Mapped Files Option is available 
 otherwise\ 0.
 .It Li kern.maxfiles ( Dv KERN_MAXFILES )
 The maximum number of open files that may be open in the system.
+This also controls the maximum file locks per unprivilegied user 
+enforced by
+.Xr fnctl 2
+and 
+.Xr flock 2 .
 .It Li kern.maxpartitions ( Dv KERN_MAXPARTITIONS )
 The maximum number of partitions allowed per disk.
 .It Li kern.maxlwp

Index: src/sys/kern/vfs_lockf.c
diff -u src/sys/kern/vfs_lockf.c:1.73 src/sys/kern/vfs_lockf.c:1.74
--- src/sys/kern/vfs_lockf.c:1.73	Mon Jan 31 08:25:32 2011
+++ src/sys/kern/vfs_lockf.c	Tue Jul 27 09:32:55 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: vfs_lockf.c,v 1.73 2011/01/31 08:25:32 dholland Exp $	*/
+/*	$NetBSD: vfs_lockf.c,v 1.74 2021/07/27 09:32:55 manu Exp $	*/
 
 /*
  * Copyright (c) 1982, 1986, 1989, 1993
@@ -35,7 +35,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: vfs_lockf.c,v 1.73 2011/01/31 08:25:32 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_lockf.c,v 1.74 2021/07/27 09:32:55 manu Exp $");
 
 #include 
 #include 
@@ -123,7 +123,7 @@ int	lockf_debug = 0;
  * so that the unlock can succeed.  If the unlocking causes too many splits,
  * however, you're totally cutoff.
  */
-int maxlocksperuid = 1024;
+#define MAXLOCKSPERUID (2 * maxfiles)
 
 #ifdef LOCKF_DEBUG
 /*
@@ -200,7 +200,7 @@ lf_alloc(int allowfail)
 	uip = uid_find(uid);
 	lcnt = atomic_inc_ulong_nv(>ui_lockcnt);
 	if (uid && allowfail && lcnt >
-	(allowfail == 1 ? maxlocksperuid : (maxlocksperuid * 2))) {
+	(allowfail == 1 ? MAXLOCKSPERUID : (MAXLOCKSPERUID * 2))) {
 		atomic_dec_ulong(>ui_lockcnt);
 		return NULL;
 	}



CVS commit: src

2021-07-27 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Tue Jul 27 09:32:55 UTC 2021

Modified Files:
src/lib/libc/sys: fcntl.2 flock.2
src/share/man/man7: sysctl.7
src/sys/kern: vfs_lockf.c

Log Message:
Tie the maximum file lock per unprivilegied uid to kern.maxfiles

This makes the limit simple to raise at run time. While there, document
that fcntl(2) and flock(2) may return ENOMEM when this limit is reached.


To generate a diff of this commit:
cvs rdiff -u -r1.45 -r1.46 src/lib/libc/sys/fcntl.2
cvs rdiff -u -r1.22 -r1.23 src/lib/libc/sys/flock.2
cvs rdiff -u -r1.152 -r1.153 src/share/man/man7/sysctl.7
cvs rdiff -u -r1.73 -r1.74 src/sys/kern/vfs_lockf.c

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



Re: CVS commit: src/lib/libcurses

2021-07-27 Thread nia
On Tue, Jul 27, 2021 at 12:22:18AM +0300, Valery Ushakov wrote:
> I'm not sure what is the discussion you are referring to, but it's not
> a matter of a simple rewording.  "It's complicated", as it ties into a
> few other things, so ideally it needs a coordinated change to several
> man pages.

During aiomixer review, someone complained that it wasn't usable and
mentioned that their terminal only had A_STANDOUT. I was reluctant to
start using A_STANDOUT because of the big warning in the BUGS section
of the man page not to use it, which you mentioned is probably bogus.

I think you told me that A_STANDOUT should be used for semantic
purposes where it makes sense to use.

> The two key points from the spec that the BUGS section tries to warn
> you about is (emphasis mine):
> 
>   A_STANDOUT - Best highlighting mode of the terminal
> 
>   The standend() and wstandend() functions turn off ALL attributes of
>   the current or specified window.
> 
> Roughly speaking "standout" is a kind of higher-level alais and it
> works differently than other attributes (standend).  Mixing it with
> explicit use of other lower-level attributes is not a good idea.

With this in mind, I would also change curses_attributes.3 to
adequately explain what standout is intended to do rather than
just warning against it.

Proposed diff attached.
Index: curses_attributes.3
===
RCS file: /cvsroot/src/lib/libcurses/curses_attributes.3,v
retrieving revision 1.9
diff -u -r1.9 curses_attributes.3
--- curses_attributes.3 25 Oct 2018 10:36:56 -  1.9
+++ curses_attributes.3 27 Jul 2021 07:37:27 -
@@ -25,7 +25,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd October 25, 2018
+.Dd July 27, 2021
 .Dt CURSES_ATTRIBUTES 3
 .Os
 .Sh NAME
@@ -102,7 +102,7 @@
 .It A_NORMAL
 no special attributes are applied
 .It A_STANDOUT
-characters are displayed in standout mode
+characters are displayed in the "best" highlighting mode of the terminal
 .It A_UNDERLINE
 characters are displayed underlined
 .It A_REVERSE
@@ -193,7 +193,7 @@
 .Pp
 .Bl -tag -width "COLOR_PAIR(n)" -compact -offset indent
 .It WA_STANDOUT
-characters are displayed in standout mode
+characters are displayed in the "best" highlighting mode of the terminal
 .It WA_UNDERLINE
 characters are displayed underlined
 .It WA_REVERSE
@@ -336,7 +336,10 @@
 .Sh HISTORY
 These functions first appeared in
 .Nx 1.5 .
-.Sh BUGS
+.Sh CAVEATS
 Some terminals do not support characters with both color and other attributes
 set.
 In this case, the other attribute is displayed instead of the color attribute.
+.Pp
+The standout attribute is a higher-level alias and should not be mixed with
+other attributes.
Index: curses_standout.3
===
RCS file: /cvsroot/src/lib/libcurses/curses_standout.3,v
retrieving revision 1.8
diff -u -r1.8 curses_standout.3
--- curses_standout.3   26 Jul 2021 20:17:09 -  1.8
+++ curses_standout.3   27 Jul 2021 07:37:27 -
@@ -25,7 +25,7 @@
 .\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 .\" POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd July 26, 2021
+.Dd July 27, 2021
 .Dt CURSES_STANDOUT 3
 .Os
 .Sh NAME
@@ -55,6 +55,9 @@
 These functions manipulate the standout attribute on
 .Dv stdscr
 or on the specified window.
+The standout attribute applies the "best highlighting mode"
+supported by the current terminal, which may be an alias of
+other attributes.
 .Pp
 The
 .Fn standout
@@ -101,3 +104,9 @@
 .Sh HISTORY
 The Curses package appeared in
 .Bx 4.0 .
+.Sh CAVEATS
+On some terminals, characters with standout set may have the same appearance
+as characters with the reverse video or bold attribute set.
+However, on legacy terminals, standout may be the only attribute that can be
+used to emphasize characters.
+The standout attribute should not be mixed with other attributes.