From patchwork Thu May 24 00:13:31 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Kennington X-Patchwork-Id: 919467 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40rqgB6Xzbz9s1w for ; Thu, 24 May 2018 10:16:22 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="ezVOUDEB"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 40rqgB4Fw6zF1Hf for ; Thu, 24 May 2018 10:16:22 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="ezVOUDEB"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=flex--wak.bounces.google.com (client-ip=2607:f8b0:4002:c05::24a; helo=mail-yw0-x24a.google.com; envelope-from=32amgwwmkb9un1b7ff7c5.3fdjb92ffkc9jkj.fqc12j.fi7@flex--wak.bounces.google.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.b="ezVOUDEB"; dkim-atps=neutral Received: from mail-yw0-x24a.google.com (mail-yw0-x24a.google.com [IPv6:2607:f8b0:4002:c05::24a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 40rqcx2rdMzF1LJ for ; Thu, 24 May 2018 10:14:19 +1000 (AEST) Received: by mail-yw0-x24a.google.com with SMTP id v2-v6so12959251ywg.9 for ; Wed, 23 May 2018 17:14:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:date:in-reply-to:message-id:references:subject:from:to :cc; bh=XY0wVcszuU9lwGz26slkcmFkxUm3+nUR9FXxXsnk9WY=; b=ezVOUDEBFdCxl8yHIYy9daV+j4uWPqgqctMEosvvLoypMS/yzuGSvN/9h+yovLVycq WfeT9Sfj7gwvlO16HlsTUUUjHYZ/cGyXiSMtDTMN6GGcQ2M7VNdWjJ4mZ2UaeSJnRCzn nNdeatS+DSV8slM2zYskCeHU+tPeSMAC6pBTCWxgvCQ0ZYOPnJ2NVHvgJKmusNiKf9BL vIKM1gT3itn57UxuobODGXms69nFJKqjNQPD+kXli5y4bkC1DLzQV+nb3ItNxkDeWSO0 fsJ06u+SxdKP95qfBetc2DsVWEwVJ7N7qGdLWGSiZjiL8EH39BKmiFPIYQf1eZKU4+1E vH1w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:date:in-reply-to:message-id :references:subject:from:to:cc; bh=XY0wVcszuU9lwGz26slkcmFkxUm3+nUR9FXxXsnk9WY=; b=rmfzC3/k4TIuIuwB/L5qcP4/elEMayrYY0Ax55/Y9hin1BNCozvXwUOlLh1n4ph6jb xaK6Mjl2YU5VbzgF08Rn0HTxkF56Y5VvDU4RA4oc0fYFFn21XywQvprh4z8EQDfsAXJX Nn4wWRpdEE7ItkU1BVuyAxqoq7Y1UX2CKIxPUTGo7Fj/C3nSNJWBWWVN3wTZBivFlseB 3iBm1sRIC+am8Ft1fzSlX7iOLNyLAfGuPE6ohViRb9q04GOfpSdfKBiFW+JqVJ7aL+xl qSoYyehCJtjRNijdXoAQeFSsw8rv7acG82PHFRw1S8DsPFVzn1xNy133+z/hL6C3dd+r tXSA== X-Gm-Message-State: ALKqPwdP51HW1AY/6gRS2ORysP8UAc365qDbS1zofk0OZwnWs4sYKY4x AelX2CnPRpl1jLcavhStrx9HKfVWLMu1KoHPXcmBM7JbQAUB3Ud8laKWZcyBwRNSPyWNiNJtnn3 ysCeTCMTbxhocr4brKx5L+lAy5dHNIbI74I4NcZel+a+ycmflVOZCi8lu X-Google-Smtp-Source: AB8JxZqyvyCbvWw4YBAaLHgZYSGXrWwrsgKrARiWZgG09Gja9xFA6/5Ub2infQYZ1yRRImyC5m1RnsM= MIME-Version: 1.0 X-Received: by 2002:a0d:dd0c:: with SMTP id g12-v6mr1542959ywe.34.1527120856652; Wed, 23 May 2018 17:14:16 -0700 (PDT) Date: Wed, 23 May 2018 17:13:31 -0700 In-Reply-To: <20180524001335.15457-1-wak@google.com> Message-Id: <20180524001335.15457-6-wak@google.com> References: <20180524001335.15457-1-wak@google.com> X-Mailer: git-send-email 2.17.0 From: "William A. Kennington III" To: skiboot@lists.ozlabs.org, alistair@popple.id.au, jk@ozlabs.org Subject: [Skiboot] [PATCH 5/9] ipmi-watchdog: Add a flag to determine if we are still ticking X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" This makes it easier for future changes to ensure that the watchdog stops ticking and doesn't requeue itself for execution in the background. This way it is safe for resets to be performed after the ticks are assumed to be stopped and it won't start the timer again. Signed-off-by: William A. Kennington III --- hw/ipmi/ipmi-watchdog.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/hw/ipmi/ipmi-watchdog.c b/hw/ipmi/ipmi-watchdog.c index b5cb5fee4..fc559c6da 100644 --- a/hw/ipmi/ipmi-watchdog.c +++ b/hw/ipmi/ipmi-watchdog.c @@ -46,11 +46,12 @@ more frequently than necessary. */ #define WDT_MARGIN 300 static struct timer wdt_timer; -static bool wdt_stopped = false; +static bool wdt_stopped; +static bool wdt_ticking; static void ipmi_wdt_complete(struct ipmi_msg *msg) { - if (msg->cmd == IPMI_CMD(IPMI_RESET_WDT) && !msg->user_data) + if (msg->cmd == IPMI_CMD(IPMI_RESET_WDT) && wdt_ticking) schedule_timer(&wdt_timer, msecs_to_tb( (WDT_TIMEOUT - WDT_MARGIN)*100)); @@ -121,11 +122,18 @@ void ipmi_wdt_stop(void) void ipmi_wdt_final_reset(void) { + /* We can safely stop the timer prior to setting up our final + * watchdog timeout since we have enough margin before the + * timeout. */ + wdt_ticking = false; + cancel_timer(&wdt_timer); + + /* Configure the watchdog and make sure it is still enabled */ set_wdt(WDT_RESET_ACTION | WDT_PRETIMEOUT_SMI, WDT_TIMEOUT, WDT_MARGIN/10, true); sync_reset_wdt(); + ipmi_set_boot_count(); - cancel_timer(&wdt_timer); } void ipmi_wdt_init(void) @@ -136,6 +144,7 @@ void ipmi_wdt_init(void) /* Start the WDT. We do it synchronously to make sure it has * started before skiboot continues booting. Otherwise we * could crash before the wdt has actually been started. */ + wdt_ticking = true; sync_reset_wdt(); return;