From patchwork Tue Dec 28 07:34:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Palmer X-Patchwork-Id: 12700224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2EDB5C433F5 for ; Tue, 28 Dec 2021 07:36:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=RQIXS1+kGb2lhxLoN5KHCOzceckqy7Q4xW36eg00Nq4=; b=xaE9UzVbrqc9T7 KJwn67JnKuNZ9tz7gDRlo3hmwHrPmw5rIVwnaH26L3sxtJQs2X09uKFOgSFSASE27qYK05qoa4X6c Ck0NHQbY+FI8vEoEi3q/pP+1kCsOu79HlRNfCOQS+FUYFJNDJJdK5llBOgJdzOapBtsjHhq9244pt 3do3zgHnevlf1NHco0n0cEZgWAdX59q2OSqVcxWl52lVUsQOSTp7lyKx44okhE7pxgLIUxDWawDlU Lt0PBGnONGSyGEPVZWWiTUxm9DEhT5t0qDcMc9SGWe0vu86Ix4TDeA7OZWXRHr2jweoE/cjvAfr92 gu31mngk8DteLkjsgu3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n270Q-000MuI-Ji; Tue, 28 Dec 2021 07:34:46 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n270N-000Mtd-PG for linux-arm-kernel@lists.infradead.org; Tue, 28 Dec 2021 07:34:45 +0000 Received: by mail-pl1-x632.google.com with SMTP id l16so915726plg.10 for ; Mon, 27 Dec 2021 23:34:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=0x0f.com; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XZGp/Og2JLoiZTQ5Xn+2ac/mEmvxQdHSb67vZpgQZio=; b=o0M/DxGSAmV168C/Rgzb09FN2MZLLukkNzNod1UEouN7p4ljaHU5A/JqfX3DB0mKdf 3dKa/YzH+I2iSbxt8wxJfMWUCTOJanwdpXny7tRITn9lAGOoeQK7Af5GpzrVW1Uz5vtx 0oBDPAZjius+FqOyi1LLsK6BeHAtFQtiO2LLw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XZGp/Og2JLoiZTQ5Xn+2ac/mEmvxQdHSb67vZpgQZio=; b=N/35CEwAkfljeS6mJkncoPPI6PBA+ew5UKeM7Rt6Z/Xm4lnYh8uuBIryY7UhNqnv53 9Gl41a5ndIP3Nr0vq20hplexVpuHZ+Iv3KHurhOsSHqDsXPkjA+ZOgj6NNA4BoLAcZDo lxnWpy/TnsrBYbT3Oe/R95zDHmNeH0TE34QnB+AafS1MJ07aroSQ2W/cyRCVSZP10yFm 39g+TlDbsc2pCSeaWOJ2eQ0I/NqRxOlGoI3BZiIA7XTAd/p9gAXBXXVCBkbFIi+evEuT 2xbke0UGmRh6HhnuiFBmtsMsuIy7aVmIwLvjO/f5D+RTz9ZBs5aMsLeD1gb30uTJPJ91 sMwg== X-Gm-Message-State: AOAM533lfwdWDIJnZA4zy4UQKYuifvGcEyshQC1eVRrAOvXGnoH1Lzex Rxs1aSAYqpz6lUME5IxHQdsciQ== X-Google-Smtp-Source: ABdhPJz4MxcVRMaSHMqNCp6hhFY00f3woceMBYR/uguD+RLCfRBu3O5zxtWG6tkbHglFC7Mqzd1KVg== X-Received: by 2002:a17:902:820f:b0:149:8d21:3e42 with SMTP id x15-20020a170902820f00b001498d213e42mr3723552pln.111.1640676881774; Mon, 27 Dec 2021 23:34:41 -0800 (PST) Received: from shiro.work ([2400:4162:2428:2f01:7285:c2ff:fe8e:66d7]) by smtp.googlemail.com with ESMTPSA id ke3sm22363800pjb.46.2021.12.27.23.34.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Dec 2021 23:34:41 -0800 (PST) From: Daniel Palmer To: wim@linux-watchdog.org, linux@roeck-us.net, linux-watchdog@vger.kernel.org Cc: romain.perier@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Palmer Subject: [PATCH] watchdog: msc313e: Check if the WDT was running at boot Date: Tue, 28 Dec 2021 16:34:27 +0900 Message-Id: <20211228073427.2443174-1-daniel@0x0f.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211227_233443_990437_7AC72219 X-CRM114-Status: GOOD ( 12.19 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Check if the WDT was running at boot and set the running flag if it was. This prevents the system from getting rebooted if the userland daemon doesn't take over soon enough or there isn't a userland daemon at all. Signed-off-by: Daniel Palmer Reviewed-by: Guenter Roeck --- drivers/watchdog/msc313e_wdt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/watchdog/msc313e_wdt.c b/drivers/watchdog/msc313e_wdt.c index 0d497aa0fb7d..90171431fc59 100644 --- a/drivers/watchdog/msc313e_wdt.c +++ b/drivers/watchdog/msc313e_wdt.c @@ -120,6 +120,10 @@ static int msc313e_wdt_probe(struct platform_device *pdev) priv->wdev.max_timeout = U32_MAX / clk_get_rate(priv->clk); priv->wdev.timeout = MSC313E_WDT_DEFAULT_TIMEOUT; + /* If the period is non-zero the WDT is running */ + if (readw(priv->base + REG_WDT_MAX_PRD_L) | (readw(priv->base + REG_WDT_MAX_PRD_H) << 16)) + set_bit(WDOG_HW_RUNNING, &priv->wdev.status); + watchdog_set_drvdata(&priv->wdev, priv); watchdog_init_timeout(&priv->wdev, timeout, dev);