Received: by 10.192.165.156 with SMTP id m28csp50585imm; Tue, 10 Apr 2018 16:10:33 -0700 (PDT) X-Google-Smtp-Source: AIpwx49BUJ08ARSctSA7JcLc2Dy+9EjUGaABNb+dGW95I4tMwLfZ44db2+RiDp/b4tUXT+h56dkC X-Received: by 10.101.100.9 with SMTP id a9mr1616392pgv.209.1523401833062; Tue, 10 Apr 2018 16:10:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523401833; cv=none; d=google.com; s=arc-20160816; b=rB27RYZ3hBkvo4gT3tVKxJKSYrRVK8BhHLUkQefSpb2KUd9uQIJPcZyn207B+NuUIY KWpIsEsVBsjRt18cURmKav1rphh5+PjwH4WYifbY5h4YWFGCp79Zete2pKAw70EwTQIE 4e2FU7LFS61c4abRuhBZ3fPTR1ZALshiLIO/s0AW4UvL93zZqFICrMK1l1ItTwV3z+0b 4sodBtN/Z2e/8YHFlEVIfA7JPhfx8r7GtivLZVJb60ey4yi4fGAL4oubEENlliMVWC2q eaVB0/6vLkO8oVA5gmhj1FhPlAlCjgNQOiNPJFKRyAv7SQO0S28QXmE5TzZ6030LuvMe wBPw== 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=e/n4KpbMjiaIR+HEeOR+c07AgdKRCQEzSXtCBpmogLU=; b=OADgq05JBWWM8sKW6UFmUGNdSFmPw/n08ClNLvXHMHzyLXGFdoZlu9SJx76ObxQW86 cwtFpc6dIXWX8tCHJhq3HMHHarOBc76dGI0niIY0pbbhqZFNZzrDerJhiak2Jx1GAL5z Glcph86Lc+YBycrBLh8uv5ymtJ3MjCDXL1U/NxpbL5Zaej5CsE5KJWc4RKXtIDyzBdIv IXadps/ZO7ex6+jr0C8P6JseAJnN8OPlfBJyegEqjTrKmUD/ZCkIi7uYxCEmHfQyudvi 4EoatisVBceRPQc7BXG3tL2r3WAK94uzU1p58P54UJDig9BTI4u83AL3zOb3+raN2+4g 96sQ== 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 n34-v6si3577019pld.331.2018.04.10.16.09.56; Tue, 10 Apr 2018 16:10:33 -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 S932104AbeDJWeZ (ORCPT + 99 others); Tue, 10 Apr 2018 18:34:25 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:41730 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754264AbeDJWeX (ORCPT ); Tue, 10 Apr 2018 18:34:23 -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 5E551D66; Tue, 10 Apr 2018 22:34:22 +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.14 019/138] watchdog: dw_wdt: add stop watchdog operation Date: Wed, 11 Apr 2018 00:23:29 +0200 Message-Id: <20180410212904.317032823@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180410212902.121524696@linuxfoundation.org> References: <20180410212902.121524696@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.14-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,