From patchwork Tue Aug 16 04:36:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alice Guo \(OSS\)" X-Patchwork-Id: 597828 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D548C2BB41 for ; Tue, 16 Aug 2022 07:13:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231700AbiHPHN1 (ORCPT ); Tue, 16 Aug 2022 03:13:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37758 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231905AbiHPHNH (ORCPT ); Tue, 16 Aug 2022 03:13:07 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2058.outbound.protection.outlook.com [40.107.21.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C40ED2DDB12; Mon, 15 Aug 2022 21:44:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L6eGOF1zjYqZ214/4C1IyGu+IooE93DEJi7xpFNOSq8WIFm3rA7o9XTN70kJipRDDD+CYOH9C5KnN/jHzRvtD5Mix/WTfyj8Byro1hVv38RWysgjRTeRKh/OGEJZ52hPAXrCUYmuHFzVkP5lbKAsIM51Ix9ByvGV+eeHqxaKB8vu7aLP2I81faTRy5vSs9r3ipLPOLVRKwtrmYX/X2B+famQt8cQ+L2XBBGkGAoG+1+0pzU1Aakr3N1CbHBE4qGDNlcxG9QnDcUtiSyhc5ZKaXY5+fr3lFJNlZoJwyM4jUx9fJWtfRmp3oyODyxX/L3b6nMEpAYHgyWumOz8GUZ3Lg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xlppLxbhiH8pVXvKxsN2ggIsR551PtIcTNJtuK9QHfY=; b=lQuqifUjNOz8tK1OlDOyzLPNfDhF8/xCAlK09AcZhiPGZu/l4hq98fPDjRPxl//eLsqCyUonmnRd67b1OHbKXN7w9FN0SQ/yk6L72YCdkPq7lY5DhNO2cB6yFFXLqZfvg2GZFKDVOB7y619nrm/jlDvUQLanm3zle8RVjV5Eiop7inE+IjUaCYoZVSvfFI1GuaUMQ0Zix4BuAX+BXLOE34PyLPSPL9NoekTNE/hGcf/gDNbVIHe6keyEsYf7B027mWku4sXFVgn7rEKXBSPRtbd74Lnx6BJHH+a0c+tzUlx7yddjvQuIfCm9ncDe+a37wKsD1Anhau5zOs4eZmqScg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xlppLxbhiH8pVXvKxsN2ggIsR551PtIcTNJtuK9QHfY=; b=NrjNnLVXNickkHCMxLj02hRsJ8+vdU1PrX1lbRGaOUoTG0NOzod973h6xygkECPXDxkIRQp0zJx4oQwlrc4BLKW2ViNbkFlgX+ifVDjV9oEKs2dJ7vaF1tzdk3Im7hOuKQAXK7fc95UWLt1uE0CEASC2E96dwjSEs5C32erVJ3U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) by DB8PR04MB7036.eurprd04.prod.outlook.com (2603:10a6:10:12f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.28; Tue, 16 Aug 2022 04:38:14 +0000 Received: from AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c]) by AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c%3]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 04:38:14 +0000 From: "Alice Guo (OSS)" To: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] watchdog: imx7ulp: Move suspend/resume to noirq phase Date: Tue, 16 Aug 2022 12:36:37 +0800 Message-Id: <20220816043643.26569-2-alice.guo@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220816043643.26569-1-alice.guo@oss.nxp.com> References: <20220816043643.26569-1-alice.guo@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:3:17::27) To AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 060638eb-64a0-4d85-569e-08da7f4121a8 X-MS-TrafficTypeDiagnostic: DB8PR04MB7036:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fb893SoLYlWqVRnRN8qq5YLpySOKk3AliVgRpdy7jZBE2Gw6+fYwK0hfKs/huVHzIEnatdxxcWvrsJ4erwpUEEIQK4lYAhQheUTbbxlqSYgQC/3xPpEKA8etbScAhYhYSXM9nLZfU9k3ne1FBXkUFn5OvWNx0u/nbt2/In3sUfbKADrJpyYexpLazF4F1w41gnW3F49PqW2qQIbQIhYyihKWclUENl+IMjnWE0tGes21xdzg+GsVd/v0ywlGgLlafoPkS+0xzz9VMSBHj30pPJ7BRZqT9ExdNXlid4QeH4xvmhff0zIrCAwd1XAkfM6fzW7hgkVxMZ719f5H+1rF3ZaPXpyd/98ytmXBAod0/pil8ALd+ejMRwvcbkcJxqrbcZMUv7cTynGxOGjk+LoY+y7adL+kUbDJLXXH9ux1FYh38Kd0D3VWOwkRhwRIXibsNUzI4Mb7IOmL53qH37pnPZVT45vvN4fCQFLcmydzkMLwASuqGHPvNancygO43cAt8PusQHAd7Vn1gkWZfXTHY7oxK782okhbQeqBC/NYbgPLm8byucXffmzQu2z6aoCzggl8n38+qwnlW5jAcYqkaI+UW40oY364CoR4CYXO+3ooXSlxYI3GPuTLBMeqfBAe7EmsK2bj6JIzklHpxPTjjBIUs/7RVDcDGGZIbPR+ISM5CSoU17WzOniWmCsmCb7GN5A7k1dTo9T52JY8cG7f/Kl9IYZUpaMeIB4qEwBnXEi/fbmOvwSmiqBqwNaE/2lZ7w+ftz9aBiHDl/fcniOoeiCaZiFpzls9dTRfuC/Gxu0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6053.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(83380400001)(38350700002)(86362001)(38100700002)(4326008)(8676002)(66556008)(66946007)(66476007)(316002)(2906002)(8936002)(5660300002)(6512007)(6506007)(26005)(15650500001)(1076003)(41300700001)(2616005)(186003)(52116002)(6666004)(6486002)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 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Y8aMlQtiMvDEmg/HLVtSCvu21FusqWFXoj1qlYT9JwehrR00chPvIkSBZPUsjgaN0jzlK6byJKkZ7WPXu63Cwnc6VO5EwsFTP9EAk+zopS0gx4w/U62PAT6sF6Owghn1xdzLNoVdYQDJfX4qaux5nBIvpH89+Blau9rpAIY2zml4GicgiasyV3DtxMrVMmmHVl9NFis/WiGFGfBXIVbnQp40OGCtOrEYNKdHhHinfh3z+d2t7ddBjNDr95lcKgOGBUHb4vxWeeuREeUFHREmMXBg7zmr7io2HwrrQZTPsVxTxvLUVsWCptUPnb67H8q/KE/3qhkQAuUeVrLI8UBmcv9HBH4ilUAokmNPCjusTYZ/MtwwQhMFcW/F7Bjg/gGITEWaXqkLffLl6LpKv8zzgLfQTY6Hcl5UCcQf22TcPM2zp9tbVtc0DJFAQFfCAkbifS6EVrn6ZipdZJYPW+CFxdN/v/DPutuAyRWH5vkLTkn/Vpq9WL83PDFFEPVEP4sMYuL4/zEwn89ODCGzGrZTz6Et5Tnt2jtXZXxZuRkVP4snZyCc X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 060638eb-64a0-4d85-569e-08da7f4121a8 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6053.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 04:38:14.2815 (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: jdx49KZ5w0THbQ7ePeX8/EJtORTCe5VGQdUKUgov3Kia0xCqsHTe8uOFbs1Pjh7slRkXWUXQR+tKbM+85jveng== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7036 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org From: Anson Huang The i.MX7ULP's watchdog is enabled by default when out of reset, so the resume callback which is to disable watchdog should be called earlier to avoid unexpected timeout, move suspend/resume callback to noirq phase. Signed-off-by: Anson Huang Signed-off-by: Alice Guo Reviewed-by: Jacky Bai Tested-by: Peter Chen Tested-by: Li Jun --- drivers/watchdog/imx7ulp_wdt.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/watchdog/imx7ulp_wdt.c b/drivers/watchdog/imx7ulp_wdt.c index 922b60374295..014f497ea0dc 100644 --- a/drivers/watchdog/imx7ulp_wdt.c +++ b/drivers/watchdog/imx7ulp_wdt.c @@ -255,7 +255,7 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev) return devm_watchdog_register_device(dev, wdog); } -static int __maybe_unused imx7ulp_wdt_suspend(struct device *dev) +static int __maybe_unused imx7ulp_wdt_suspend_noirq(struct device *dev) { struct imx7ulp_wdt_device *imx7ulp_wdt = dev_get_drvdata(dev); @@ -267,7 +267,7 @@ static int __maybe_unused imx7ulp_wdt_suspend(struct device *dev) return 0; } -static int __maybe_unused imx7ulp_wdt_resume(struct device *dev) +static int __maybe_unused imx7ulp_wdt_resume_noirq(struct device *dev) { struct imx7ulp_wdt_device *imx7ulp_wdt = dev_get_drvdata(dev); u32 timeout = imx7ulp_wdt->wdd.timeout * WDOG_CLOCK_RATE; @@ -286,8 +286,10 @@ static int __maybe_unused imx7ulp_wdt_resume(struct device *dev) return 0; } -static SIMPLE_DEV_PM_OPS(imx7ulp_wdt_pm_ops, imx7ulp_wdt_suspend, - imx7ulp_wdt_resume); +static const struct dev_pm_ops imx7ulp_wdt_pm_ops = { + SET_NOIRQ_SYSTEM_SLEEP_PM_OPS(imx7ulp_wdt_suspend_noirq, + imx7ulp_wdt_resume_noirq) +}; static const struct of_device_id imx7ulp_wdt_dt_ids[] = { { .compatible = "fsl,imx7ulp-wdt", }, From patchwork Tue Aug 16 04:36:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alice Guo \(OSS\)" X-Patchwork-Id: 597826 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AC5F0C32773 for ; Tue, 16 Aug 2022 07:28:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232118AbiHPH2P (ORCPT ); Tue, 16 Aug 2022 03:28:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52948 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232058AbiHPH1e (ORCPT ); Tue, 16 Aug 2022 03:27:34 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2062b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A1E9D385C9A; Mon, 15 Aug 2022 21:39:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W7RHtRMzIiw1J5fhbWxj8q0eiCkaURXnvl8PVW3rp/f/rixm6/+Nnyb4q0eo45ERY4v5wQdXIwLE9/FM6glTRR30lZ+ylOVUwJvGLzUNiJl9P/JZtE1cwqCd6EyN/eItACooy2FPk6vI3FXGpfqoCr6RLnsxUMf6uIdRiTOfIQBj+iFyvgreRxqH60bTuGZm0FAXFJwQaq1XWb9zVEXP0x4tLMcGcexrLYr3RmhDQGwiyFQqHuGRnL/I1Dplbrroo0xKyEt6jyaAH/XGgEHygeqOPAW8Osj3Oj/KdMhBc5Jb/0CLzVK0df0JwQ1Hq0mGrIuaqClFQ8LPOZP+tdJ0gw== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mAw8oyWLOxCLx45tJz7GhSsan1KQMNYfM9w0MZxAHPo=; b=I5fabj4UhEBN8DlL1EQ+v67LsR/O52VA6lUexSer4e06p/B9Q24BQFJyrj0f76VYXdgBOTjZqOuC7L2Zp7RSzdb9A6jdciLaqffuH0T4E10sj7cdUaoOu3TOHyf0BunC9HqYF7mbHYhV31oUunQl6vo2+GLUP8zYVCGDtHzCrF2JH3Tks+8IcsPAXvcZBjTjhRdReIuxVLkkrJJoQVSfZ3tTbVpH6/e8/UAQfydGGk6A5P0lOIA2Hg/ABbqvhHfxq0qC34DMOgYRYsoAQFd8XTTFwH+Pm0p3KtqnsRlYQFcYwAbcD2d5xRVnKIb9QuKF8L0sh1jysSrgJQs0t+YQ2g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mAw8oyWLOxCLx45tJz7GhSsan1KQMNYfM9w0MZxAHPo=; b=ecLLZNy2QOxmwKOloOqLqp1V5o/P42SDhgUdlaK5tNsw1VXvW34QzlShSKiSIUrRebGuPMD/57ZW38WDSaOmvnES4p8XfON0oU07CGyey1vb4NIITwqG/z3+ZSnWa2BxnOyZ7MvISiLuHFBqQSuKTaOvi1d11G5tSbbDrKis+UI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) by DB8PR04MB7036.eurprd04.prod.outlook.com (2603:10a6:10:12f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.28; Tue, 16 Aug 2022 04:38:18 +0000 Received: from AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c]) by AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c%3]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 04:38:18 +0000 From: "Alice Guo (OSS)" To: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] watchdog: imx7ulp: Add explict memory barrier for unlock sequence Date: Tue, 16 Aug 2022 12:36:38 +0800 Message-Id: <20220816043643.26569-3-alice.guo@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220816043643.26569-1-alice.guo@oss.nxp.com> References: <20220816043643.26569-1-alice.guo@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:3:17::27) To AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 18d34d1f-70bf-46fe-19fa-08da7f412420 X-MS-TrafficTypeDiagnostic: DB8PR04MB7036:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0cmhOoEn1o0M3f6tqf5Sjt1PYNLYi1Ed6o6rrYA++shnCOeyLYsamfCM3OCNq59sQTYjN8wdjCKBk40AQt0AXsiH/tJ9MMxQZkQoC3t24qdT5NWv4cMudjvKqSWRbPeB5EbndmBbocB607Pqbk6qqA4tMSYD5pzvY/nH3t283whwT7qBoYvervDTutyxPLlTxExT8pLnaPUl9EDntllt2TGtyVI1ox5bgw77jiJJov517atUrJXAdQOSSOVVrYPVydSMDY25elyeh/HyBxmGq9P4oFlDg7++amP6ijGRhrNc8U3bjJNE+m0W1cmNCvJaC5iOFfX2g1dRaFldRiLbxqN+4bF7D2qR9NaQqpD5rYUaPQErzvxd0iXgIzmIEYOKcsh1rC+q3M50QQJgOdNeYm99ZOUI2QdslHmXT83/nbJ+kH8TFs9XIV97++hoNddYnqUUaI36ApYbrbBwDiiK77RL9BhdMcr4vI7K41eyby7V6OBAo3kG7fJ1tcJoa2XnqlPD7E6LaaVuU3mG2DfvT5k/Z2z/Qp+fTMokVopL2DfubnOPSbiC+j+LAy9A0BE5SUwbcAqfkM1feliofMq7hv2zIlmDgnEMSAtxPyziH90TfyjkFOrAN7kSinui6CMStstvWiVMESUaMjI8DRXU+F9Z7ZjTuUkGBX3kssBQLRfzbx+mrrv840MoHTfTtoa9XzQzppK6MTX8mEEqlyyW3FuJjP1h3kVaHnRFfdZ0rV6zHZD2ylNiKRQcoJY95UEHTDEkub060WGy8M2fiK7ffYPW6SYITT9DZb+CEdinZ58= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6053.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(83380400001)(38350700002)(86362001)(38100700002)(4326008)(8676002)(66556008)(66946007)(66476007)(316002)(2906002)(8936002)(5660300002)(6512007)(6506007)(4744005)(26005)(1076003)(41300700001)(2616005)(186003)(52116002)(6666004)(6486002)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: p/SsI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csvCRXN2hCppiTStd0TaeHSE+dXdbxcq27b3/HgXC8OZi8CWr2cOkQ2WXYB4AFsF6XAlfaTvfzOq9avUBahOsr5/u9bnqnhfxEY7Wn11ztZN5t/YBUf70ZKCjG/FU76Nzr0FUITLIXxVBQriNFquF4SvWhrxk2KZFvx9bOCcFRK8m2I4DvoNeH4n+ndeZwcPd9SQ5XKl7JcSenLzrcndQaXHdulT/7EX1nqoxY2BwHsoExBD5nubZiC9Q+BbrFozNy0LSyHZhiJB464KWUoccD3cfATwT+gi281606HTQNhIt59DInwQb+yulOHd8qocwb2uYgRUIWhvg9PafJchxFrWt/DX+t8ieBKLB00g3EH8zB6AlnJjl1P8waSlxG+Un6KXYv+GWGF0/+X5rsQbxl718j9+APuG+qkvK1q/lZ1tSwHP4AcUvdF2jDxs6j01+aCU8wvaVNNa67MOYUH0mJRRwEBhMkquh2gRTz3E1KtbENQLyXUMM9nFNxHYimMTZAButO X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 18d34d1f-70bf-46fe-19fa-08da7f412420 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6053.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 04:38:18.5156 (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: O2g5RIOkrXpKlz4R5RJm1AN47cTn4gggik/GSLlucNezXpFKTDuyadA+eZD/ZnGrf2wqCtoCxzq4t/ede6J+hw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7036 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org From: Jacky Bai Add explict memory barrier for the wdog unlock sequence. Suggested-by: Ye Li Signed-off-by: Jacky Bai Signed-off-by: Alice Guo Reviewed-by: Ye Li --- drivers/watchdog/imx7ulp_wdt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/watchdog/imx7ulp_wdt.c b/drivers/watchdog/imx7ulp_wdt.c index 014f497ea0dc..b8ac0cb04d2f 100644 --- a/drivers/watchdog/imx7ulp_wdt.c +++ b/drivers/watchdog/imx7ulp_wdt.c @@ -179,9 +179,13 @@ static int imx7ulp_wdt_init(void __iomem *base, unsigned int timeout) int ret; local_irq_disable(); + + mb(); /* unlock the wdog for reconfiguration */ writel_relaxed(UNLOCK_SEQ0, base + WDOG_CNT); writel_relaxed(UNLOCK_SEQ1, base + WDOG_CNT); + mb(); + ret = imx7ulp_wdt_wait(base, WDOG_CS_ULK); if (ret) goto init_out; From patchwork Tue Aug 16 04:36:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alice Guo \(OSS\)" X-Patchwork-Id: 598088 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45BB8C2BB41 for ; Tue, 16 Aug 2022 07:28:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231956AbiHPH2L (ORCPT ); Tue, 16 Aug 2022 03:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53410 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232109AbiHPH13 (ORCPT ); Tue, 16 Aug 2022 03:27:29 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2062b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67C7D3864EA; Mon, 15 Aug 2022 21:39:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JQHsc9DiWxCPVeRB+WyAxa1C2qv5zgw9qyui0zfkObcFYw4yYVwZ8IpLGt+Mvo2KHzpvu46QWpnLg+ZIm69rqbMfsC8A/JPmr1YY8PjfM/FhJN7fLkxayED5cjVQG5QJ3Qls3zaXVrSMuPnr9eYYdI4+LqEOA77Kw4xh7y8aEgyxMZlELrMzVkWO2YJa+bes3V/f9M+cF6s+lTfLzX6pWOjEKDzzTyXL++mrURiTZQn4q6RCHZOTwxmIb8OaOZKZAe4ISn8z5ulm0nCm8euzQ9ThPeL7T7m5FpdhUMntsz293mELbelwx1Xa6zYgrTV+gt2PmGyvH8VF3jOUtHSNAg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=T5hpjNwbk8vQDqaCUukofnGkqq9KOzgrcN2F/SeyUQw=; b=Tncts5SxQ9nO+3oIGEdPOxAUW2NB5vxHR8TuxC/EAO5JFOsGZUuKkHV1appT2LKBlUHo91wBKfccfzPIpKHGPUWZS3sJBaouBdK3HlCP+Dq7w+MkG4V7QojX1MbFejjMOqfKJxVmRNiyfZCZLtaAS6oA26iyXx8Iyk19kAYKFncjgGwuRUEtofD3lhm7EYw3A49ez9gpNHDYYj1e2tIh7bIVqSG6AMhzFsUl9X/zeiCwZn87cFBBVoF8X7hhdCJ+Cz3tFjCn4oHX7rICNIdNy3ReGMzVggCyjUSgZrgH2Fev5yIIu1qJ6QYGcWNvfhd3m/jn5D7luet6tU41kmStmA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T5hpjNwbk8vQDqaCUukofnGkqq9KOzgrcN2F/SeyUQw=; b=KZqdcWQLLwnIPgxdM2J1WCgspC2QLxoUUo63fBbYhuMLOZD/jHnQxTyx5zfkZePU0L8OUDTnj62xeP2uN1yWupfklgXbJT3UOJ2tTNHAR2BqywlFYuIDFlw7fMAzqYydMb5hFSAX6YuuIAd9/Qd2DtXSyRWZxc2smg+pvXWVElg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) by DB8PR04MB7036.eurprd04.prod.outlook.com (2603:10a6:10:12f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.28; Tue, 16 Aug 2022 04:38:23 +0000 Received: from AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c]) by AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c%3]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 04:38:23 +0000 From: "Alice Guo (OSS)" To: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] watchdog: imx7ulp_wdt: Check CMD32EN in wdog init Date: Tue, 16 Aug 2022 12:36:39 +0800 Message-Id: <20220816043643.26569-4-alice.guo@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220816043643.26569-1-alice.guo@oss.nxp.com> References: <20220816043643.26569-1-alice.guo@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:3:17::27) To AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 72ed86bc-4c01-42c5-d555-08da7f412713 X-MS-TrafficTypeDiagnostic: DB8PR04MB7036:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: KQIpHroOdNG2Gd+qzA1iUgy/PKvXJcJ+DzZWYwpdlob7uHr843lsFwb9AFE+Ag0+hZxDlYzTEqEOHOajOmQ7mZzW+65ntInr63QGSckjxJcgxm7nxXdDSC327xyt7vPgkyWdvBvmjs7pmBwRzejRWei9Ujn31kbdjvjrQM4515p9ptPIT/y1kZapiGj0G9tR6WKu7AgyC/yLEFmkV1J61IO0cd76XvEQ/YB+ZDZMHLNmQayHRGzVQ2UvSZgsftHGU4pFWDzn6nrKp4JMNEuK7CbqIQ87cbRCB1LTcLkRHx1lrhjx7HkAUu/WmuLwtxC8YBSgUqVRlRQyINSaGlLITuflaSE8qTm5n6Ix8Zuy1gDHMikjwbYRPHIo9MqQfQCSEvJ3P/Z7plOZE/fXR9Vh0zvjlJ2GlIFUCPkU+vxGZJfVwhbW9ugMtMkt+7XWMeeDE/OJtYwrpTn1llJT2XuIf8Insb1mDPoUZaGdJN7cuOKTCpqG/6xo2EBhwgQ2kaKfW9CjTUsjDsp2qP8BUHCMEN6yAmdBLP3ymsKh1kdkE2/I3LETS4bqMSldke+9anxIclifAcpOoBxWqeC9ZLH1k7fNWiad+vtK7VwFvQ8OlBdi3xzWAaePDj9+US5x1HkPaDmzqxeUiFYtGw+49JspEW8X/SHkqEaYrnCIlSMm0wWgwoMQgiawVcc0LsmL5ALNbDoZJZcIxojgrl3KXEh+57Mn547SccoxUu63GADXm6fdircJc3GchGKN7GQbT4EFOdkQHQqAens2RuleIgPU164FsHeO/fQbPhrG7RrMjqs= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6053.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(83380400001)(38350700002)(86362001)(38100700002)(4326008)(8676002)(66556008)(66946007)(66476007)(316002)(2906002)(8936002)(5660300002)(6512007)(6506007)(26005)(1076003)(41300700001)(2616005)(186003)(52116002)(6666004)(6486002)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: bKguP+eNNwJzMmebtuo8Ur4edd5l8gUUEJw2e98SqsokHupbjso1BFLdKPZnkJB+BTagx4F/O9mnHCKnQ2JTW600hYEK+BBG6esUrlVvDqeb7I2z6gKD7B3alky7+wCTGweizdjDJWWXl5BxJlodSVT1qS0mmgb02miJIKnhj2b9pRg+pkdCacP/fTW2kUIL6F0ylyPca9SoXfGZzYRdVjh9mxBhus49QeVtYPypir80Trxr0APOoLNOzffZs9R2na6oGk+N1J2j0e+bzFjN3QFBVdUKZ04vOAkaO6YaBlFt93YnADzFLRv9mhKKw1ncBiecYfNFHApbYsd9sRKFOUPZqw0ahg5Zgq4+MBeExRYmqEi2RTXOD99qdNyNHbliB9jtRn/FMzYvLXq1O5k8Ny9j/MEYJV33OmvsOP8kkbgabCAUCgu/PIG1Ph1mdxWhS2QNfgWP9YLXmHWSLcCERYxWNze50FS0hSyYMdzKgRsI1es9og09ksznzs1yKyviSlJmatali6TkW23+Pwo98cnqi2W+qKP7D3bFjDkqArrKuZZhFcudVtakv2r+qly1o2GfbYEjH58xXemaGzLKANQayZFLQT3Y4f3vSUzGOOUJxxlSR7IQdOC2KAWZOuREou5pMpcaQ+2ethtnNMBxXKA1rfVgXzvhSWSDwE7C7I3DNbbOlojs5vXTgsG/u2H7e63GMam63X8+6nvxS0hIQyh7IjoYNUilS7fBFzCB9E17bj+hme9YU2EoSAZkdtRrsogkm6xQTnhpZh0xt1R2xlAWdJaCaCJVFVXH+wJ21INoIxici/SJMdnYoozNDZGyv7UYT7RfImofi6sp8/FG62TpN/IuIFw6TzyfG735B+kAwcLvQMTX9mfZFFKwiBoPvEwfDZ283eED4VraPbjfprZ+nfghBH53TOCra428SFbmAdRYgpdExO8o5nQaonm86kZ3o313XGYCyh8363KdebvXTo06SGj0W7ZoY6qMFSe09QOVjeMBjMyP5qie2Yy8q7ur2ZRBIcJlHIrVH9/t5t6+isKJTMopVKQG78QQqJ6+7mpt/69q7KB1ncQqn0a05mTf6AcMJJB83MzepekLileab9spIdFX2Xk0H7NYuuNAvWfFGEQkzZCXDVhIsgtoIu++WsVDPCEUiKhHQkpG7iQD+MEeOFi+GC3/4qSPnfXPQziPbAExALiscYdR6u85IvthTTieI5ibxWAPNvvV5OIE1UyFnZ3u33C9Ukr1kTxYLyFs3ndBmyXNl0uUW7Pc3LXkcKBSTZCBGmI9HtDPwSnI3gD6IAyYk6QdphiEvECrTbe6c8aiRwiUCbPsW7OYaHrsQVc9Pstup5PTmAhH8VL40ugcveq8L/tP937HghTkNIStqyhcwFyGddvhqJIHO2KhhyYvTlAeoAIUWdIr+MU7ZAelbPsE1kbIDMjogRCOegLn8+TXxlXzpQQX0J3cIXQcMuwtaIFp8AfSyrwYWASNknRMxe8oO2k5InWT4ipMcdD6oIFK0VzAlX033Z225MN2/c6hTL7EX6XFmKqSX5/03xwNk/T+GHbfFTVz3/5vhKCoppkWaKowjcODTVMs X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 72ed86bc-4c01-42c5-d555-08da7f412713 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6053.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 04:38:23.4528 (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: 8+LBMrVEUyd3ly3Say73HSVUi7Pl9LgvBbRIxwnOouY5qxOlDxb4YvduzwDGZS2HycllNDE6GG9wWZSFcdJEzA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7036 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org From: Ye Li When bootloader has enabled the CMD32EN bit, switch to use 32bits unlock command to unlock the CS register. Using 32bits command will help on avoiding 16 bus cycle window violation for two 16 bits commands. Signed-off-by: Ye Li Signed-off-by: Alice Guo Reviewed-by: Jacky Bai Acked-by: Jason Liu --- drivers/watchdog/imx7ulp_wdt.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/imx7ulp_wdt.c b/drivers/watchdog/imx7ulp_wdt.c index b8ac0cb04d2f..a0f6b8cea78f 100644 --- a/drivers/watchdog/imx7ulp_wdt.c +++ b/drivers/watchdog/imx7ulp_wdt.c @@ -180,11 +180,16 @@ static int imx7ulp_wdt_init(void __iomem *base, unsigned int timeout) local_irq_disable(); - mb(); - /* unlock the wdog for reconfiguration */ - writel_relaxed(UNLOCK_SEQ0, base + WDOG_CNT); - writel_relaxed(UNLOCK_SEQ1, base + WDOG_CNT); - mb(); + val = readl(base + WDOG_CS); + if (val & WDOG_CS_CMD32EN) { + writel(UNLOCK, base + WDOG_CNT); + } else { + mb(); + /* unlock the wdog for reconfiguration */ + writel_relaxed(UNLOCK_SEQ0, base + WDOG_CNT); + writel_relaxed(UNLOCK_SEQ1, base + WDOG_CNT); + mb(); + } ret = imx7ulp_wdt_wait(base, WDOG_CS_ULK); if (ret) From patchwork Tue Aug 16 04:36:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alice Guo \(OSS\)" X-Patchwork-Id: 597827 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 97C59C32772 for ; Tue, 16 Aug 2022 07:27:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229831AbiHPH1g (ORCPT ); Tue, 16 Aug 2022 03:27:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59222 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231810AbiHPH1K (ORCPT ); Tue, 16 Aug 2022 03:27:10 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2062b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 45220387F07; Mon, 15 Aug 2022 21:39:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PgIGOngJzYBwME1zH03m/Ccdg9S7XJXgHuU3gq5YI4sjQ5Aoo/N9/Es2NcoYvfkFOK0g+AkSxbO8zsLO4b1KzvpvBp69+8s9SsX+XhiBPmnaAvQWmrGniBg9YUIb4qw4+tB5mk0DOjjPdxfwij/FHII5qVAICQM8EJ+hcDIdfpaRpvwvA9wDXl25mULEp+9704vwvfLG+0wuD1GOL9VouZrfNGmTl/nc3sUTZLR1Y5sNB1y5+HpmY/8++tUueqXjJ6Rfai9En2JtTm2PmBe49jbIYuUndD1SZaZqsMBU2ZAGiz6nHmMtAdUC6ATxsZp8KQAeHp9BLUsAbv4H7c5yLg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=eGKj1rwSAlQl0PrpC19gH6L7Yx2EKBBTDjPaskBxWto=; b=Ft4nu5qhZklJC3C9jtPg/mpYibiqmp264QhTaWpzuz3Xm2dh6LTTJJRmr/kmrf7eGdUOEmWr/n6bIhZydZLbfFK3cSm6vW8zdaSsffoA5E9SVidvgSiuWn36dCYvZnzXE+kZTPyp8y3YD2EIh22+/4aEeGuiRwon8HbgRfGd5sFVJr+ef/nh+ErH3cwXZhSY+G7+7YzQUyBHvL439MPifEmPv8hIHWfKEH/CV8a5BMmNPB5i8nbNx2pEwuladxwZmXwcUXQ1n0J9YlNcnejW6eQMWNwQXFD6gTWlwaH9EPTPPrP97B2WCKOVa+OT85PJc0Bi3UX2mHWykARyAfm9LA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=eGKj1rwSAlQl0PrpC19gH6L7Yx2EKBBTDjPaskBxWto=; b=Z1wB1MPuPxgg/r3w91C85RbIN87DZILEfM//TIaaK/Sy01xyeYi5XO4e12YE45t+XmLSkclznYWWD4s1GgKKCejbu/JrKuTLUyaKYSBQB1Qkf5GZI+vfDP5B2H1eudIy4UdMxm4ialKlDgi7DhWK//S2tJTvUZBSGZaGMIt3vfw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) by DB8PR04MB7036.eurprd04.prod.outlook.com (2603:10a6:10:12f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.28; Tue, 16 Aug 2022 04:38:28 +0000 Received: from AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c]) by AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c%3]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 04:38:28 +0000 From: "Alice Guo (OSS)" To: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] watchdog: imx7ulp_wdt: Fix RCS timeout issue Date: Tue, 16 Aug 2022 12:36:40 +0800 Message-Id: <20220816043643.26569-5-alice.guo@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220816043643.26569-1-alice.guo@oss.nxp.com> References: <20220816043643.26569-1-alice.guo@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:3:17::27) To AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b148172b-d1ba-4701-44c3-08da7f4129da X-MS-TrafficTypeDiagnostic: DB8PR04MB7036:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BSFAk7x5Z74+JMUG0Fqp1N1z8mcK/smbt5OCrsC+vpKV1CwS/It9l5BcfNOERN7jM+PplmR/AFt3PPJ/LqH5A1pSC2ltKNVSTCtT5av3VwCPi2kde3GeVjb1Nox1fkEDRqUEzO+0Ub3uHJdlgChqRAjlDRRJjkdQwoQnhB0/tnBWLaQs0Qxpe1WADC3EK83S3IOmgw9O+WLerLzMZtaAG0YVCUS21twZvzwYf3vg5ZiO/iwl7kw3s1claJmSXm+9m8MtOVjIOwH+54VN9Ska4GNgcgInG1ORkwrm+01pTiUkZdLPKcz2wDAiRBvgtZ06AcJMETAcQThcH4xT+DY6CVuSKXbPydo/Y4rO7oGnbQLKUs796nnyG1pSpr9nouvdVeiViyhV7yBMc3Vm24Cm3bOaeYQK37csS4onRqeKqbJ+GFIP38+ibx7WY800NwVNfWzWOeikib9QAbcHXoiPDbN4X/yudOW5//A4o1Om7ofYYXZuMbvkvuJOG9Bu1adcaPtd4P/q4nXca/J1u9v1aJbON/x4mgr3A77Fs1HOC+u4hPjvgqwJcJFEatxFtrrJzyMXODOeApHT4HXlaJm1KInVBUxTrHsQovH8HsGNAjvcCj06tgaDCIdXXDrA+tKaJV0kBhqDsV20lXU4MaWoxK3p/1sA60CCK6QYEonS8MYYJU0SDDiwDsxfv/eNT4R78E8PDL5PaNM+7OVfpq9RqMzAxcaRP3qfiorIIqSacGa8hzXHSC+gnqjHAZXfEbpirs6+jgwLUMOv5ezw6piGAC7huHY+oqqasPBTVC4hjHY= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6053.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(83380400001)(38350700002)(86362001)(38100700002)(4326008)(8676002)(66556008)(66946007)(66476007)(316002)(2906002)(8936002)(5660300002)(6512007)(6506007)(26005)(1076003)(41300700001)(2616005)(186003)(52116002)(6666004)(6486002)(478600001); DIR:O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8QfyihYWduNgWigGwNSyPKaBbW0ROidoA7QhWpyuzsbj3WNTfGraZlx4n6B6gdw1vGviQSXYtfmkjq00yKq8TtR60uvpwg7t/5GAHpwAQcicYrn63PR8W59SVq37IZkiFx+CAXXLydH3EfAeeRSuVaec8X9S7O2kO0TxLnZ0KQCA0uDbXP2yu3rKnW6yqYKeIdsad2tGGfAGxNK6UwzVABJeaNGEALsM9AKkK6yoTpuJVhvKxrqfHY4QA9wIfCYcv67GmT2z9zvIh2VN90vJXW0gdUtS90xRIQBQBvMMXbS53f/maZOdLbueaQnoVeXCCb++Bhs8r3/rdJgKQpCLUyn2cEUQKH2Njd+d7MoTSqmLskCFYmEjWmPBWak/s7o4m87reIR/UwrBwOkTSlRvQvQ3/f3kzYtKycSdr3o74T5CCpZW8zvdGw2KQn1ma7/F7b6hlcQKoD3xuJPArwaH78Nb5PUu/t0zuI/SYQzDS67N4cw+rwwyiJi+qrBS6JOozMFEP27XCJtuSa4D2a+DSzf9mk6Wz0ydZR6c1Ic1gVQomgzzXRBFvfkzdcPLqZLHVW17MYtWYBTn X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: b148172b-d1ba-4701-44c3-08da7f4129da X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6053.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 04:38:27.9680 (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: I8EZulMkZ3KAg1COZiki9IUsqbKyoFNF8uI2z7gZuk21YI8/XFrfLBrCvDdzgT9ib7LZ2a/RRAUGdwFoAyj27A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7036 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org From: Ye Li According to measure on i.MX7ULP and i.MX8ULP, the RCS done needs about 3400us and 6700us respectively. So current 20us timeout is not enough. When reconfiguring is on-going, unlock and configure CS will lead to unknown result. Increase the wait timeout value to 10ms and check the return value of RCS wait to fix the issue Signed-off-by: Ye Li Signed-off-by: Alice Guo Reviewed-by: Jacky Bai Acked-by: Jason Liu --- drivers/watchdog/imx7ulp_wdt.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/watchdog/imx7ulp_wdt.c b/drivers/watchdog/imx7ulp_wdt.c index a0f6b8cea78f..12715c248688 100644 --- a/drivers/watchdog/imx7ulp_wdt.c +++ b/drivers/watchdog/imx7ulp_wdt.c @@ -39,7 +39,7 @@ #define DEFAULT_TIMEOUT 60 #define MAX_TIMEOUT 128 #define WDOG_CLOCK_RATE 1000 -#define WDOG_WAIT_TIMEOUT 20 +#define WDOG_WAIT_TIMEOUT 10000 static bool nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, bool, 0000); @@ -80,7 +80,7 @@ static int imx7ulp_wdt_enable(struct watchdog_device *wdog, bool enable) writel(val | WDOG_CS_EN, wdt->base + WDOG_CS); else writel(val & ~WDOG_CS_EN, wdt->base + WDOG_CS); - imx7ulp_wdt_wait(wdt->base, WDOG_CS_RCS); + ret = imx7ulp_wdt_wait(wdt->base, WDOG_CS_RCS); enable_out: local_irq_enable(); @@ -127,7 +127,9 @@ static int imx7ulp_wdt_set_timeout(struct watchdog_device *wdog, if (ret) goto timeout_out; writel(val, wdt->base + WDOG_TOVAL); - imx7ulp_wdt_wait(wdt->base, WDOG_CS_RCS); + ret = imx7ulp_wdt_wait(wdt->base, WDOG_CS_RCS); + if (ret) + goto timeout_out; wdog->timeout = timeout; From patchwork Tue Aug 16 04:36:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alice Guo \(OSS\)" X-Patchwork-Id: 598089 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78945C2BB41 for ; Tue, 16 Aug 2022 07:27:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231531AbiHPH1f (ORCPT ); Tue, 16 Aug 2022 03:27:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53952 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbiHPH1I (ORCPT ); Tue, 16 Aug 2022 03:27:08 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2062b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EDB61387F34; Mon, 15 Aug 2022 21:39:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jGjgCK1ZFT+2uUDKSD5/tLD7nta24qBBWD4+gV23gFUJ4X2QNYwZL3mYP3JFNiuguAS7wDFqg57uWh4Y3dPrTg0SQnkDVnQyB1v5q6I8nIu1isMEj54YhIbGPY81kWve0PTYqLUj0TwFGee9WcCE8RLUmXAsUSzhDBs/ZgHeScdilVkOoXTrB50p8FbXZcCGYsjCeF6GB91i2LpsuNWLG/OaS7VDgtg2d4DJTuTNxrFWxpRWeTPvXG/aGBvGIx6cMANMFYKvtdPtcTI3aq8uLvWYo3/LjWnRfUjYGVVkROfRCPV8HEpqq5q6FfhEp+9HWRdYr5sY7qyh3MZMSpLhkg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=IPe6kcN/NBW8g1cXcvCKdKblR9rCHhvtA00RdleoZhc=; b=P4+lVhuU9xjKu6zmb5InURSjeY9ove2irSoTdJFRBP7ei1j2dHoTFuVW8UBfskExxLbfedjo1i3Fyywzup77aCjG1cxKIaGd7I4DiMtIKvDC4seTw9MYuxlgj6pnV93WOlAkDZIEuYwkKZeGjCQfbL9DowFx30e9VRPdwJHWO5+5AuDOfMDNS3tQGxUTeNH3deIBlhiSIQmM8Z4xZsIkSIqwNX0qx5ln7dvLuJmgJZdtiCijxB2zTWYHz3QRN4N6DAU2EV5xtncHf/39z+zwpGMtDmPoyKT5S6+BMOswyO9FQ95kMZvUcPTYAZsHPWCpPjf3KH3GQTK6TGhZWH9Qew== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IPe6kcN/NBW8g1cXcvCKdKblR9rCHhvtA00RdleoZhc=; b=fBNxTLs17/pMah3+KnETEEzYm+DcDpDhIEyxHbP8ks1lRKu6TcErHGudN+C0l1YQNmgxJkUoLVqlRV1JN6lYT9jKbtOWrOFcULsBCD2vyeEHVto1UYJUwaYZVSD+bqANfBvnfHPtjJXN5YpDQYXG4ZAsb/drReJ/VKQt8/vocdM= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) by DB8PR04MB7036.eurprd04.prod.outlook.com (2603:10a6:10:12f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.28; Tue, 16 Aug 2022 04:38:32 +0000 Received: from AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c]) by AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c%3]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 04:38:32 +0000 From: "Alice Guo (OSS)" To: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] watchdog: imx7ulp_wdt: Handle wdog reconfigure failure Date: Tue, 16 Aug 2022 12:36:41 +0800 Message-Id: <20220816043643.26569-6-alice.guo@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220816043643.26569-1-alice.guo@oss.nxp.com> References: <20220816043643.26569-1-alice.guo@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:3:17::27) To AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 49ecbad4-de7e-4d81-5407-08da7f412c7f X-MS-TrafficTypeDiagnostic: DB8PR04MB7036:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hK02G+206QfsbnUmnWJD/+8j2ZunoQLSUBKjNTAxiCflSz3GnAAfcBgCyMpB1m1pHho8/l4WTrq71gV2bE3wl5/IVTvw4YbhvWZYKfoqFQbSqI6MvLGTvH7m4Ag60IM8/0cIX2w/UR0jFasy8aD26J8XwsSMPnsd4YWkrz61wFxKxLmdrWtDwn5TNgDqNdz19BJxa8UimmpDPJ6fXkia5tk6ZSwzhOgBZOtP9N1SgebbpCdxVbxBRrVpAY7qerNLWO1we/Bc+tC6ah22uXK+UEvtmlb/2Bz+Djl/Z0PUEM7hbBlJ8TzaVGUPUjTZi6XN0YXp11zLoR9uIl4msEMPULBmAS5b0tzmiDYajseHJyvPrsG7KghTdpDwbO6l0YxL6whwgI5iOkq+pyvop8L39DNAeYQfO9w8Dbb5+ul0baBRGcwQGcwLUpxR4o1oFM1pGdOGcYFJeZQEBTpaYzzoMDkBc0ltTDcwhOFgOoksqaDsmABraRkdLpTmuN6EAI9KVF+1TV888008jo3t3OM0lgRzYIbJ0lOOG0sDRLML7DBKEb25Acai1f4Z6zxmZ227MlgwWtQN+53OeO7sdhzp1rWpYt5Acpg1fF+mbDxnIPOfs4goyDRFGnbk9hc6eyYcwBiR8xxIvq2+zBXGEkTWAGZXNxCkgsIzgcYFM0fmDHYgshk3W/DMBCrxlUxj5wuoMqdbYA5mDGQ1LAzosykZbFvyK/kuYqfZHOWvUKCPkcdxohBmoTnilGXboJooTO3rhIr5LbMD9449eBqe8ivKrfEfxxDGRQ7ey7pguy7pcHw= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6053.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(83380400001)(38350700002)(86362001)(38100700002)(4326008)(8676002)(66556008)(66946007)(66476007)(316002)(2906002)(8936002)(5660300002)(6512007)(6506007)(26005)(1076003)(41300700001)(2616005)(186003)(52116002)(6666004)(6486002)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: rq1uxz80MThjU7Pn2Dn1c99DK2vbt8GCloRI9DJRpcFDNuBGfFGp0WOKr1asHHWRz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V93Ic+/CvttxytT2o/Zy3YJxPhV5G5EubiQ7KaCzYcsPChiXEaIWxWDPl58dpESfErIslMS4Ojcc1V+w4gShzOwltC3dKZvJtNkCiP27eg5zWAzCBFfcL5kIYL6ueolDNC/h8SBf8jTok6BQxM63CYpbRw9+CHc/346XXjoiW8MHCCfIVz02q5LxptXHeoIEwTQ91GmzH1poNhyrGDFzLo+/HIcSnujlv2Ra13rYwJeFnnbXo5xCoLhuxjgjgjtrU1ww5NQGDHMJKp1RjBxdqweht/+Bz0tQM2nHh6hl7vLM4uYOIrBNQmIXf1BsXtlbkhRy2t3DZRsJgqTpwcisKfTFPvIy28XRwDkQNPbnzRU3JCKsShIjRrMHcj/sjXemjxyJhtii7Cq4dSEjPCZWGMraDemwD0ZwILSrdxpv0RxQO1TEt2diWV4pIRF8veu8PBg51xVxIaaXDm0Oqe5d9 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 49ecbad4-de7e-4d81-5407-08da7f412c7f X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6053.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 04:38:32.5146 (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: vfv7IAmDlf/IRjAq/1A43SaleJE61HxKpAiZdZvN51ZzexVNm/TFmVlmQyZAdz1KdC4hceMYcX+miXyCdku8yQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7036 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org From: Ye Li Current driver may meet reconfigure failure caused by below reasons: 1. The wdog on iMX7ULP has different behavior after RCS valid. It needs to wait more than 2.5 wdog clock for clock sync before next reconfiguration, while imx8ulp wdog does not need such delay. 2. After unlock, there is 128 bus clock window opened for reconfiguration, but on iMX8ULP, the HW can't guarantee the latency. So it is possible the window is closed before the writing arrives to wdog. 3. If the PRES is enabled, the RCS valid time becomes x256 to the time of PRES disabled. It is about 1715ms on iMX8ULP. So We have to increase the RCS timeout and can't wait it in IRQ disabled. The patch updates the driver to handle failures 1. Using different wait for unlock and RCS. Unlock valid time is very short and only related to bus clock. It must be in IRQ disabled to avoid being interrupted in 128 clock window. But for RCS time, it is longer and ok for IRQ enabled. 2. Add retry for any reconfigure failure with default 5 times. 3. Add "fsl,imx8ulp-wdt" compatile string for iMX8ULP and afterwards platform which don't need more 2.5 wdog clock after RCS valid. For imx7ulp, add post delay of 2.5 clock after RCS valid. Signed-off-by: Ye Li Signed-off-by: Alice Guo Reviewed-by: Jacky Bai --- drivers/watchdog/imx7ulp_wdt.c | 163 ++++++++++++++++++++++++++------- 1 file changed, 129 insertions(+), 34 deletions(-) diff --git a/drivers/watchdog/imx7ulp_wdt.c b/drivers/watchdog/imx7ulp_wdt.c index 12715c248688..51eaaf24bd8f 100644 --- a/drivers/watchdog/imx7ulp_wdt.c +++ b/drivers/watchdog/imx7ulp_wdt.c @@ -14,7 +14,9 @@ #include #define WDOG_CS 0x0 +#define WDOG_CS_FLG BIT(14) #define WDOG_CS_CMD32EN BIT(13) +#define WDOG_CS_PRES BIT(12) #define WDOG_CS_ULK BIT(11) #define WDOG_CS_RCS BIT(10) #define LPO_CLK 0x1 @@ -39,7 +41,11 @@ #define DEFAULT_TIMEOUT 60 #define MAX_TIMEOUT 128 #define WDOG_CLOCK_RATE 1000 -#define WDOG_WAIT_TIMEOUT 10000 +#define WDOG_ULK_WAIT_TIMEOUT 1000 +#define WDOG_RCS_WAIT_TIMEOUT 10000 +#define WDOG_RCS_POST_WAIT 3000 + +#define RETRY_MAX 5 static bool nowayout = WATCHDOG_NOWAYOUT; module_param(nowayout, bool, 0000); @@ -50,40 +56,82 @@ struct imx7ulp_wdt_device { struct watchdog_device wdd; void __iomem *base; struct clk *clk; + bool post_rcs_wait; }; -static int imx7ulp_wdt_wait(void __iomem *base, u32 mask) +static int imx7ulp_wdt_wait_ulk(void __iomem *base) { u32 val = readl(base + WDOG_CS); - if (!(val & mask) && readl_poll_timeout_atomic(base + WDOG_CS, val, - val & mask, 0, - WDOG_WAIT_TIMEOUT)) + if (!(val & WDOG_CS_ULK) && + readl_poll_timeout_atomic(base + WDOG_CS, val, + val & WDOG_CS_ULK, 0, + WDOG_ULK_WAIT_TIMEOUT)) return -ETIMEDOUT; return 0; } -static int imx7ulp_wdt_enable(struct watchdog_device *wdog, bool enable) +static int imx7ulp_wdt_wait_rcs(struct imx7ulp_wdt_device *wdt) { - struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog); + int ret = 0; + u32 val = readl(wdt->base + WDOG_CS); + u64 timeout = (val & WDOG_CS_PRES) ? + WDOG_RCS_WAIT_TIMEOUT * 256 : WDOG_RCS_WAIT_TIMEOUT; + unsigned long wait_min = (val & WDOG_CS_PRES) ? + WDOG_RCS_POST_WAIT * 256 : WDOG_RCS_POST_WAIT; + if (!(val & WDOG_CS_RCS) && + readl_poll_timeout(wdt->base + WDOG_CS, val, val & WDOG_CS_RCS, 0, + timeout)) + ret = -ETIMEDOUT; + + /* Wait 2.5 clocks after RCS done */ + if (wdt->post_rcs_wait) + usleep_range(wait_min, wait_min + 2000); + + return ret; +} + +static int _imx7ulp_wdt_enable(struct imx7ulp_wdt_device *wdt, bool enable) +{ u32 val = readl(wdt->base + WDOG_CS); int ret; local_irq_disable(); writel(UNLOCK, wdt->base + WDOG_CNT); - ret = imx7ulp_wdt_wait(wdt->base, WDOG_CS_ULK); + ret = imx7ulp_wdt_wait_ulk(wdt->base); if (ret) goto enable_out; if (enable) writel(val | WDOG_CS_EN, wdt->base + WDOG_CS); else writel(val & ~WDOG_CS_EN, wdt->base + WDOG_CS); - ret = imx7ulp_wdt_wait(wdt->base, WDOG_CS_RCS); + + local_irq_enable(); + ret = imx7ulp_wdt_wait_rcs(wdt); + + return ret; enable_out: local_irq_enable(); + return ret; +} + +static int imx7ulp_wdt_enable(struct watchdog_device *wdog, bool enable) +{ + struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog); + int ret; + u32 val; + u32 loop = RETRY_MAX; + + do { + ret = _imx7ulp_wdt_enable(wdt, enable); + val = readl(wdt->base + WDOG_CS); + } while (--loop > 0 && ((!!(val & WDOG_CS_EN)) != enable || ret)); + + if (loop == 0) + return -EBUSY; return ret; } @@ -114,28 +162,44 @@ static int imx7ulp_wdt_stop(struct watchdog_device *wdog) return imx7ulp_wdt_enable(wdog, false); } -static int imx7ulp_wdt_set_timeout(struct watchdog_device *wdog, - unsigned int timeout) +static int _imx7ulp_wdt_set_timeout(struct imx7ulp_wdt_device *wdt, + unsigned int toval) { - struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog); - u32 val = WDOG_CLOCK_RATE * timeout; int ret; local_irq_disable(); writel(UNLOCK, wdt->base + WDOG_CNT); - ret = imx7ulp_wdt_wait(wdt->base, WDOG_CS_ULK); + ret = imx7ulp_wdt_wait_ulk(wdt->base); if (ret) goto timeout_out; - writel(val, wdt->base + WDOG_TOVAL); - ret = imx7ulp_wdt_wait(wdt->base, WDOG_CS_RCS); - if (ret) - goto timeout_out; - - wdog->timeout = timeout; + writel(toval, wdt->base + WDOG_TOVAL); + local_irq_enable(); + ret = imx7ulp_wdt_wait_rcs(wdt); + return ret; timeout_out: local_irq_enable(); + return ret; +} +static int imx7ulp_wdt_set_timeout(struct watchdog_device *wdog, + unsigned int timeout) +{ + struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog); + u32 toval = WDOG_CLOCK_RATE * timeout; + u32 val; + int ret; + u32 loop = RETRY_MAX; + + do { + ret = _imx7ulp_wdt_set_timeout(wdt, toval); + val = readl(wdt->base + WDOG_TOVAL); + } while (--loop > 0 && (val != toval || ret)); + + if (loop == 0) + return -EBUSY; + + wdog->timeout = timeout; return ret; } @@ -175,38 +239,59 @@ static const struct watchdog_info imx7ulp_wdt_info = { WDIOF_MAGICCLOSE, }; -static int imx7ulp_wdt_init(void __iomem *base, unsigned int timeout) +static int _imx7ulp_wdt_init(struct imx7ulp_wdt_device *wdt, unsigned int timeout, unsigned int cs) { u32 val; int ret; local_irq_disable(); - val = readl(base + WDOG_CS); + val = readl(wdt->base + WDOG_CS); if (val & WDOG_CS_CMD32EN) { - writel(UNLOCK, base + WDOG_CNT); + writel(UNLOCK, wdt->base + WDOG_CNT); } else { mb(); /* unlock the wdog for reconfiguration */ - writel_relaxed(UNLOCK_SEQ0, base + WDOG_CNT); - writel_relaxed(UNLOCK_SEQ1, base + WDOG_CNT); + writel_relaxed(UNLOCK_SEQ0, wdt->base + WDOG_CNT); + writel_relaxed(UNLOCK_SEQ1, wdt->base + WDOG_CNT); mb(); } - ret = imx7ulp_wdt_wait(base, WDOG_CS_ULK); + ret = imx7ulp_wdt_wait_ulk(wdt->base); if (ret) goto init_out; /* set an initial timeout value in TOVAL */ - writel(timeout, base + WDOG_TOVAL); - /* enable 32bit command sequence and reconfigure */ - val = WDOG_CS_CMD32EN | WDOG_CS_CLK | WDOG_CS_UPDATE | - WDOG_CS_WAIT | WDOG_CS_STOP; - writel(val, base + WDOG_CS); - imx7ulp_wdt_wait(base, WDOG_CS_RCS); + writel(timeout, wdt->base + WDOG_TOVAL); + writel(cs, wdt->base + WDOG_CS); + local_irq_enable(); + ret = imx7ulp_wdt_wait_rcs(wdt); + + return ret; init_out: local_irq_enable(); + return ret; +} + +static int imx7ulp_wdt_init(struct imx7ulp_wdt_device *wdt, unsigned int timeout) +{ + /* enable 32bit command sequence and reconfigure */ + u32 val = WDOG_CS_CMD32EN | WDOG_CS_CLK | WDOG_CS_UPDATE | + WDOG_CS_WAIT | WDOG_CS_STOP; + u32 cs, toval; + int ret; + u32 loop = RETRY_MAX; + + do { + ret = _imx7ulp_wdt_init(wdt, timeout, val); + toval = readl(wdt->base + WDOG_TOVAL); + cs = readl(wdt->base + WDOG_CS); + cs &= ~(WDOG_CS_FLG | WDOG_CS_ULK | WDOG_CS_RCS); + } while (--loop > 0 && (cs != val || toval != timeout || ret)); + + if (loop == 0) + return -EBUSY; return ret; } @@ -239,6 +324,15 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev) return PTR_ERR(imx7ulp_wdt->clk); } + imx7ulp_wdt->post_rcs_wait = true; + if (of_device_is_compatible(dev->of_node, + "fsl,imx8ulp-wdt")) { + dev_info(dev, "imx8ulp wdt probe\n"); + imx7ulp_wdt->post_rcs_wait = false; + } else { + dev_info(dev, "imx7ulp wdt probe\n"); + } + ret = clk_prepare_enable(imx7ulp_wdt->clk); if (ret) return ret; @@ -259,7 +353,7 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev) watchdog_stop_on_reboot(wdog); watchdog_stop_on_unregister(wdog); watchdog_set_drvdata(wdog, imx7ulp_wdt); - ret = imx7ulp_wdt_init(imx7ulp_wdt->base, wdog->timeout * WDOG_CLOCK_RATE); + ret = imx7ulp_wdt_init(imx7ulp_wdt, wdog->timeout * WDOG_CLOCK_RATE); if (ret) return ret; @@ -289,7 +383,7 @@ static int __maybe_unused imx7ulp_wdt_resume_noirq(struct device *dev) return ret; if (imx7ulp_wdt_is_enabled(imx7ulp_wdt->base)) - imx7ulp_wdt_init(imx7ulp_wdt->base, timeout); + imx7ulp_wdt_init(imx7ulp_wdt, timeout); if (watchdog_active(&imx7ulp_wdt->wdd)) imx7ulp_wdt_start(&imx7ulp_wdt->wdd); @@ -303,6 +397,7 @@ static const struct dev_pm_ops imx7ulp_wdt_pm_ops = { }; static const struct of_device_id imx7ulp_wdt_dt_ids[] = { + { .compatible = "fsl,imx8ulp-wdt", }, { .compatible = "fsl,imx7ulp-wdt", }, { /* sentinel */ } }; From patchwork Tue Aug 16 04:36:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alice Guo \(OSS\)" X-Patchwork-Id: 598090 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4FD4FC3F6B0 for ; Tue, 16 Aug 2022 07:10:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231712AbiHPHKG (ORCPT ); Tue, 16 Aug 2022 03:10:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231793AbiHPHJm (ORCPT ); Tue, 16 Aug 2022 03:09:42 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2062b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7112F388E11; Mon, 15 Aug 2022 21:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W6RjiUr50TrAunoquwR3lNAH1o/UPVlZojuxRetRbVaDWFXyqXp8Ha/9zqQytFa85zG4LDpjypnprtBgrYOnebWNa7XvwS8hjGX508HXfhw+pMnIuEanxqjLVsXJ3QBfkWA8y9NyHNU82UCNPPznWjHqXoPYia4wQkKqEOZV/l60YDhb5YGcnLNYixHnnjcWTEBcoDsGwBT3jZ8lJuX6a/FQUB3UxtK/Z4u4zrXSuWGysMktQGwShJ3kDlsRBxCp4c/SfC65Qh5i5mBA8ZNSFueiJ/MerlWyzvhrpxI7/pAMMIFd8EGlOGBhiIp/0ZZUKqQSjXq3e5Ln/+uJFyJhsQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=HN7RZu25ghqhBP/V91DHU17DP4GGuZaqlXLciTMYaKY=; b=F4BRMIh/o0+QsKDtf9cOLtg++GbrEdQ2ZVKhfn9MZhEZdKT3yDRTUGVIJrbs2axz9TKXa4rqVYbNd1LBCE6vV1K4N+qrVqUuIvDYa/JJdwYXwZyr0l+3V7U4snT3wZhGImfHC/Z0BiUddBL2+LNfe3ts0Yv1Us8ME46oDT7hQdImmQ5O3ksGkRQsLYmxbgs4lSs6g5uaWigIobfZ+AhdErLsRN6gQtVGq3ILekR2F62OM7ja5cdtQkCp6JpfqxECkR9aoTw7bT+Mv5Caistr/RTmVa/jvX/3EpNorgSVZGequjyf6QnWMv3jd6EkdUKOFkoKHsnA/2MLJoWr7pV7XA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HN7RZu25ghqhBP/V91DHU17DP4GGuZaqlXLciTMYaKY=; b=N2dRfH51Qo7VTQm8J9QpcYq3nuyBMQdRTvGngBhVT1MeStF9L/NwhjJ+K7Q2zVLDiHRUUCmdY079P+1qjm6jztq0tcZNTkGkplyoZxkSqoTU8EGnzliY5jx1eT8CKI4rJP/lUNJMA6VvtwOMH55HYo8XQeRZW59T9zsU+wUiAKY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) by DB8PR04MB7036.eurprd04.prod.outlook.com (2603:10a6:10:12f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.28; Tue, 16 Aug 2022 04:38:39 +0000 Received: from AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c]) by AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c%3]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 04:38:39 +0000 From: "Alice Guo (OSS)" To: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] watchdog: imx7ulp_wdt: init wdog when it was active Date: Tue, 16 Aug 2022 12:36:42 +0800 Message-Id: <20220816043643.26569-7-alice.guo@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220816043643.26569-1-alice.guo@oss.nxp.com> References: <20220816043643.26569-1-alice.guo@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:3:17::27) To AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6bf71125-59a0-4349-d45c-08da7f4130a1 X-MS-TrafficTypeDiagnostic: DB8PR04MB7036:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gXs/QVch9fuPt/5ciCERqtCgXsIfZWw1KexpDJzu2Ku48u3E8DI8CvXuWXnWfPAJqfbf8UBZK3Wi57oGFhSRx17yEc7T/4qrj3zYvfXGcdR1rGxIWhA5qJPb+hbOj6NpSq4xFyMWv165wa73Oh86lJtX9MrXAX295K7hZfikIiYkepeLGrxAUke5aD2z6lk+pqXrCLl+nGDhlUm/JY1w/1X+fhTqbVtXZPo4+vNDwNgFC3OLP7WC2jpPT9mbUDwdBn1QwEa8ZS8TOM6RlUF856HzjIDINGdYP23NgEJ1Lz3Iu6ZZXCcFBwU5UTm2qcLRfMoXKn2P64pIGtbd+0ceO5Abfu3wRvZ9swTzb/XkWOWnKQXJODpzwwbkPS2PE2Le0OTqfAXjJVVvua38UP3gjRV3ruHXR3lpcAtIyZw0XdvyDEtgSofCXhzqbY9QX2Bmf0A27UsCnIKFD6YUBpORameRqANhYaunPKhUqMC91KcpGRHPqWZrlWOmq7Q6SpkIMqVU+HVRwxOEcJB5CugZbxDSydglSjSIpFyQzHnLiE/lAVuIifKtvO3Y1HuNzTVsOylDhzBfwiiPi8YiUffjgBaHVxWXOf6zie7lIlMXrQ5jPsGbkfNmCWsIstpNhv+7PVBLHos5eBwedTmECafNbi6nCNqcg/kK1GoYmuEZ6nrM2IEp1Cut0gN7Xki4fMV+LSCUYLCfazOrzXwbw8HRbAQHbxD6P71SM5iiXi5hr/15TGoa4gEeCXrU0TolJeJGb5izgsbYnTu8zYc6lQjaGiLHg+o9SbmpShEM6CyZQE0= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6053.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(83380400001)(38350700002)(86362001)(38100700002)(4326008)(8676002)(66556008)(66946007)(66476007)(316002)(2906002)(8936002)(5660300002)(6512007)(6506007)(26005)(1076003)(41300700001)(2616005)(186003)(52116002)(6666004)(6486002)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tHkSgZj4/9dGGv+8XQHHGPrQbaEl5fzXtw0wYnfFWoS8NRS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LFGg58QZheCQujfQ9WqsCmykwLOxkYDViIudF7DVA2UdTAMwvN9/ok6S2gVgU6dM1u16110X7WRWsmQya/Ow7L9Fs2nposPqqGVkM1eZv08ZdSsES3KnURTEuXfPvpVAACtzk1acjRnZh8N5yavuylOkl9r9NuZ5Fzn4DY0o+HPS0qasNl9dZOQ3LuUIRGjWCJ3hJ26e1Zo+Uc+WnxAjFBchZ1bkm/yjJ7YW3dNOnQQhFP1PlTH3p/fh16ErlhFZghI4gFIO7wSlhUes6We7mds2EgzuaUvRbhL5srxSGryhtjAfcJK6fwj7Onub2cG7KMKgoBqNKqBRPPH5rUhZSEMjHxYNzTBAVJgJ5mO+tiepG+6j11SjcFz694PxWoLzB8mnTKxiolIHZ1+1m3hGH0044s2kgq7fFs8hOi0RmjyIeD9VFanHD/BLU2BWaqSdTLENIhOpPb3o9CiqVsDw3P2EuETcRHOHG X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bf71125-59a0-4349-d45c-08da7f4130a1 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6053.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 04:38:39.3422 (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: Az8rl9YUM+EnMd/LlqxwgvYVN/o0ZBe5dVbaTtVvZy3Bskqqmq8xNkOYFV5yupQ2DSFF3/ZJi//UbbX0Qs7cvg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7036 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org From: Jason Liu Paired with suspend, we can only init wdog again when it was active and ping it once to avoid the watchdog timeout after it resumed. Signed-off-by: Jason Liu Signed-off-by: Alice Guo Reviewed-by: Ye Li Reviewed-by: Jacky Bai Tested-by: Jacky Bai --- drivers/watchdog/imx7ulp_wdt.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/drivers/watchdog/imx7ulp_wdt.c b/drivers/watchdog/imx7ulp_wdt.c index 51eaaf24bd8f..58508f69d933 100644 --- a/drivers/watchdog/imx7ulp_wdt.c +++ b/drivers/watchdog/imx7ulp_wdt.c @@ -136,13 +136,6 @@ static int imx7ulp_wdt_enable(struct watchdog_device *wdog, bool enable) return ret; } -static bool imx7ulp_wdt_is_enabled(void __iomem *base) -{ - u32 val = readl(base + WDOG_CS); - - return val & WDOG_CS_EN; -} - static int imx7ulp_wdt_ping(struct watchdog_device *wdog) { struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog); @@ -382,11 +375,11 @@ static int __maybe_unused imx7ulp_wdt_resume_noirq(struct device *dev) if (ret) return ret; - if (imx7ulp_wdt_is_enabled(imx7ulp_wdt->base)) + if (watchdog_active(&imx7ulp_wdt->wdd)) { imx7ulp_wdt_init(imx7ulp_wdt, timeout); - - if (watchdog_active(&imx7ulp_wdt->wdd)) imx7ulp_wdt_start(&imx7ulp_wdt->wdd); + imx7ulp_wdt_ping(&imx7ulp_wdt->wdd); + } return 0; } From patchwork Tue Aug 16 04:36:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Alice Guo \(OSS\)" X-Patchwork-Id: 597829 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ECC5FC2BB41 for ; Tue, 16 Aug 2022 07:09:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231638AbiHPHJs (ORCPT ); Tue, 16 Aug 2022 03:09:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59062 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231613AbiHPHJd (ORCPT ); Tue, 16 Aug 2022 03:09:33 -0400 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2062b.outbound.protection.outlook.com [IPv6:2a01:111:f400:7d00::62b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA3D238A98F; Mon, 15 Aug 2022 21:39:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gZoCCQJ7yiIdc4SzaWQ8+lraF51DmkbNfv2qwoca5ZtIEP5HXRJZvLmzhjEndDfNyCrgZNISMxGYWcIJQONDZij+G05Ffyad8MFtElIaVY2U8FPFSBbLIAMr6wCwSiJhbbKKmGlPLUBXO9LFDlwsaHNqK5dqY3C0b6Oi5jGeSh3MB/SOYvGX8Eo1d7lbUANN4prNCbn3Ztk34pKNmOiRFCxwFNd/weFsm+DRz6J6bhhyy64M9HmhDU8UtY8hDsXHNYHlCMS81SqELT7MCBG+QO2hYv+igCv6jc3DroNHok7LwX2My57MPfHCmR2NRiM2mMGJkp+qfIJvx5fbhiv9zg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6bwa+IDV+1k34kBc/2efKKAgqy3sBdoQjBKkNiHtb3k=; b=BDr0Rr5wU4xoD/z7ABs4NMaXkY+gCo4oYzh/SOG0MahD+qjycwj3N+TYC041gfxnzbUk7TXHWurR563n6p011B0X/MI+1Ce3VBavyz0o1CT16A9+s7F+iD4ihwTWvQvCVR0o1FyYEx7zM1V53kBTo1o3ilwEX8wgx7KWRe8QMAOGUTqWx3/utdxiM530L0e1ZYB5LFuFTu1IcDNRBvTjtAqsskxOcHWjzycSNYMKCyrqZPrV1nX8DBYHOeHrsGxaqBkTYVEtSXqxAPkd3PjReOAFMVvxXIwQkSjiCmy2GOiklBe6xnB9Ttf4KzKY8qP/mFfKUKZg5DPLsxTr1vtzLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6bwa+IDV+1k34kBc/2efKKAgqy3sBdoQjBKkNiHtb3k=; b=W5htE8H3x3p8dHE9CoguMSbIELk3EXfkiMMQusJlTfvbhXurmo0LU7GfOBOC4n3dd6pu/5hcI04ouAwt9oXJcAn1aK8x8ThHeBAjDwE5HL0Kn4AXn+rFTudhCRBoIWXG0yKoC1kftScXBiXy+2YO7GSKUSSDV+xWFIcnbaAAypA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) by DB8PR04MB7036.eurprd04.prod.outlook.com (2603:10a6:10:12f::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.28; Tue, 16 Aug 2022 04:38:43 +0000 Received: from AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c]) by AM6PR04MB6053.eurprd04.prod.outlook.com ([fe80::6cd5:f11c:4e5c:d79c%3]) with mapi id 15.20.5525.011; Tue, 16 Aug 2022 04:38:43 +0000 From: "Alice Guo (OSS)" To: wim@linux-watchdog.org, linux@roeck-us.net, shawnguo@kernel.org, s.hauer@pengutronix.de, festevam@gmail.com Cc: kernel@pengutronix.de, linux-imx@nxp.com, linux-watchdog@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/7] watchdog: imx93: add watchdog timer on imx93 Date: Tue, 16 Aug 2022 12:36:43 +0800 Message-Id: <20220816043643.26569-8-alice.guo@oss.nxp.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220816043643.26569-1-alice.guo@oss.nxp.com> References: <20220816043643.26569-1-alice.guo@oss.nxp.com> X-ClientProxiedBy: SG2PR02CA0015.apcprd02.prod.outlook.com (2603:1096:3:17::27) To AM6PR04MB6053.eurprd04.prod.outlook.com (2603:10a6:20b:b9::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4de274ab-0357-4cef-6cbb-08da7f413350 X-MS-TrafficTypeDiagnostic: DB8PR04MB7036:EE_ X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: BlAubPDZ8ukH47IiNKMkSi2Cm2I3Ndi0gmRoZdaUcnquRM6YePTXXUfR1CwcRf038Ya6iSQ/RX45nuxKLYqrppqbwWjm7b7zJfbictgJF79tfa3BOWUXmOEEmiEzKAQBJvhHcagBSx1twL+0ieqkplmI5uwoBA3/Q0CdG5bT8Pw5t0wJjcJeolbO0Moqapx6QZU2WsiXesZV8PY+gri7Kym6iHGx8sOmpt0L+38vFwkofnS4EZ1g/XSbhNApp9In3fL9fvmhq6Cm1iaOyjqixLfcmQLIQP+PPuRqIqLOGBirIbq8+cRV4bQMGvwql95uLjLaogfJGmCcYCF1iBnQgGd5nYv956rDWLeBlnNbO5EspYWa3UMqLfNLam//1pWPByGYbr4nwcSLFLXaDa/CAysUCYrO1bMIZH3wqhYeNKSAOzygTZHBvyCBC8io0PcwOQyeLQZXozUHTYdVM4LkHlrpZnzdmp0QUIK+RjV46WUbFmkn/6fW298SY0s92rlM/Q6bKLQ2CxB1RDJJLMj2UP6i7A9CrqzHU7h/08sOBp3ThtIPFTjwfcYnQqzyxjSEmuSHY2JRZdRe6AaR5leLiDOc5aALRI7aNProtgaVT4vzVsiZfzsqnl//0546YhtiwwqFQeYnu8zvZ47Wzq4OIbjXWO4WtgSytpROZs5uJR2qGX2QXdPkK9T1qgQBBZjC0UTKAoAMVUCMAgtHyxPNRi3tGiJSxiTNfRthWwHhX81lwbVYjl/dQ51Iuc54AD6kYQ2nfjbBGyRY7zh4jfxg05RctzGeZ8Nr0uNyHACniNM= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR04MB6053.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230016)(4636009)(346002)(366004)(396003)(39860400002)(376002)(136003)(83380400001)(38350700002)(86362001)(38100700002)(4326008)(8676002)(66556008)(66946007)(66476007)(316002)(2906002)(8936002)(5660300002)(6512007)(6506007)(26005)(1076003)(41300700001)(2616005)(186003)(52116002)(6486002)(478600001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: g1WZ8/oFu5ClsEDGmYXW9EpL+xz+lXH1qgzTtE0+mOs9a+y4EKBU+ldwIj6TXkxHuWaQJbP28QY65dfHw6e2LDu9TCRowg4vkRtQOtqrwE+1uIHZaz6PafChkE2lkt6f/5hJVa329Tnmf1u1E9ydCGBQAJ324HCa1fKFw+wRIOI/1A7FNNsujwBpIP7dI2VqpDVSS48V5vsENq77uOPtLdrO1QAbGjyrO+cksPqNiqE8gBjXRN46JNYrFheaXI7ngtTepVSK3HTunfj5Ya94vS3XvtxuDmIdo3ufuS+g15tlQ5J7TcXOWexRKiP5dWZQ5jHiBTS/dMscGbFfVToVC2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DW6lTFwJJbfXX1uQXuAFBiOLFjoa5xuRtAvf/NHGtndj2ESU+nk3qK3CHV5aIXQQSsUKJ2VyqOQO6Yt+r1VDHT+V3MmBvUucTz+Nz92h/xS0IYzg48xBG2s4Z2UkWsUzFMULY1uIQ2lJEK+PPyCdIBg9d+iPCNCY2uYA1ilcRZJSTN5Vz X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4de274ab-0357-4cef-6cbb-08da7f413350 X-MS-Exchange-CrossTenant-AuthSource: AM6PR04MB6053.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 04:38:43.8106 (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: IYmG6bZed++TSUnF70LDAIU3+FENLk/bMLzDR1ueH8GVPol/WnYqunSJtoUTDA3lVvSVhxRLTyWOzdcup1KlzQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR04MB7036 Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org From: Alice Guo The WDOG clocks are sourced from lpo_clk, and lpo_clk is the fixed 32KHz. TOVAL contains the 16-bit value used to set the timeout period of the watchdog. When the timeout period exceeds 2 seconds, the value written to the TOVAL register is larger than 16-bit can represent. Enabling watchdog prescaler can solve this problem. Two points need to be aware of: 1. watchdog prescaler enables a fixed 256 pre-scaling of watchdog counter reference clock 2. reconfiguration takes about 55ms on imx93 Reviewed-by: Jacky Bai Signed-off-by: Alice Guo --- drivers/watchdog/imx7ulp_wdt.c | 33 ++++++++++++++++++++++++++++----- 1 file changed, 28 insertions(+), 5 deletions(-) diff --git a/drivers/watchdog/imx7ulp_wdt.c b/drivers/watchdog/imx7ulp_wdt.c index 58508f69d933..4694aa4b8cfb 100644 --- a/drivers/watchdog/imx7ulp_wdt.c +++ b/drivers/watchdog/imx7ulp_wdt.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -52,11 +53,17 @@ module_param(nowayout, bool, 0000); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); +struct imx_wdt_hw_feature { + bool prescaler_enable; + u32 wdog_clock_rate; +}; + struct imx7ulp_wdt_device { struct watchdog_device wdd; void __iomem *base; struct clk *clk; bool post_rcs_wait; + const struct imx_wdt_hw_feature *hw; }; static int imx7ulp_wdt_wait_ulk(void __iomem *base) @@ -179,7 +186,7 @@ static int imx7ulp_wdt_set_timeout(struct watchdog_device *wdog, unsigned int timeout) { struct imx7ulp_wdt_device *wdt = watchdog_get_drvdata(wdog); - u32 toval = WDOG_CLOCK_RATE * timeout; + u32 toval = wdt->hw->wdog_clock_rate * timeout; u32 val; int ret; u32 loop = RETRY_MAX; @@ -276,6 +283,9 @@ static int imx7ulp_wdt_init(struct imx7ulp_wdt_device *wdt, unsigned int timeout int ret; u32 loop = RETRY_MAX; + if (wdt->hw->prescaler_enable) + val |= WDOG_CS_PRES; + do { ret = _imx7ulp_wdt_init(wdt, timeout, val); toval = readl(wdt->base + WDOG_TOVAL); @@ -346,7 +356,9 @@ static int imx7ulp_wdt_probe(struct platform_device *pdev) watchdog_stop_on_reboot(wdog); watchdog_stop_on_unregister(wdog); watchdog_set_drvdata(wdog, imx7ulp_wdt); - ret = imx7ulp_wdt_init(imx7ulp_wdt, wdog->timeout * WDOG_CLOCK_RATE); + + imx7ulp_wdt->hw = of_device_get_match_data(dev); + ret = imx7ulp_wdt_init(imx7ulp_wdt, wdog->timeout * imx7ulp_wdt->hw->wdog_clock_rate); if (ret) return ret; @@ -368,7 +380,7 @@ static int __maybe_unused imx7ulp_wdt_suspend_noirq(struct device *dev) static int __maybe_unused imx7ulp_wdt_resume_noirq(struct device *dev) { struct imx7ulp_wdt_device *imx7ulp_wdt = dev_get_drvdata(dev); - u32 timeout = imx7ulp_wdt->wdd.timeout * WDOG_CLOCK_RATE; + u32 timeout = imx7ulp_wdt->wdd.timeout * imx7ulp_wdt->hw->wdog_clock_rate; int ret; ret = clk_prepare_enable(imx7ulp_wdt->clk); @@ -389,9 +401,20 @@ static const struct dev_pm_ops imx7ulp_wdt_pm_ops = { imx7ulp_wdt_resume_noirq) }; +static const struct imx_wdt_hw_feature imx7ulp_wdt_hw = { + .prescaler_enable = false, + .wdog_clock_rate = 1000, +}; + +static const struct imx_wdt_hw_feature imx93_wdt_hw = { + .prescaler_enable = true, + .wdog_clock_rate = 125, +}; + static const struct of_device_id imx7ulp_wdt_dt_ids[] = { - { .compatible = "fsl,imx8ulp-wdt", }, - { .compatible = "fsl,imx7ulp-wdt", }, + { .compatible = "fsl,imx8ulp-wdt", .data = &imx7ulp_wdt_hw, }, + { .compatible = "fsl,imx7ulp-wdt", .data = &imx7ulp_wdt_hw, }, + { .compatible = "fsl,imx93-wdt", .data = &imx93_wdt_hw, }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, imx7ulp_wdt_dt_ids);