From patchwork Wed Mar 1 11:37:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Wensheng X-Patchwork-Id: 62870 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp3585933wrd; Wed, 1 Mar 2023 03:56:14 -0800 (PST) X-Google-Smtp-Source: AK7set+gzJKYhpvn03WHQV/arv64PYp/A8lC8Eva29H3ziG9eawSoDvO7wYSMN+zgnNpjyh20eV/ X-Received: by 2002:a05:6a20:4c1f:b0:9d:efbe:52ae with SMTP id fm31-20020a056a204c1f00b0009defbe52aemr5192115pzb.30.1677671774460; Wed, 01 Mar 2023 03:56:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677671774; cv=none; d=google.com; s=arc-20160816; b=bboJxXve4+p1Yzwgyc8KTScFH9YmAsEruTD57bGpOpXefMlvGUH4czlWmmVBg/sJ7G dxMyN2ZS5Nw8mIsxNtXwKFQRHP/I6TZSC5SMcc/vu2xURVerzpuHxkx9ZSp/L/Jz58wJ 5gqeRZyewc7ecBZn1ckwApIV+Afj6YH8TxRvLSHgYf3RHa+GwJCUiEegoqIhoYvuheLB 3xh/5pG6rrP3lkOOpZ51Q0W8s1c6c6pOylX4KSyqi3tykzlTqA6UebfhcsbR3KYv9fzf 1pWKuLZHcoBmHeZEOy4ruZHgABCojSoEkz3xzggtZHsnIo8BhJfu0qStRF5DzFDoN8X/ Ciyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=6M9uUP24crWLBHvB950nvS3DLnApVCjPLiUzy0474YA=; b=mUA4K80XiflGOWv9d4OMPypXoryXxXgKdl3KYKpIsq999F7mHTREGK9Pa8iFsDla9y n5DDVguFpdA4dqb8k6pcUCp9cjZn2iTVZawhnW2wLo6KJjJ+lnFd4+7MYsDn9xCFw0jd 32+nEcOMAxm1EfDbdfLGR6R32vtKBwUE9yUg0tCiZfRz8IWeUbFpcyJm+0n65CBZWl5T Bfg9t5jnPfcMAVK7uhA+Qv7OBlG88zcFm9HwExxj3qSD11/lqOH3ybDcG//VpgSL3kj3 CcngAF8Djt62lwblNZeo6ePi201QMO3a2S2auWYeLoYKJBDD5DPNXTq0d3QEo4CTj52d dM/w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x202-20020a6331d3000000b005001709205bsi12007802pgx.722.2023.03.01.03.56.01; Wed, 01 Mar 2023 03:56:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229747AbjCALkV (ORCPT + 99 others); Wed, 1 Mar 2023 06:40:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229602AbjCALkU (ORCPT ); Wed, 1 Mar 2023 06:40:20 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16C753C781; Wed, 1 Mar 2023 03:40:01 -0800 (PST) Received: from kwepemi500015.china.huawei.com (unknown [172.30.72.56]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4PRXFw5r7YzKmK6; Wed, 1 Mar 2023 19:34:44 +0800 (CST) Received: from huawei.com (10.175.112.208) by kwepemi500015.china.huawei.com (7.221.188.92) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.21; Wed, 1 Mar 2023 19:39:42 +0800 From: Wang Wensheng To: , , , CC: Subject: [PATCH -next] watchdog: sbsa: Test WDOG_HW_RUNNING bit in suspend and resume Date: Wed, 1 Mar 2023 11:37:02 +0000 Message-ID: <20230301113702.76437-1-wangwensheng4@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 X-Originating-IP: [10.175.112.208] X-ClientProxiedBy: dggems701-chm.china.huawei.com (10.3.19.178) To kwepemi500015.china.huawei.com (7.221.188.92) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759166358392561768?= X-GMAIL-MSGID: =?utf-8?q?1759166358392561768?= If the sbsa_gwdt is enabled by BIOS, the kernel set WDOG_HW_RUNNING bit and keep it alive before anyone else would open it. When system suspend, the sbsa_gwdt would not be disabled because WDOG_ACTIVE is not set. Then the sbsa_gwdt would reach timeout since no one touch it during system suspend. To solve this, just test WDOG_HW_RUNNING bit in suspend and disable the sbsa_gwdt if the bit is set, then reopen it accordingly in resume process. Signed-off-by: Wang Wensheng Reviewed-by: Guenter Roeck --- drivers/watchdog/sbsa_gwdt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/watchdog/sbsa_gwdt.c b/drivers/watchdog/sbsa_gwdt.c index 9791c74aebd4..60875a710e43 100644 --- a/drivers/watchdog/sbsa_gwdt.c +++ b/drivers/watchdog/sbsa_gwdt.c @@ -360,7 +360,7 @@ static int __maybe_unused sbsa_gwdt_suspend(struct device *dev) { struct sbsa_gwdt *gwdt = dev_get_drvdata(dev); - if (watchdog_active(&gwdt->wdd)) + if (watchdog_hw_running(&gwdt->wdd)) sbsa_gwdt_stop(&gwdt->wdd); return 0; @@ -371,7 +371,7 @@ static int __maybe_unused sbsa_gwdt_resume(struct device *dev) { struct sbsa_gwdt *gwdt = dev_get_drvdata(dev); - if (watchdog_active(&gwdt->wdd)) + if (watchdog_hw_running(&gwdt->wdd)) sbsa_gwdt_start(&gwdt->wdd); return 0;