svn commit: r248048 - in stable/9/sys: conf sparc64/pci
Marius Strobl
marius at FreeBSD.org
Fri Mar 8 12:50:30 UTC 2013
Author: marius
Date: Fri Mar 8 12:50:29 2013
New Revision: 248048
URL: http://svnweb.freebsd.org/changeset/base/248048
Log:
MFC: r247600, r247620
- While Netra X1 generally show no ill effects when registering a power
fail interrupt handler, there seems to be either a broken batch of them
or a tendency to develop a defect which causes this interrupt to fire
inadvertedly. Given that apart from this problem these machines work
just fine, add a tunable allowing the setup of the power fail interrupt
to be disabled.
While at it, remove the DEBUGGER_ON_POWERFAIL compile time option and
make that behavior also selectable via the newly added tunable.
- Correct an incorrect argument to shutdown_nice(9).
- Mark unused parameters as such.
- Use NULL instead of 0 for pointers.
Modified:
stable/9/sys/conf/options.sparc64
stable/9/sys/sparc64/pci/psycho.c
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/conf/ (props changed)
Modified: stable/9/sys/conf/options.sparc64
==============================================================================
--- stable/9/sys/conf/options.sparc64 Fri Mar 8 12:44:40 2013 (r248047)
+++ stable/9/sys/conf/options.sparc64 Fri Mar 8 12:50:29 2013 (r248048)
@@ -23,7 +23,6 @@ PSM_DEBUG opt_psm.h
PSM_HOOKRESUME opt_psm.h
PSM_RESETAFTERSUSPEND opt_psm.h
-DEBUGGER_ON_POWERFAIL opt_psycho.h
PSYCHO_DEBUG opt_psycho.h
SCHIZO_DEBUG opt_schizo.h
Modified: stable/9/sys/sparc64/pci/psycho.c
==============================================================================
--- stable/9/sys/sparc64/pci/psycho.c Fri Mar 8 12:44:40 2013 (r248047)
+++ stable/9/sys/sparc64/pci/psycho.c Fri Mar 8 12:50:29 2013 (r248048)
@@ -54,6 +54,7 @@ __FBSDID("$FreeBSD$");
#include <sys/pcpu.h>
#include <sys/reboot.h>
#include <sys/rman.h>
+#include <sys/sysctl.h>
#include <dev/ofw/ofw_bus.h>
#include <dev/ofw/ofw_pci.h>
@@ -94,7 +95,8 @@ static void psycho_intr_clear(void *);
static driver_filter_t psycho_ue;
static driver_filter_t psycho_ce;
static driver_filter_t psycho_pci_bus;
-static driver_filter_t psycho_powerfail;
+static driver_filter_t psycho_powerdebug;
+static driver_intr_t psycho_powerdown;
static driver_intr_t psycho_overtemp;
#ifdef PSYCHO_MAP_WAKEUP
static driver_filter_t psycho_wakeup;
@@ -159,9 +161,16 @@ static devclass_t psycho_devclass;
DEFINE_CLASS_0(pcib, psycho_driver, psycho_methods,
sizeof(struct psycho_softc));
-EARLY_DRIVER_MODULE(psycho, nexus, psycho_driver, psycho_devclass, 0, 0,
+EARLY_DRIVER_MODULE(psycho, nexus, psycho_driver, psycho_devclass, NULL, NULL,
BUS_PASS_BUS);
+static SYSCTL_NODE(_hw, OID_AUTO, psycho, CTLFLAG_RD, 0, "psycho parameters");
+
+static u_int psycho_powerfail = 1;
+TUNABLE_INT("hw.psycho.powerfail", &psycho_powerfail);
+SYSCTL_UINT(_hw_psycho, OID_AUTO, powerfail, CTLFLAG_RDTUN, &psycho_powerfail,
+ 0, "powerfail action (0: none, 1: shutdown (default), 2: debugger)");
+
static SLIST_HEAD(, psycho_softc) psycho_softcs =
SLIST_HEAD_INITIALIZER(psycho_softcs);
@@ -612,13 +621,18 @@ psycho_attach(device_t dev)
*/
psycho_set_intr(sc, 1, PSR_UE_INT_MAP, psycho_ue, NULL);
psycho_set_intr(sc, 2, PSR_CE_INT_MAP, psycho_ce, NULL);
-#ifdef DEBUGGER_ON_POWERFAIL
- psycho_set_intr(sc, 3, PSR_POWER_INT_MAP, psycho_powerfail,
- NULL);
-#else
- psycho_set_intr(sc, 3, PSR_POWER_INT_MAP, NULL,
- (driver_intr_t *)psycho_powerfail);
-#endif
+ switch (psycho_powerfail) {
+ case 0:
+ break;
+ case 2:
+ psycho_set_intr(sc, 3, PSR_POWER_INT_MAP,
+ psycho_powerdebug, NULL);
+ break;
+ default:
+ psycho_set_intr(sc, 3, PSR_POWER_INT_MAP, NULL,
+ psycho_powerdown);
+ break;
+ }
if (sc->sc_mode == PSYCHO_MODE_PSYCHO) {
/*
* Hummingbirds/Sabres do not have the following two
@@ -629,8 +643,8 @@ psycho_attach(device_t dev)
* The spare hardware interrupt is used for the
* over-temperature interrupt.
*/
- psycho_set_intr(sc, 4, PSR_SPARE_INT_MAP,
- NULL, psycho_overtemp);
+ psycho_set_intr(sc, 4, PSR_SPARE_INT_MAP, NULL,
+ psycho_overtemp);
#ifdef PSYCHO_MAP_WAKEUP
/*
* psycho_wakeup() doesn't do anything useful right
@@ -837,27 +851,28 @@ psycho_pci_bus(void *arg)
}
static int
-psycho_powerfail(void *arg)
+psycho_powerdebug(void *arg __unused)
{
-#ifdef DEBUGGER_ON_POWERFAIL
- struct psycho_softc *sc = arg;
kdb_enter(KDB_WHY_POWERFAIL, "powerfail");
-#else
+ return (FILTER_HANDLED);
+}
+
+static void
+psycho_powerdown(void *arg __unused)
+{
static int shutdown;
/* As the interrupt is cleared we may be called multiple times. */
if (shutdown != 0)
- return (FILTER_HANDLED);
+ return;
shutdown++;
printf("Power Failure Detected: Shutting down NOW.\n");
- shutdown_nice(0);
-#endif
- return (FILTER_HANDLED);
+ shutdown_nice(RB_POWEROFF);
}
static void
-psycho_overtemp(void *arg)
+psycho_overtemp(void *arg __unused)
{
static int shutdown;
More information about the svn-src-stable-9
mailing list