Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp4017807imm; Mon, 17 Sep 2018 07:00:28 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZbwfjTB13aIyAjBLy6QrDfeuh6rhLYxczz/10KrN+Fz17PF2ISFoS72iKvZFPLzSiRlYCT X-Received: by 2002:a62:1456:: with SMTP id 83-v6mr25885036pfu.50.1537192828241; Mon, 17 Sep 2018 07:00:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537192828; cv=none; d=google.com; s=arc-20160816; b=EgFY3SyY/U7VODAehlFW9FI4ABJUNhNYWJ1CiMHQ6pt1jNRKuF0JCvUkGsLkhaVd39 RYwcoa67qAej7MDoCVBokAC9ORrDWNmRaKR36Pa80RgMgZ8QKfnnnCA7au9t0CTiv/I9 OlnHY7+2+TkXAuxx88La4f9hXIIz1sD1nPv/Xfgo0TE7WZnX2ziifVkHB0GzIuU04bMu jltdApks2OLc0Oj9mKqLKa4eGPlJ5lX5D6qqkntk/FUm9M9cNHaWgfdzpR61mso87KCN ibFf8ytAW1M+iGGmZBTGBZwrnzG4RDA28k1fkmBWTVDkrVFYDPVSLfwKXO5Klt0hbwtr YbgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature:dkim-signature; bh=kZbZBrMuTcRef6SfXV2mspjsEoJ3kc6pYd2ikKr3Jw8=; b=C6uW/l6rpACyJ32BvxmJKjVMapqhfs7r5Mo4OT7k9vtoW5oMKqm9UMPWEsqErG3IEZ TJ+G+kQAkc4bqpKxX3eacJresw3LGUrK1CjNTNEsCYSUdbhZHJ1P9/a24h8y3bvqhd/R cCIVW+q5g5lp9LlxisbDFgdk9I9fvtcnpxD5AydHsaIFlzuyCcL5Rba3oAFtnKS364Ws /aFrSGSMPGvvfPVPl9u+RRRefDl5vQMDusUUo/hUE1aHUeFyT301QMdhQbL1vw83wGsZ k/nKhRCIx1g8NtR8hXSsyKW0cQj1DCvOlGapUW5MaL2W8XG0eu9YkXM2U8g9DGaUKrNL TzrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mobile-devices.fr header.s=google header.b="OfT5s/jy"; dkim=fail header.i=@gmail.com header.s=20161025 header.b=rgAgLQsI; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u7-v6si15042208plz.353.2018.09.17.07.00.12; Mon, 17 Sep 2018 07:00:28 -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; dkim=fail header.i=@mobile-devices.fr header.s=google header.b="OfT5s/jy"; dkim=fail header.i=@gmail.com header.s=20161025 header.b=rgAgLQsI; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728706AbeIQT0f (ORCPT + 99 others); Mon, 17 Sep 2018 15:26:35 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:40879 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727052AbeIQT0e (ORCPT ); Mon, 17 Sep 2018 15:26:34 -0400 Received: by mail-oi0-f66.google.com with SMTP id l202-v6so18943546oig.7 for ; Mon, 17 Sep 2018 06:59:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mobile-devices.fr; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=kZbZBrMuTcRef6SfXV2mspjsEoJ3kc6pYd2ikKr3Jw8=; b=OfT5s/jyMaSUV7MYh9aPTDkJwGnggI5kH58NS4JXaoP+8vZluogCQuo/ipnauh9x8u 5mM31vEyQ8V2bZr2+5zrvloHEf/SIfCdCkzJmYCS8b0Fik/nuJ/jS+xq/sUGQQdcjYQ5 hER3dmGeUNJL7TnSQ+tacrRgrztSxZWPu8Rq4= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=kZbZBrMuTcRef6SfXV2mspjsEoJ3kc6pYd2ikKr3Jw8=; b=rgAgLQsIkbswEI2KIZUhzrR+q60YDvcI6v3W0oJLZlhZFO2xQlewgLq9VTHsoSO4kk tzcf6Zba4sgG3HrkAhJBThXqSC8uzKD+MNTA4RDjZGJRISIcB7cXHOzPQL+2XT5prufD kAdq6UXBovSy/nzD6HqPPqVx53jI22ZAJSuulg+kahfqAQOXBiDAl0TLIrMRBGojLvwT 1kXGv/8ehaLgzLFyGkFb9NvxURYvWWoYNw1VmNudkNXLgsZML5f+TXyr/ETTVqKUYCum k9alCHAreucX2zswgxqGW4UP5jImUk5NXfRqMYCqvIv0wBsdh9VC+jt5s5istPEOasLn i14g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=kZbZBrMuTcRef6SfXV2mspjsEoJ3kc6pYd2ikKr3Jw8=; b=YNPskFNL8p1cihNMpWL8m4T772JVNITRDmypgKvO3hfJRpPw3VpgCrxqQ1uIFoD8NE 5aejeSqrz0cOzpQEs7mbaFu0zh1JXrx/JPxxhFte/pXjUI20LKWQXdBOqvBo6u1a3ldR hqLv/aLXua5tLp6R03qgBuJesiyZ+XS7yV2fh7hL9ewlagsAOKmvvBZtA4nQq/nQrLq2 i8F1D7XiJHg2/+UoOWsInOMg/EFwCqHj+JqSa+a/MKQQsJ9wQTq+nVhybQw9T5QTPs4l 6YHzi7TZJbNM2f++COqKCPsakSt2uUjQ6+0MHHn8HzR0qQK40TaHB7yEcT0uLmGXZmSq w55Q== X-Gm-Message-State: APzg51CHQEdmP7rb+WJJ8EwtdbYRwosMIcJ6Xz1QGbwFXoEnUUmNSbRY lJYXpzXiuISHj5Bu9qXnsaLgkXH9f88OUZEtKQGskQ== X-Received: by 2002:aca:7c5:: with SMTP id 188-v6mr18310456oih.58.1537192746163; Mon, 17 Sep 2018 06:59:06 -0700 (PDT) MIME-Version: 1.0 Received: by 2002:a9d:328a:0:0:0:0:0 with HTTP; Mon, 17 Sep 2018 06:58:45 -0700 (PDT) In-Reply-To: <20180914102732.GP14988@piout.net> References: <20180914101339.7382-1-romain.izard.pro@gmail.com> <20180914101339.7382-3-romain.izard.pro@gmail.com> <20180914102732.GP14988@piout.net> From: Romain Izard Date: Mon, 17 Sep 2018 15:58:45 +0200 X-Google-Sender-Auth: 1YKlElW2lcb93Wo48WNbZR0eA5Q Message-ID: Subject: Re: [PATCH 2/2] watchdog: sama5d4: write the mode register in two steps To: Alexandre Belloni Cc: Nicolas Ferre , Wim Van Sebroeck , Guenter Roeck , Marcus Folkesson , linux-arm-kernel , linux-watchdog@vger.kernel.org, LKML 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 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 Best regards, -- Romain Izard