From owner-svn-src-all@freebsd.org Tue Apr 5 06:38:00 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 055ACB03266; Tue, 5 Apr 2016 06:38:00 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id D10A3119E; Tue, 5 Apr 2016 06:37:59 +0000 (UTC) (envelope-from mav@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u356bwRn085329; Tue, 5 Apr 2016 06:37:58 GMT (envelope-from mav@FreeBSD.org) Received: (from mav@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u356bwDT085328; Tue, 5 Apr 2016 06:37:58 GMT (envelope-from mav@FreeBSD.org) Message-Id: <201604050637.u356bwDT085328@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mav set sender to mav@FreeBSD.org using -f From: Alexander Motin Date: Tue, 5 Apr 2016 06:37:58 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r297574 - stable/10/sys/dev/ipmi X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.21 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: Tue, 05 Apr 2016 06:38:00 -0000 Author: mav Date: Tue Apr 5 06:37:58 2016 New Revision: 297574 URL: https://svnweb.freebsd.org/changeset/base/297574 Log: MFC r297179: Optimize IPMI watchdog patting. Set watchdog timer parameters only when they really need to be changed. In other cases just restart the timer with single Reset command instead of two (Set and Reset). From one side this visually reduces amount of CPU time burned in tight loop waiting while some slow BMC configures its watchdog hardware, that seems to be much more complicated task then just resetting the timer. From another side on some BMCs those slow Set commands sometimes tend to timeout, that leads to noisy log messages and even more CPU time burned, so avoiding them can provide even bigger bonuses. Modified: stable/10/sys/dev/ipmi/ipmi.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/dev/ipmi/ipmi.c ============================================================================== --- stable/10/sys/dev/ipmi/ipmi.c Tue Apr 5 03:27:33 2016 (r297573) +++ stable/10/sys/dev/ipmi/ipmi.c Tue Apr 5 06:37:58 2016 (r297574) @@ -603,6 +603,20 @@ ipmi_polled_enqueue_request(struct ipmi_ */ static int +ipmi_reset_watchdog(struct ipmi_softc *sc) +{ + struct ipmi_request *req; + int error; + + IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), + IPMI_RESET_WDOG, 0, 0); + error = ipmi_submit_driver_request(sc, req, 0); + if (error) + device_printf(sc->ipmi_dev, "Failed to reset watchdog\n"); + return (error); +} + +static int ipmi_set_watchdog(struct ipmi_softc *sc, unsigned int sec) { struct ipmi_request *req; @@ -613,7 +627,6 @@ ipmi_set_watchdog(struct ipmi_softc *sc, IPMI_ALLOC_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), IPMI_SET_WDOG, 6, 0); - if (sec) { req->ir_request[0] = IPMI_SET_WD_TIMER_DONT_STOP | IPMI_SET_WD_TIMER_SMS_OS; @@ -630,24 +643,10 @@ ipmi_set_watchdog(struct ipmi_softc *sc, req->ir_request[4] = 0; req->ir_request[5] = 0; } - error = ipmi_submit_driver_request(sc, req, 0); if (error) device_printf(sc->ipmi_dev, "Failed to set watchdog\n"); - else if (sec) { - IPMI_INIT_DRIVER_REQUEST(req, IPMI_ADDR(IPMI_APP_REQUEST, 0), - IPMI_RESET_WDOG, 0, 0); - - error = ipmi_submit_driver_request(sc, req, 0); - if (error) - device_printf(sc->ipmi_dev, - "Failed to reset watchdog\n"); - } - return (error); - /* - dump_watchdog(sc); - */ } static void @@ -665,12 +664,24 @@ ipmi_wd_event(void *arg, unsigned int cm timeout = ((uint64_t)1 << cmd) / 1000000000; if (timeout == 0) timeout = 1; - e = ipmi_set_watchdog(sc, timeout); - if (e == 0) { - *error = 0; - sc->ipmi_watchdog_active = 1; - } else - (void)ipmi_set_watchdog(sc, 0); + if (timeout != sc->ipmi_watchdog_active) { + e = ipmi_set_watchdog(sc, timeout); + if (e == 0) { + sc->ipmi_watchdog_active = timeout; + } else { + (void)ipmi_set_watchdog(sc, 0); + sc->ipmi_watchdog_active = 0; + } + } + if (sc->ipmi_watchdog_active != 0) { + e = ipmi_reset_watchdog(sc); + if (e == 0) { + *error = 0; + } else { + (void)ipmi_set_watchdog(sc, 0); + sc->ipmi_watchdog_active = 0; + } + } } else if (atomic_readandclear_int(&sc->ipmi_watchdog_active) != 0) { e = ipmi_set_watchdog(sc, 0); if (e != 0 && cmd == 0)