From 913cd0a8e6ea357704546eb2606fd17e07d6ac59 Mon Sep 17 00:00:00 2001 From: bouyer Date: Tue, 11 Aug 2009 17:15:32 +0000 Subject: [PATCH] Fix watchdog code: - the timer bound constants are in tick, so convert period to tick before checking it against the bounds - for ICH5 or older, fix code that would have always written a 0 period to the register. --- sys/arch/x86/pci/ichlpcib.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/sys/arch/x86/pci/ichlpcib.c b/sys/arch/x86/pci/ichlpcib.c index 26bd076dbbb8..d22baec7d428 100644 --- a/sys/arch/x86/pci/ichlpcib.c +++ b/sys/arch/x86/pci/ichlpcib.c @@ -1,4 +1,4 @@ -/* $NetBSD: ichlpcib.c,v 1.17 2009/04/29 14:55:36 njoly Exp $ */ +/* $NetBSD: ichlpcib.c,v 1.18 2009/08/11 17:15:32 bouyer Exp $ */ /*- * Copyright (c) 2004 The NetBSD Foundation, Inc. @@ -39,7 +39,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.17 2009/04/29 14:55:36 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ichlpcib.c,v 1.18 2009/08/11 17:15:32 bouyer Exp $"); #include #include @@ -414,6 +414,7 @@ tcotimer_setmode(struct sysmon_wdog *smw) struct lpcib_softc *sc = smw->smw_cookie; unsigned int period; uint16_t ich6period = 0; + uint8_t ich5period = 0; if ((smw->smw_mode & WDOG_MODE_MASK) == WDOG_MODE_DISARMED) { /* Stop the TCO timer. */ @@ -423,16 +424,16 @@ tcotimer_setmode(struct sysmon_wdog *smw) * ICH6 or newer are limited to 2s min and 613s max. * ICH5 or older are limited to 4s min and 39s max. */ + period = lpcib_tcotimer_second_to_tick(smw->smw_period); if (sc->sc_has_rcba) { - if (smw->smw_period < LPCIB_TCOTIMER2_MIN_TICK || - smw->smw_period > LPCIB_TCOTIMER2_MAX_TICK) + if (period < LPCIB_TCOTIMER2_MIN_TICK || + period > LPCIB_TCOTIMER2_MAX_TICK) return EINVAL; } else { - if (smw->smw_period < LPCIB_TCOTIMER_MIN_TICK || - smw->smw_period > LPCIB_TCOTIMER_MAX_TICK) + if (period < LPCIB_TCOTIMER_MIN_TICK || + period > LPCIB_TCOTIMER_MAX_TICK) return EINVAL; } - period = lpcib_tcotimer_second_to_tick(smw->smw_period); /* Stop the TCO timer, */ tcotimer_stop(sc); @@ -447,11 +448,11 @@ tcotimer_setmode(struct sysmon_wdog *smw) LPCIB_TCO_TMR2, ich6period | period); } else { /* ICH5 or older */ - period |= bus_space_read_1(sc->sc_iot, sc->sc_ioh, + ich5period = bus_space_read_1(sc->sc_iot, sc->sc_ioh, LPCIB_TCO_TMR); - period &= 0xc0; + ich5period &= 0xc0; bus_space_write_1(sc->sc_iot, sc->sc_ioh, - LPCIB_TCO_TMR, period); + LPCIB_TCO_TMR, ich5period | period); } /* and start/reload the timer. */