From patchwork Fri Mar 20 10:52:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1258836 X-Patchwork-Delegate: mario.six@gdsys.cc Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.a=rsa-sha256 header.s=selector1 header.b=D1wQSYCo; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 48kLGr6gPtz9sSL for ; Fri, 20 Mar 2020 21:53:24 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 7920781662; Fri, 20 Mar 2020 11:53:09 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=prevas.dk header.i=@prevas.dk header.b="D1wQSYCo"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0A360800DF; Fri, 20 Mar 2020 11:53:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FORGED_SPF_HELO,MSGID_FROM_MTA_HEADER, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-am5eur02on072c.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe07::72c]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 83657800DF for ; Fri, 20 Mar 2020 11:53:03 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=prevas.dk Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=rasmus.villemoes@prevas.dk ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=NSp/FoC3UxpTne41ljE2tBStmHv2ROedYMG3Dv+g1cQiFG/B7kHn2eAC6CtYlGKGqs133C4GE2pGagQmftw13hGoOegqHrlKe81g6Ywqurtr/DlAdH0lqYOAwxyC64zeNpTmtLL+t5zCYTs9LLU6MESKcuy20R6YXgVvCeukB9fczyx2uNF60jKYdwMCiYCHypS0P2/jy2xmXSHdfUUGcqQZnm7Lpaots0/lVfIJ5VJJTKF+Ygc0VJOJgM0iHNYQcDVxEW0KhKTUOmTFffo4j4DXQgmMNyQ7aUYnHL/OiggV6/P7crwpiqAW6exd6Fj3+RKtwGH4wz/CLeF+v3hUdQ== 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=exgZ8vdEICJ+eXRzAfZS9dDH0tpJ1DDND868cxVwi90=; b=VujKpsOYSTPSkWiEOqjwfrzRK7HPLW6CDoJkQy82ZKDo7aMAELO1JA/TIzuXpNiyfZf07KfU+SKCQWqEQnwcQ7rTKYN/ASg7go+3CgmssT1dDyZc89+BTBUrU4DMkkLFbxEZY/uSa/DYq4375vmguWq/oZXjQNkjmcqrwHN596THOjWDZublGfD+LJtW0FaEkv0bbQtva7rf0tSXRfZL6dkVvhaU3Ru8Oq/EW/CenelmJxZtbFd8HrLYYPBRz2KbehE/YZTzeogyQ7GtAZ2vN3I/H5xAis8Pl0ECvLqilu8tuGvQBKnpz9sc+qWVixRD5J93UQ9oyLYOcpTPB6AkVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=prevas.dk; dmarc=pass action=none header.from=prevas.dk; dkim=pass header.d=prevas.dk; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.dk; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=exgZ8vdEICJ+eXRzAfZS9dDH0tpJ1DDND868cxVwi90=; b=D1wQSYCokS/wEpThwYXtyMXRB/DvyCoksLP5miHaoPU1jrBeqGmxyHBAmNcMnFWABPH56n8FksDstNUuQv3Vr7ZV09wFkm/cS16qMOqCxrjruWJOz8BsOo4kC0A4linZXfXQvSLvv+1PNThIQxMV4faIanOB7CVl1NLOPAFvaLU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=rasmus.villemoes@prevas.dk; Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (20.178.126.85) by VI1PR10MB2493.EURPRD10.PROD.OUTLOOK.COM (20.177.62.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.20; Fri, 20 Mar 2020 10:52:57 +0000 Received: from VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7]) by VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM ([fe80::e58f:1097:b71d:32c7%5]) with mapi id 15.20.2835.017; Fri, 20 Mar 2020 10:52:57 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Wolfgang Denk , Christophe Leroy , Mario Six , Huan Wang , Rasmus Villemoes Subject: [PATCH v3 2/2] allow opting out of WATCHDOG_RESET() from timer interrupt Date: Fri, 20 Mar 2020 11:52:48 +0100 Message-Id: <20200320105248.24518-2-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20200320105248.24518-1-rasmus.villemoes@prevas.dk> References: <20200320105248.24518-1-rasmus.villemoes@prevas.dk> X-ClientProxiedBy: BEXP281CA0013.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::23) To VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::21) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (5.186.116.45) by BEXP281CA0013.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2835.18 via Frontend Transport; Fri, 20 Mar 2020 10:52:56 +0000 X-Mailer: git-send-email 2.23.0 X-Originating-IP: [5.186.116.45] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b75c6636-fd91-418c-5d44-08d7ccbcd947 X-MS-TrafficTypeDiagnostic: VI1PR10MB2493: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-Forefront-PRVS: 03484C0ABF X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(366004)(396003)(376002)(136003)(39850400004)(346002)(199004)(186003)(478600001)(26005)(86362001)(16526019)(4326008)(6916009)(54906003)(6486002)(6666004)(316002)(66946007)(6512007)(66476007)(6506007)(66556008)(81166006)(2616005)(8936002)(8676002)(81156014)(8976002)(2906002)(956004)(36756003)(44832011)(1076003)(5660300002)(52116002)(107886003); DIR:OUT; SFP:1102; SCL:1; SRVR:VI1PR10MB2493; H:VI1PR10MB2765.EURPRD10.PROD.OUTLOOK.COM; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; Received-SPF: None (protection.outlook.com: prevas.dk does not designate permitted sender hosts) X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: HPOfHOl+vuUhu66udiAsl8vEV/ChiTeUMHuoIPZJWIv16xFfCHegKgjbPByx3Si/qVOmvmb0pPAlEnP5gf16Ydby0MelGXrYOH+2r/CC9XnlS87S0TX6vJr3Gu2oDDzl4ZPOUAiw0Kl2TstEP1y8Jm9nAn7TknpbI63/VtVQpG16v0Abd1GyOa8/ejQE9bTM5ABYKNAYr+mNG/+sOICj63Rh2WZJT/w0YLWYQG1KvSREzCIcj9H7r0aLa2TmheTSkP9pkHqmdeqTTvSJ4F87T6t2OMd3lXrp6Y8z0PYy89LgaoW6pZdvR5nc4wnriMo+ElI8y64Bkcz5Ku7aeoULBBC4Ui8Dg0FcFojm2G5x41seG1JxQRtuNMV2uvJf9nYGc/5NmWdbWIHZyL311SC2zyCMmDq+rwrM5fpwZRyfjXsIlNrxz/E1a8aiM4t5S1Uo X-MS-Exchange-AntiSpam-MessageData: cstvN/ZHm4SxX+E8uB/BzUQGvKs/Jz/AvnLuaRSk1ObJTPb+8pUKzYWBoDoRuScPEhjv0SQ8N1nDcKS+fTQzhoQJj/OnToNOuyBziBZkCgHb/IA4M+G7/QWTfdIvQaCXdFGvNRwCXdsdYcq+nCwQ7w== X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: b75c6636-fd91-418c-5d44-08d7ccbcd947 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Mar 2020 10:52:56.8684 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: d350cf71-778d-4780-88f5-071a4cb1ed61 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: tbdbo7il8rwSsEBc6JYr5b11ybUYXtWEIV2t7242czWUsaBM2+b95O3R+1k5wHB2qMyzkujmryMehBZS6kimq0w5GL69yV1/CsjLkonFO+E= X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2493 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.30rc1 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.2 at phobos.denx.de X-Virus-Status: Clean When using CONFIG_(SPL_)WDT, the watchdog_reset function is a lot more complicated than just poking a few SOC-specific registers - it involves accessing all kinds of global data, and if the interrupt happens at the wrong time (say, in the middle of an WATCHDOG_RESET() call from ordinary code), that can end up corrupting said global data. Also, having WATCHDOG_RESET() called automatically from the timer interrupt runs counter to the idea of a watchdog device - if the board runs into an infinite loops with interrupts still enabled, the watchdog will never fire. Allow the board to opt out of this behaviour by setting CONFIG_SYS_WATCHDOG_FREQ to 0 - as that setting is currently nonsensical, it cannot affect any existing boards. Add documentation for both the existing and extended meaning of CONFIG_SYS_WATCHDOG_FREQ. Signed-off-by: Rasmus Villemoes --- README | 9 +++++++++ arch/m68k/lib/time.c | 2 +- arch/powerpc/lib/interrupts.c | 2 +- drivers/timer/mpc83xx_timer.c | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README b/README index 8cfa92fac9..79e8da4adc 100644 --- a/README +++ b/README @@ -768,6 +768,15 @@ The following options need to be configured: SoC, then define this variable and provide board specific code for the "hw_watchdog_reset" function. + CONFIG_SYS_WATCHDOG_FREQ + Some platforms automatically call WATCHDOG_RESET() + from the timer interrupt handler every + CONFIG_SYS_WATCHDOG_FREQ interrupts. If not set by the + board configuration file, a default of CONFIG_SYS_HZ/2 + (i.e. 500) is used. Setting CONFIG_SYS_WATCHDOG_FREQ + to 0 disables calling WATCHDOG_RESET() from the timer + interrupt. + - Real-Time Clock: When CONFIG_CMD_DATE is selected, the type of the RTC diff --git a/arch/m68k/lib/time.c b/arch/m68k/lib/time.c index bde1f4c228..038019ff36 100644 --- a/arch/m68k/lib/time.c +++ b/arch/m68k/lib/time.c @@ -68,7 +68,7 @@ void dtimer_interrupt(void *not_used) timestamp++; #if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG) - if ((timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0) { + if (CONFIG_SYS_WATCHDOG_FREQ && (timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0) { WATCHDOG_RESET (); } #endif /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */ diff --git a/arch/powerpc/lib/interrupts.c b/arch/powerpc/lib/interrupts.c index 64ee0cc210..23ac5bca1e 100644 --- a/arch/powerpc/lib/interrupts.c +++ b/arch/powerpc/lib/interrupts.c @@ -79,7 +79,7 @@ void timer_interrupt(struct pt_regs *regs) timestamp++; #if defined(CONFIG_WATCHDOG) || defined (CONFIG_HW_WATCHDOG) - if ((timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0) + if (CONFIG_SYS_WATCHDOG_FREQ && (timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0) WATCHDOG_RESET (); #endif /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */ diff --git a/drivers/timer/mpc83xx_timer.c b/drivers/timer/mpc83xx_timer.c index da516c9d74..b85f10ad99 100644 --- a/drivers/timer/mpc83xx_timer.c +++ b/drivers/timer/mpc83xx_timer.c @@ -171,7 +171,7 @@ void timer_interrupt(struct pt_regs *regs) priv->timestamp++; #if defined(CONFIG_WATCHDOG) || defined(CONFIG_HW_WATCHDOG) - if ((priv->timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0) + if (CONFIG_SYS_WATCHDOG_FREQ && (priv->timestamp % (CONFIG_SYS_WATCHDOG_FREQ)) == 0) WATCHDOG_RESET(); #endif /* CONFIG_WATCHDOG || CONFIG_HW_WATCHDOG */