From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 09AA5C48BE5 for ; Tue, 15 Jun 2021 16:51:47 +0000 (UTC) Received: from bombadil.infradead.org (unknown [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CC75860E0B for ; Tue, 15 Jun 2021 16:51:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CC75860E0B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=B5SbAJHic2c2aF8pqnVnMb+TSYAfgql0/wZUxUHDkWc=; b=2dUxZ2qhYPzMwF DlabuqTOHywttP0fZ/D44J5SAVqs/ipaLBXck4cNj9RpDVDypn1EeI9CK9fvcjU552a+/HEV0izsI kZqhEsftTpZzYd7MJTUJ64xe3aXoqqZcpIbnh6TsaUHiQnqyUGNVsnJOPTPqJJHLltKnT7yGYzlj5 HXVxalfvO4VMzssOymw1t9gKrw4bCgLN5caswMJ0KrljmWDzLx6HjpQOmdvYk6rEzMoY51fEE02ck YahMya05KBVmhmtjRCbpnpkvPm10nMpQ0x8//FywYY1F3Encb23BN/f9AlAne8MjIZPTThigeD2Bf JiozIqIetiS7f0AjoVRw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltCAI-001SAT-FS; Tue, 15 Jun 2021 16:43:51 +0000 Received: from mail-ot1-x336.google.com ([2607:f8b0:4864:20::336]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt9tJ-000WoY-Df for linux-arm-kernel@lists.infradead.org; Tue, 15 Jun 2021 14:18:11 +0000 Received: by mail-ot1-x336.google.com with SMTP id w22-20020a0568304116b02904060c6415c7so12095170ott.1 for ; Tue, 15 Jun 2021 07:18:07 -0700 (PDT) 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; bh=sJVfISVEAo4JYp+mcOTwuzwAUOscDkKkqgdru4mktaY=; b=HjhRmve41RdRloXtoYvcLwqjuYzgi4Yboi50lCsiqhUQTQDjht85QI9vAXsnukJmsx 1UOrC5gtyUS0hceJZpKkCezdgZRa8/R/uIoyAzdrYUrdsyuKywltgztqGJ5mv95NDp29 QKnWAs6SJe3EppFAZBqBvwMTeBBV8GjDzWe9RS57/nHmN1WoFeTHOxefD+KOIeowflIa wgQHJMZC6mCJ54poL+zPlrk07WC6TJUXTKKerV1xDO5NXdeDax5qhWsBhy+/fWyb7Cpo QA87Wjx5ydjQ0TKDpZQ4LtzcjPVpiXEJSsIz+q1buJm4cumkEa4sM8Kq4RmuCjYsBqUV pxmQ== 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; bh=sJVfISVEAo4JYp+mcOTwuzwAUOscDkKkqgdru4mktaY=; b=uZ4pXNlArJZqyX7L3YUc4Qo+1Qg3zudx8jMXXu3WMuGm6e8yVmTbwfH5m8BqtJeNRE 460jG6pzlxIhF5uLWFBppgKr56sxLWPZEiPmaBVj2hoeKdw2XYzDba5XeOZ8MfkvCRWj NQB3FNLlQYEwEozSKH/aeiGLp+C+D/kEXxw4AYA7cUwEv6Qy4xfQRNVKMIos9XAAA3Fn HiIE9jMUvqDfIlTvEt4pGjD5gIh3gAZ+dF13n/kouMNQfFMDGzRguX4lMOjR68/aXJU/ 6C+gvYL3ZF4erVqvVRA0NdSfl3VNH/w/me7Lw5V1xr/hvLngRi2BrXmY2JfMUGYPc2P4 YRCg== X-Gm-Message-State: AOAM533eYsukUwd20SEiqZ36YF0QzP5nwvh0roeq/NfSDc1STUULtYH+ kSB53dx1DLdLRf55OERYy6I= X-Google-Smtp-Source: ABdhPJyV6/rdIISBgV1gWqBC4JaEtdD6175LeHdH2N10Ka1X3gdTMThBddSgxnWhoidVX7ln6SfktA== X-Received: by 2002:a9d:4c0a:: with SMTP id l10mr18907559otf.363.1623766687345; Tue, 15 Jun 2021 07:18:07 -0700 (PDT) Received: from localhost ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id u42sm3449201oiw.50.2021.06.15.07.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 07:18:06 -0700 (PDT) Date: Tue, 15 Jun 2021 07:18:03 -0700 From: Guenter Roeck To: Grzegorz Jaszczyk Cc: wim@linux-watchdog.org, shawnguo@kernel.org, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] watchdog: introduce watchdog_dev_suspend/resume Message-ID: <20210615141803.GA957871@roeck-us.net> References: <20210615123904.2568052-1-grzegorz.jaszczyk@linaro.org> <20210615123904.2568052-2-grzegorz.jaszczyk@linaro.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20210615123904.2568052-2-grzegorz.jaszczyk@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210615_071809_527283_1761CDDE X-CRM114-Status: GOOD ( 27.11 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Jun 15, 2021 at 02:39:03PM +0200, Grzegorz Jaszczyk wrote: > 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 introduce > watchdog_dev_suspend/resume which can be used by any wdog driver and > actually cancel ping worker during suspend and restore it back, if > needed, during resume. > I'll have to look into this further, but I don't think this is the correct solution. Most likely the watchdog core needs to have its own independent suspend/resule functions and suspend the high resolution timer on suspend and restore it on resume. This may require an additional flag to be set by drivers to indicate that the timer should be stopped on suspend. > Signed-off-by: Grzegorz Jaszczyk > --- > drivers/watchdog/watchdog_dev.c | 49 +++++++++++++++++++++++++++++++++ > include/linux/watchdog.h | 2 ++ > 2 files changed, 51 insertions(+) > > diff --git a/drivers/watchdog/watchdog_dev.c b/drivers/watchdog/watchdog_dev.c > index 2946f3a63110..3feca1567281 100644 > --- a/drivers/watchdog/watchdog_dev.c > +++ b/drivers/watchdog/watchdog_dev.c > @@ -1219,6 +1219,55 @@ 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; > + > + 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; > +} > +EXPORT_SYMBOL_GPL(watchdog_dev_suspend); > + > +int watchdog_dev_resume(struct watchdog_device *wdd) > +{ > + struct watchdog_core_data *wd_data = wdd->wd_data; > + int ret; > + > + 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; > +} > +EXPORT_SYMBOL_GPL(watchdog_dev_resume); > + > 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..febfde3b1ff6 100644 > --- a/include/linux/watchdog.h > +++ b/include/linux/watchdog.h > @@ -209,6 +209,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); > > -- > 2.29.0 > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel