Module Name: src Committed By: pgoyette Date: Sat Apr 10 19:02:39 UTC 2010
Modified Files: src/sys/arch/x86/x86: ipmi.c src/sys/dev/i2c: dbcool.c dbcool_var.h sdtemp.c Log Message: Save initial, boot-time limit values, and restore them upon request from sysmon_envsys(9). To generate a diff of this commit: cvs rdiff -u -r1.45 -r1.46 src/sys/arch/x86/x86/ipmi.c cvs rdiff -u -r1.23 -r1.24 src/sys/dev/i2c/dbcool.c cvs rdiff -u -r1.11 -r1.12 src/sys/dev/i2c/dbcool_var.h cvs rdiff -u -r1.12 -r1.13 src/sys/dev/i2c/sdtemp.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/x86/ipmi.c diff -u src/sys/arch/x86/x86/ipmi.c:1.45 src/sys/arch/x86/x86/ipmi.c:1.46 --- src/sys/arch/x86/x86/ipmi.c:1.45 Mon Mar 22 23:21:29 2010 +++ src/sys/arch/x86/x86/ipmi.c Sat Apr 10 19:02:39 2010 @@ -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 @@ 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 @@ /* 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_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; } } Index: src/sys/dev/i2c/dbcool.c diff -u src/sys/dev/i2c/dbcool.c:1.23 src/sys/dev/i2c/dbcool.c:1.24 --- src/sys/dev/i2c/dbcool.c:1.23 Thu Apr 1 05:26:48 2010 +++ src/sys/dev/i2c/dbcool.c Sat Apr 10 19:02:39 2010 @@ -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 @@ (*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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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); + } } Index: src/sys/dev/i2c/dbcool_var.h diff -u src/sys/dev/i2c/dbcool_var.h:1.11 src/sys/dev/i2c/dbcool_var.h:1.12 --- src/sys/dev/i2c/dbcool_var.h:1.11 Mon Mar 1 03:14:49 2010 +++ src/sys/dev/i2c/dbcool_var.h Sat Apr 10 19:02:39 2010 @@ -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 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]; Index: src/sys/dev/i2c/sdtemp.c diff -u src/sys/dev/i2c/sdtemp.c:1.12 src/sys/dev/i2c/sdtemp.c:1.13 --- src/sys/dev/i2c/sdtemp.c:1.12 Sun Mar 14 18:05:49 2010 +++ src/sys/dev/i2c/sdtemp.c Sat Apr 10 19:02:39 2010 @@ -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 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 @@ 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 @@ 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);