Received: by 10.223.176.46 with SMTP id f43csp1059828wra; Sat, 20 Jan 2018 09:57:48 -0800 (PST) X-Google-Smtp-Source: AH8x227PosaVrE1Nt7jF996OB591rWdoPp+vmtZZ5QAFh5tVyh4Gi5+Xtri9kZxPQ1/cti+f3o0g X-Received: by 10.101.90.202 with SMTP id d10mr2604210pgt.366.1516471068305; Sat, 20 Jan 2018 09:57:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516471068; cv=none; d=google.com; s=arc-20160816; b=nccXYl3PdeF7uFOZ5km6B7qVX/06lE/S7w8BVfBevo5kzYrHFZFcJd2NrA7AMnnzFC 5ohzDwnMZpoFYiUPcBogcuo0gY8RSyKleCEnCYReLpJqSvOqDGvRpFmWbGk8k7pJkLss gCZgeEqnx/bTiLef0YPnvcZCPqhwjBqC5o9reQPLcrIADJ1KmXHMvcehupovcUVnt+Bl Y7fTi3X2mG51Hu4ZrLqd+s8qIAO5fdsapM/omv9b6z0nDBEzBtQraf3+Lzx087pqRkRB mjGuvrbZB40lvEXbnnrwopJwgoCUEyR8TTKI89kb0jtuigI7YBKgG6ZiqkhaPNLCk9eY F2/A== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=Si7KRwpeozYat4RhCBTpjcWvJhU3rJkyDf4cG8c9Goc=; b=k6UOAk7oMGlRxXRpVcNPbcWYlw2yEvE3+SslNZS+pYhTU2bvrUL+r3cOgm1z9VuL8T vW8QiAbhBood3pFcimOcu5FAFyCBV+HGDUPHxIvTGmbZHddOiROHvh89esiidTvSquVi YIRXRtx9zU53m9xPGOSS8XMp93pQF1vFc8k8W5QuS2Xi1g0ga+YKnaYqCqNpcQmi30ud e3rYeJB0dcgXw9wSo68c0YCZViiAqSoc9VwIsfS9ZxZlKHEgCWSnMr74Tu6+a3jy6ZRE Z31AoqhGyQfCHo0SZ7AuGpOCZqNqjwPrKa6SbLOPqh/4zVJIDaFxcO6TV+J5E8MMv4kx p31A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=d/22EEvp; 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 i188si10470076pgc.177.2018.01.20.09.57.34; Sat, 20 Jan 2018 09:57:48 -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=fail header.i=@gmail.com header.s=20161025 header.b=d/22EEvp; 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 S1756578AbeATR47 (ORCPT + 99 others); Sat, 20 Jan 2018 12:56:59 -0500 Received: from mail-pg0-f65.google.com ([74.125.83.65]:33768 "EHLO mail-pg0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755008AbeATR4w (ORCPT ); Sat, 20 Jan 2018 12:56:52 -0500 Received: by mail-pg0-f65.google.com with SMTP id u1so3861038pgr.0; Sat, 20 Jan 2018 09:56:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Si7KRwpeozYat4RhCBTpjcWvJhU3rJkyDf4cG8c9Goc=; b=d/22EEvpHzS/Y5/esUVX/WXX+Jlt8hQO/Zzr8suSgUZKE0+d+RlR8l9l27x1gpg+61 HfVP+YQbb640/QKGIFhMk0cBkQkM9eEkvvv1V8DHjc878zt0ghdsW8GwKlOBduk8DgoS oRNrVLtd7hLJPqRxUgjOdPbj2BEvbUlWYQdgGzrun18d3s2x/Lx9z6I3NSOsvQoGfEtH +2JGRyHeSWL5QzTc58DfMXRVamnVvDyRmxmjt+zgF3XObtwm6SIWJ6YjgvCZiw8pHD9N +be9r/jx/zu4s/xJDkIhZc9YQ5+nEVKCfbQ0aYrhlt4mTwl32RcDs9B/9gIJ8NOhh2qr fz1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Si7KRwpeozYat4RhCBTpjcWvJhU3rJkyDf4cG8c9Goc=; b=oaU2JWcA3HSSj+KLa+u2FscA1ysc5Xkh+HLdYvNzoK55bw7OOkG1UyEXirhac/xF1K rhDjyadthntXFr8BdHN0tUNLSQKyLS0PJ+FdLElt+K5V8C+fvShs9l8xqbTDfl8Wvaj8 PwYEosLxjChlfLA3fClcsGStmgPYyWan4A6q0Oc1Cqwo0AVGLbmCDFMz4nUd8A0JxBeN 8FKVixtj1KOvoh0YQdAb0kjIP5y08hCDO9N07pzfe/o/ks2YW+ljW4LW8+U0HVjlskjN d9ZmaiuHFJnVwuGdE/oofyEO9v94XmcfdKkX2FfwV42+8tlBmZOSkwUouOqG2zkO/3+O PYIA== X-Gm-Message-State: AKwxytfePFN25IsAwEimmSRbwiAH7i/7ohl5rxbAF1uyS0c+xvX3430U +JLdNWN/hlH6nQ16joCWQ67joQ== X-Received: by 10.99.53.15 with SMTP id c15mr2677500pga.333.1516471012203; Sat, 20 Jan 2018 09:56:52 -0800 (PST) Received: from server.roeck-us.net (108-223-40-66.lightspeed.sntcca.sbcglobal.net. [108.223.40.66]) by smtp.gmail.com with ESMTPSA id q24sm9682431pgn.15.2018.01.20.09.56.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 20 Jan 2018 09:56:51 -0800 (PST) Subject: Re: [PATCH v2 3/8] watchdog: JZ4740: Register a restart handler To: PrasannaKumar Muralidharan Cc: Paul Cercueil , Ralf Baechle , Rob Herring , Mark Rutland , Wim Van Sebroeck , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux-MIPS , open list , linux-watchdog@vger.kernel.org References: <20171228162939.3928-2-paul@crapouillou.net> <20171230135108.6834-1-paul@crapouillou.net> <20171230135108.6834-3-paul@crapouillou.net> <20061de8-fa1f-93eb-eb9b-089c699018aa@roeck-us.net> From: Guenter Roeck Message-ID: Date: Sat, 20 Jan 2018 09:56:48 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/20/2018 08:04 AM, PrasannaKumar Muralidharan wrote: > Hi Guenter, > > On 20 January 2018 at 21:15, Guenter Roeck wrote: >> On 01/19/2018 11:31 PM, PrasannaKumar Muralidharan wrote: >>> >>> Hi Paul, >>> >>> On 30 December 2017 at 19:21, Paul Cercueil wrote: >>>> >>>> The watchdog driver can restart the system by simply configuring the >>>> hardware for a timeout of 0 seconds. >>>> >>>> Signed-off-by: Paul Cercueil >>>> Reviewed-by: Guenter Roeck >>>> --- >>>> drivers/watchdog/jz4740_wdt.c | 9 +++++++++ >>>> 1 file changed, 9 insertions(+) >>>> >>>> v2: No change >>>> >>>> diff --git a/drivers/watchdog/jz4740_wdt.c >>>> b/drivers/watchdog/jz4740_wdt.c >>>> index 92d6ca8ceb49..fa7f49a3212c 100644 >>>> --- a/drivers/watchdog/jz4740_wdt.c >>>> +++ b/drivers/watchdog/jz4740_wdt.c >>>> @@ -130,6 +130,14 @@ static int jz4740_wdt_stop(struct watchdog_device >>>> *wdt_dev) >>>> return 0; >>>> } >>>> >>>> +static int jz4740_wdt_restart(struct watchdog_device *wdt_dev, >>>> + unsigned long action, void *data) >>>> +{ >>>> + wdt_dev->timeout = 0; >>>> + jz4740_wdt_start(wdt_dev); >>>> + return 0; >>>> +} >>>> + >>>> static const struct watchdog_info jz4740_wdt_info = { >>>> .options = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING | >>>> WDIOF_MAGICCLOSE, >>>> .identity = "jz4740 Watchdog", >>>> @@ -141,6 +149,7 @@ static const struct watchdog_ops jz4740_wdt_ops = { >>>> .stop = jz4740_wdt_stop, >>>> .ping = jz4740_wdt_ping, >>>> .set_timeout = jz4740_wdt_set_timeout, >>>> + .restart = jz4740_wdt_restart, >>>> }; >>>> >>>> #ifdef CONFIG_OF >>>> -- >>>> 2.11.0 >>>> >>>> >>> >>> Noticed that min_timeout of the watchdog device is set to 1 but this >>> function calls start with timeout set to 0. Even though this works I >>> feel it is better to set min_timeout to 0. >>> >> >> No. That would be wrong. If you want to be pedantic, write a new function >> __jz4740_wdt_set_timeout(u16 clock_div, u16 timeout_value) and call it >> instead, but don't mess with min_timeout. >> >> Guenter > > What is the effect of changing min_timeout? I could see only > validation checks with it. > Let me ask you - you want to let userspace set a timeout of 0, which would effectively reboot the system through the backdoor. Why ? Guenter