Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp685261ybv; Thu, 13 Feb 2020 07:44:47 -0800 (PST) X-Google-Smtp-Source: APXvYqwCl5rpbUd7OJEftUTDZM8SzliHJ84t3WrnTgcwLIR39WI6t6W+LDb4cGl+EF9EZsCRB1nM X-Received: by 2002:a9d:7509:: with SMTP id r9mr13238936otk.270.1581608687036; Thu, 13 Feb 2020 07:44:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581608687; cv=none; d=google.com; s=arc-20160816; b=Pw15XM3FGBkFxUZgy7XwQdD9VhIb0VasWljpmv3aQ/KS7JF7D64sdYGd5Ko37HrIM/ i824vaB1/SzrLlcZcj7PL5yHpxa21VzMaYkSr6O3VWWK4Wu+uDEXNw0B9C7M1dfuXm4e jXKuIuavES8tALfkfAkDFiSPrTDLN84L8EomHOl9pZShriyVtTcUoiOm6sa6G8jq+anr ECOXqOJv13Ucbk3Y+wVULw4hrH5lt62t21xhxlNo2MTpAb1Eo8y6Fzq+TIUd6evcg4EV m2OUdJFm3s7ArnhMaA8qsA3ozm+sh4mjqXTjZ3KqfcZGANWKW4O6BGqjYV13ZSLpEbpO 7Z9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Pc58KMJ72+i6QAoaB9BBOqKCd4koEFK6Ey8Pdn/mOzE=; b=Z/8QGuWCP/5qVA5XBBQjWfpVbK1xrDAzn7FdsJ6vgeqe0JCfR6Pkt1hX7EEXzqD+in bkgfItyF7pQd0aNBK8+9CwvgDW3QmGu676KtD5zd/wAp0dVj7rKW2K9pTbCdGMdT4oPv t3HRYx9F8XlxecY8qBbtH85DLpMt4eTJbuR7NPUAmN6Kn2C6BHzSN+2MUBW1Aa9bAjmZ H7PhGa5t2b8V0ZjLUR7oQ2RfXHYdy2yo3c5WQf1+d9u57pNhgkn5fpqDUV1LSmAYKwOs FtBsdjOOnuXlUOCj/ys14Og8hK/MB0TyrzUo6EiQie/L8+5oxY8XPqggyTkx2Z7EjuZz +cZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fYMUasyo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l26si1307271oti.152.2020.02.13.07.44.34; Thu, 13 Feb 2020 07:44:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fYMUasyo; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729042AbgBMPnc (ORCPT + 99 others); Thu, 13 Feb 2020 10:43:32 -0500 Received: from mail.kernel.org ([198.145.29.99]:53270 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729505AbgBMP1y (ORCPT ); Thu, 13 Feb 2020 10:27:54 -0500 Received: from localhost (unknown [104.132.1.104]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id D43932465D; Thu, 13 Feb 2020 15:27:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1581607674; bh=Rz7lJTFMsK3PbyJvA7oCormXXhuf2NgqQc2/DqCu1hM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fYMUasyo1wPSzIw8XrBGdHnCm4HiiO74II83N9jzISg9UW+Z/qy21wpE/2O54mQem r/FIDGcCrtBSZvGY46RGJGAsaZhqXceFpbVS9ikT5P6J50xR80lBRs2R4SoofbUi3E lV+atlyl+W9DXoEXpodVfQNXU2xv8m/wGz64jrrg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christophe Roullier , Guenter Roeck , Wim Van Sebroeck Subject: [PATCH 5.4 81/96] drivers: watchdog: stm32_iwdg: set WDOG_HW_RUNNING at probe Date: Thu, 13 Feb 2020 07:21:28 -0800 Message-Id: <20200213151909.676392504@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200213151839.156309910@linuxfoundation.org> References: <20200213151839.156309910@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christophe Roullier commit 85fdc63fe256b595f923a69848cd99972ff446d8 upstream. If the watchdog hardware is already enabled during the boot process, when the Linux watchdog driver loads, it should start/reset the watchdog and tell the watchdog framework. As a result, ping can be generated from the watchdog framework (if CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED is set), until the userspace watchdog daemon takes over control Fixes:4332d113c66a ("watchdog: Add STM32 IWDG driver") Signed-off-by: Christophe Roullier Reviewed-by: Guenter Roeck Link: https://lore.kernel.org/r/20191122132246.8473-1-christophe.roullier@st.com Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Greg Kroah-Hartman --- drivers/watchdog/stm32_iwdg.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) --- a/drivers/watchdog/stm32_iwdg.c +++ b/drivers/watchdog/stm32_iwdg.c @@ -262,6 +262,24 @@ static int stm32_iwdg_probe(struct platf watchdog_set_nowayout(wdd, WATCHDOG_NOWAYOUT); watchdog_init_timeout(wdd, 0, dev); + /* + * In case of CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED is set + * (Means U-Boot/bootloaders leaves the watchdog running) + * When we get here we should make a decision to prevent + * any side effects before user space daemon will take care of it. + * The best option, taking into consideration that there is no + * way to read values back from hardware, is to enforce watchdog + * being run with deterministic values. + */ + if (IS_ENABLED(CONFIG_WATCHDOG_HANDLE_BOOT_ENABLED)) { + ret = stm32_iwdg_start(wdd); + if (ret) + return ret; + + /* Make sure the watchdog is serviced */ + set_bit(WDOG_HW_RUNNING, &wdd->status); + } + ret = devm_watchdog_register_device(dev, wdd); if (ret) return ret;