From patchwork Thu May 24 00:13:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: William Kennington X-Patchwork-Id: 919470 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40rqgz03Qwz9s1w for ; Thu, 24 May 2018 10:17:03 +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="ly6lEQ3o"; 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 40rqgy58H5zF1H5 for ; Thu, 24 May 2018 10:17:02 +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="ly6lEQ3o"; 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:400d:c0d::249; helo=mail-qt0-x249.google.com; envelope-from=33qmgwwmkb9os6gckkcha.8kioge7kkpheopo.kvh67o.knc@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="ly6lEQ3o"; dkim-atps=neutral Received: from mail-qt0-x249.google.com (mail-qt0-x249.google.com [IPv6:2607:f8b0:400d:c0d::249]) (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 40rqd331vKzF1F0 for ; Thu, 24 May 2018 10:14:23 +1000 (AEST) Received: by mail-qt0-x249.google.com with SMTP id g12-v6so22301566qtj.22 for ; Wed, 23 May 2018 17:14:23 -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=1NYqjWKpv0CjyL+yRKc/DDUzWF17ZxPyN4xuu9XeKLk=; b=ly6lEQ3oeMsMz8lLRbTQ2Mh+NvqUMHu64ekt2V1jZ7/QV9B/1uayR4LCeb5e/F4c1l jeZNxYqjuPOQyLL+twRUNqTZA5DYjBOK0h5UjZgfQTveCAGMVa0C19UuCGKbFwxs68R4 oWo/i5c/EYUgskA0AAE1GASAwKXowZ1xK6r7CB/FVlGDS9hGYynMtS/sUyw8O7dTBjgQ NlKf/ScqO8fPNR13X5BmMG17NkihJNQZZ/iqbLe9E2CSkH7HpejTtSnVV7pPqe/mdbVA 5utFPzpxXnDn39oI6xPCqFgAOVjf6lAigiljMLeuPhSICSimJ2RA+nD52u78C6TJMegp Xf4w== 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=1NYqjWKpv0CjyL+yRKc/DDUzWF17ZxPyN4xuu9XeKLk=; b=gOOPJc1WG25gFLv+qRhsjfIbua3SpL4f/HtMHMLYNpEgkrLuApmNkrfPy8YCBPA6S8 dq3+4fLR3gVCne87xk1EQg1REhUFAEbCVveLV0HdcFEezrxClmb8+f/pkkjoVfEgEwiK s0uizrqqH97a9dyyarBtlRzFYLbJPOehw1rd+0m6Oin15SR07zHviyz6f7+TpM6X5YUz r5Lj/0990ZT8pNaHZAbxIK2IATzxwQRH8ztzoPK6tIsRjFohZtwYjCUZr2HaQnpnCyTC ofmA7GmE95EhEPg8EEjbRBXZsSUBlgkd/kwuxSpzm4DfbZMp8ct6RcTi14/SGNff5UpT XTvg== X-Gm-Message-State: ALKqPwcgI2YuH3NXQpt5Glunew2UB+YOvw68fKDnHSeVecZTHwxFYG8u GaJZBFsv2MYbhKixtuih7GOOW+owj22BVeD2soEShrv2QhLQMDuWJOE+zeR8b4Vhmpq0njs5YCn Bnm94F2BHejecU3NnM1DjuaVPKvmV/m65Jq9FOA+Tv/jiDPZ4ZrTTQwTR X-Google-Smtp-Source: AB8JxZqCzftcMzHTIhCS15xKkx7+NyJBZP7lQGhWqudelrf6Vo0lkYgWFMxERF2DROTg/d8zqOYXuh8= MIME-Version: 1.0 X-Received: by 2002:a0c:d2ee:: with SMTP id x43-v6mr2559213qvh.45.1527120861559; Wed, 23 May 2018 17:14:21 -0700 (PDT) Date: Wed, 23 May 2018 17:13:33 -0700 In-Reply-To: <20180524001335.15457-1-wak@google.com> Message-Id: <20180524001335.15457-8-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 7/9] ipmi-watchdog: Simplify our completion function 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 no functional changes, just refactors the completion function to be used for reset only, since it does nothing but free the message for set calls. This will be useful for future changes to reduce nesting depth. Signed-off-by: William A. Kennington III --- hw/ipmi/ipmi-watchdog.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/hw/ipmi/ipmi-watchdog.c b/hw/ipmi/ipmi-watchdog.c index 6f2ac4abf..a43100ade 100644 --- a/hw/ipmi/ipmi-watchdog.c +++ b/hw/ipmi/ipmi-watchdog.c @@ -49,27 +49,18 @@ static struct timer wdt_timer; 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) && wdt_ticking) - schedule_timer(&wdt_timer, msecs_to_tb( - (WDT_TIMEOUT - WDT_MARGIN)*100)); - - ipmi_free_msg(msg); -} - static void set_wdt(uint8_t action, uint16_t count, uint8_t pretimeout, bool dont_stop) { struct ipmi_msg *ipmi_msg; ipmi_msg = ipmi_mkmsg(IPMI_DEFAULT_INTERFACE, IPMI_SET_WDT, - ipmi_wdt_complete, NULL, NULL, 6, 0); + ipmi_free_msg, NULL, NULL, 6, 0); if (!ipmi_msg) { prerror("Unable to allocate set wdt message\n"); return; } - ipmi_msg->error = ipmi_wdt_complete; + ipmi_msg->error = ipmi_free_msg; ipmi_msg->data[0] = TIMER_USE_POST | TIMER_USE_DONT_LOG | (dont_stop ? TIMER_USE_DONT_STOP : 0); @@ -81,12 +72,24 @@ static void set_wdt(uint8_t action, uint16_t count, uint8_t pretimeout, ipmi_queue_msg(ipmi_msg); } +static void reset_wdt_complete(struct ipmi_msg *msg) +{ + const uint64_t reset_delay_ms = (WDT_TIMEOUT - WDT_MARGIN) * 100; + + /* If we are inside of skiboot we need to periodically restart the + * timer. Reschedule a reset so it happens before the timeout. */ + if (wdt_ticking) + schedule_timer(&wdt_timer, msecs_to_tb(reset_delay_ms)); + + ipmi_free_msg(msg); +} + static struct ipmi_msg *wdt_reset_mkmsg(void) { struct ipmi_msg *ipmi_msg; ipmi_msg = ipmi_mkmsg(IPMI_DEFAULT_INTERFACE, IPMI_RESET_WDT, - ipmi_wdt_complete, NULL, NULL, 0, 0); + reset_wdt_complete, NULL, NULL, 0, 0); if (!ipmi_msg) { prerror("Unable to allocate reset wdt message\n"); return NULL;