CVS commit: [netbsd-5] src/sys/arch/sparc64/dev
Module Name:src Committed By: riz Date: Sat Jul 16 00:14:57 UTC 2011 Modified Files: src/sys/arch/sparc64/dev [netbsd-5]: lom.c Log Message: Pull up following revision(s) (requested by nakayama in ticket #1641): sys/arch/sparc64/dev/lom.c: revision 1.8 Limit reading from registers at most once every second with using ratecheck(9). To generate a diff of this commit: cvs rdiff -u -r1.1.2.7 -r1.1.2.8 src/sys/arch/sparc64/dev/lom.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/sparc64/dev/lom.c diff -u src/sys/arch/sparc64/dev/lom.c:1.1.2.7 src/sys/arch/sparc64/dev/lom.c:1.1.2.8 --- src/sys/arch/sparc64/dev/lom.c:1.1.2.7 Sun Mar 20 21:23:32 2011 +++ src/sys/arch/sparc64/dev/lom.c Sat Jul 16 00:14:57 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: lom.c,v 1.1.2.7 2011/03/20 21:23:32 bouyer Exp $ */ +/* $NetBSD: lom.c,v 1.1.2.8 2011/07/16 00:14:57 riz Exp $ */ /* $OpenBSD: lom.c,v 1.21 2010/02/28 20:44:39 kettenis Exp $ */ /* * Copyright (c) 2009 Mark Kettenis @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.1.2.7 2011/03/20 21:23:32 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.1.2.8 2011/07/16 00:14:57 riz Exp $"); #include #include @@ -171,6 +171,12 @@ int32_t sc_sysctl_num[LOM_MAX_ALARM]; + struct timeval sc_alarm_lastread; + uint8_t sc_alarm_lastval; + struct timeval sc_fan_lastread[LOM_MAX_FAN]; + struct timeval sc_psu_lastread[LOM_MAX_PSU]; + struct timeval sc_temp_lastread[LOM_MAX_TEMP]; + uint8_t sc_fan_cal[LOM_MAX_FAN]; uint8_t sc_fan_low[LOM_MAX_FAN]; @@ -239,6 +245,7 @@ static const char *nodedesc[LOM_MAX_ALARM] = { "Fault LED status", "Alarm1 status", "Alarm2 status ", "Alarm3 status" }; #endif +static const struct timeval refresh_interval = { 1, 0 }; static int lom_match(device_t parent, cfdata_t match, void *aux) @@ -1002,24 +1009,31 @@ /* Fault LED or Alarms */ KASSERT(i < sc->sc_num_alarm); - if (lom_read(sc, LOM_IDX_ALARM, &val)) { - edata->state = ENVSYS_SINVALID; - } else { - if (i == 0) { - /* Fault LED */ - if ((val & LOM_ALARM_FAULT) == LOM_ALARM_FAULT) -edata->value_cur = 0; - else -edata->value_cur = 1; - } else { - /* Alarms */ - if ((val & (LOM_ALARM_1 << (i - 1))) == 0) -edata->value_cur = 0; - else -edata->value_cur = 1; + /* Read new value at most once every second. */ + if (ratecheck(&sc->sc_alarm_lastread, &refresh_interval)) { + if (lom_read(sc, LOM_IDX_ALARM, &val)) { + edata->state = ENVSYS_SINVALID; + return; } - edata->state = ENVSYS_SVALID; + sc->sc_alarm_lastval = val; + } else { + val = sc->sc_alarm_lastval; + } + + if (i == 0) { + /* Fault LED */ + if ((val & LOM_ALARM_FAULT) == LOM_ALARM_FAULT) + edata->value_cur = 0; + else + edata->value_cur = 1; + } else { + /* Alarms */ + if ((val & (LOM_ALARM_1 << (i - 1))) == 0) + edata->value_cur = 0; + else + edata->value_cur = 1; } + edata->state = ENVSYS_SVALID; } static void @@ -1030,6 +1044,10 @@ /* Fan speed */ KASSERT(i < sc->sc_num_fan); + /* Read new value at most once every second. */ + if (!ratecheck(&sc->sc_fan_lastread[i], &refresh_interval)) + return; + if (lom_read(sc, LOM_IDX_FAN1 + i, &val)) { edata->state = ENVSYS_SINVALID; } else { @@ -1049,6 +1067,10 @@ /* PSU status */ KASSERT(i < sc->sc_num_psu); + /* Read new value at most once every second. */ + if (!ratecheck(&sc->sc_psu_lastread[i], &refresh_interval)) + return; + if (lom_read(sc, LOM_IDX_PSU1 + i, &val) || !ISSET(val, LOM_PSU_PRESENT)) { edata->state = ENVSYS_SINVALID; @@ -1076,6 +1098,10 @@ /* Temperature */ KASSERT(i < sc->sc_num_temp); + /* Read new value at most once every second. */ + if (!ratecheck(&sc->sc_temp_lastread[i], &refresh_interval)) + return; + if (lom_read(sc, LOM_IDX_TEMP1 + i, &val)) { edata->state = ENVSYS_SINVALID; } else {
CVS commit: [netbsd-5] src/sys/arch/sparc64/dev
Module Name:src Committed By: bouyer Date: Sun Mar 20 21:23:32 UTC 2011 Modified Files: src/sys/arch/sparc64/dev [netbsd-5]: lom.c Log Message: Pull up following revision(s) (requested by nakayama in ticket #1570): sys/arch/sparc64/dev/lom.c: revision 1.7 lom_refresh(): Update only the sensor status specified by the edata as noted in sysmon_envsys(9). lom_sysctl_alarm(): Update alarm status before reading via sysctl to make it usable at a boot time. To generate a diff of this commit: cvs rdiff -u -r1.1.2.6 -r1.1.2.7 src/sys/arch/sparc64/dev/lom.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/sparc64/dev/lom.c diff -u src/sys/arch/sparc64/dev/lom.c:1.1.2.6 src/sys/arch/sparc64/dev/lom.c:1.1.2.7 --- src/sys/arch/sparc64/dev/lom.c:1.1.2.6 Sun Mar 28 16:48:36 2010 +++ src/sys/arch/sparc64/dev/lom.c Sun Mar 20 21:23:32 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: lom.c,v 1.1.2.6 2010/03/28 16:48:36 snj Exp $ */ +/* $NetBSD: lom.c,v 1.1.2.7 2011/03/20 21:23:32 bouyer Exp $ */ /* $OpenBSD: lom.c,v 1.21 2010/02/28 20:44:39 kettenis Exp $ */ /* * Copyright (c) 2009 Mark Kettenis @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.1.2.6 2010/03/28 16:48:36 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.1.2.7 2011/03/20 21:23:32 bouyer Exp $"); #include #include @@ -217,6 +217,10 @@ static int lom_init_desc(struct lom_softc *); static void lom_refresh(struct sysmon_envsys *, envsys_data_t *); +static void lom_refresh_alarm(struct lom_softc *, envsys_data_t *, uint32_t); +static void lom_refresh_fan(struct lom_softc *, envsys_data_t *, uint32_t); +static void lom_refresh_psu(struct lom_softc *, envsys_data_t *, uint32_t); +static void lom_refresh_temp(struct lom_softc *, envsys_data_t *, uint32_t); static void lom1_write_hostname(struct lom_softc *); static void lom2_write_hostname(struct lom_softc *); @@ -947,88 +951,136 @@ lom_refresh(struct sysmon_envsys *sme, envsys_data_t *edata) { struct lom_softc *sc = sme->sme_cookie; + uint32_t i; + + /* Sensor number */ + i = edata->sensor; + + /* Sensor type */ + switch (edata->units) { + case ENVSYS_INDICATOR: + if (i < sc->sc_num_alarm) + lom_refresh_alarm(sc, edata, i); + else + lom_refresh_psu(sc, edata, + i - sc->sc_num_alarm - sc->sc_num_fan); + break; + case ENVSYS_SFANRPM: + lom_refresh_fan(sc, edata, i - sc->sc_num_alarm); + break; + case ENVSYS_STEMP: + lom_refresh_temp(sc, edata, + i - sc->sc_num_alarm - sc->sc_num_fan - sc->sc_num_psu); + break; + default: + edata->state = ENVSYS_SINVALID; + break; + } + + /* + * If our hostname is set and differs from what's stored in + * the LOM, write the new hostname back to the LOM. Note that + * we include the terminating NUL when writing the hostname + * back to the LOM, otherwise the LOM will print any trailing + * garbage. + */ + if (i == 0 && hostnamelen > 0 && + strncmp(sc->sc_hostname, hostname, sizeof(hostname)) != 0) { + if (sc->sc_type < LOM_LOMLITE2) + lom1_write_hostname(sc); + else + lom2_write_hostname(sc); + strlcpy(sc->sc_hostname, hostname, sizeof(hostname)); + } +} + +static void +lom_refresh_alarm(struct lom_softc *sc, envsys_data_t *edata, uint32_t i) +{ uint8_t val; - int i; + + /* Fault LED or Alarms */ + KASSERT(i < sc->sc_num_alarm); if (lom_read(sc, LOM_IDX_ALARM, &val)) { - for (i = 0; i < sc->sc_num_alarm; i++) - sc->sc_alarm[i].state = ENVSYS_SINVALID; + edata->state = ENVSYS_SINVALID; } else { - /* Fault LED */ - if ((val & LOM_ALARM_FAULT) == LOM_ALARM_FAULT) - sc->sc_alarm[0].value_cur = 0; - else - sc->sc_alarm[0].value_cur = 1; - sc->sc_alarm[0].state = ENVSYS_SVALID; - - /* Alarms */ - for (i = 1; i < sc->sc_num_alarm; i++) { + if (i == 0) { + /* Fault LED */ + if ((val & LOM_ALARM_FAULT) == LOM_ALARM_FAULT) +edata->value_cur = 0; + else +edata->value_cur = 1; + } else { + /* Alarms */ if ((val & (LOM_ALARM_1 << (i - 1))) == 0) -sc->sc_alarm[i].value_cur = 0; +edata->value_cur = 0; else -sc->sc_alarm[i].value_cur = 1; - sc->sc_alarm[i].state = ENVSYS_SVALID; +edata->value_cur = 1; } + edata->state = ENVSYS_SVALID; } +} - for (i = 0; i < sc->sc_num_fan; i++) { - if (lom_read(sc, LOM_IDX_FAN1 + i, &val)) { - sc->sc_fan[i].state = ENVSYS_SINVALID; - continue; - } +static void +lom_refresh_fan(struct lom_softc *sc, envsys_data_t *edata, uint32_t i) +{ + uint8_t val; + + /* Fan speed */ + KASSERT(i < sc->sc_num_fan); - sc->sc_fan[i].value_cur = (60 * sc->sc_fan_cal[i] * val) / 100; + if (lom_read(sc, LOM_IDX_FAN1 + i, &val)) { + edata->state = ENVSYS_SINVALID; + } else { + edata->value_cur = (60 * sc->sc_fan_cal[i] * val) / 100; if (val < sc->sc_fan_low[i]) - sc->sc_fan[i].state = ENVSYS_SCRITICAL; + edata->state = ENVSYS_SCRITICAL; else - sc->sc_fan[i].state = ENVSYS_SVALID; + eda
CVS commit: [netbsd-5] src/sys/arch/sparc64/dev
Module Name:src Committed By: bouyer Date: Wed Feb 16 21:21:21 UTC 2011 Modified Files: src/sys/arch/sparc64/dev [netbsd-5]: psycho.c Log Message: Pull up following revision(s) (requested by nakayama in ticket #1555): sys/arch/sparc64/dev/psycho.c: revision 1.102 via patch Don't enable the powerfail interrupt on Netra X1 since it may hang. Discussed on port-sparc64. To generate a diff of this commit: cvs rdiff -u -r1.91 -r1.91.4.1 src/sys/arch/sparc64/dev/psycho.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/sparc64/dev/psycho.c diff -u src/sys/arch/sparc64/dev/psycho.c:1.91 src/sys/arch/sparc64/dev/psycho.c:1.91.4.1 --- src/sys/arch/sparc64/dev/psycho.c:1.91 Sat Oct 18 03:31:10 2008 +++ src/sys/arch/sparc64/dev/psycho.c Wed Feb 16 21:21:21 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: psycho.c,v 1.91 2008/10/18 03:31:10 nakayama Exp $ */ +/* $NetBSD: psycho.c,v 1.91.4.1 2011/02/16 21:21:21 bouyer Exp $ */ /* * Copyright (c) 1999, 2000 Matthew R. Green @@ -55,7 +55,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.91 2008/10/18 03:31:10 nakayama Exp $"); +__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.91.4.1 2011/02/16 21:21:21 bouyer Exp $"); #include "opt_ddb.h" @@ -288,6 +288,7 @@ int psycho_br[2], n, i; bus_space_handle_t pci_ctl; char *model = prom_getpropstring(ma->ma_node, "model"); + extern char machine_model[]; aprint_normal("\n"); @@ -519,10 +520,15 @@ psycho_set_intr(sc, 15, psycho_bus_a, &sc->sc_regs->pciaerr_int_map, &sc->sc_regs->pciaerr_clr_int); - psycho_set_intr(sc, 15, psycho_powerfail, - &sc->sc_regs->power_int_map, - &sc->sc_regs->power_clr_int); - psycho_register_power_button(sc); + /* + * Netra X1 may hang when the powerfail interrupt is enabled. + */ + if (strcmp(machine_model, "SUNW,UltraAX-i2") != 0) { + psycho_set_intr(sc, 15, psycho_powerfail, +&sc->sc_regs->power_int_map, +&sc->sc_regs->power_clr_int); + psycho_register_power_button(sc); + } if (sc->sc_mode != PSYCHO_MODE_SABRE) { /* sabre doesn't have these interrupts */ psycho_set_intr(sc, 15, psycho_bus_b,
CVS commit: [netbsd-5] src/sys/arch/sparc64/dev
Module Name:src Committed By: snj Date: Sun Mar 28 16:48:36 UTC 2010 Modified Files: src/sys/arch/sparc64/dev [netbsd-5]: lom.c Log Message: Pull up following revision(s) (requested by nakayama in ticket #1349): sys/arch/sparc64/dev/lom.c: revision 1.6 Fix off-by-one in LOMlite hostname code. From rev 1.21 of OpenBSD. To generate a diff of this commit: cvs rdiff -u -r1.1.2.5 -r1.1.2.6 src/sys/arch/sparc64/dev/lom.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/sparc64/dev/lom.c diff -u src/sys/arch/sparc64/dev/lom.c:1.1.2.5 src/sys/arch/sparc64/dev/lom.c:1.1.2.6 --- src/sys/arch/sparc64/dev/lom.c:1.1.2.5 Sat Jan 9 01:30:13 2010 +++ src/sys/arch/sparc64/dev/lom.c Sun Mar 28 16:48:36 2010 @@ -1,5 +1,5 @@ -/* $NetBSD: lom.c,v 1.1.2.5 2010/01/09 01:30:13 snj Exp $ */ -/* $OpenBSD: lom.c,v 1.20 2009/12/12 13:01:00 kettenis Exp $ */ +/* $NetBSD: lom.c,v 1.1.2.6 2010/03/28 16:48:36 snj Exp $ */ +/* $OpenBSD: lom.c,v 1.21 2010/02/28 20:44:39 kettenis Exp $ */ /* * Copyright (c) 2009 Mark Kettenis * @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.1.2.5 2010/01/09 01:30:13 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.1.2.6 2010/03/28 16:48:36 snj Exp $"); #include #include @@ -1035,7 +1035,7 @@ static void lom1_write_hostname(struct lom_softc *sc) { - char name[LOM1_IDX_HOSTNAME12 - LOM1_IDX_HOSTNAME1 + 1]; + char name[(LOM1_IDX_HOSTNAME12 - LOM1_IDX_HOSTNAME1 + 1) + 1]; char *p; int i; @@ -1045,7 +1045,7 @@ * strip off the domain name. */ strlcpy(name, hostname, sizeof(name)); - if (hostnamelen > sizeof(name)) { + if (hostnamelen >= sizeof(name)) { p = strchr(name, '.'); if (p) *p = '\0';
CVS commit: [netbsd-5] src/sys/arch/sparc64/dev
Module Name:src Committed By: snj Date: Fri Dec 18 06:03:51 UTC 2009 Modified Files: src/sys/arch/sparc64/dev [netbsd-5]: lom.c Log Message: Pull up following revision(s) (requested by nakayama in ticket #1193): sys/arch/sparc64/dev/lom.c: revision 1.4 Merge change of OpenBSD rev 1.20: Remove debug printf and properly dequeue command instead when a read times out on LOMLite2. To generate a diff of this commit: cvs rdiff -u -r1.1.2.3 -r1.1.2.4 src/sys/arch/sparc64/dev/lom.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/sparc64/dev/lom.c diff -u src/sys/arch/sparc64/dev/lom.c:1.1.2.3 src/sys/arch/sparc64/dev/lom.c:1.1.2.4 --- src/sys/arch/sparc64/dev/lom.c:1.1.2.3 Sat Nov 28 15:55:14 2009 +++ src/sys/arch/sparc64/dev/lom.c Fri Dec 18 06:03:51 2009 @@ -1,5 +1,5 @@ -/* $NetBSD: lom.c,v 1.1.2.3 2009/11/28 15:55:14 bouyer Exp $ */ -/* $OpenBSD: lom.c,v 1.19 2009/11/10 22:26:48 kettenis Exp $ */ +/* $NetBSD: lom.c,v 1.1.2.4 2009/12/18 06:03:51 snj Exp $ */ +/* $OpenBSD: lom.c,v 1.20 2009/12/12 13:01:00 kettenis Exp $ */ /* * Copyright (c) 2009 Mark Kettenis * @@ -17,7 +17,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.1.2.3 2009/11/28 15:55:14 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lom.c,v 1.1.2.4 2009/12/18 06:03:51 snj Exp $"); #include #include @@ -643,7 +643,7 @@ error = tsleep(&lc, PZERO, "lom2rd", hz); if (error) - aprint_error_dev(sc->sc_dev, "lom2_read failed\n"); + lom_dequeue_cmd(sc, &lc); *val = lc.lc_data;
CVS commit: [netbsd-5] src/sys/arch/sparc64/dev
Module Name:src Committed By: bouyer Date: Sun Oct 18 14:39:38 UTC 2009 Modified Files: src/sys/arch/sparc64/dev [netbsd-5]: ffb.c Log Message: back out ticket 972 To generate a diff of this commit: cvs rdiff -u -r1.35.4.2 -r1.35.4.3 src/sys/arch/sparc64/dev/ffb.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/sparc64/dev/ffb.c diff -u src/sys/arch/sparc64/dev/ffb.c:1.35.4.2 src/sys/arch/sparc64/dev/ffb.c:1.35.4.3 --- src/sys/arch/sparc64/dev/ffb.c:1.35.4.2 Sun Oct 18 13:45:50 2009 +++ src/sys/arch/sparc64/dev/ffb.c Sun Oct 18 14:39:37 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ffb.c,v 1.35.4.2 2009/10/18 13:45:50 bouyer Exp $ */ +/* $NetBSD: ffb.c,v 1.35.4.3 2009/10/18 14:39:37 bouyer Exp $ */ /* $OpenBSD: creator.c,v 1.20 2002/07/30 19:48:15 jason Exp $ */ /* @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.35.4.2 2009/10/18 13:45:50 bouyer Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.35.4.3 2009/10/18 14:39:37 bouyer Exp $"); #include #include @@ -239,12 +239,11 @@ sc->sc_fb.fb_device = &sc->sc_dv; fb_attach(&sc->sc_fb, sc->sc_console); - ffb_clearscreen(sc); - if (sc->sc_console) { wsdisplay_cnattach(&ffb_stdscreen, ri, 0, 0, defattr); - vcons_replay_msgbuf(&ffb_console_screen); } + + ffb_clearscreen(sc); waa.console = sc->sc_console; waa.scrdata = &ffb_screenlist; @@ -434,6 +433,7 @@ break; #endif } + return (-1); }
CVS commit: [netbsd-5] src/sys/arch/sparc64/dev
Module Name:src Committed By: bouyer Date: Sun Oct 18 13:45:50 UTC 2009 Modified Files: src/sys/arch/sparc64/dev [netbsd-5]: ffb.c Log Message: Pull up following revision(s) (requested by macallan in ticket #972): sys/arch/sparc64/dev/ffb.c: revision 1.37 call vcons_replay_msgbuf() when appropriate To generate a diff of this commit: cvs rdiff -u -r1.35.4.1 -r1.35.4.2 src/sys/arch/sparc64/dev/ffb.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/sparc64/dev/ffb.c diff -u src/sys/arch/sparc64/dev/ffb.c:1.35.4.1 src/sys/arch/sparc64/dev/ffb.c:1.35.4.2 --- src/sys/arch/sparc64/dev/ffb.c:1.35.4.1 Wed Feb 25 20:52:09 2009 +++ src/sys/arch/sparc64/dev/ffb.c Sun Oct 18 13:45:50 2009 @@ -1,4 +1,4 @@ -/* $NetBSD: ffb.c,v 1.35.4.1 2009/02/25 20:52:09 snj Exp $ */ +/* $NetBSD: ffb.c,v 1.35.4.2 2009/10/18 13:45:50 bouyer Exp $ */ /* $OpenBSD: creator.c,v 1.20 2002/07/30 19:48:15 jason Exp $ */ /* @@ -33,7 +33,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.35.4.1 2009/02/25 20:52:09 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffb.c,v 1.35.4.2 2009/10/18 13:45:50 bouyer Exp $"); #include #include @@ -239,11 +239,12 @@ sc->sc_fb.fb_device = &sc->sc_dv; fb_attach(&sc->sc_fb, sc->sc_console); + ffb_clearscreen(sc); + if (sc->sc_console) { wsdisplay_cnattach(&ffb_stdscreen, ri, 0, 0, defattr); + vcons_replay_msgbuf(&ffb_console_screen); } - - ffb_clearscreen(sc); waa.console = sc->sc_console; waa.scrdata = &ffb_screenlist; @@ -433,7 +434,6 @@ break; #endif } - return (-1); }