Received: by 10.192.165.156 with SMTP id m28csp74338imm; Tue, 10 Apr 2018 16:44:43 -0700 (PDT) X-Google-Smtp-Source: AIpwx48mVz3bA7ETfLfXCftKR7Y/Tb8rqFUcg0lE238N/1Z1gJxI7lbnF1KkCR6txXCK6vKROEoC X-Received: by 10.98.194.195 with SMTP id w64mr1995406pfk.83.1523403883272; Tue, 10 Apr 2018 16:44:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523403883; cv=none; d=google.com; s=arc-20160816; b=L+mjrgx45I+VTwsgh/M+tzpm1Aq+xbNVoXwDRbv2IOa3lfzKbJzfmFY58dZKeoOsgB P1ZszP++QmCR4a+87bhcVnwIjZFv8nqp7v81GaB1HyFc28fGh09gJwX2ehPdxtlDAiAU G20A++OhARtm4Bn+1sXeMw8RlhYLTrIzvN1FdY+kpzt89THxb62w3Gk2tHi3+JbzQsKv 53Vdd6GpqEtGDasDNCwKS/1vJfAqoxwzNKXgKGZHIfjyeu3MfaXPd9CMvU/bQ2C1xFsr B7d26Jc0kPuU0zT2C9muuYCjiMZM1G7Dxxxph0d1nLyBD/mJT2ula3Cp9Bxb4uL0/SMG RsuQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=iRMQ+SOjkgZjt7o885AXoJxSKsNyS4enJTs3EgCiaRc=; b=gyw0xi+eyrj3Niw0qq1F8hnJBmXm/SwV/6ui7ox5zYc1zTfFp+bwwwSRWZuiRrYO/t 6sbo37uq+xv0YBuVmWt84QEOb1URC32DbzGBYKiWh3QSoghgH0W+/yR1WzNxUNDBC5Nr D5EFGHItr+AuhvIBgM5CDftQfcNmpxQntn+P296D3xbBH9+8P9a8ryyJPOwQJKJVnOqR EQwJp2qKPsxdCmOhwJgwpdE3BVWKeMgX2eTY94vcXvk1BUy18Kqs6WfyVNEAIyKcW5gM utFqzjvd46TZNe+n7m1GAfYJNLCN4pNUzznnXJr41hvEaoltTdzOZvZw4LmC8pAGu9Qo +DWg== ARC-Authentication-Results: i=1; mx.google.com; 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 g12-v6si3515743plt.294.2018.04.10.16.44.06; Tue, 10 Apr 2018 16:44:43 -0700 (PDT) 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; 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 S1753223AbeDJW0m (ORCPT + 99 others); Tue, 10 Apr 2018 18:26:42 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:37538 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753187AbeDJW0j (ORCPT ); Tue, 10 Apr 2018 18:26:39 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 3EC9DC03; Tue, 10 Apr 2018 22:26:38 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oleksij Rempel , Wim Van Sebroeck , Guenter Roeck , linux-watchdog@vger.kernel.org, Sasha Levin Subject: [PATCH 4.15 022/168] watchdog: dw_wdt: add stop watchdog operation Date: Wed, 11 Apr 2018 00:22:44 +0200 Message-Id: <20180410212801.146104435@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212800.144079021@linuxfoundation.org> References: <20180410212800.144079021@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Oleksij Rempel [ Upstream commit 1bfe8889380890efe4943d125124f5a7b48571b0 ] The only way of stopping the watchdog is by resetting it. Add the watchdog op for stopping the device and reset if a reset line is provided. At same time WDOG_HW_RUNNING should be remove from dw_wdt_start. As commented by Guenter Roeck: dw_wdt sets WDOG_HW_RUNNING in its open function. Result is that the kref_get() in watchdog_open() won't be executed. But then kref_put() in close will be called since the watchdog now does stop. This causes the imbalance. Signed-off-by: Oleksij Rempel Cc: Wim Van Sebroeck Cc: Guenter Roeck Cc: linux-watchdog@vger.kernel.org Reviewed-by: Guenter Roeck Signed-off-by: Guenter Roeck Signed-off-by: Wim Van Sebroeck Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/watchdog/dw_wdt.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) --- a/drivers/watchdog/dw_wdt.c +++ b/drivers/watchdog/dw_wdt.c @@ -127,14 +127,27 @@ static int dw_wdt_start(struct watchdog_ dw_wdt_set_timeout(wdd, wdd->timeout); - set_bit(WDOG_HW_RUNNING, &wdd->status); - writel(WDOG_CONTROL_REG_WDT_EN_MASK, dw_wdt->regs + WDOG_CONTROL_REG_OFFSET); return 0; } +static int dw_wdt_stop(struct watchdog_device *wdd) +{ + struct dw_wdt *dw_wdt = to_dw_wdt(wdd); + + if (!dw_wdt->rst) { + set_bit(WDOG_HW_RUNNING, &wdd->status); + return 0; + } + + reset_control_assert(dw_wdt->rst); + reset_control_deassert(dw_wdt->rst); + + return 0; +} + static int dw_wdt_restart(struct watchdog_device *wdd, unsigned long action, void *data) { @@ -173,6 +186,7 @@ static const struct watchdog_info dw_wdt static const struct watchdog_ops dw_wdt_ops = { .owner = THIS_MODULE, .start = dw_wdt_start, + .stop = dw_wdt_stop, .ping = dw_wdt_ping, .set_timeout = dw_wdt_set_timeout, .get_timeleft = dw_wdt_get_timeleft,