Save initial, boot-time limit values, and restore them upon request

from sysmon_envsys(9).
This commit is contained in:
pgoyette 2010-04-10 19:02:39 +00:00
parent d8f35b6e65
commit 0321f1cd9a
4 changed files with 70 additions and 25 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ipmi.c,v 1.45 2010/03/22 23:21:29 dyoung Exp $ */
/* $NetBSD: ipmi.c,v 1.46 2010/04/10 19:02:39 pgoyette Exp $ */
/*
* Copyright (c) 2006 Manuel Bouyer.
@ -52,7 +52,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.45 2010/03/22 23:21:29 dyoung Exp $");
__KERNEL_RCSID(0, "$NetBSD: ipmi.c,v 1.46 2010/04/10 19:02:39 pgoyette Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -84,8 +84,8 @@ struct ipmi_sensor {
char i_envdesc[64];
int i_envtype; /* envsys compatible type */
int i_envnum; /* envsys index */
sysmon_envsys_lim_t i_limits;
uint32_t i_props;
sysmon_envsys_lim_t i_limits, i_deflims;
uint32_t i_props, i_defprops;
SLIST_ENTRY(ipmi_sensor) i_list;
};
@ -1359,6 +1359,10 @@ ipmi_set_limits(struct sysmon_envsys *sme, envsys_data_t *edata,
/* Find the ipmi_sensor corresponding to this edata */
SLIST_FOREACH(ipmi_s, &ipmi_sensor_list, i_list) {
if (ipmi_s->i_envnum == edata->sensor) {
if (limits == NULL) {
limits = &ipmi_s->i_deflims;
props = &ipmi_s->i_defprops;
}
*props |= PROP_DRIVER_LIMITS;
ipmi_s->i_limits = *limits;
ipmi_s->i_props = *props;
@ -1381,6 +1385,10 @@ ipmi_get_limits(struct sysmon_envsys *sme, envsys_data_t *edata,
ipmi_get_sensor_limits(sc, ipmi_s, limits, props);
ipmi_s->i_limits = *limits;
ipmi_s->i_props = *props;
if (ipmi_s->i_defprops == 0) {
ipmi_s->i_defprops = *props;
ipmi_s->i_deflims = *limits;
}
return;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: dbcool.c,v 1.23 2010/04/01 05:26:48 macallan Exp $ */
/* $NetBSD: dbcool.c,v 1.24 2010/04/10 19:02:39 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -49,7 +49,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.23 2010/04/01 05:26:48 macallan Exp $");
__KERNEL_RCSID(0, "$NetBSD: dbcool.c,v 1.24 2010/04/10 19:02:39 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -1812,6 +1812,15 @@ dbcool_get_limits(struct sysmon_envsys *sme, envsys_data_t *edata,
(*props & PROP_CRITMAX) &&
(limits->sel_critmin >= limits->sel_critmax))
*props &= ~(PROP_CRITMIN | PROP_CRITMAX);
/*
* If this is the first time through, save these values
* in case user overrides them and then requests a reset.
*/
if (sc->sc_defprops[index] == 0) {
sc->sc_defprops[index] = *props | PROP_DRIVER_LIMITS;
sc->sc_deflims[index] = *limits;
}
}
static void
@ -1905,6 +1914,10 @@ dbcool_set_limits(struct sysmon_envsys *sme, envsys_data_t *edata,
int index = edata->sensor;
struct dbcool_softc *sc = sme->sme_cookie;
if (limits == NULL) {
limits = &sc->sc_deflims[index];
props = &sc->sc_defprops[index];
}
switch (edata->units) {
case ENVSYS_STEMP:
dbcool_set_temp_limits(sc, index, limits, props);
@ -1944,12 +1957,16 @@ dbcool_set_temp_limits(struct dbcool_softc *sc, int idx,
else if (limit > 127)
limit = 127;
}
} else
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg,
(uint8_t)limit);
} else if (*props & PROP_DRIVER_LIMITS) {
if (sc->sc_temp_offset)
limit = 0x00;
else
limit = 0x80;
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg, (uint8_t)limit);
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg,
(uint8_t)limit);
}
if (*props & PROP_CRITMAX) {
limit = lims->sel_critmax - 273150000;
@ -1966,12 +1983,16 @@ dbcool_set_temp_limits(struct dbcool_softc *sc, int idx,
else if (limit > 127)
limit = 127;
}
} else
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->hi_lim_reg,
(uint8_t)limit);
} else if (*props & PROP_DRIVER_LIMITS) {
if (sc->sc_temp_offset)
limit = 0xff;
else
limit = 0x7f;
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->hi_lim_reg, (uint8_t)limit);
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->hi_lim_reg,
(uint8_t)limit);
}
}
static void
@ -1995,9 +2016,9 @@ dbcool_set_volt_limits(struct dbcool_softc *sc, int idx,
limit = 0xff;
else if (limit < 0)
limit = 0;
} else
limit = 0;
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg, limit);
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg, limit);
} else if (*props & PROP_DRIVER_LIMITS)
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg, 0);
if (*props & PROP_CRITMAX) {
limit = lims->sel_critmax;
@ -2007,9 +2028,9 @@ dbcool_set_volt_limits(struct dbcool_softc *sc, int idx,
limit = 0xff;
else if (limit < 0)
limit = 0;
} else
limit = 0xff;
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->hi_lim_reg, limit);
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->hi_lim_reg, limit);
} else if (*props & PROP_DRIVER_LIMITS)
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->hi_lim_reg, 0xff);
}
static void
@ -2032,9 +2053,13 @@ dbcool_set_fan_limits(struct dbcool_softc *sc, int idx,
if (limit > 0xffff)
limit = 0xffff;
}
} else
limit = 0xffff;
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg, limit & 0xff);
limit >>= 8;
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg + 1, limit & 0xff);
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg,
limit & 0xff);
limit >>= 8;
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg + 1,
limit & 0xff);
} else if (*props & PROP_DRIVER_LIMITS) {
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg, 0xff);
sc->sc_dc.dc_writereg(&sc->sc_dc, reg->lo_lim_reg + 1, 0xff);
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: dbcool_var.h,v 1.11 2010/03/01 03:14:49 pgoyette Exp $ */
/* $NetBSD: dbcool_var.h,v 1.12 2010/04/10 19:02:39 pgoyette Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: dbcool_var.h,v 1.11 2010/03/01 03:14:49 pgoyette Exp $");
__KERNEL_RCSID(0, "$NetBSD: dbcool_var.h,v 1.12 2010/04/10 19:02:39 pgoyette Exp $");
#include <dev/i2c/i2cvar.h>
@ -119,6 +119,8 @@ struct dbcool_softc {
struct sysmon_envsys *sc_sme;
struct dbcool_chipset sc_dc;
envsys_data_t sc_sensor[DBCOOL_MAXSENSORS];
sysmon_envsys_lim_t sc_deflims[DBCOOL_MAXSENSORS];
uint32_t sc_defprops[DBCOOL_MAXSENSORS];
int sc_root_sysctl_num;
int sc_sysctl_num[DBCOOL_MAXSENSORS];
struct reg_list *sc_regs[DBCOOL_MAXSENSORS];

View File

@ -1,4 +1,4 @@
/* $NetBSD: sdtemp.c,v 1.12 2010/03/14 18:05:49 pgoyette Exp $ */
/* $NetBSD: sdtemp.c,v 1.13 2010/04/10 19:02:39 pgoyette Exp $ */
/*
* Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.12 2010/03/14 18:05:49 pgoyette Exp $");
__KERNEL_RCSID(0, "$NetBSD: sdtemp.c,v 1.13 2010/04/10 19:02:39 pgoyette Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -51,6 +51,8 @@ struct sdtemp_softc {
struct sysmon_envsys *sc_sme;
envsys_data_t *sc_sensor;
sysmon_envsys_lim_t sc_deflims;
uint32_t sc_defprops;
int sc_resolution;
uint16_t sc_capability;
};
@ -327,6 +329,10 @@ sdtemp_get_limits(struct sysmon_envsys *sme, envsys_data_t *edata,
iic_release_bus(sc->sc_tag, 0);
if (*props != 0)
*props |= PROP_DRIVER_LIMITS;
if (sc->sc_defprops == 0) {
sc->sc_deflims = *limits;
sc->sc_defprops = *props;
}
}
/* Send current limit values to the device */
@ -337,6 +343,10 @@ sdtemp_set_limits(struct sysmon_envsys *sme, envsys_data_t *edata,
uint16_t val;
struct sdtemp_softc *sc = sme->sme_cookie;
if (limits == NULL) {
limits = &sc->sc_deflims;
props = &sc->sc_defprops;
}
iic_acquire_bus(sc->sc_tag, 0);
if (*props & PROP_WARNMIN) {
val = __UK2C(limits->sel_warnmin);