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,