Received: by 10.223.176.5 with SMTP id f5csp1216924wra; Tue, 6 Feb 2018 15:02:31 -0800 (PST) X-Google-Smtp-Source: AH8x224XwdvrhAemNHLhUPilwd218Bm0B1UFhQlQDBk12Q+5DrN2z4IrgicD+aY6VgdQxUhiDPsT X-Received: by 2002:a17:902:824:: with SMTP id 33-v6mr3840036plk.258.1517958151200; Tue, 06 Feb 2018 15:02:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517958151; cv=none; d=google.com; s=arc-20160816; b=TFf2wFb6mFKhzQgj3piNZ6mBnf9WCSg85EsIhIJ7aBOhnZJmSOkaodO06gml+I5QXD F2l9+FUn2+bOmkqW7mPC5kJRlRDZM+1yT6NQ5SwhSeJgno2IMfpf26Mzm753k8Tcwwo8 +JxVB5zZWXqg3lNoHAUWy0u1rH1bDk7aQoBU4vkf76GHVRFB6fmhFvU1zuXZhB483Nx5 PkNjqfno6bk490oepcCFzIEtT06rxMJlqu77anpvux7CquCqHmsucVeYZgq2pl4OQ58L /s8EMz+y2hjiShBigkzh0jfj4fdAOMI+FbVhaWSRstfUebmb6kuVcLaG1wxV2LfYYfdI NuzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=1sBBdXQiQsrshmMUrJUDCJUZ2xQRSrhdM5AdVZ90WH8=; b=iUzTeC4xfeesOutoQKldHXtRodIgozq/ZltfHw7SmLD9E+N4vvoTTjLSTQ7oaBtDz4 ZlJnCD0LQfcx7sMH4v3teugb+9WMKD7fqMBWJU7F5gr6CWVepJTyvQaKn5vEIXAFRTQV FjOldOMEb8GwKhg/jyK3umEP/TXZG2EkOfVaiwNExXcLJUQiCUEdSf7z2U5dMtxI4XOq dpHveO4vKhfgPqdmGk2YOBWOS8nQhYlEpyt3g3yZ/S4xgpLyh8cPs8qzSM/pWWAXplof Ko2iUtdhLm5y5OUaW5HnOFGwUbkCPh+W8xOQ+wTa2pr+DEUSRLhHZLoqjlSzwU4tmS94 JKbg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 28si84669pfl.53.2018.02.06.15.02.15; Tue, 06 Feb 2018 15:02:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753975AbeBFXAS (ORCPT + 99 others); Tue, 6 Feb 2018 18:00:18 -0500 Received: from g2t1383g.austin.hpe.com ([15.233.16.89]:13048 "EHLO g2t1383g.austin.hpe.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753935AbeBFXAR (ORCPT ); Tue, 6 Feb 2018 18:00:17 -0500 Received: from g4t3426.houston.hpe.com (g4t3426.houston.hpe.com [15.241.140.75]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by g2t1383g.austin.hpe.com (Postfix) with ESMTPS id A478115E2; Tue, 6 Feb 2018 23:00:16 +0000 (UTC) Received: from g9t2301.houston.hpecorp.net (g9t2301.houston.hpecorp.net [16.220.97.129]) by g4t3426.houston.hpe.com (Postfix) with ESMTP id CEDA862; Tue, 6 Feb 2018 23:00:15 +0000 (UTC) Received: from anatevka.ftc.rdlabs.hpecorp.net (anatevka.americas.hpqcorp.net [10.34.81.6]) by g9t2301.houston.hpecorp.net (Postfix) with ESMTP id 6BA4253; Tue, 6 Feb 2018 23:00:15 +0000 (UTC) From: Jerry Hoemann To: wim@linux-watchdog.org, linux@roeck-us.net Cc: linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, rwright@hpe.com, maurice.a.saldivar@hpe.com, Jerry Hoemann Subject: [PATCH 08/10] watchdog/hpwdt: Programable Pretimeout NMI Date: Tue, 6 Feb 2018 15:58:53 -0700 Message-Id: <20180206225855.30582-9-jerry.hoemann@hpe.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180206225855.30582-1-jerry.hoemann@hpe.com> References: <20180206225855.30582-1-jerry.hoemann@hpe.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make whether or not the hpwdt watchdog delivers a pretimeout NMI programable by the user. The underlying iLO hardware is programmable as to whether or not a pre-timeout NMI is delivered to the system before the iLO resets the system. However, the iLO does not allow for programming the length of time that NMI is delivered before the system is reset. Hence, in hpwdt_set_pretimeout, val == 0 disables the NMI. Any non-zero value sets the pretimeout length to what the hardware supports. Signed-off-by: Jerry Hoemann --- drivers/watchdog/hpwdt.c | 42 +++++++++++++++++++++++++++++++++++------- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c index a8e5c6542406..1edbcb8f1537 100644 --- a/drivers/watchdog/hpwdt.c +++ b/drivers/watchdog/hpwdt.c @@ -23,16 +23,21 @@ #include -#define HPWDT_VERSION "1.4.0" +#define HPWDT_VERSION "1.5.0" #define SECS_TO_TICKS(secs) ((secs) * 1000 / 128) #define TICKS_TO_SECS(ticks) ((ticks) * 128 / 1000) #define HPWDT_MAX_TIMER TICKS_TO_SECS(65535) #define DEFAULT_MARGIN 30 +#define PRETIMEOUT_SEC 9 static unsigned int soft_margin = DEFAULT_MARGIN; /* in seconds */ -static unsigned int reload; /* the computed soft_margin */ static bool nowayout = WATCHDOG_NOWAYOUT; static unsigned int allow_kdump = 1; +#ifdef CONFIG_HPWDT_NMI_DECODING /* { */ +static bool pretimeout = 1; +#else +static bool pretimeout; +#endif /* } */ static void __iomem *pci_mem_addr; /* the PCI-memory address */ static unsigned long __iomem *hpwdt_nmistat; @@ -53,10 +58,12 @@ static struct watchdog_device hpwdt_dev; */ static int hpwdt_start(struct watchdog_device *dev) { - reload = SECS_TO_TICKS(dev->timeout); + int control = 0x81 | (pretimeout ? 0x4 : 0); + int reload = SECS_TO_TICKS(dev->timeout); + pr_debug("start watchdog 0x%08x:0x%02x\n", reload, control); iowrite16(reload, hpwdt_timer_reg); - iowrite8(0x85, hpwdt_timer_con); + iowrite8(control, hpwdt_timer_con); return 0; } @@ -65,6 +72,8 @@ static int hpwdt_stop(struct watchdog_device *dev) { unsigned long data; + pr_debug("stop watchdog\n"); + data = ioread8(hpwdt_timer_con); data &= 0xFE; iowrite8(data, hpwdt_timer_con); @@ -73,8 +82,9 @@ static int hpwdt_stop(struct watchdog_device *dev) static int hpwdt_ping(struct watchdog_device *dev) { - reload = SECS_TO_TICKS(dev->timeout); + int reload = SECS_TO_TICKS(dev->timeout); + pr_debug("ping watchdog 0x%08x\n", reload); iowrite16(reload, hpwdt_timer_reg); return 0; @@ -96,6 +106,16 @@ static int hpwdt_settimeout(struct watchdog_device *dev, unsigned int val) } #ifdef CONFIG_HPWDT_NMI_DECODING /* { */ +static int hpwdt_set_pretimeout(struct watchdog_device *dev, unsigned int val) +{ + if (val && (val != PRETIMEOUT_SEC)) { + pr_info("Setting pretimeout to %d\n", PRETIMEOUT_SEC); + val = PRETIMEOUT_SEC; + } + dev->pretimeout = val; + pretimeout = val ? 1 : 0; + return 0; +} static unsigned int hpwdt_my_nmi(void) { @@ -106,7 +126,6 @@ static inline int hexdigit(int v) { return (v > 9) ? (v-9+'A') : (v+'0'); } - /* * NMI Handler */ @@ -126,6 +145,9 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs) pr_debug("nmi: ulReason=%d, mynmi=0x%0x\n", ulReason, mynmi); + if (!pretimeout) + return NMI_DONE; + if (allow_kdump) hpwdt_stop(&hpwdt_dev); @@ -142,7 +164,8 @@ static int hpwdt_pretimeout(unsigned int ulReason, struct pt_regs *regs) static const struct watchdog_info hpwdt_info = { .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | - WDIOF_MAGICCLOSE, + WDIOF_MAGICCLOSE | + WDIOF_PRETIMEOUT, .identity = "HPE iLO2+ HW Watchdog Timer", }; @@ -294,6 +317,7 @@ static const struct watchdog_ops hpwdt_ops = { .ping = hpwdt_ping, .set_timeout = hpwdt_settimeout, .get_timeleft = hpwdt_gettimeleft, + .set_pretimeout = hpwdt_set_pretimeout, }; static struct watchdog_device hpwdt_dev = { @@ -302,6 +326,7 @@ static struct watchdog_device hpwdt_dev = { .min_timeout = 1, .max_timeout = HPWDT_MAX_TIMER, .timeout = DEFAULT_MARGIN, + .pretimeout = PRETIMEOUT_SEC, }; @@ -320,6 +345,9 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" #ifdef CONFIG_HPWDT_NMI_DECODING /* { */ module_param(allow_kdump, int, 0444); MODULE_PARM_DESC(allow_kdump, "Start a kernel dump after NMI occurs"); + +module_param(pretimeout, bool, 0444); +MODULE_PARM_DESC(pretimeout, "Watchdog pretimeout enabled"); #endif /* } */ module_pci_driver(hpwdt_driver); -- 2.13.6