On Thu, Jan 07, 2016 at 01:48:53PM +0900, Masao Uebayashi wrote:
> Reflected kettenis@'s comments:
> - Initialize sc_wdog_period before use.
> - Define less stupid register names.
>
> *
>
> When stopping wdog, not only disabling reboot, but also stop timer.
Forgot to mention the reason:
Without this, BMC records a watchdog timer expiration event log, which
is only confusing.
> diff --git a/sys/dev/ipmi.c b/sys/dev/ipmi.c
> index c837234..d579987 100644
> --- a/sys/dev/ipmi.c
> +++ b/sys/dev/ipmi.c
> @@ -1681,6 +1681,8 @@ ipmi_activate(struct device *self, int act)
> return (0);
> }
>
> +#define MIN_PERIOD 10
> +
> int
> ipmi_watchdog(void *arg, int period)
> {
> @@ -1700,8 +1702,9 @@ ipmi_watchdog(void *arg, int period)
> return (period);
> }
>
> - if (period < 10 && period > 0)
> - period = 10;
> + if (period < MIN_PERIOD && period > 0)
> + period = MIN_PERIOD;
> + sc->sc_wdog_period = period;
>
> s = splsoftclock();
> /* XXX what to do if poking wdog fails? */
> @@ -1709,13 +1712,15 @@ ipmi_watchdog(void *arg, int period)
> APP_GET_WATCHDOG_TIMER, 0, NULL);
> rc = ipmi_recvcmd(sc, IPMI_GET_WDOG_MAX, &len, wdog);
>
> + wdog[IPMI_SET_WDOG_TIMER] &= ~IPMI_WDOG_TIMER_DONTSTOP;
> + wdog[IPMI_SET_WDOG_TIMER] |= (sc->sc_wdog_period == 0) ?
> + 0 : IPMI_WDOG_TIMER_DONTSTOP;
> + wdog[IPMI_SET_WDOG_ACTION] &= ~IPMI_WDOG_ACTION_TOACT_MASK;
> + wdog[IPMI_SET_WDOG_ACTION] |= (sc->sc_wdog_period == 0) ?
> + IPMI_WDOG_ACTION_TOACT_DISABLED : IPMI_WDOG_ACTION_TOACT_REBOOT;
> /* Period is 10ths/sec */
> uint16_t timo = htole16(period * 10);
> -
> memcpy(&wdog[IPMI_SET_WDOG_TIMOL], &timo, 2);
> - wdog[IPMI_SET_WDOG_ACTION] &= ~IPMI_WDOG_MASK;
> - wdog[IPMI_SET_WDOG_ACTION] |= (period == 0) ? IPMI_WDOG_DISABLED :
> - IPMI_WDOG_REBOOT;
>
> rc = ipmi_sendcmd(sc, BMC_SA, BMC_LUN, APP_NETFN,
> APP_SET_WATCHDOG_TIMER, IPMI_SET_WDOG_MAX, wdog);
> @@ -1723,6 +1728,7 @@ ipmi_watchdog(void *arg, int period)
>
> splx(s);
>
> - sc->sc_wdog_period = period;
> + printf("%s: watchdog %sabled\n", DEVNAME(sc),
> + (sc->sc_wdog_period == 0) ? "dis" : "en");
> return (period);
> }
> diff --git a/sys/dev/ipmivar.h b/sys/dev/ipmivar.h
> index c0ae492..9939f79 100644
> --- a/sys/dev/ipmivar.h
> +++ b/sys/dev/ipmivar.h
> @@ -106,11 +106,15 @@ struct ipmi_thread {
> volatile int running;
> };
>
> -#define IPMI_WDOG_MASK 0x03
> -#define IPMI_WDOG_DISABLED 0x00
> -#define IPMI_WDOG_REBOOT 0x01
> -#define IPMI_WDOG_PWROFF 0x02
> -#define IPMI_WDOG_PWRCYCLE 0x03
> +#define IPMI_WDOG_TIMER_DONTLOG 0x80
> +#define IPMI_WDOG_TIMER_DONTSTOP 0x40
> +#define IPMI_WDOG_TIMER_USE_MASK 0x07
> +
> +#define IPMI_WDOG_ACTION_TOACT_MASK 0x03
> +#define IPMI_WDOG_ACTION_TOACT_DISABLED 0x00
> +#define IPMI_WDOG_ACTION_TOACT_REBOOT 0x01
> +#define IPMI_WDOG_ACTION_TOACT_PWROFF 0x02
> +#define IPMI_WDOG_ACTION_TOACT_PWRCYCLE 0x03
>
> #define IPMI_WDOG_PRE_DISABLED 0x00
> #define IPMI_WDOG_PRE_SMI 0x01
> --
> 2.6.3
>