Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp216878imm; Mon, 1 Oct 2018 08:53:09 -0700 (PDT) X-Google-Smtp-Source: ACcGV62P3t29jjl8gLxet3BSXxbpPBNXA3SzDvfZADKB+wzJseT88jonye69ZK11qPE+dE19ZTEQ X-Received: by 2002:a17:902:934a:: with SMTP id g10-v6mr12553926plp.288.1538409189831; Mon, 01 Oct 2018 08:53:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1538409189; cv=none; d=google.com; s=arc-20160816; b=qUZVakRCUim0mrxZ7KJhnR81MJqplTYxH9IMZRoeOyYyTxieY+lfBJ9Wk35/DI83dM t3SIYPHtHk4HAXcuc2k0As/GjC1ifkzUsiifxOZCMm13G+KaF1Uw3NTgq429tT49jT9L XgOmXNTNMvl/Z005Io/Wlo7KvwFvpOz/uJSTR3PUXhTFQ6uYowIo+M2V1liUxkaC8nas qfIwd9TsB6K8yd/ROInf2gj2G7nepO1b33d5siHVjxMD9xPKzqUykZaf9Ys0cIDAi46y gIIyyGZHSeHQGSPdZP8nNfDZdhbcqW6qxKvzCtGmYKYFHRzAfzw7Q8wVtD7Yh8VuVQBC c5iA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=nyI8GMU/fwiXU9xUQ+d4qkYcTBgaWtkwMtGw3HL1Iao=; b=JwNvNgUPj7E7v6GYCezArZXYBeXwDqodl7gwauUiIdBg/3sEmGQKCZ/U7s83yawqTL bUI3KqsrjNl5hpUl2vFB+XGVc7NA2IVsKpxvcMmRUoFLY0ohxpcowUnFsYxA1wV+ABaI kA2Nti7L2bserb6dIsbztRnDaqkECqRDYyuGuktlLyjWrQAbwb+CSOSHTSoTHlgrzBSl OArhBCBajPE19aDpByga7QTu+RekhltWSTrDpnb3WOAlk6gA8vXW4Rdmnolnr8O6arqM lqMu8d4gUq7mopjbrdjeg+A10w0RbQbVP+fxR9lZzoPXyPJ/2OA/8ydCY4LRgA5ZpbCs No1A== 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 y12-v6si13468050pfd.254.2018.10.01.08.52.55; Mon, 01 Oct 2018 08:53:09 -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 S1726285AbeJAWaz (ORCPT + 99 others); Mon, 1 Oct 2018 18:30:55 -0400 Received: from mail.bootlin.com ([62.4.15.54]:36470 "EHLO mail.bootlin.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725945AbeJAWaz (ORCPT ); Mon, 1 Oct 2018 18:30:55 -0400 Received: by mail.bootlin.com (Postfix, from userid 110) id 4B70520717; Mon, 1 Oct 2018 17:52:26 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mail.bootlin.com X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,SHORTCIRCUIT, URIBL_BLOCKED shortcircuit=ham autolearn=disabled version=3.4.0 Received: from localhost (242.171.71.37.rev.sfr.net [37.71.171.242]) by mail.bootlin.com (Postfix) with ESMTPSA id 1D1782073D; Mon, 1 Oct 2018 17:52:16 +0200 (CEST) Date: Mon, 1 Oct 2018 17:52:17 +0200 From: Alexandre Belloni To: Romain Izard Cc: Nicolas Ferre , Wim Van Sebroeck , Guenter Roeck , Marcus Folkesson , linux-arm-kernel , linux-watchdog@vger.kernel.org, LKML Subject: Re: [PATCH 2/2] watchdog: sama5d4: write the mode register in two steps Message-ID: <20181001155217.GE2967@piout.net> References: <20180914101339.7382-1-romain.izard.pro@gmail.com> <20180914101339.7382-3-romain.izard.pro@gmail.com> <20180914102732.GP14988@piout.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 17/09/2018 15:58:45+0200, Romain Izard wrote: > 2018-09-14 12:27 GMT+02:00 Alexandre Belloni : > > On 14/09/2018 12:13:39+0200, Romain Izard wrote: > >> The specification for SAMA5D2 and SAMA5D4 chips, that use this IP for > >> their watchdog timer, has the following advice regarding the Mode Register: > >> > >> "When setting the WDDIS bit, and while it is set, the fields WDV and WDD > >> must not be modified." > >> > >> I have observed on a board based on a SAMA5D2 chip that using any other > >> timeout duration than the default 16s in the device tree will reset the > >> board when the watchdog device is opened; this is probably due to ignoring > >> the aforementioned constraint. > >> > >> To fix this, read the content of the Mode Register before writing it, > >> and split the access into two parts if WDV or WDD need to be changed. > >> > > > > Hum, that is really weird because when I developed > > 015b528644a84b0018d3286ecd6ea5f82dce0180, I tested with a program doing: > > > > flags = WDIOS_DISABLECARD; > > ioctl(fd, WDIOC_SETOPTIONS, &flags); > > for (i = 16; i > 2; i--) { > > ioctl(fd, WDIOC_SETTIMEOUT, &i); > > } > > > > ioctl(fd, WDIOC_KEEPALIVE, &dummy); > > > > flags = WDIOS_ENABLECARD; > > ioctl(fd, WDIOC_SETOPTIONS, &flags); > > > > for (i = 16; i > 2; i--) { > > ioctl(fd, WDIOC_SETTIMEOUT, &i); > > } > > > > This would immediately reproduce the reset when changing WDV/WDD with > > WDDIS set. > > > > I'll test again. > > > > The issue is visible when setting a custom value for the timeout on startup. > In the past it was only possible to do so with a module parameter, and the > previous patch in the series makes it possible to do with the device tree. > > When using the Linux4SAM 5.7 release, it is sufficient to set the timeout on > the command line to reproduce the issue: > > In the bootloader: > # setenv bootargs $bootargs sama5d4_wdt.wdt_timeout=10 > > To trigger an immediate reset (with some code that should work): > # (echo 1; while sleep 3; do echo 1; done) > /dev/watchdog > Ok, I've tested and seen the issue. I agree with Guenter that it is probably worth having a function to update MR that takes the timeout value and whether the watchdog needs to be enabled. It would probably make caching mr unnecessary. -- Alexandre Belloni, Bootlin Embedded Linux and Kernel engineering https://bootlin.com