From patchwork Wed Jun 5 14:06:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 10977061 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B9F115E6 for ; Wed, 5 Jun 2019 14:06:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B778289CD for ; Wed, 5 Jun 2019 14:06:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E98128676; Wed, 5 Jun 2019 14:06:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38DFE289CA for ; Wed, 5 Jun 2019 14:06:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727883AbfFEOG4 (ORCPT ); Wed, 5 Jun 2019 10:06:56 -0400 Received: from mail-eopbgr30099.outbound.protection.outlook.com ([40.107.3.99]:52096 "EHLO EUR03-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726442AbfFEOGz (ORCPT ); Wed, 5 Jun 2019 10:06:55 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=prevas.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ACVOhg70v0CTLXaEzDvN55EbCM307+bydDMczZZhx6Q=; b=AWYtaRLIX3LgFHMKrK/JvSTxDuYZ32h3OT7Rlxf4j2ekTpO+mfITR9YwnTVI+SH3gE9gKdvT8Cf2yzQTd7HAoxUDFnG3thg1I4vTyujAn8sbxmfxFjfEn5/zvn7qAo155ZNNsJ4PTXlor+PYa7WyVDKip/G0Y12FDqHdJP3bHrM= Received: from VI1PR10MB2639.EURPRD10.PROD.OUTLOOK.COM (20.178.126.80) by VI1PR10MB2382.EURPRD10.PROD.OUTLOOK.COM (20.177.62.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1965.12; Wed, 5 Jun 2019 14:06:40 +0000 Received: from VI1PR10MB2639.EURPRD10.PROD.OUTLOOK.COM ([fe80::8844:426d:816b:f5d5]) by VI1PR10MB2639.EURPRD10.PROD.OUTLOOK.COM ([fe80::8844:426d:816b:f5d5%6]) with mapi id 15.20.1965.011; Wed, 5 Jun 2019 14:06:40 +0000 From: Rasmus Villemoes To: "linux-watchdog@vger.kernel.org" , Guenter Roeck , Wim Van Sebroeck , Jonathan Corbet CC: "linux-kernel@vger.kernel.org" , "linux-doc@vger.kernel.org" , Esben Haabendal , Jerry Hoemann , Rasmus Villemoes Subject: [PATCH v10 0/3] watchdog: allow setting deadline for opening /dev/watchdogN Thread-Topic: [PATCH v10 0/3] watchdog: allow setting deadline for opening /dev/watchdogN Thread-Index: AQHVG6flPtQuHkfnpUyBpSjztSqwZw== Date: Wed, 5 Jun 2019 14:06:40 +0000 Message-ID: <20190605140628.618-1-rasmus.villemoes@prevas.dk> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: HE1PR0202CA0034.eurprd02.prod.outlook.com (2603:10a6:3:e4::20) To VI1PR10MB2639.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:803:e1::16) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Rasmus.Villemoes@prevas.se; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.20.1 x-originating-ip: [81.216.59.226] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: f735bfee-cd42-4551-a4be-08d6e9bf081e x-microsoft-antispam: BCL:0;PCL:0;RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(2017052603328)(7193020);SRVR:VI1PR10MB2382; x-ms-traffictypediagnostic: VI1PR10MB2382: x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:9508; x-forefront-prvs: 00594E8DBA x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(376002)(366004)(39850400004)(346002)(396003)(136003)(189003)(199004)(6436002)(66066001)(5660300002)(52116002)(478600001)(107886003)(71200400001)(71190400001)(6486002)(74482002)(3846002)(6116002)(44832011)(72206003)(2501003)(6512007)(54906003)(486006)(2906002)(102836004)(73956011)(110136005)(8976002)(6506007)(99286004)(7736002)(386003)(53936002)(64756008)(316002)(476003)(66946007)(66556008)(81156014)(8676002)(81166006)(66446008)(66476007)(4326008)(14454004)(50226002)(25786009)(2616005)(305945005)(26005)(36756003)(68736007)(42882007)(186003)(256004)(8936002)(14444005)(1076003);DIR:OUT;SFP:1102;SCL:1;SRVR:VI1PR10MB2382;H:VI1PR10MB2639.EURPRD10.PROD.OUTLOOK.COM;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: prevas.se does not designate permitted sender hosts) x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: LEI2nUOcTSd5ia2aOm+8StyfiYGTRnxugplWIlSMuvbZX5bXprytO8ZpVFMB307g1rUaU+tx6FTRIpMWznRHibw+fVnOBN5QxhL0I5CbBJmFdvpWdWc3LLOrNa1SG9R8zgoHrXn2ufyvqW5TEqlaxgI2DhGVnjfjSKnwasPilEMpZGtdmBG6xeN3VA6OSt6/90n0TH2vGfmXeW9P6AUPZsuGQ8WNj/y5xKo1fTcUDJaJGm9KTM+6h0Lv3FfoxBU1rZHLFfUj8wwCzmkK6mtOi/5yjnpCT7XxLZYEj6MO6vD3a/qj1frXoAEh3GxcMzp8JNb72b9+W1tNFLmObYLHiUuyhfb5pmVXq98ZS5zM7sY7jLbrEMWIyXiEJyx7ZrkBAaHhyaiGrZbauFdLQhF9YpFI075VRBzmVjMn30qRSh0= MIME-Version: 1.0 X-OriginatorOrg: prevas.dk X-MS-Exchange-CrossTenant-Network-Message-Id: f735bfee-cd42-4551-a4be-08d6e9bf081e X-MS-Exchange-CrossTenant-originalarrivaltime: 05 Jun 2019 14:06:40.7043 (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: Rasmus.Villemoes@prevas.dk X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR10MB2382 Sender: linux-watchdog-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-watchdog@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If a watchdog driver tells the framework that the device is running, the framework takes care of feeding the watchdog until userspace opens the device. If the userspace application which is supposed to do that never comes up properly, the watchdog is fed indefinitely by the kernel. This can be especially problematic for embedded devices. The existing handle_boot_enabled cmdline parameter/config option partially solves that, but that is only usable for the subset of hardware watchdogs that have (or can be configured by the bootloader to have) a timeout that is sufficient to make it realistic for userspace to come up. Many devices have timeouts of only a few seconds, or even less, making handle_boot_enabled insufficient. These patches allow one to set a maximum time for which the kernel will feed the watchdog, thus ensuring that either userspace has come up, or the board gets reset. This allows fallback logic in the bootloader to attempt some recovery (for example, if an automatic update is in progress, it could roll back to the previous version). The patches have been tested on a Raspberry Pi 2 and a Wandboard. Changes in v10: The open_timeout now only applies to the first open from userspace. If userspace needs to close and re-open the watchdog device (e.g. to re-exec itself), and wants the board to reset in case it doesn't come back quickly enough, the open_timeout can easily be emulated by combining nowayout with an appropriate WDIOC_SETTIMEOUT. Changes in v9: Make the unit seconds instead of milliseconds. Rasmus Villemoes (3): watchdog: introduce watchdog.open_timeout commandline parameter watchdog: introduce CONFIG_WATCHDOG_OPEN_TIMEOUT watchdog: make the device time out at open_deadline when open_timeout is used .../watchdog/watchdog-parameters.txt | 8 ++++ drivers/watchdog/Kconfig | 9 ++++ drivers/watchdog/watchdog_dev.c | 48 ++++++++++++++++--- 3 files changed, 59 insertions(+), 6 deletions(-)