From patchwork Thu May 27 22:00:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 1484901 X-Patchwork-Delegate: sr@denx.de 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=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) 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=eRwHPqZ/; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (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 4Frhcw1kgKz9sCD for ; Fri, 28 May 2021 08:02:24 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AD93A82F0D; Fri, 28 May 2021 00:01:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject 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="eRwHPqZ/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 185CD82EFE; Fri, 28 May 2021 00:00:58 +0200 (CEST) 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,T_FILL_THIS_FORM_SHORT autolearn=no autolearn_force=no version=3.4.2 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0728.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::728]) (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 B6AAA82EE6 for ; Fri, 28 May 2021 00:00:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject 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=I954N0gr0faxCu3agIOplaii5RtUhBrBhIOa7dXOr5qxonfD4JtnYcL84kHio+o9Ax3GjLooPwlBiAmR47cGOiyHrOEmjiOBJoyO7VLLgZGr190Mu2IxXN/0sLaSxVHWx5MTjKFy/fMJAN8yyWY4sWpR4ojiyjLEo5hITPgKY+j9tjf8CwHuhSwRv7wxfrpIdoiKLugf/a13rSaEsCYiNOdJ0uzIkouwSgU091BYV4Aq/xnlFsNwNuhjNGCTMAL0DhKCbvdUlvoulEPxp+3FHgGt0thJIp7wAsiU7SFVfM0ewj7xu3hys58r0fyxVjlvaxPNKIFk1S7C+r9AWA38vA== 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=yFIu2iLTC5KCXOihPI+RMUTm0RfGmH35S0I2hs6d56Y=; b=CoSjL4T1JdYWdLRxmvf0hotHvuuxY7pAdJXQGMz6nBYiucEZfWm7mfzNIUXsKjLKTbcYPEtBJqm5CYwJDh5vckeHAuQofHZCOG4AA7AYg2FNnow0Wzp2yc8ynUXDRM+KSrkm7uS75XF7QQEPG/Dy/XmFzDU25GtzBWnZvZ3f4S0xlIlPO4SfhxPr5lIbzftRgJ8yarBveQK0qWW7La+qXozQOEprGA/jzXmU561P6CPdl+LP42pf7uzvFws0EKeeoIXVXQmrAzMHTCf0XNsjE8BHozwWY2Pu/meNZWLz9BQbv4XGomuebf8YhK6vmwHVW+vfRckaV2dKbzFL1YkT2Q== 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=yFIu2iLTC5KCXOihPI+RMUTm0RfGmH35S0I2hs6d56Y=; b=eRwHPqZ/uP2Ep6z6rjOvw6XSQmcbbgoM7dTVeN447YNvn9+SMr+m/WSZg/1vxCLKji8Xd8Nbk7pXyeUmVul+fuoEQlHVB4/DYU9zbn5cG0RH/e9JlxWVMH6EFJ8gUzEl0NYCGz4Cg4Sh+36s9pi0MNC7g/Eedf4jYUy52T/WB5w= Authentication-Results: lists.denx.de; dkim=none (message not signed) header.d=none;lists.denx.de; dmarc=none action=none header.from=prevas.dk; Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) by AM0PR10MB1921.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.21; Thu, 27 May 2021 22:00:32 +0000 Received: from AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::888d:190b:b3b5:1ad2]) by AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM ([fe80::888d:190b:b3b5:1ad2%3]) with mapi id 15.20.4129.036; Thu, 27 May 2021 22:00:32 +0000 From: Rasmus Villemoes To: u-boot@lists.denx.de Cc: Stefan Roese , Tom Rini , Simon Glass , Rasmus Villemoes Subject: [PATCH v2 10/10] sandbox: add test of wdt-uclass' watchdog_reset() Date: Fri, 28 May 2021 00:00:17 +0200 Message-Id: <20210527220017.1266765-11-rasmus.villemoes@prevas.dk> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210527220017.1266765-1-rasmus.villemoes@prevas.dk> References: <20210527220017.1266765-1-rasmus.villemoes@prevas.dk> X-Originating-IP: [80.208.74.47] X-ClientProxiedBy: AS8PR04CA0198.eurprd04.prod.outlook.com (2603:10a6:20b:2f3::23) To AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:208:3f::10) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from prevas-ravi.prevas.se (80.208.74.47) by AS8PR04CA0198.eurprd04.prod.outlook.com (2603:10a6:20b:2f3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4173.20 via Frontend Transport; Thu, 27 May 2021 22:00:31 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 99399318-f479-4d04-543d-08d9215ad8e9 X-MS-TrafficTypeDiagnostic: AM0PR10MB1921: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:3631; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SHbUpCmfTzDMVRwhBvFkRbMWhYPNrcKDeGogmwBO8380KDDOkhG4Ifg9Fdjt228anB84a9mCwZyAukAQ5+aBOoZzfgVT3Q/gFgOja9xYNwEiCa47Q87gVk8eEv0RKlZKUDVGOGF+K1/lS0+27E4d0Op8jAvO38j/StuHGzLGASxLiovZVVU0T1lKM1j2Zefd7Y6Bk9Dim31LDGkd1CWSLrHukytTleoBipCp8aA8a3OA55dUPocXprzLCfrTHDs+goGNqLvayjaZS/hlwbeFXrOgoeejAj2HSheTDIgHMnIv4T/viLxSx078I/htL8mrW1wwax6+0MnRwDSGyv/KzvUtMMt4g0LsZTxIodOz5XhkSj4jM0uCuScIkr+5NRL5YdgA3d5HuOZdkSdASqSEyCt+KQZK36gupzcZhYuFoC8PSq73hVRp4+bVkizZPTDZpc4CfQ7ZuRWjf3IzaW73M/25x5OLdQFQ/OI9m45M51I65tFlP72u6jndZPqjHEq+HB74CssON191AhaaDnmoiPgCzG074FOhkuPzAiky5cFVZSwWfsqMyppq04m31Byqg27S10Gfzx/dR2s1FaLb9F3kDgMNS4dG3CgdxMaIKqqgd5OgF2lgNz4xHPzIV1do2RrQxqJOXMM9KuGQWkfAUc/3ayrzsvscQfX4l9D2SFU= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM; PTR:; CAT:NONE; SFS:(346002)(376002)(136003)(366004)(39830400003)(396003)(66556008)(66476007)(2906002)(8676002)(83380400001)(6916009)(1076003)(66946007)(86362001)(54906003)(36756003)(52116002)(26005)(6506007)(8976002)(38350700002)(38100700002)(4326008)(107886003)(8936002)(478600001)(6486002)(5660300002)(44832011)(186003)(16526019)(6666004)(6512007)(2616005)(316002)(956004); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData: PKyuT4TKTbuVfOcrAhV54hCN1A+XvifZwQhlOEkwkfnpthpfkbtITDp8S9Xgyc60NqZ9r8dpjOXWKjxmonLpCzuU4sK2DrTHUR2ffZf6CCwULev8iN8MV7bNWX/tsI8H5H39xRZb8ta/1cQWk0dq0rDHf5IFql8A+jmQsmMYgVUpYKm9XnemR9pkD92I1Qc4XCFIIdrfm21cUH4dmLEkmoTy9lsTEwbLaYVn1kTTcqNSqAR9xYS5tXr9CIVy9YDLjuJY67AmugSnnbjwW7w0XlNTQSjcl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exchange-CrossTenant-Network-Message-Id: 99399318-f479-4d04-543d-08d9215ad8e9 X-MS-Exchange-CrossTenant-AuthSource: AM0PR10MB1874.EURPRD10.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 May 2021 22:00:32.1338 (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: AHeuelISJaS83VpKj2cKMMgKAscmdqwBnSGkkZTFVYz8YS4u7ONVOsoSi+1YBOyo9oltO/14MRcoGU7QUUFclO107c3qWFnfvptCIPEmnWE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR10MB1921 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.4 at phobos.denx.de X-Virus-Status: Clean Check that the watchdog_reset() implementation in wdt-uclass behaves as expected: - resets all activated watchdog devices - leaves unactivated/stopped devices alone - that the rate-limiting works, with a per-device threshold Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass Reviewed-by: Stefan Roese --- arch/sandbox/dts/test.dts | 2 ++ test/dm/wdt.c | 54 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/arch/sandbox/dts/test.dts b/arch/sandbox/dts/test.dts index cee5b14ecb..1853b5f29a 100644 --- a/arch/sandbox/dts/test.dts +++ b/arch/sandbox/dts/test.dts @@ -758,6 +758,7 @@ gpio-wdt { gpios = <&gpio_a 7 0>; compatible = "linux,wdt-gpio"; + hw_margin_ms = <100>; always-running; }; @@ -1239,6 +1240,7 @@ wdt0: wdt@0 { compatible = "sandbox,wdt"; + hw_margin_ms = <200>; }; axi: axi@0 { diff --git a/test/dm/wdt.c b/test/dm/wdt.c index abff853a02..8997aaebc8 100644 --- a/test/dm/wdt.c +++ b/test/dm/wdt.c @@ -12,6 +12,8 @@ #include #include #include +#include +#include /* Test that watchdog driver functions are called */ static int dm_test_wdt_base(struct unit_test_state *uts) @@ -73,3 +75,55 @@ static int dm_test_wdt_gpio(struct unit_test_state *uts) return 0; } DM_TEST(dm_test_wdt_gpio, UT_TESTF_SCAN_FDT); + +static int dm_test_wdt_watchdog_reset(struct unit_test_state *uts) +{ + struct sandbox_state *state = state_get_current(); + struct udevice *gpio_wdt, *sandbox_wdt; + struct udevice *gpio; + const u64 timeout = 42; + const int offset = 7; + uint reset_count; + int val; + + ut_assertok(uclass_get_device_by_driver(UCLASS_WDT, + DM_DRIVER_GET(wdt_gpio), &gpio_wdt)); + ut_assertnonnull(gpio_wdt); + ut_assertok(uclass_get_device_by_driver(UCLASS_WDT, + DM_DRIVER_GET(wdt_sandbox), &sandbox_wdt)); + ut_assertnonnull(sandbox_wdt); + ut_assertok(uclass_get_device_by_name(UCLASS_GPIO, "base-gpios", &gpio)); + ut_assertnonnull(gpio); + + /* Neither device should be "started", so watchdog_reset() should be a no-op. */ + reset_count = state->wdt.reset_count; + val = sandbox_gpio_get_value(gpio, offset); + watchdog_reset(); + ut_asserteq(reset_count, state->wdt.reset_count); + ut_asserteq(val, sandbox_gpio_get_value(gpio, offset)); + + /* Start both devices. */ + ut_assertok(wdt_start(gpio_wdt, timeout, 0)); + ut_assertok(wdt_start(sandbox_wdt, timeout, 0)); + + /* Make sure both devices have just been pinged. */ + mdelay(100); + watchdog_reset(); + reset_count = state->wdt.reset_count; + val = sandbox_gpio_get_value(gpio, offset); + + /* The gpio watchdog should be pinged, the sandbox one not. */ + mdelay(30); + watchdog_reset(); + ut_asserteq(reset_count, state->wdt.reset_count); + ut_asserteq(!val, sandbox_gpio_get_value(gpio, offset)); + + /* After another ~30ms, both devices should get pinged. */ + mdelay(30); + watchdog_reset(); + ut_asserteq(reset_count + 1, state->wdt.reset_count); + ut_asserteq(val, sandbox_gpio_get_value(gpio, offset)); + + return 0; +} +DM_TEST(dm_test_wdt_watchdog_reset, UT_TESTF_SCAN_FDT);