From owner-svn-src-all@FreeBSD.ORG Mon Dec 21 13:53:36 2009 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 81973106566B; Mon, 21 Dec 2009 13:53:36 +0000 (UTC) (envelope-from ru@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 56C668FC15; Mon, 21 Dec 2009 13:53:36 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id nBLDraDO029600; Mon, 21 Dec 2009 13:53:36 GMT (envelope-from ru@svn.freebsd.org) Received: (from ru@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id nBLDrZ8x029599; Mon, 21 Dec 2009 13:53:35 GMT (envelope-from ru@svn.freebsd.org) Message-Id: <200912211353.nBLDrZ8x029599@svn.freebsd.org> From: Ruslan Ermilov Date: Mon, 21 Dec 2009 13:53:35 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r200772 - in stable: 7/sys/dev/ipmi 8/sys/dev/ipmi X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 21 Dec 2009 13:53:36 -0000 Author: ru Date: Mon Dec 21 13:53:33 2009 New Revision: 200772 URL: http://svn.freebsd.org/changeset/base/200772 Log: MFC r200666: Fixed incorrect watchdog timeout setting. PR: kern/130512 Modified: stable/8/sys/dev/ipmi/ipmi.c Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) stable/8/sys/dev/xen/xenpci/ (props changed) Changes in other areas also in this revision: Modified: stable/7/sys/dev/ipmi/ipmi.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/8/sys/dev/ipmi/ipmi.c ============================================================================== --- stable/8/sys/dev/ipmi/ipmi.c Mon Dec 21 12:32:13 2009 (r200771) +++ stable/8/sys/dev/ipmi/ipmi.c Mon Dec 21 13:53:33 2009 (r200772) @@ -588,12 +588,15 @@ ipmi_polled_enqueue_request(struct ipmi_ * Watchdog event handler. */ -static void -ipmi_set_watchdog(struct ipmi_softc *sc, int sec) +static int +ipmi_set_watchdog(struct ipmi_softc *sc, unsigned int sec) { struct ipmi_request *req; int error; + if (sec > 0xffff / 10) + return (EINVAL); + req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_SET_WDOG, 6, 0); @@ -604,7 +607,7 @@ ipmi_set_watchdog(struct ipmi_softc *sc, req->ir_request[2] = 0; req->ir_request[3] = 0; /* Timer use */ req->ir_request[4] = (sec * 10) & 0xff; - req->ir_request[5] = (sec * 10) / 2550; + req->ir_request[5] = (sec * 10) >> 8; } else { req->ir_request[0] = IPMI_SET_WD_TIMER_SMS_OS; req->ir_request[1] = 0; @@ -617,8 +620,7 @@ ipmi_set_watchdog(struct ipmi_softc *sc, error = ipmi_submit_driver_request(sc, req, 0); if (error) device_printf(sc->ipmi_dev, "Failed to set watchdog\n"); - - if (error == 0 && sec) { + else if (sec) { ipmi_free_request(req); req = ipmi_alloc_driver_request(IPMI_ADDR(IPMI_APP_REQUEST, 0), @@ -631,6 +633,7 @@ ipmi_set_watchdog(struct ipmi_softc *sc, } ipmi_free_request(req); + return (error); /* dump_watchdog(sc); */ @@ -641,14 +644,22 @@ ipmi_wd_event(void *arg, unsigned int cm { struct ipmi_softc *sc = arg; unsigned int timeout; + int e; cmd &= WD_INTERVAL; if (cmd > 0 && cmd <= 63) { - timeout = ((uint64_t)1 << cmd) / 1800000000; - ipmi_set_watchdog(sc, timeout); - *error = 0; + timeout = ((uint64_t)1 << cmd) / 1000000000; + if (timeout == 0) + timeout = 1; + e = ipmi_set_watchdog(sc, timeout); + if (e == 0) + *error = 0; + else + (void)ipmi_set_watchdog(sc, 0); } else { - ipmi_set_watchdog(sc, 0); + e = ipmi_set_watchdog(sc, 0); + if (e != 0 && cmd == 0) + *error = EOPNOTSUPP; } }