From patchwork Tue May 11 11:20:32 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Gong X-Patchwork-Id: 12250413 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=-17.4 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,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,URIBL_BLOCKED,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 67351C433ED for ; Tue, 11 May 2021 10:15:29 +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 AD9F5610C9 for ; Tue, 11 May 2021 10:15:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org AD9F5610C9 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=12UHilHGf1XVD3+6x6wBOnEvyFYP2BWiQgVxoiTO8cg=; b=RKAehg2h/wIfkIYEewZKtkQVPF fTMybiLsqzsrq93fo80jl1SRu/wuUVlZzPTnp46YwFyI1bynk2I+eMMRJsuS/yQRZ8KN9SFrzW05X lWh51BOw0ghc+goZ9E83rPNmntrkpvcZbiXX04J/R8E+hYLkeB7BlRR4T3mvvW8WOYaMzm+YlCwpJ iMu7qL3dAAtigHLdh6w4JzS1SibiHNeKm7b4YxsKyheKJuv/1bD/PsqtGxKauEsvncW/vX6rq3Wks iQkLhc/bgnBK/r+2767RGrgShb8BC7OEOuaviYUaNDqUVDM4Krkfd4A90P8h0/tgOeAycymKjucUd 9zJi2IIw==; Received: from localhost ([::1] helo=desiato.infradead.org) by desiato.infradead.org with esmtp (Exim 4.94 #2 (Red Hat Linux)) id 1lgPPB-00GrmY-Cp; Tue, 11 May 2021 10:14:22 +0000 Received: from [2607:7c80:54:e::133] (helo=bombadil.infradead.org) by desiato.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgIgk-00G9S1-Lx for linux-arm-kernel@desiato.infradead.org; Tue, 11 May 2021 03:04:04 +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=WCNDCRU0T+rg8PLRHW8CUxI5ByJVM+n0Uq7O1pRdyYE=; b=jgMR3IzwG5oMqXR8kex80iR1oV HMNPvfULbpao5xw+jRgm6LJ8hSJa6cOBFmf4tp9fStfCKAvOSWRGMTnLz27aVSB7Li9XHhO3wKr6K Miw3ayhe9Rz9CaulmkISgUX0/hZcSXya+dfHAO2b98umDuslE1AmUPt/MtOzY6hQ80ZYq0VXmjm8d TDT0b2XJlmy/6nQ6gz6x2OCkYyb/PSW4WhUgEnGLeKZHaqhunVXCK5WQ4u8OBDNHMUnZIua46pQIm GQrOhbOaKbvv50zE3QyWGlsDsWvKzPCrKpeWb+EI73ovc9GsedAqCxDSX0u3scoD4uZHXFbpqZTBC Shr0+O/A==; Received: from mail-eopbgr60040.outbound.protection.outlook.com ([40.107.6.40] helo=EUR04-DB3-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.94 #2 (Red Hat Linux)) id 1lgIgg-009Gqb-Hw for linux-arm-kernel@lists.infradead.org; Tue, 11 May 2021 03:03:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FIXqe6OtqE5rjsGOjuClDwoD5JAI5nOSy8W58ovwOBvBncJrpGX5dUU7aJUDxZ+QsXXT9fYrUhcmmC4m7FczF0ZQ5QzgNjMGiYx9AVsa5O7ojNVO14Dfa4r+HrbIldb6yANg3GmU7BXSOpL3AGkPX4P7mhp+ODEZv0Asx+eXZOSrFc4HCm386KLLqwLB910ugco8Jc+TOkyN2MHeoBXHFIoKDIerlDMuF+wv7WAEiIlB8jpKKOxRwFemjGA4r066I+4eOHwpT5OAmZn8c9wgs4vyW116zeSMBHaG+Pt56lzcD7oGSvvXDvTpNqe95uABmnloUaAprF6Jrlk+F33e+g== 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=WCNDCRU0T+rg8PLRHW8CUxI5ByJVM+n0Uq7O1pRdyYE=; b=GAnDif8vBlDJPv/UQBg3RfZSY7Y8nYRc5DtAlKnz7Fe2JyfjCoAaEHuMsRB7wfdLhrv1UVtqh2pdkY9FDpKUYOjB5mfzXFUKQXWwhZMpFKx2JlUGFUuZn5JsHS0IJhZbZZHQCbZ/kfkILzRVWXAoJ49Inehg3d+7C9DaX9Q68u0iwAE9S/y+7kFAfQZXKDbjgGxupL/ltxqBOFq2/BzoG1FyH1NWPjajs5J2+xU4cYQsQYtQetqTGs7eoFmMJoSyDYrDRhlsGEsbOdu5PGvaK4yzoHJPaNuLqVLW6eCKi0QljVBjMcmftwByHZh8gK6a1xpFyeEs0NdTwmGuvsH5dQ== 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=WCNDCRU0T+rg8PLRHW8CUxI5ByJVM+n0Uq7O1pRdyYE=; b=jIiqZ8h9Nv+p45JSmSw62Z9U36KEwGlNYLt9mOinThhzE4gNKbSeEHlC7u9Crq8k+j58ypvsa15cx8iyWljlaparwSDbLXXHUhvd0Ea3Z1m/6nmPKplWyAcziCY5vhc6zPNOXJk2N75Y6Xn/lGFXWe73BYhoY/RQZnm/iHWAvUg= 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 VI1PR04MB4559.eurprd04.prod.outlook.com (2603:10a6:803:74::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4108.26; Tue, 11 May 2021 03:03:52 +0000 Received: from VE1PR04MB6688.eurprd04.prod.outlook.com ([fe80::de2:8b2:852b:6eca]) by VE1PR04MB6688.eurprd04.prod.outlook.com ([fe80::de2:8b2:852b:6eca%7]) with mapi id 15.20.4108.031; Tue, 11 May 2021 03:03:52 +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 v1] watchdog: imx2_wdt: clear WDOG_HW_RUNNING before suspend Date: Tue, 11 May 2021 19:20:32 +0800 Message-Id: <1620732032-7675-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: SG2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::17) 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 SG2P153CA0030.APCP153.PROD.OUTLOOK.COM (2603:1096:4:c7::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.20.4150.5 via Frontend Transport; Tue, 11 May 2021 03:03:48 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8f159e6a-840c-4656-d313-08d9142967b7 X-MS-TrafficTypeDiagnostic: VI1PR04MB4559: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:4941; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: K1u3ZN0c83PyEmkHX2JIlPkAcT51IkKDhX/ZMOX3roPpTN47/c6Y15sh5uEwVhmiPSMjHCdi/EEK9iaUiQjKyLQG1q9fdwXzwEhvhYwG2Km8vX1J8tWem6ynP4G2H9z9Lpy/VUd7uVKNYzu8f5h0iH+mUM6Grx49QoPimGRalIDm+AQfKXCZOT+kFKZmZ39LfKHLAPSe5O7UUW9jxKo6QS8oCCIj/2qSPk0YYV+YLOHus6OoJdpXeWf05Tz1HsxpVqb+Mja/HVWLqeFwMKd1BT/YzEje2EJSUj8djOdAsXIpRFjXVnG8mUelpe0phCRvw8P/FME+6JUasr79BTcvvt9ABMvk+Q/YyJZHjqVZ+MtDFU6D5utNpOb5pqB3tcpIq1vzQ61KTZ8Eddo8j+E7RW4WT651rSCUk6x6CTMUaPypjgR4vjSX04e21FyN1QPKnCIe3cgdhD/TEx4Dl3feBkDm1J8LI3w+HnWM9n9xXoeOCyJvOltrsyYig2V/trhIMZjolgWl0RzT1sUQDuVQ1eaXc0Ho+El/8HrkcpwlAUuL4v5kX0CaTkHssNWOt/DfsfB3sTK+xWCU/X+cTB/CkYmCRMof0RMYY5ELgDLEpX5og0qv+MjdqVsFdiXmJcLnxD4ZJPBZ6WLVXkdjQSVBWrepqfw8jISWPUKPNcMuWzc= 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)(39860400002)(396003)(346002)(136003)(376002)(366004)(8676002)(2616005)(478600001)(83380400001)(316002)(6506007)(16526019)(66476007)(66556008)(8936002)(4326008)(86362001)(186003)(956004)(66946007)(26005)(5660300002)(6512007)(36756003)(52116002)(15650500001)(38100700002)(2906002)(38350700002)(6486002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: vkJ5g6MNLJeAdNOccl3hakg9Zp8wQ6joe+HtQ4xTWW+W0YGF1hpsX31qpltp4y5idTHOULtih8pH/3DxgU49Nkocv2vO0bUMLd3yWYt2WUEP0tbqO7aM8P4mtW25g3auTGzt0J3YA/z0RUKxzhsWYCUuOan0QeSJBu1boB2bkpBnNxWby+kDUWzRl/D9ckeQI1mjy80V0urE836Qo0EJLDfLZJa3mPtZXtT8OWppWsGgTBrU1UOMo3eHT/R1dXAsb1bcaumB4FLGz3Nz2TcJg8SUryd6Szjvd3FaKnBck2lUE8hws3ZwrFBSHQSVVfDsNdCEi2R7llRttNYoully3qm/7Co15JrEAU1aoFP2XZtc1A+oKTSTedISlQ+BdVSS3I2vT5NkjSBgV5z+8UEkEyiFxP/f2hgEPgXEDYGukCfynTUp/8X0iJ6ga3CvOzkF6zozi5kJvcgahE7KVWC4D6HwjQ4r20piaRm8YSPaMOPsUcHAbSmO/HDUQtt1mO8SI1z/pQ7IswpyX865auNNToxmHHEoqTGsRr3pfhv4ZH+QRMoZcujIBT+7/bI6ac5LWyoj56iPXTFV2fAGOptNCP9lan2rmH2KhYK7Fxi5SV7e1dbzUMEsvnaowutG07YXY29IuryXQzy3t9S5EPLXLFI9h0PTd11+SgLHlImN1MLsYbrzdJ+l8UKnOXQctplDCx0R3itCNW/biZO59lQj+NHwnHQdPWMMe/8rdSZkQ3ByX4Ool+cQroaHb59IlL7NonD0AqT3XzAQS8mV/4DuQH9vVUiGgguPEf87F7R28CQcPv5Z+djShthg+7DchAidQ/Y+bWwWq79ZU1ImPP2pZi80Q1aOrsnBsJvZrVFsDqUgCI3ejcs4OD9ffsPWT9/zjRyH+y7AVGLsTN9apY3bgYDV8MYtqMcI7y/7GY6pwDFnZU5lF5OAsGlYvDQacuy/SbL+iE++QkUdWMO0jQpTJ+KTauc5PF/UfTnVg8yurB11NwX0aUzyt381fHn59v5ztohUSUJ2ksT3Bj11acXgNUnL53ZI3OXhaEV3khnQYRhOGCJ8dm8RCbCF4dZSAnA1EcFx0zOETPs/DrBohsrZQ55GYWEJyi/8uzK3HDpeoiWY9t6cmi4rBrhPbQHZUH0lf12n+cZFnb8neDwfkzvCOojH5KoB6Q6HPB7AzyB5wj0jgRZeTjqwJKWOmoLyaEBClV0hwx6XAHRxKdSSW6Num8XmmapFmlCY89Ai1FRIyAV74s2uhpkxpnZWb34Inv0krSq2Kty1X3ngU3RepR0JnA7YQ4kw81/s9daP/qT+U451RQChPIM3QLgJGeT9uLkx X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f159e6a-840c-4656-d313-08d9142967b7 X-MS-Exchange-CrossTenant-AuthSource: VE1PR04MB6688.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2021 03:03:51.9328 (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: BML+wBFUe1E9f6WCTHu/Dp+yQ4dAhCuc7Vthvgh+0Uit4XtnxtBbxRW9nsMBikC1Nwca9cermeDnG4LVJjLtOg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB4559 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_200358_613172_DDC11B29 X-CRM114-Status: GOOD ( 10.60 ) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210510_200358_613172_DDC11B29 X-CRM114-Status: UNSURE ( 6.87 ) X-CRM114-Notice: Please train this message. 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. Prevent the above case by clearing WDOG_HW_RUNNING before suspend, and restore it with ping in imx2_wdt_resume. Signed-off-by: Robin Gong --- drivers/watchdog/imx2_wdt.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/watchdog/imx2_wdt.c b/drivers/watchdog/imx2_wdt.c index b84f80f..d3751e9 100644 --- a/drivers/watchdog/imx2_wdt.c +++ b/drivers/watchdog/imx2_wdt.c @@ -357,6 +357,13 @@ static int __maybe_unused imx2_wdt_suspend(struct device *dev) */ __imx2_wdt_set_timeout(wdog, IMX2_WDT_MAX_TIME); imx2_wdt_ping(wdog); + + /* + * clear WDOG_HW_RUNNING to prevent watchdog_ping_work running + * before imx2_wdt_resume where clock enabled, otherwise kernel + * will hang and watchdog reset happen then. + */ + clear_bit(WDOG_HW_RUNNING, &wdog->status); } clk_disable_unprepare(wdev->clk); @@ -386,6 +393,7 @@ static int __maybe_unused imx2_wdt_resume(struct device *dev) if (imx2_wdt_is_running(wdev)) { imx2_wdt_set_timeout(wdog, wdog->timeout); imx2_wdt_ping(wdog); + set_bit(WDOG_HW_RUNNING, &wdog->status); } return 0;