From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,NICE_REPLY_A,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 93A31C433E0 for ; Wed, 29 Jul 2020 14:57:38 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 518CE20829 for ; Wed, 29 Jul 2020 14:57:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="AVvAXz8t"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pMVsa2kF" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 518CE20829 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=IFI+21kZHnek4qUb/2gMvvdYyIOkNcr2g9n1+okVIck=; b=AVvAXz8tdzquhHiJ66ZTI++Jw 56f9CebkLi+a1DZMvyfTmX9m/GRA7p/Pv/ivWiYIS6pGmGM9fGTJoRcINvQQ4zfQpKkdmIVdrv/Zc eKLfdhLciHppXp96KXmBFWTvgZybOfJfo5kiMYPrJQ5NAspV5hsreYtpM704mGwD8cowf+Iwm+1NU YVi92eTs2VTxwsF5Q384vfmEnOrCV/5ll75Sl+Px6Dv6WrpAqxQxLM74OsZcI2OLtSbDLavEOflJV R1AyKnuWVLTgwD5RLI4D4dh/r1qBx1y/Hy+fL/c3WhLnDiiC/dMt+oRLBdVQp0gKZ5vnTBbM9ARNv cvV/1tv6A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0nUC-0002YH-TW; Wed, 29 Jul 2020 14:55:17 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k0nU8-0002Ur-M6 for linux-arm-kernel@lists.infradead.org; Wed, 29 Jul 2020 14:55:13 +0000 Received: by mail-pl1-x642.google.com with SMTP id p1so11896992pls.4 for ; Wed, 29 Jul 2020 07:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:cc:references:from:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=fHVJHfObezpNx93Kfw2osfsK9YONudmdl/9M9ShWilA=; b=pMVsa2kFrNxwiB+woqhgYWEmPn6hxu1Wl5nP5VSpDroHqn1u0KYJ1mE9/92HKhEc1Q 8wzWWmFhrGiPJuj52Y2xzZP7q6TueWaVa/q7syP4dztKYcsMaolh0hn47kWbbS+rThMp Cn2ZhJkC0/L7paLD0z+v1Vhs0BvVCmUcCAaidjSkCfV6OJMnyuq6V0jlBoTETA6PTVfO 2+xyEu79lwJcIvs8hJPSo5NxK3xjQ7H+Y2cEE86POj8MsJgg20NdVr36jAqmTwOVDRgP RHelmv8nQ3VBlMz5M8coMH1Qq4Cl6VwdY8mXqrCJ45ZNbK6MRVh9yXciLpv3JGTSKjIJ 6yYQ== 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:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=fHVJHfObezpNx93Kfw2osfsK9YONudmdl/9M9ShWilA=; b=J0Ly/bpF6BSPuoqYURwMyxPyV4tFfqnkdlbJEV4hiz/UUW9MocfmLqlCYIfMMKmttz 1PlQOQSHD2/tab83t3mhaiVjgb7nuvUWaF2+busovJPdzI7cBaimVQCrVRa+En+XIGNP dY8ENpWGcn8Zx/CykFX5Kv3ilmEyoEkBMWvERMqn1KJXG4AsQgjNzhgkAxzgUtG0VwTY RnBR2iC5Mw5VR97t/bXD+k1/rix5C+2HEGqrKZS7ONo0DyXNO8Z7OiSFBYAb26AL5km5 ScRgE1K1PLIabSKvW/lKgI1ZQX3nNjQBj9Ia7o3mGr8CzhMMCA2q72WkjoENZjQIODhZ ijiQ== X-Gm-Message-State: AOAM5339wZ3Nh4TZ/7B5sDmR/AdNEqpvHrmCnLiR1OjWcR++Oa87biCE E9fzaXUis0dH0tMXlg9MQ2Y= X-Google-Smtp-Source: ABdhPJzg9Kx70gtjWlbtTC6HVc9CHC8eWPqmI+dtjQiDk47CJiiTp6Ly1fgXMC4Jvbgc/r8g0A/ZSA== X-Received: by 2002:a17:90a:c094:: with SMTP id o20mr9648330pjs.12.1596034509012; Wed, 29 Jul 2020 07:55:09 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id y69sm2714578pfc.111.2020.07.29.07.55.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 29 Jul 2020 07:55:08 -0700 (PDT) Subject: Re: [PATCH V2 1/2] watchdog: imx7ulp: Strictly follow the sequence for wdog operations To: Anson Huang , "wim@linux-watchdog.org" , "shawnguo@kernel.org" , "s.hauer@pengutronix.de" , "kernel@pengutronix.de" , "festevam@gmail.com" , "linux-watchdog@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" References: <1595989227-24700-1-git-send-email-Anson.Huang@nxp.com> <00587a78-8069-4fbd-7e02-b774d541f75a@roeck-us.net> From: Guenter Roeck Autocrypt: addr=linux@roeck-us.net; keydata= xsFNBE6H1WcBEACu6jIcw5kZ5dGeJ7E7B2uweQR/4FGxH10/H1O1+ApmcQ9i87XdZQiB9cpN RYHA7RCEK2dh6dDccykQk3bC90xXMPg+O3R+C/SkwcnUak1UZaeK/SwQbq/t0tkMzYDRxfJ7 nyFiKxUehbNF3r9qlJgPqONwX5vJy4/GvDHdddSCxV41P/ejsZ8PykxyJs98UWhF54tGRWFl 7i1xvaDB9lN5WTLRKSO7wICuLiSz5WZHXMkyF4d+/O5ll7yz/o/JxK5vO/sduYDIlFTvBZDh gzaEtNf5tQjsjG4io8E0Yq0ViobLkS2RTNZT8ICq/Jmvl0SpbHRvYwa2DhNsK0YjHFQBB0FX IdhdUEzNefcNcYvqigJpdICoP2e4yJSyflHFO4dr0OrdnGLe1Zi/8Xo/2+M1dSSEt196rXaC kwu2KgIgmkRBb3cp2vIBBIIowU8W3qC1+w+RdMUrZxKGWJ3juwcgveJlzMpMZNyM1jobSXZ0 VHGMNJ3MwXlrEFPXaYJgibcg6brM6wGfX/LBvc/haWw4yO24lT5eitm4UBdIy9pKkKmHHh7s jfZJkB5fWKVdoCv/omy6UyH6ykLOPFugl+hVL2Prf8xrXuZe1CMS7ID9Lc8FaL1ROIN/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dertmw7eyAYOo4RuWJguYMg5DRnBk WkRwrSuCn7UG+qVWZeKEsFKFOkynOs3pVbcbq1pxbhk3TRWCGRU5JolI4ohy/7JV1TVbjiDI HP/aVnm6NC8of26P40Pg8EdAhajZnHHjA7FrJXsy3cyIGqvg9os4rNkUWmrCfLLsZDHD8FnU mDW4+i+XlNFUPUYMrIKi9joBhu18ssf5i5Q= Message-ID: <22e16ed3-355a-70c4-ccc7-aece498b29fb@roeck-us.net> Date: Wed, 29 Jul 2020 07:55:06 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200729_105512_801582_304B250F X-CRM114-Status: GOOD ( 26.62 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: dl-linux-imx Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 7/28/20 10:02 PM, Anson Huang wrote: > Hi, Guenter > > >> Subject: RE: [PATCH V2 1/2] watchdog: imx7ulp: Strictly follow the sequence >> for wdog operations >> >> Hi, Guenter >> >> >>> Subject: Re: [PATCH V2 1/2] watchdog: imx7ulp: Strictly follow the >>> sequence for wdog operations >>> >>> On 7/28/20 7:20 PM, Anson Huang wrote: >>>> According to reference manual, the i.MX7ULP WDOG's operations should >>>> follow below sequence: >>>> >>>> 1. disable global interrupts; >>>> 2. unlock the wdog and wait unlock bit set; 3. reconfigure the wdog >>>> and wait for reconfiguration bit set; 4. enabel global interrupts. >>>> >>>> Strictly follow the recommended sequence can make it more robust. >>>> >>>> Signed-off-by: Anson Huang >>>> --- >>>> Changes since V1: >>>> - use readl_poll_timeout_atomic() instead of usleep_ranges() since >>>> IRQ is >>> disabled. >>>> --- >>>> drivers/watchdog/imx7ulp_wdt.c | 29 +++++++++++++++++++++++++++++ >>>> 1 file changed, 29 insertions(+) >>>> >>>> diff --git a/drivers/watchdog/imx7ulp_wdt.c >>>> b/drivers/watchdog/imx7ulp_wdt.c index 7993c8c..7d2b12e 100644 >>>> --- a/drivers/watchdog/imx7ulp_wdt.c >>>> +++ b/drivers/watchdog/imx7ulp_wdt.c >>>> @@ -5,6 +5,7 @@ >>>> >>>> #include >>>> #include >>>> +#include >>>> #include >>>> #include >>>> #include >>>> @@ -36,6 +37,7 @@ >>>> #define DEFAULT_TIMEOUT 60 >>>> #define MAX_TIMEOUT 128 >>>> #define WDOG_CLOCK_RATE 1000 >>>> +#define WDOG_WAIT_TIMEOUT 10000 >>>> >>>> static bool nowayout = WATCHDOG_NOWAYOUT; >>> module_param(nowayout, >>>> bool, 0000); @@ -48,17 +50,31 @@ struct imx7ulp_wdt_device { >>>> struct clk *clk; >>>> }; >>>> >>>> +static inline void imx7ulp_wdt_wait(void __iomem *base, u32 mask) { >>>> + u32 val = readl(base + WDOG_CS); >>>> + >>>> + if (!(val & mask)) >>>> + WARN_ON(readl_poll_timeout_atomic(base + WDOG_CS, val, >>>> + val & mask, 0, >>>> + WDOG_WAIT_TIMEOUT)); >>> >>> I am not a friend of WARN_ON, especially in situations like this. >>> Please explain why this is needed, and why a return of -ETIMEDOUT is >>> not feasible. >> >> OK, I will use return value of -ETIMEOUT and handle it in the caller. > > After a further look, some of the imx7ulp_wdt_wait () callers are void function, so if want > to handle the return value, all those functions return type need to be changed. And, when > the return value is -ETIMEDOUT, the ONLY action is to print out some error message > for these void function, need to use pr_err() due to no dev pointer available, so > do you think it is acceptable to just replace the WARN_ON with pr_err() as below? > First, the point here is that the callers can't do their work if the function times out. So, if the return value isn't necessary, and callers don't need to check it, the function would not be necessary to start with. If it is necessary, and if there is a concern that it can fail, callers should make sure that it actually succeeded. With that in mind, yes, imx7ulp_wdt_init() should fail and return an error, because presumably that is what happened. The same is true for imx7ulp_wdt_enable(). Really, what is the point of detecting a problem just to ignore it ? Second, the wait function is also called _after_ a register was set. In many cases that won't do any good or bad. While it is ok to ignore the error in that case (when nothing else is done), the error message is pointless in that situation. Thanks, Guenter _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel