From patchwork Fri May 14 17:21:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 12257283 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=-15.5 required=3.0 tests=BAYES_00, DATE_IN_FUTURE_06_12,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE,SPF_PASS, USER_AGENT_GIT autolearn=ham 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 76887C433B4 for ; Fri, 14 May 2021 09:07:37 +0000 (UTC) Received: from desiato.infradead.org (desiato.infradead.org [90.155.92.199]) (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 E976C613DF for ; Fri, 14 May 2021 09:07:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E976C613DF Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=nxp.com 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=desiato.20200630; h=Sender:Content-Transfer-Encoding :Content-Type:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version: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:In-Reply-To:References:List-Owner; bh=AJmC41707r+qMV/ZyJlo4I3sDi8F9Jx2lbcqbujaCsU=; b=PuZhkeS+B/yIF1dGUF99+t8dZf HExhcW0wR9md4m8px1pa51v5C4WVTZVGCJcO3Hm3AEbiYEmnmG/eWJ9Kf3SucvfG41fLIBnTolUnk QZdbuN6nWeh68YrgSEqpl3Z1wAv8JDqu3BoTCdz8qMn97UvViZDqUhYQFNjlQ2EboNaOv4mei6+qL 7in5Vv2UrnyBMu7DjGR5CjItkQf0qgmICXxUlFEO/ngCoIGM3zqKDzsSe/Iq3iLOR0+tteUamUYhZ IHH+KgSL6j3quboVDY5ZbgPiXjs+sDVQwd2vEPxPaC7dxtcdZR+z0QUjaTLApwQzYjZTZyNhXC3RB w2eQ4WzQ==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lhTkj-007aH2-Oz; Fri, 14 May 2021 09:05:03 +0000 Received: from bombadil.infradead.org ([2607:7c80:54:e::133]) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhTkg-007aGT-Fc for linux-arm-kernel@desiato.infradead.org; Fri, 14 May 2021 09:04:58 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=MIME-Version:Content-Type:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:In-Reply-To:References; bh=O2ikud2sBoFPzs8BHjFUyxowV5mT/JOXYolNXjIZ2oE=; b=LZePKYU1nXnltO/mQTiHxXQCNy Lcir4BeJih0VphokSLSxi8/1SCFfMzgt+JltQrkMxPEXeclopXGuu+/WgX17Segktut9RYFmMDbk8 xuqQPjA89Jm8wsA0euAPF38cMM05sM8XuajNxULjMM3IWmLFHLP131d4vA1ZQWYyXIf5FK1OPb9/M YrqdZY2HoCKU2FgXTCFbd7vz3ZA//WdmO9NlkstBo0pL7VdFXrp/442gGF+WsNaTrUgsUOHQ6+xRW USGsM1BzMJVBvN8X4So02EzkW2Wjcezq3L6ZscFH4YXMu0KGImi3uE6Ey2KqsZqewvLxYssoligWf PJ8LzoeA==; Received: from mail-eopbgr30085.outbound.protection.outlook.com ([40.107.3.85] helo=EUR03-AM5-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lhTkd-00BqMB-LE for linux-arm-kernel@lists.infradead.org; Fri, 14 May 2021 09:04:57 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hEgRXfgGQ7zyvsXbn/VibrXA+wxehwV5P0I2k2IwwCx+aPk5vwF/VVsxWTTOrclQejhWTaHbtD7zbzhlhJO8zI9RO9DQpqOEzn0cQePX6goWrp076CBhyNdMj650FefHm9zFgIXnZ8Dh5QjLmT5SIm3MkprHSVp1b4CNBzEQ4I2qJvKZaI8rjDYdyPit1oHV2P5ObP5FFhQkVDXBLWp9w2njoFIXE3w7VSauNicKSpEeCvJkO2H99VNDfL8RGirEcLXVCKyvseLV06RNPAXDlIrYwdozLDzpGHmxGFBWwEblyr4ot/xoHrqTTIdtG1iX/Zrlcgf3zqF8R8lUK6PGOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O2ikud2sBoFPzs8BHjFUyxowV5mT/JOXYolNXjIZ2oE=; b=h4OO3sGwiWSQH4P/QrNU2NRZVy3sDQvpVjaYJAMnL43MgbIEd0wVv/OGvOU20KcWFawi2Kj5gOQavgHhuvKoFHRC+tC3narKN/BsOWUpmJtPHMozlwXhXem+q+7aKXAMs1RM0XKGTv9LsnpldvRrZt7JOSRYTc1iaZehCoPIGBTBwnMkRwCK+VIAQnm37a0LlW87MV9Dsno6ROuCfd6C2greT3of678uy1MmSx+k1Eah++jBCk4ZuhLTB7LmNrdZXOmeNPCCAT0JXIiaFPKqNHpXjsTN5s6K2kdi+gbxu8oCmPXz5gCrQTXpTBRllaaUpA8SKpFNGrIJCF03G/7Qvg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O2ikud2sBoFPzs8BHjFUyxowV5mT/JOXYolNXjIZ2oE=; b=YWDGG5EmnN0zojClepqoyx+/suou3kewfJnBFco99trtL4YDVw2z3Hz7kdhLMRu5hF2u6YduzsoB8vpFkUXlDEnm4sNQQBXL6b8wpPCr4+itAtg7rA/GuQLnxKS8eQ6Bp8Ku20F1ccJLvwjXbbAFUR/UUisE09Kuj2pQ+6qxn/w= Authentication-Results: linux-watchdog.org; dkim=none (message not signed) header.d=none; linux-watchdog.org; dmarc=none action=none header.from=nxp.com; Received: from VE1PR04MB6688.eurprd04.prod.outlook.com (2603:10a6:803:127::25) by VI1PR04MB4317.eurprd04.prod.outlook.com (2603:10a6:803:3f::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4129.26; Fri, 14 May 2021 09:04:49 +0000 Received: from VE1PR04MB6688.eurprd04.prod.outlook.com ([fe80::bcfe:215c:1b66:6011]) by VE1PR04MB6688.eurprd04.prod.outlook.com ([fe80::bcfe:215c:1b66:6011%4]) with mapi id 15.20.4129.026; Fri, 14 May 2021 09:04:49 +0000 From: Robin Gong To: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Cc: linux-imx@nxp.com, kernel@pengutronix.de, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v2] watchdog: imx2_wdt: avoid to ping before resume back Date: Sat, 15 May 2021 01:21:15 +0800 Message-Id: <1621012875-22667-1-git-send-email-yibin.gong@nxp.com> X-Mailer: git-send-email 2.7.4 X-Originating-IP: [119.31.174.66] X-ClientProxiedBy: SG2PR03CA0167.apcprd03.prod.outlook.com (2603:1096:4:c9::22) To VE1PR04MB6688.eurprd04.prod.outlook.com (2603:10a6:803:127::25) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from robin-OptiPlex-790.ap.freescale.net (119.31.174.66) by SG2PR03CA0167.apcprd03.prod.outlook.com (2603:1096:4:c9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4150.11 via Frontend Transport; Fri, 14 May 2021 09:04:45 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ada7213f-feda-4287-17ac-08d916b75390 X-MS-TrafficTypeDiagnostic: VI1PR04MB4317: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:5797; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0NOHi5+A1qAv0b14OA9I54OEig0BVN59ELINLh4PcKmp9L5RoAiWc+XF/0BmxWaj1YprLGZ0cauk2KXZxSObmvvBIaf6twvNmfZi1i/BsSS68oeDpF9yewhF3c+XSxwvMUrtOtxoJ0VwnC2TMXGBwwDzr3tCU356WBFC/Vki59ab2+IKHYBvG+kFop6wIYwlTnK/VVCwREQMuSKyrTJr50eNeKa6gFABAkNqjrylnsxcf7EgOBce6gP/aZub4bosecyXIcTDJjsN4/2UDVQ0p8TChd3p8D3IQRYO+x0gigpU65oy8Lg1BGFgGMqPo/RO+lvbNWQpCz4CoI2Qm+wbpNb1eqrO6md5o1btQ4neJucxEgjQAXvGUuC58suI3I60Ek+LJF7Vbj/ZcD4ec12IPkdFbDprAs1/9/P3Lm6udnjC/Tx+UIUtmk4V6ZA72ttcsB3aipY+0sQ3Jfu6bsLiOVNJPFRge2ZVnZqN3R7tSXaL4s3F0SVKHE7EkEObImP2sD5ybKJ2VfdjyU1kJNQIgYHO2fhb09mQPOftsnIurlDL29kuaU05ilnHuWi7/tU1g0zjQx+BJqd9F1ol3+V0iw7Q9hbiKZzWiFwU0YmQTc0IrA2s7Mfefps54QlPVCgkX9aMzKZbEjP/Fq+GmUM3RHTRkNqNSH2Z8BLzksVYpGU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:VE1PR04MB6688.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(4636009)(136003)(376002)(396003)(346002)(366004)(39860400002)(956004)(2616005)(2906002)(26005)(86362001)(16526019)(186003)(83380400001)(38100700002)(66946007)(52116002)(66556008)(8936002)(66476007)(478600001)(316002)(6512007)(36756003)(5660300002)(6666004)(6506007)(6486002)(4326008)(8676002)(38350700002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: 6OCxojCJLkWEXhyXQz4GDL/kv2PlhvnAJ84l6OM/b5uMsce4DUeDFkE0Su2/+fZW/gSh2bkE+JmRwNOVTZXy+qHKdbENrpr/wiNIeBo/S5CZVI4F9B+9aRY6QslXYb967vmnEPQ3OUcIVBgJX27wVciWl5xQkofYcJB2Z2gImqSDVaJfQgLVVM7eQQQAtVha+c+tEz0ts3XJgA3QN44NhWFzIdkjHKJAe2/p7R+jXTONuCp+f8NXL+hZhuJ/c0ucF1NTwwWqQYvGTB8Uw2C+DdDcJ106bY0xvnBsLv0D80QUMv+TwQawlNumQr3IrDB5FZ6v0GTM5mbHwZWHnDC4gDOwocT0JB76xlI3guLmQqNHVf8AOand3aHbeKkpTubMgatxuSCzxOiHlPZNHcBX3S7IYOHBZTPkLGofm3yYnfzdL39RcUCSQjlh14pYqLYNnSYf8Dw6ZIs/rkU18/3fhjKEvpwo4mg8Q4cQA3fX2t7+qbI1BsPqzwEyC0PDUAwXZXFjBAoKEIAZfM7FFjRmxiNg2cQvwEZwOiPmxXmSbJN9+2eb+c20Jn3qMZ1qCOu7hW0CIBWnc/e5s+9jHWCjG7NY2aiFzhSNvk8OPykByp+R+/6wGKrPcn82+yURsoG8kBtx/zXNi8oDDjM4Rwvc7rBW9kIOEdiWU/+JMHH987eFDM6fp0V8FF6qtFgeNAjCm6Ta3EfiAbMQDDdQNKPom7wkOY3ydX8r8UxA761rH5A7e4sF4hwaguOfP/195T4JakK9Mw8XPi1oYwB2+kwf84eYCv9g1cxEV2/dNDGRwA31k4chwrWtAnWmmSueGBHiqAqZHqjGbZfeiQyMWYhl/YnVlEAAdZKlI2m2lcTzlYiszxadEOvGItPydB402xnup4hLxT4A8Wxegg5XuCoJvTkxysCVpwRrogIm9XqZgcx+6rnTTcKNahQz9RPBb2IQnrfOosCzqDm9pFuBcAqZv6PilkCIig8KjAlcjeIiTmmAQWNYEEBGWC9gUzfvdnwjeeWPP/3x7BtRoSfSVm4/2p89YGVL7a/LW30uVTkleWws+L7lVn/BTxzsPRtZkbXt7pdxFQ1KphFOwX2gg+0KtIHPP0R78nj/TaN3BGmxr9DX81GXGaR4KveGs58nqrTNmHbDbQ220MYJR/dSIFtMOiESRn1CXqgU2jnCEtz3Heaymu4ZOx49vcyjlG2vBzeSMIQf8hf/k/ho2EO4LkcPIOwZODJJOMfs4Yv4mpDh5VcjHSNNUKBKGxksnBpfWx1LdBErrNxo1SSIPFMdaxELBV5q+BvmMDLHBQmbAO7ZZ4diazCLP6PN+CSF68jOy5I0 X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ada7213f-feda-4287-17ac-08d916b75390 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6688.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 May 2021 09:04:48.8373 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: kt6AYcJ6S1cXU9lYTzGhwnEDv5hfYvSvjrURCwfjrSYGQ5bwqPv3aDSaxN03nCXKMSXSTTgGHAntsn2bA4NrzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4317 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210514_020455_741086_70CB5463 X-CRM114-Status: GOOD ( 12.61 ) 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 Since watchdog_ping_work is not freezable so that it maybe scheduled before imx2_wdt_resume where watchdog clock enabled, hence, kernel will hang in imx2_wdt_ping without clock, and then watchdog reset happen. Add clk_is_on to prevent the above case by ignoring ping until watchdog driver resume back indeed. Signed-off-by: Robin Gong Reviewed-by: Guenter Roeck --- drivers/watchdog/imx2_wdt.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index b84f80f..cc86018 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -65,6 +65,7 @@ struct imx2_wdt_device { struct regmap *regmap; struct watchdog_device wdog; bool ext_reset; + bool clk_is_on; }; static bool nowayout = WATCHDOG_NOWAYOUT; @@ -160,6 +161,9 @@ static int imx2_wdt_ping(struct watchdog_device *wdog) { struct imx2_wdt_device *wdev = watchdog_get_drvdata(wdog); + if (!wdev->clk_is_on) + return 0; + regmap_write(wdev->regmap, IMX2_WDT_WSR, IMX2_WDT_SEQ1); regmap_write(wdev->regmap, IMX2_WDT_WSR, IMX2_WDT_SEQ2); return 0; @@ -301,6 +305,8 @@ static int __init imx2_wdt_probe(struct platform_device *pdev) if (ret) return ret; + wdev->clk_is_on = true; + regmap_read(wdev->regmap, IMX2_WDT_WRSR, &val); wdog->bootstatus = val & IMX2_WDT_WRSR_TOUT ? WDIOF_CARDRESET : 0; @@ -361,6 +367,8 @@ static int __maybe_unused imx2_wdt_suspend(struct device *dev) clk_disable_unprepare(wdev->clk); + wdev->clk_is_on = false; + return 0; } @@ -375,6 +383,8 @@ static int __maybe_unused imx2_wdt_resume(struct device *dev) if (ret) return ret; + wdev->clk_is_on = true; + if (watchdog_active(wdog) && !imx2_wdt_is_running(wdev)) { /* * If the watchdog is still active and resumes