Module Name:    src
Committed By:   pgoyette
Date:           Tue Jun 30 16:14:49 UTC 2009

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

Log Message:
Change acpi_tz sensor behavior as follows:

1. ENVSYS_WARNOVER event is generated whenever any active cooling level
   is exceeded.

2. ENVSYS_CRITOVER event is generated whenever _HOT limit is exceeded;
   if the _HOT limit is not defined, then ENVSYS_CRITOVER will be
   generated when the _CRT limit is exceeded.

3. For Passive Cooling Only mode, there will be no change in behavior.

Additionally, since there are specific actions taken at each of the Active
Cooling Levels (powering parts of a zone on or off), and the limits are not
user-programmable,

4. The {warn,crit}{min,max} threshold levels will be specified only
   by the device itself;  event reporting thresholds may not be set
   from userland.

No comments received for two weeks after proposing these changes on both
current-users@ and tech-kern@


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

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

Modified files:

Index: src/sys/dev/acpi/acpi_tz.c
diff -u src/sys/dev/acpi/acpi_tz.c:1.41 src/sys/dev/acpi/acpi_tz.c:1.42
--- src/sys/dev/acpi/acpi_tz.c:1.41	Wed Jun  3 22:34:18 2009
+++ src/sys/dev/acpi/acpi_tz.c	Tue Jun 30 16:14:49 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: acpi_tz.c,v 1.41 2009/06/03 22:34:18 pgoyette Exp $ */
+/* $NetBSD: acpi_tz.c,v 1.42 2009/06/30 16:14:49 pgoyette Exp $ */
 
 /*
  * Copyright (c) 2003 Jared D. McNeill <jmcne...@invisible.ca>
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: acpi_tz.c,v 1.41 2009/06/03 22:34:18 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: acpi_tz.c,v 1.42 2009/06/30 16:14:49 pgoyette Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -129,6 +129,8 @@
 static int	acpitz_get_integer(device_t, const char *, UINT32 *);
 static void	acpitz_tick(void *);
 static void	acpitz_init_envsys(device_t);
+static void	acpitz_get_limits(struct sysmon_envsys *, envsys_data_t *,
+				  sysmon_envsys_lim_t *);
 
 CFATTACH_DECL_NEW(acpitz, sizeof(struct acpitz_softc), acpitz_match,
     acpitz_attach, NULL, NULL);
@@ -262,6 +264,8 @@
 			if (sc->sc_zone.ac[i] <= tmp)
 				active = i;
 		}
+		if (active != ATZ_ACTIVE_NONE)
+			sc->sc_sensor.state = ENVSYS_SWARNOVER;
 
 		flags = sc->sc_flags &
 		    ~(ATZ_F_CRITICAL|ATZ_F_HOT|ATZ_F_PASSIVE);
@@ -284,7 +288,7 @@
 				    "zone went critical at temp %sC\n",
 				    acpitz_celcius_string(tmp));
 			} else if (changed & ATZ_F_HOT) {
-				sc->sc_sensor.state = ENVSYS_SWARNOVER;
+				sc->sc_sensor.state = ENVSYS_SCRITOVER;
 				aprint_debug_dev(dv,
 				    "zone went hot at temp %sC\n",
 				    acpitz_celcius_string(tmp));
@@ -584,21 +588,45 @@
 	struct acpitz_softc *sc = device_private(dv);
 
 	sc->sc_sme = sysmon_envsys_create();
+	sc->sc_sme->sme_get_limits = acpitz_get_limits;
+	sc->sc_sme->sme_cookie = sc;
+	sc->sc_sme->sme_name = device_xname(dv);
+	sc->sc_sme->sme_flags = SME_DISABLE_REFRESH;
 	sc->sc_sensor.monitor = true;
-	sc->sc_sensor.flags = ENVSYS_FMONLIMITS;
+	sc->sc_sensor.flags = ENVSYS_FMONLIMITS | ENVSYS_FMONNOTSUPP;
 	sc->sc_sensor.units = ENVSYS_STEMP;
 	strlcpy(sc->sc_sensor.desc, "temperature", sizeof(sc->sc_sensor.desc));
-	if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor)) {
-		sysmon_envsys_destroy(sc->sc_sme);
-		return;
-	}
+	if (sysmon_envsys_sensor_attach(sc->sc_sme, &sc->sc_sensor))
+		goto out;
 
 	/* hook into sysmon */
-	sc->sc_sme->sme_name = device_xname(dv);
-	sc->sc_sme->sme_flags = SME_DISABLE_REFRESH;
+	if (sysmon_envsys_register(sc->sc_sme) == 0)
+		return;
+out:
+	aprint_error_dev(dv, "unable to register with sysmon\n");
+	sysmon_envsys_destroy(sc->sc_sme);
+}
 
-	if (sysmon_envsys_register(sc->sc_sme)) {
-		aprint_error_dev(dv, "unable to register with sysmon\n");
-		sysmon_envsys_destroy(sc->sc_sme);
-	}
+static void
+acpitz_get_limits(struct sysmon_envsys *sme, envsys_data_t *edata,
+		  sysmon_envsys_lim_t *limits)
+{
+	struct acpitz_softc *sc = sme->sme_cookie;
+	int i;
+
+	limits->sel_flags = 0;
+
+	if (sc->sc_zone.hot != ATZ_TMP_INVALID) {
+		limits->sel_flags |= PROP_CRITMAX;
+		limits->sel_critmax = sc->sc_zone.hot;
+	} else if (sc->sc_zone.crt != ATZ_TMP_INVALID) {
+		limits->sel_flags |= PROP_CRITMAX;
+		limits->sel_critmax = sc->sc_zone.crt;
+	}
+	for (i = 0; i < ATZ_NLEVELS; i++) 
+		if (sc->sc_zone.ac[i] != ATZ_TMP_INVALID) {
+			limits->sel_critmax = sc->sc_zone.ac[i];
+			limits->sel_flags |= PROP_WARNMAX;
+			break;
+		}
 }

Reply via email to