From patchwork Fri Jun 18 19:50:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grzegorz Jaszczyk X-Patchwork-Id: 463093 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp183638jao; Fri, 18 Jun 2021 12:51:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy+8VQohSLuyk+IBs/jOzrrxwu8zwbGWolfo2TF0MfmPswJUmpXsWDYbZbus1LI/Ohh8cP9 X-Received: by 2002:a05:6602:2bfa:: with SMTP id d26mr9332864ioy.13.1624045876087; Fri, 18 Jun 2021 12:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045876; cv=none; d=google.com; s=arc-20160816; b=MMo0xYZh6DccaNhEfOPF/ErHGBMkqCUU5oC+bDJ7jdQcSgbDKT6aifoq+3EqHSrTlm B6+ptUeutuFgpVhZ/dNtpG6JGvDntXABxGTpJ2APUsNeDrekEamAYM82jNXu2mIYvI5O hIIQGxslftNi1fBsrNjj7vZI7ohrt34Qv32rxJ4m0m1wivU8fZPMcL1GkM8o8a2J8gGe IWazXe5ejCEJS8Vip8SELTspd5xGjeaY9iS4ArZlHEWSSfvIDC5ED8YiDyvh494iW4uo +M5fUUiOzU48jNNhDUNxmL+hA7kYQsdWiQTzkvIvF/8nCt8Ie+ZEfwSTD3so+8+wx1QN XB2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=SXSfZ0yjSVsxn5eRKp0etGkWpRG1f0QQ/H1nKyqZJz0=; b=oQGKLWPfuoG8RCtpmP/CNBD4TuFmchUgOmOXCqPUiN2azq6iDtR4jIX3l5NBtc/PvE 3g61yvqKh5VgixaSiFMHdHlWTslsWM7BRk56YzTgf9dSLzRZ4v3AXiTj8BzwEKU1TKyu ILlxiuFD/7GxpqBTVEhk9rx3nIWxYRPUv3WKYpNJRbJRonKjmgt4XigkR3ZbMjf4p3mF NiJLMl6zsUaQaj5Wdb8hKMGknRkAEx03QSOvqBw+2fs4CPAVYwIIY5qdKZAIVn5Kg/Ko a3K0mKaWz0THnUVHSP9VPD9giNtT0p9X0o++hGOs/tDDsrtMYVFUhKVXvQ7cWZt85x42 T0Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CwQItVsd; spf=pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si11976117jad.12.2021.06.18.12.51.16 for ; Fri, 18 Jun 2021 12:51:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=CwQItVsd; spf=pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232806AbhFRTxQ (ORCPT ); Fri, 18 Jun 2021 15:53:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233070AbhFRTxP (ORCPT ); Fri, 18 Jun 2021 15:53:15 -0400 Received: from mail-lj1-x235.google.com (mail-lj1-x235.google.com [IPv6:2a00:1450:4864:20::235]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 18A0BC061767 for ; Fri, 18 Jun 2021 12:51:04 -0700 (PDT) Received: by mail-lj1-x235.google.com with SMTP id d2so15516571ljj.11 for ; Fri, 18 Jun 2021 12:51:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SXSfZ0yjSVsxn5eRKp0etGkWpRG1f0QQ/H1nKyqZJz0=; b=CwQItVsdahafPhOTHmMogTMFf7+NUnLo1por+XzOBH/LH0csLGG5782/VVxCMS+ZHn MVMn8q6c+ZxVFsAPoL79OcryTkDl2JxtN50vWi45WEOMoqBGmtPPf9WnvE44cLnJze39 fFpdJWInV1Pkg38VNiDtbgglrLjG8oSM05cfKnu9Ds3FsIirSDw9wBG+zdwD4jDUNt4w er3G7lT33crWuODMlC+nFZoGSWcL7rnKEPivBJHUe3xXgNjsZzLSm2xsZ3wPdY0G1MQA A6td3CvITLFPUn7X0jaa5Qp8+C1tvagVU3piXhF18FivnZOif+LE4zKWirdlC+IMCDIk VVPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SXSfZ0yjSVsxn5eRKp0etGkWpRG1f0QQ/H1nKyqZJz0=; b=Xm4m8Rv0AcwI/EC/knDYFTNkYMzMURB4wZgaeDhoCehcNPx6zb6vbFHJgqDqm7tce/ PSg+Ffjn1shig2mxZKwKLU79p1ucJWg84u6/YJabbYceyFZP6kHETpxYac7kGf5DWxb7 SpwGnH+jlpnb/GPfPwoYin4rY+o9tFu9PYibMZpYtADYxl1WorMpvpnCERIF4gjnYBVh mdbeLJ3Kh3CGqzuI8/mYT3VyzDuy9XLXhQepDJmtuHby2/gM4Nw3ybl72gOcE3rMeIYE ObWXLdOzP8TRNubzuGPB/dfNXtr57ZEB9Bz2W43VVIeFNljp/dHIxohMoZE1u/2obXGB PtMg== X-Gm-Message-State: AOAM533mhuHE0NSA/7J94tXdesmhjcfpbCkEKTiG/kE18Sqw7d2obWha F/n2fCczrS3wqe0reIx0cIk4Pg== X-Received: by 2002:a2e:5850:: with SMTP id x16mr10813908ljd.231.1624045863309; Fri, 18 Jun 2021 12:51:03 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id o7sm993221lfu.215.2021.06.18.12.51.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:51:02 -0700 (PDT) From: Grzegorz Jaszczyk To: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org Cc: linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, grzegorz.jaszczyk@linaro.org Subject: [PATCH v2 1/2] watchdog: introduce watchdog_dev_suspend/resume Date: Fri, 18 Jun 2021 21:50:32 +0200 Message-Id: <20210618195033.3209598-2-grzegorz.jaszczyk@linaro.org> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210618195033.3209598-1-grzegorz.jaszczyk@linaro.org> References: <20210618195033.3209598-1-grzegorz.jaszczyk@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org The watchdog drivers often disable wdog clock during suspend and then enable it again during resume. Nevertheless the ping worker is still running and can issue low-level ping while the wdog clock is disabled causing the system hang. To prevent such condition register pm notifier in the watchdog core which will call watchdog_dev_suspend/resume and actually cancel ping worker during suspend and restore it back, if needed, during resume. Signed-off-by: Grzegorz Jaszczyk --- v1->v2: - Instead of using watchdog_dev_suspend/resume directly in wdog drivers suspend/resume callbacks, register pm notifier in the watchdog core when new WDOG_NO_PING_ON_SUSPEND status flag is set by the driver. Suggested by Guenter Roeck . - Initialize ret variable in watchdog_dev_suspend/resume. - Drop EXPORT_SYMBOL_GPL for watchdog_dev_suspend/resume since from now one they are used only by the watchdog core and not by the drivers. - Commit log was updated accordingly. --- drivers/watchdog/watchdog_core.c | 37 +++++++++++++++++++++++++ drivers/watchdog/watchdog_dev.c | 47 ++++++++++++++++++++++++++++++++ include/linux/watchdog.h | 10 +++++++ 3 files changed, 94 insertions(+) -- 2.29.0 Reviewed-by: Guenter Roeck diff --git a/drivers/watchdog/watchdog_core.c b/drivers/watchdog/watchdog_core.c index 5df0a22e2cb4..3fe8a7edc252 100644 --- a/drivers/watchdog/watchdog_core.c +++ b/drivers/watchdog/watchdog_core.c @@ -34,6 +34,7 @@ #include /* For ida_* macros */ #include /* For IS_ERR macros */ #include /* For of_get_timeout_sec */ +#include #include "watchdog_core.h" /* For watchdog_dev_register/... */ @@ -185,6 +186,33 @@ static int watchdog_restart_notifier(struct notifier_block *nb, return NOTIFY_DONE; } +static int watchdog_pm_notifier(struct notifier_block *nb, unsigned long mode, + void *data) +{ + struct watchdog_device *wdd; + int ret = 0; + + wdd = container_of(nb, struct watchdog_device, pm_nb); + + switch (mode) { + case PM_HIBERNATION_PREPARE: + case PM_RESTORE_PREPARE: + case PM_SUSPEND_PREPARE: + ret = watchdog_dev_suspend(wdd); + break; + case PM_POST_HIBERNATION: + case PM_POST_RESTORE: + case PM_POST_SUSPEND: + ret = watchdog_dev_resume(wdd); + break; + } + + if (ret) + return NOTIFY_BAD; + + return NOTIFY_DONE; +} + /** * watchdog_set_restart_priority - Change priority of restart handler * @wdd: watchdog device @@ -292,6 +320,15 @@ static int __watchdog_register_device(struct watchdog_device *wdd) wdd->id, ret); } + if (test_bit(WDOG_NO_PING_ON_SUSPEND, &wdd->status)) { + wdd->pm_nb.notifier_call = watchdog_pm_notifier; + + ret = register_pm_notifier(&wdd->pm_nb); + if (ret) + pr_warn("watchdog%d: Cannot register pm handler (%d)\n", + wdd->id, ret); + } + return 0; } diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c index 2946f3a63110..9d1c340a3024 100644 --- a/drivers/watchdog/watchdog_dev.c +++ b/drivers/watchdog/watchdog_dev.c @@ -1219,6 +1219,53 @@ void __exit watchdog_dev_exit(void) kthread_destroy_worker(watchdog_kworker); } +int watchdog_dev_suspend(struct watchdog_device *wdd) +{ + struct watchdog_core_data *wd_data = wdd->wd_data; + int ret = 0; + + if (!wdd->wd_data) + return -ENODEV; + + /* ping for the last time before suspend */ + mutex_lock(&wd_data->lock); + if (watchdog_worker_should_ping(wd_data)) + ret = __watchdog_ping(wd_data->wdd); + mutex_unlock(&wd_data->lock); + + if (ret) + return ret; + + /* + * make sure that watchdog worker will not kick in when the wdog is + * suspended + */ + hrtimer_cancel(&wd_data->timer); + kthread_cancel_work_sync(&wd_data->work); + + return 0; +} + +int watchdog_dev_resume(struct watchdog_device *wdd) +{ + struct watchdog_core_data *wd_data = wdd->wd_data; + int ret = 0; + + if (!wdd->wd_data) + return -ENODEV; + + /* + * __watchdog_ping will also retrigger hrtimer and therefore restore the + * ping worker if needed. + */ + mutex_lock(&wd_data->lock); + if (watchdog_worker_should_ping(wd_data)) + ret = __watchdog_ping(wd_data->wdd); + mutex_unlock(&wd_data->lock); + + return ret; +} + module_param(handle_boot_enabled, bool, 0444); MODULE_PARM_DESC(handle_boot_enabled, "Watchdog core auto-updates boot enabled watchdogs before userspace takes over (default=" diff --git a/include/linux/watchdog.h b/include/linux/watchdog.h index 9b19e6bb68b5..99660197a36c 100644 --- a/include/linux/watchdog.h +++ b/include/linux/watchdog.h @@ -107,6 +107,7 @@ struct watchdog_device { unsigned int max_hw_heartbeat_ms; struct notifier_block reboot_nb; struct notifier_block restart_nb; + struct notifier_block pm_nb; void *driver_data; struct watchdog_core_data *wd_data; unsigned long status; @@ -116,6 +117,7 @@ struct watchdog_device { #define WDOG_STOP_ON_REBOOT 2 /* Should be stopped on reboot */ #define WDOG_HW_RUNNING 3 /* True if HW watchdog running */ #define WDOG_STOP_ON_UNREGISTER 4 /* Should be stopped on unregister */ +#define WDOG_NO_PING_ON_SUSPEND 5 /* Ping worker should be stopped on suspend */ struct list_head deferred; }; @@ -156,6 +158,12 @@ static inline void watchdog_stop_on_unregister(struct watchdog_device *wdd) set_bit(WDOG_STOP_ON_UNREGISTER, &wdd->status); } +/* Use the following function to stop the wdog ping worker when suspending */ +static inline void watchdog_stop_ping_on_suspend(struct watchdog_device *wdd) +{ + set_bit(WDOG_NO_PING_ON_SUSPEND, &wdd->status); +} + /* Use the following function to check if a timeout value is invalid */ static inline bool watchdog_timeout_invalid(struct watchdog_device *wdd, unsigned int t) { @@ -209,6 +217,8 @@ extern int watchdog_init_timeout(struct watchdog_device *wdd, unsigned int timeout_parm, struct device *dev); extern int watchdog_register_device(struct watchdog_device *); extern void watchdog_unregister_device(struct watchdog_device *); +int watchdog_dev_suspend(struct watchdog_device *wdd); +int watchdog_dev_resume(struct watchdog_device *wdd); int watchdog_set_last_hw_keepalive(struct watchdog_device *, unsigned int); From patchwork Fri Jun 18 19:50:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grzegorz Jaszczyk X-Patchwork-Id: 463094 Delivered-To: patch@linaro.org Received: by 2002:a05:6638:102:0:0:0:0 with SMTP id x2csp183643jao; Fri, 18 Jun 2021 12:51:16 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwfFkye2AYCsm3W836Ar1tOjCqjRB0KR2tntBRXo4+6rb0MNVeUFXzEE2aKs5Wpfl8KpLye X-Received: by 2002:a05:6602:1616:: with SMTP id x22mr9338513iow.173.1624045876601; Fri, 18 Jun 2021 12:51:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624045876; cv=none; d=google.com; s=arc-20160816; b=XGeLFQbeuQVv4Zq0UVxgoF7o5S1YbM2bf4h5KbfaHtg61ZSrcsMZJmEAORdNIqPy30 +vQkpk0t5C7RLAAw6ClTHheSkPbfLTK33VxgV1HVXhI97rpjdnzfDfMu5V9/AegFJDwG Yr1GSLQXmdx3KOKGIko4ejll2NmYHv/b/LYQMlmzT1AkM//OgLRPLPCqU/M8fWI9zi3J 9pwN4i09G37Aj4ultfEN9iTQIN1yPO79Nqn+AdHYc7Y3YaxSxExIgsENceng5wDQmdZS CNBU9gxoHC9ZhtgtJJpNpawcHW94VqVoDmCU/dAZAI4DHbPtyu4VzpSNBmk44PN9mJYK /EUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=xMVSNrHGcdt1vbOgCt0p2SZ9LSnvDYsg9SnZkED+C08=; b=mjy1w3GIvvIgCwZttSV5tEVPaUvFwlWmUS7jhKZGUQG9kxwldSZkCD5MIRgYuUihnz 6q/xmnHD300MxfSkUJLKxBL7U2NQ9kIb8w9w6+9IaX27UhL29OdlBg46QYgym1rRKljd xBUxLQb7b9tgaHxGDDgRJnaOxCfRxmGGvR2Ghwpj2rsaCkgJGXLoLSzaGiU7svFtqfC/ hoqPOA2uK3FNQ+j77kfIjCeuroQ2ud4wLBzvBkU0s7K/BamHM3V9OnFki7BjTOagsyJO GYvV61xpB9UClAd2tRcF1g2iAZ3692VFIKgNbEy7IK05nJ8d/++BqabSEQxrEnxoaUb9 wkZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OI+p8vNS; spf=pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y3si11976117jad.12.2021.06.18.12.51.16 for ; Fri, 18 Jun 2021 12:51:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OI+p8vNS; spf=pass (google.com: domain of linux-watchdog-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-watchdog-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233494AbhFRTxU (ORCPT ); Fri, 18 Jun 2021 15:53:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233003AbhFRTxT (ORCPT ); Fri, 18 Jun 2021 15:53:19 -0400 Received: from mail-lf1-x12d.google.com (mail-lf1-x12d.google.com [IPv6:2a00:1450:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99556C061574 for ; Fri, 18 Jun 2021 12:51:08 -0700 (PDT) Received: by mail-lf1-x12d.google.com with SMTP id q20so18495777lfo.2 for ; Fri, 18 Jun 2021 12:51:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xMVSNrHGcdt1vbOgCt0p2SZ9LSnvDYsg9SnZkED+C08=; b=OI+p8vNSYtg5dOKoFneDPR48HNRCn5+KtmQCC1iEiqeAkn90I7DNnoQ+1FM+nplYfP 3G8Bcf6gj2Veo22h9O+8GD5/NmlqM8wVuLUEXuYSQW2TiFmCI9geu61KyyJITWbw4dD5 RwtGyFY+nmPaVQBF6pZuo1fQ5EWDOIUpdiyQjvXGWoHvzaqaB4tHqISE3lOa0p8JVH16 aKRi/LfxMyvI08TLkYOS1nt2K6i8a6wCsffNAMk+B9/AG43n4M7EhkqVyFlW4QlHAsA+ CEvkfsnwzQ7BtnmuP9WaFc5g9E2fRp9jQnDGC/Ik0UMdQ36Z4YnZa6uPHeMXDgmvtEFc DvGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xMVSNrHGcdt1vbOgCt0p2SZ9LSnvDYsg9SnZkED+C08=; b=eF0pUrK9yg0YM9shrE1OLe7W+OvFB0UU9jer9IySRtLNGzyqBwFH61qNYocMgZ4ivR rD5Gc6ohnHoZoGTfzqVdm44Lsg7D/t4M7pP/IWueU6Yw+tFP/9SJRi5ee+Et827uWpcN aqQgoXPb6GRykiFtyYOClwqntye/2y3IzgJMBPXX+nYaNCc8re9NArAtzcdZQC/+6IPR qEjOsVdU5UKKD6gwdCEgNMeXLFSMtMtXB/k11e1YFeIzUD9lFAWpzVlYzqeC88qSxVnK 0zpMX34mBog2IRIgGTf19EcozzLRAICtBzBg47Why9ITPNNZB8vBjQ4I7vO5hgyA5kWU JhSw== X-Gm-Message-State: AOAM532zWDBmlFCAJRiucUo0y8RSHk6O1o4Q3a/ghs16/v7mX+n/5mXV dafgqDc7zkeCwsX1Q1Q2azzc4Q== X-Received: by 2002:a19:24c3:: with SMTP id k186mr4452699lfk.472.1624045867006; Fri, 18 Jun 2021 12:51:07 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id o7sm993221lfu.215.2021.06.18.12.51.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Jun 2021 12:51:06 -0700 (PDT) From: Grzegorz Jaszczyk To: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org Cc: linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, grzegorz.jaszczyk@linaro.org, Michal Koziel Subject: [PATCH v2 2/2] watchdog: imx2_wdg: notify wdog core to stop ping worker on suspend Date: Fri, 18 Jun 2021 21:50:33 +0200 Message-Id: <20210618195033.3209598-3-grzegorz.jaszczyk@linaro.org> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210618195033.3209598-1-grzegorz.jaszczyk@linaro.org> References: <20210618195033.3209598-1-grzegorz.jaszczyk@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org Suspend routine disables wdog clk. Nevertheless, the watchdog subsystem is not aware of that and can still try to ping wdog through watchdog_ping_work. In order to prevent such condition and therefore prevent from system hang (caused by the wdog register access issued while the wdog clock is disabled) notify watchdog core that the ping worker should be canceled during watchdog core suspend and restored during resume. Signed-off-by: Michal Koziel Signed-off-by: Grzegorz Jaszczyk --- v1->v2: - Do not use watchdog_dev_suspend/resume directly, instead notify the watchdog core that the ping worker should be canceled during watchdog core suspend and restored during resume. - Commit log was updated accordingly. --- drivers/watchdog/imx2_wdt.c | 1 + 1 file changed, 1 insertion(+) -- 2.29.0 Reviewed-by: Guenter Roeck diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index b84f80f7d342..3e8d9c3b6386 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -311,6 +311,7 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) watchdog_set_nowayout(wdog, nowayout); watchdog_set_restart_priority(wdog, 128); watchdog_init_timeout(wdog, timeout, dev); + watchdog_stop_ping_on_suspend(wdog); if (imx2_wdt_is_running(wdev)) { imx2_wdt_set_timeout(wdog, wdog->timeout);