From patchwork Tue Jun 15 12:39:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grzegorz Jaszczyk X-Patchwork-Id: 12322531 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=-16.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,USER_AGENT_GIT 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 97377C48BE5 for ; Tue, 15 Jun 2021 17:36:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 5ED04613E4 for ; Tue, 15 Jun 2021 17:36:14 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5ED04613E4 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=iyQZfUkY6khRCIVQdW4CIvJ13+em8oczSjROhTcOI0k=; b=kqfI8r/nTVugyD K4WcEa3lk+yo+0KRGWKctXGGhgxtxC/ADipmu+yvQ+bQtgD7XWiJSq3F0gkKFu0OYESaU42/q23vd gy4rV50Tj0PcBT9CEBNg9ZzuohsKwXkcYcgCmopl+UNw7xkWNPOy8RGJ/thBDFg2cayQNwPkjEtXx 1XXIv/i+Mi2LJduTi3HgjnqnQEh2atHWL6Z26QzUROw+lBK7oLV/hLGjlxUmkhfw+D1RV3Hf9ytcq ARU3/UleIzpYL0cYXxsRTA3jLNnr4/P2sVTMD6KXTwAiZA36OeqUlJMWoclJtJih26jotOh5mcym6 DQT6U+JPguc3ytbr9s8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltCwN-001lcG-Qs; Tue, 15 Jun 2021 17:33:32 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt9DM-000ByJ-D6 for linux-arm-kernel@bombadil.infradead.org; Tue, 15 Jun 2021 13:34:48 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=3pEsLcQ/8PBueEyiqA/kBMEdoALnX+fHc+Skgy5Wse4=; b=dg53XdoO1HeDdPWc+Vaxg0sIyN 5Vi4YRyfW4KZR9exfyGBSnJ6sbtL/U5C3P5WBqtiFtd09RuSk7HqCTpA9OY7FA9a2VFG+GBlI8Q0+ cPeLUox1LzRH52BEF4YOxB6nftSHEu9NT4Sjv5/7Mw3ahtnT1lOPsJFWjxp4aoSEDpF1kldR5QRHa CMm9c5LjhsZQs2Ydsyp5+ALRJYC4NMuA6poRbWwY9c7eg0LctJlPxOR4+NRxTPVMr0Ek0uMrayeKE mzqX4KMZaDksbQXGdLpnYHcTau7QwBIGaXEhG6EZTLz/5sNXYO839VztCMuUumygD1i8mY1gxTzJJ IqCywPXA==; Received: from mail-lj1-x233.google.com ([2a00:1450:4864:20::233]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt8LV-007t3A-Re for linux-arm-kernel@lists.infradead.org; Tue, 15 Jun 2021 12:39:20 +0000 Received: by mail-lj1-x233.google.com with SMTP id d13so12662420ljg.12 for ; Tue, 15 Jun 2021 05:39:15 -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=3pEsLcQ/8PBueEyiqA/kBMEdoALnX+fHc+Skgy5Wse4=; b=Lo9MxugjizgQOg5AcVDyMzvLOktI70lW6BqlHYqn00ELIrDqv7V6Ov0lEQBnp5sUVD MEPCbDZuIh8/nel5c0auOPPLNOU1H5uIjDc5vhxFBss4iCdhMUGN4yXFTkQTjBA5tCqL QSweT1vPd5k3r6/wIVz2sAPIKrLLhjUZoy0MdVzBIqa6GfCi7DXrgMbCvsglVKzATE/v U2ntj3TKpDWL/fdjmifyV7fEFa9yXls5YSBx9Z7CfljNUaX8KAokcCIBmkJWHmifwOxZ Zo5LCFEfPs+mr2AHHq8fv1wP4akbn6uuxYtycGEU+5Q2vfV0FpH0JafAhiXQ/edCTEyb YM3g== 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=3pEsLcQ/8PBueEyiqA/kBMEdoALnX+fHc+Skgy5Wse4=; b=sL7dyrUYr0JvS1rFv3oiPfT6bBI7CSmFYbdHXRYovAx42jby27qgnwyN7qUSHSrrZc PI+bJttpndSm8DBFThFcPSe96ZU3dTrKajZ+toV931nS6WhDtm0McnV+Razz801yUSRi kfKGDDexzHRarBLSprVbvwalT1aZTMm/K5S0bwWYDboV6oQrK7rVysXp3VMXUINZHOEM 11ctN3GfCZ2Bh8RX8Bj9DDg9ep8pObBT+mPM+cDeloDZ3QDt7uTeVxoyRZ9LepowZCe7 LWyvMEdE5IkjFGggV6E4Tftzp6dil0iHkpD7wM7g3TtfJ6iP+04cinwJkMecYaog7CEF o6ww== X-Gm-Message-State: AOAM532z0MfgDb6/TPKoMbU3SuqffqblxGaZdnLoCthsfPYdrxkAUDmC LNfDS0pQxR3DjCvfWaRZ9KiOFw== X-Google-Smtp-Source: ABdhPJwRsf+yNOWqXkRPrg7C6+J4ziUSxP9L+WvAbfpgF/03zjoPDhYxMZParIYV9z2a3UBO/FrilQ== X-Received: by 2002:a2e:6c0e:: with SMTP id h14mr17848984ljc.267.1623760752547; Tue, 15 Jun 2021 05:39:12 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id m12sm811418lfb.231.2021.06.15.05.39.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 05:39:12 -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 1/2] watchdog: introduce watchdog_dev_suspend/resume Date: Tue, 15 Jun 2021 14:39:03 +0200 Message-Id: <20210615123904.2568052-2-grzegorz.jaszczyk@linaro.org> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210615123904.2568052-1-grzegorz.jaszczyk@linaro.org> References: <20210615123904.2568052-1-grzegorz.jaszczyk@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210615_133916_695672_3D733328 X-CRM114-Status: GOOD ( 15.23 ) 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 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. Signed-off-by: Grzegorz Jaszczyk Reported-by: kernel test robot --- 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); From patchwork Tue Jun 15 12:39:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Grzegorz Jaszczyk X-Patchwork-Id: 12322457 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=-16.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,USER_AGENT_GIT 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 1C035C48BDF for ; Tue, 15 Jun 2021 17:00:42 +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 DACA461626 for ; Tue, 15 Jun 2021 17:00:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org DACA461626 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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:MIME-Version:References:In-Reply-To: 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: List-Owner; bh=1SdZ7fBx5VRWnTann4wHJuvlN7ybEgeHXEJu6dmKPaw=; b=nm2UXXElyZWqYn I79UJRrPs/DJvbvQBjJTh/UYZt6ObxzRwFKeoTjxW6nlyOwX+xXMFOYdjW4IFLsg/hGj+wT1VlFgK ezAeElXU4eYRRe2Zt/plQeVsWJpqjqPiIKZG+G5BBKwyW6Td4iRlhxiruho5jeBOwP7IzMCLuVhUt nNTulwBndQ3qe4LQ2gxK97LoDuNySSKcCx9htcj/iSAq28XB97Z43UpQJrl7eTsoo+Vsq7HkJUz+4 D/o2O1Dl5O0k+DBZxn8WWO90fwXDnFiPv4q6piJrXcRFxbLAYbIJm83Oj+8Zrp2hxBzjBRThSRUTs MFoRo54vP7TLBZrPqciw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ltCJx-001W3z-Ea; Tue, 15 Jun 2021 16:53:51 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt9DN-000ByJ-3S for linux-arm-kernel@bombadil.infradead.org; Tue, 15 Jun 2021 13:34:49 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=pyZKI2E4xTT0UFZR/tw10S5XdRfz+byZmgoSg9CzmTo=; b=IGNMnBCpZBY1W9MqdzX3OScThl 8gFztn1QzxvqbgCXHIUjEanBHxzYi5JlQKel89RS3aD5vRLgX/3rCZ+n3I7nzjYgIuO6x8t7nZNYm g1Uf2I5H6v47hgo8plVWR0VDNwquw+T9tCS9PdCA9izzwsYAZsHdWGNCaDuI7JacC8MGMri7YVkG6 eoBPZOHl8w/j3pf+JJM9wBbnpD4GZfJlHutMYWCCFfxun6q9/PHq+Yys0xT8WDgcGWDGOUFslvAL2 MrdHDPn+2ZV80+zwp6eO31XTaQeyA2iUYVu5Cgz9Ly9yehbbNuJrbQtLi1eC0rDyNjbPraaNh9pJW 1SIabv5Q==; Received: from mail-lf1-x136.google.com ([2a00:1450:4864:20::136]) by desiato.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1lt8LV-007t38-Ka for linux-arm-kernel@lists.infradead.org; Tue, 15 Jun 2021 12:39:18 +0000 Received: by mail-lf1-x136.google.com with SMTP id p17so26755445lfc.6 for ; Tue, 15 Jun 2021 05:39:14 -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=pyZKI2E4xTT0UFZR/tw10S5XdRfz+byZmgoSg9CzmTo=; b=rIYK1gIKo3lAxjw+6EGBH8HFSTz0+g9e1u0LDG0pFGprGw/dR5tKmTnXiZVF/mu0vd FaIvQbVu7aPUysVyTt/PDXrWBB5al/txEClciVkBCvn1wy5JzYeA2qvIIKRKZl5FMk++ uwtt0d0sT3JKxIp63hf9AeAH5JhiXZUdB/UA3c3p1xlKKH4bW2e6BdPav0veoBYdrFUr rIzOqkvh8F1rYn6JB1DHFpZmoiHBOLPycUCqg6IM8leMWedzLCYb63Fz/ZxG97ged74T 30AEpzHKU2nuZ2bcGGEJ5zK1yAY5EmVPZsA7Nj2cjQ0jPlBC/KPAx7/+XGIohZY+bzVt 5NrA== 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=pyZKI2E4xTT0UFZR/tw10S5XdRfz+byZmgoSg9CzmTo=; b=CRNGn9XPEGMik+A3aTm7hHzyaYhuVl7r/54Wv5ZCTuBrCIQnDiGfY8yG/JstVYEs6k RbYE/0RrPS5IjkN3jZNC+YMZZPfdeNJTKD3tyJp+QiuAhDNyUaH2tSw8u+7r4Gyp079Z m3St+22NncPBoKsW7M8ls90Dc5wdxHAVIzIQKOkRkA1KmFSUrnwFX8PoTkCZDe/OY3xu ghtPwzZND8hg11C4IY1mMf9LhXCA2/dbCtllPz7CdP5JmqoIYWJD7vrYlyFI0fnvIEkY ez7+vVKb2z+uk3upVVrVOn3VVLIGkpV2l35q9S3XpmRfiAs6S9ZL+S0uNOZMHhMdAgwl +jQw== X-Gm-Message-State: AOAM532DwN9YXaxpjb7zouGRgQtcHRuxN8S9VX7bo6FuAunuQInpZYfN fle0BeOgrACpbTmtvITwnNTDEQ== X-Google-Smtp-Source: ABdhPJxD7qxtXON/8OSwQ7cI6lXNk91cBUpvej8MlVp9AQ7iz606MAkLBwiYkiiYtlGim4zS0KqTAA== X-Received: by 2002:a19:6a0b:: with SMTP id u11mr5558470lfu.269.1623760753465; Tue, 15 Jun 2021 05:39:13 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id m12sm811418lfb.231.2021.06.15.05.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Jun 2021 05:39:13 -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 2/2] watchdog: imx2_wdg: notify wdog subsystem about wdog suspend/resume Date: Tue, 15 Jun 2021 14:39:04 +0200 Message-Id: <20210615123904.2568052-3-grzegorz.jaszczyk@linaro.org> X-Mailer: git-send-email 2.29.0 In-Reply-To: <20210615123904.2568052-1-grzegorz.jaszczyk@linaro.org> References: <20210615123904.2568052-1-grzegorz.jaszczyk@linaro.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210615_133916_592225_7F6C3058 X-CRM114-Status: GOOD ( 16.78 ) 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 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) take advantage of watchdog_dev_suspend/resume routines which will take care of watchdog ping worker cancel and restore. Additionally remove hw ping from suspend/resume since it will be issued by watchdog_dev_suspend/resume routines. Signed-off-by: Michal Koziel Signed-off-by: Grzegorz Jaszczyk --- drivers/watchdog/imx2_wdt.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index b84f80f7d342..24e3a4d2b529 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -348,6 +348,17 @@ static int __maybe_unused imx2_wdt_suspend(struct device *dev) { struct watchdog_device *wdog = dev_get_drvdata(dev); struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); + int ret; + + /* + * Before disabling clk we need to notify wdog subsystem that HW wdog + * is being suspended. This e.g. prevents watchdog_ping_work to fire + * when the clk is disabled, which would result with system hang caused + * by wdog register access while wdog clock is disabled. + */ + ret = watchdog_dev_suspend(wdog); + if (ret) + return ret; /* The watchdog IP block is running */ if (imx2_wdt_is_running(wdev)) { @@ -356,7 +367,6 @@ static int __maybe_unused imx2_wdt_suspend(struct device *dev) * during resume. */ __imx2_wdt_set_timeout(wdog, IMX2_WDT_MAX_TIME); - imx2_wdt_ping(wdog); } clk_disable_unprepare(wdev->clk); @@ -383,12 +393,12 @@ static int __maybe_unused imx2_wdt_resume(struct device *dev) */ imx2_wdt_setup(wdog); } - if (imx2_wdt_is_running(wdev)) { + if (imx2_wdt_is_running(wdev)) imx2_wdt_set_timeout(wdog, wdog->timeout); - imx2_wdt_ping(wdog); - } - return 0; + ret = watchdog_dev_resume(wdog); + + return ret; } static SIMPLE_DEV_PM_OPS(imx2_wdt_pm_ops, imx2_wdt_suspend,