Received: by 10.223.185.116 with SMTP id b49csp1264846wrg; Fri, 16 Feb 2018 15:57:18 -0800 (PST) X-Google-Smtp-Source: AH8x224jJD2L5I/r7m9aifBeUL7Gkny0wTCyG8X7ZqCZaPiwdr7dRomqvKWGlzOdtxBW26sVlNR6 X-Received: by 10.99.171.70 with SMTP id k6mr6580934pgp.355.1518825438691; Fri, 16 Feb 2018 15:57:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518825438; cv=none; d=google.com; s=arc-20160816; b=a8uFbE9AoJIAI4v+n2EdclmNoCQ5OGAVi9vxF1EnFlWAEEmec8+VTXjUewcttWEPAf 4yOHwcpt7sPn5l0lhS2ItqRaD4ZhG5aLinwytjLsPwaN9zCi4ifPwqnc1/pZHElljLvQ mOlThEkcVxCYLUjTgXRZ+kekuBHfYBYHaEM18VQhkJPPs5jjJbddZdmSQOMVQHf5Ne9a jQZzvgvozYDT6MkXp9GzyuSIjY6IHuVWdzOekeS3HQe0ZlQRAS2k5k/KQ8xB/4iS34DX PYKTgpGEKvyv+WBdi3maQ6DpTI3kpNSgxXqShozKXGRCHou0Vl+grCJ8xw6Uvqqwo0vy 2UUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=d6MIBiEmvCjd9WgLWEjP2VXu4/T4RB65+j++k+dq3wU=; b=GzD/QdJb1r//w/jxkiqKVmT2gbdH8k8Sb25qLsORxHhLLy/MWhWNkyOYBDTi2IgVU9 8IlgZo3rBDElXRBBYRHLipB/ThQSAbrsCBX9YwApXxva3E5/n+VnLFQKDSn9jJqhTRPW U20cHdV70p+byFdzw7gDYxMpDCdA/O50UF1FqCYyx+TUIlOYuIMgW/w9EE+jKXkdkB24 P44twMh8L5Bim+m+2b1jRVowy12HvKK7V+7bISmMuOorLSttciWOUtthOIslvnm/o5mV OE723+S8+4fEiYLK3/AerjuveyMRxzokooj+a/VGhv2jUPc4/W9mLeAcW7Ute/0RJ+lA iq9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t51bA9a+; 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 m73si7390349pfj.131.2018.02.16.15.57.03; Fri, 16 Feb 2018 15:57:18 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=t51bA9a+; 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 S1750960AbeBPXzK (ORCPT + 99 others); Fri, 16 Feb 2018 18:55:10 -0500 Received: from mail-pg0-f67.google.com ([74.125.83.67]:46689 "EHLO mail-pg0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750948AbeBPXzJ (ORCPT ); Fri, 16 Feb 2018 18:55:09 -0500 Received: by mail-pg0-f67.google.com with SMTP id a11so3611427pgu.13; Fri, 16 Feb 2018 15:55:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=d6MIBiEmvCjd9WgLWEjP2VXu4/T4RB65+j++k+dq3wU=; b=t51bA9a+H/rOR8UgPKeAXdbOplKZPCJjIG/iQNjnCzL8PIQO87VzTNLZD3OO+o6PC+ QM7oS1q9e9n9ksiKHAsJ96Sx0VculIcNm75qLoC/1EApyLmtHRbjg+fUeAU49ReA0g98 2AeBzKMsqfxaOZaaNxpt6wyK7HnvSegaM1LfHTXKtyGxbvOtejAFzvsvc+MtWw9O3nYr t5GOJ/cYwGP2jd/AXdeFgLUrsqxzBhIpRQYrOzhT11kQZbPNxuP7qOinC0VXDqcJtY+k fqE2qxyrg0VLshe4v7t1L3cmGUYibz4+SvQ/Ucs6QrgmXy/TIAFAdyJVLDf+SnFkdpCR 8mvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=d6MIBiEmvCjd9WgLWEjP2VXu4/T4RB65+j++k+dq3wU=; b=Fc1Wsi5x9+EZiPVURQCwhH3KItHyjaklxLncAKQgAxVPPw8nhnj+QWcdKk9sJkvoxs qqSUzrrure4MYVr4gnlJoZhc6pYctr7kkxIDAxbtDOHnJLUKLREXqJa4NcgQ0845TvrB Aoa48wEGSa8PZlOY/Q7noqCaZs0acfVCNJhFV6lHZDLFoYbRhxm0SfGpEdCarGdlkUab /ezqf2oB+rGhBLl4RCCeWhjqhyLwN+/X6CYVwown25jTsng5v2GshXnMjVLIgfwdm6Sz t3EYFuiq7Qgmr41D04K+qRXPXPWmv/iiFPwiu/dTd5nLN4ZuyHASPeTZU0fLSwGkGFkp i+gA== X-Gm-Message-State: APf1xPCJ2PmSC1F1czoq1LbItJGuQ+O6vQqsytrsFFZ+AM2pPmUPt8nB Y7uZK/OlSoMlc+ISNniKnXs4Ew== X-Received: by 10.98.139.145 with SMTP id e17mr1680903pfl.53.1518825308664; Fri, 16 Feb 2018 15:55:08 -0800 (PST) Received: from localhost (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id b8sm47162511pff.31.2018.02.16.15.55.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 16 Feb 2018 15:55:07 -0800 (PST) Date: Fri, 16 Feb 2018 15:55:06 -0800 From: Guenter Roeck To: Jerry Hoemann Cc: wim@linux-watchdog.org, linux-watchdog@vger.kernel.org, linux-kernel@vger.kernel.org, rwright@hpe.com, maurice.a.saldivar@hpe.com, mingo@kernel.org, marcus.folkesson@gmail.com Subject: Re: [PATCH v3 08/11] watchdog/hpwdt: Programable Pretimeout NMI Message-ID: <20180216235506.GA26546@roeck-us.net> References: <20180215234400.5022-1-jerry.hoemann@hpe.com> <20180215234400.5022-9-jerry.hoemann@hpe.com> <20180216203440.GA31849@roeck-us.net> <20180216234617.GA675@anatevka.americas.hpqcorp.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180216234617.GA675@anatevka.americas.hpqcorp.net> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 16, 2018 at 04:46:17PM -0700, Jerry Hoemann wrote: > On Fri, Feb 16, 2018 at 12:34:40PM -0800, Guenter Roeck wrote: > > On Thu, Feb 15, 2018 at 04:43:57PM -0700, Jerry Hoemann wrote: > > > 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, 36 insertions(+), 6 deletions(-) > > > > > > diff --git a/drivers/watchdog/hpwdt.c b/drivers/watchdog/hpwdt.c > > > index da9a04101814..dc0ad20738ed 100644 > > > --- a/drivers/watchdog/hpwdt.c > > > +++ b/drivers/watchdog/hpwdt.c > > > @@ -28,12 +28,15 @@ > > > #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; > > > #ifdef CONFIG_HPWDT_NMI_DECODING > > > static unsigned int allow_kdump = 1; > > > +static bool pretimeout = 1; > > > +#else > > > +static bool pretimeout; > > > #endif > > > > > static bool pretimeout = IS_ENABLED(CONFIG_HPWDT_NMI_DECODING); > > ack. will do. > > > > > > static void __iomem *pci_mem_addr; /* the PCI-memory address */ > > > @@ -55,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); > > > > > > + dev_dbg(dev->parent, "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; > > > } > > > @@ -67,6 +72,8 @@ static int hpwdt_stop(struct watchdog_device *dev) > > > { > > > unsigned long data; > > > > > > + dev_dbg(dev->parent, "stop watchdog\n"); > > > + > > Unrelated. > > > > > data = ioread8(hpwdt_timer_con); > > > data &= 0xFE; > > > iowrite8(data, hpwdt_timer_con); > > > @@ -75,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); > > > > > > + dev_dbg(dev->parent, "ping watchdog 0x%08x\n", reload); > > > > Unrelated. If you want to add debug messages, please do it > > in a separate patch. > > > Different patch, but same set? I'll move these (and ones from earlier > patch to a new separate patch later in set.) > > > > > > iowrite16(reload, hpwdt_timer_reg); > > > > > > return 0; > > > @@ -98,12 +106,21 @@ 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)) { > > > > Unnecessary ( ) > > > There are several things going on here. I'm not sure which one the above > comment is intended. > The "Unnecessary" refers to the ( ) around the second part of the expression above. While there may be valid reasons to include extra ( ), I think we can trust the C compiler to get it right here. > While a pretimeout NMI isn't required by the HW to be enabled, if enabled the > length of pretimeout is fixed by HW. > > I didn't see anything in the API that would allow us to communicate to > the user this "feature." timeout at leasst has both min_timeout and max_timeout, but > I didn't see similar for pretimeout. I also don't think its reasonable to fail > here if the requested value is not 9 as the user really has no way of knowing what > the valid range of pretimeout values are. So I accept, any non-zero value > for pretimeout, but then set pretimeout to be 9. > > But at the same time, I don't like to siliently change a human request > w/o at least warning. > Sorry, I lost you here. > > > > The actual timeout can be a value smaller than 9 seconds. > > Minimum is 1 second. What happens if the user configures > > a timeout of less than 9 seconds as well as a pretimeout ? > > Will it fire immediately ? > > The architecture is silient on this issue. My experience with > this is that if timeout < 9 seconds, the NMI is not issued. > System resets when the timeout expires. This could be implementation > dependent. > > Note, this is not a new issue. > Bad argument. > I thought about setting the min timeout to ten seconds to avoid this situation. > You could reject reject request to set the pretimeout to a value <= the timeout. > I haven't dug into the various user level clients of watchdog so I'm not sure > what the impact of making this change would be to them. > > > > > > > + dev_info(dev->parent, "Setting pretimeout to %d\n", PRETIMEOUT_SEC); > > > > Please no ongoing logging noise. This can easily be abused to clog > > the kernel log. > > Good point. I will look at WARN_ONCE or something similar. > A traceback if someone sets a bad timeout ? That would be even worse. Guenter > > > > > + val = PRETIMEOUT_SEC; > > > + } > > > + dev->pretimeout = val; > > > + pretimeout = val ? 1 : 0; > > > > pretimeout = !!val; > > > > -- > > ----------------------------------------------------------------------------- > Jerry Hoemann Software Engineer Hewlett Packard Enterprise > -----------------------------------------------------------------------------