From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D46F87494; Sun, 3 Aug 2025 00:16:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754180188; cv=none; b=m2Zqk6qQSx35D0Mywz6IABasnGTorFTBs06Etn8lHh4m1+V5tIMtRY2K/l7tzxMFm7Xep+IK8ZSCFKHkYKK7xAdatI8etOqATzURgJYcSGhqL1r+jhGQGYANmE3T29XvnjYRXLjORANvEH4grKq3rC4Fk6cf3FkmCCVi2iZD6HI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1754180188; c=relaxed/simple; bh=IUvWGqpQ7Hhuylx1GyU5M5CpgvzLVzXTBfkN5Hye5PA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=qRVeKSPX9lubd7h/BeTk5W3XJ2wbA7p7oI/1LJxF5UnVsPnjrdbEnsXuCL2C+11K3BeaVFSLW+c80fsG40M2ly7qaRGoty6XhdmEAKezbsyTck43uehB7S+mBWl5ZNe9LcARanE5CGqD+qlCvrH6h/AXQuor/uwlTVoGc/7IYRU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=a+LdmqHN; arc=none smtp.client-ip=209.85.210.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=roeck-us.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="a+LdmqHN" Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-76bde897110so1424153b3a.3; Sat, 02 Aug 2025 17:16:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1754180186; x=1754784986; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:from:to:cc:subject:date:message-id:reply-to; bh=U4f6RGa1UKAKsttnf6xQ3CCtWWT/P+q0p71DgbB6kkI=; b=a+LdmqHN5EfovmiRpsQcG0o+lC3wiEAU7DHUSDvCb26qaE7EjoCGw6D5tpSGstVfWm 6GZC/OZoBPcNHKXZA35RklYtokuERMDoa48i7NdpMIGisrz+by+jl4we1pHjzOE9glB6 TjZPwc+k/DLsw9nhsasRTJISeAZmzOuDffWW8+9Ut1+R99t6Gv5PFvuca7s1TeE5KzmB wxFW68Jg47OXtvmjr8BX2qTfP4oey6LRUfJSqg7q7igAB2gkoJmlHQh05tpavDeuVH+b Poe/K3sKgSAu8IQdBb/kDCgtx3NxXYHpHfPV6qHZV19XVLVDxxjn0/Ud3kY5I65yy0/u ANyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1754180186; x=1754784986; h=content-transfer-encoding:in-reply-to:autocrypt:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=U4f6RGa1UKAKsttnf6xQ3CCtWWT/P+q0p71DgbB6kkI=; b=L3AZZekE7rkHqCeTI8d6qmDELittkNzCYm5AKrvckxZBHs6WtQXHAqeaHTOj7TnOsz 8mpJWOWUCxCe4zcT8VET3YUUgF4pdWehCyoWNmp0TpbqYVWncMdZ3xN7LIhwfDcZkF51 mJeUNjdeQaUdZkPuNAMgfZWPTFBIYr6J/OX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aLGCBD0TIinMDwoOsz3WbGd9JHBu0WHCHn NttruzJrLqGEzrRPG+RVUei/XcAoVLe6zhUQ8+NNIIVa/Nkdp6ZgeRWraKtN02wY/Z2MhzHy5MB UcqtzBfg== X-Google-Smtp-Source: AGHT+IHGwdBChEU6kB5AUKVDtfXZrhh+zzuuoFML5LEF3V9noFxNXGaBxDw9rhim8mHtyvhB7TS5xQ== X-Received: by 2002:a05:6a20:6a1b:b0:23d:f6c4:f8f1 with SMTP id adf61e73a8af0-23df9083103mr7594454637.21.1754180185956; Sat, 02 Aug 2025 17:16:25 -0700 (PDT) Received: from ?IPV6:2600:1700:e321:62f0:da43:aeff:fecc:bfd5? ([2600:1700:e321:62f0:da43:aeff:fecc:bfd5]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-b422baedf5csm6373359a12.47.2025.08.02.17.16.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 02 Aug 2025 17:16:25 -0700 (PDT) Sender: Guenter Roeck Message-ID: Date: Sat, 2 Aug 2025 17:16:22 -0700 Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 7/9] watchdog: rzv2h: Set min_timeout based on max_hw_heartbeat_ms To: "Lad, Prabhakar" Cc: Wolfram Sang , Wim Van Sebroeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Philipp Zabel , Geert Uytterhoeven , Magnus Damm , linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Biju Das , Fabrizio Castro , Lad Prabhakar References: <20250729155915.67758-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20250729155915.67758-8-prabhakar.mahadev-lad.rj@bp.renesas.com> <6b9338c0-e333-47dd-a3e0-0446b346f008@roeck-us.net> Content-Language: en-US From: Guenter Roeck Autocrypt: addr=linux@roeck-us.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7CyuFclAksOdV/sdpQnYlYcRQWOUGY HhQ5eqTRZjm9z+qQe/T0HQpmiPTqQcIaG/edgKVTUjITfA7AJMKLQHgp04Vylb+G6jocnQQX JqvvP09whbqrABEBAAHCwWUEGAECAA8CGwwFAmgrMyQFCSbODQkACgkQyx8mb86fmYHlgg/9 H5JeDmB4jsreE9Bn621wZk7NMzxy9STxiVKSh8Mq4pb+IDu1RU2iLyetCY1TiJlcxnE362kj njrfAdqyPteHM+LU59NtEbGwrfcXdQoh4XdMuPA5ADetPLma3YiRa3VsVkLwpnR7ilgwQw6u dycEaOxQ7LUXCs0JaGVVP25Z2hMkHBwx6BlW6EZLNgzGI2rswSZ7SKcsBd1IRHVf0miwIFYy j/UEfAFNW+tbtKPNn3xZTLs3quQN7GdYLh+J0XxITpBZaFOpwEKV+VS36pSLnNl0T5wm0E/y scPJ0OVY7ly5Vm1nnoH4licaU5Y1nSkFR/j2douI5P7Cj687WuNMC6CcFd6j72kRfxklOqXw zvy+2NEcXyziiLXp84130yxAKXfluax9sZhhrhKT6VrD45S6N3HxJpXQ/RY/EX35neH2/F7B RgSloce2+zWfpELyS1qRkCUTt1tlGV2p+y2BPfXzrHn2vxvbhEn1QpQ6t+85FKN8YEhJEygJ F0WaMvQMNrk9UAUziVcUkLU52NS9SXqpVg8vgrO0JKx97IXFPcNh0DWsSj/0Y8HO/RDkGXYn FDMj7fZSPKyPQPmEHg+W/KzxSSfdgWIHF2QaQ0b2q1wOSec4Rti52ohmNSY+KNIW/zODhugJ np3900V20aS7eD9K8GTU0TGC1pyz6IVJwIE= In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 8/2/25 12:26, Lad, Prabhakar wrote: > Hi Guenter, > > On Fri, Aug 1, 2025 at 10:04 PM Guenter Roeck wrote: >> >> On 8/1/25 13:51, Lad, Prabhakar wrote: >>> Hi Guenter, >>> >>> On Fri, Aug 1, 2025 at 7:04 PM Guenter Roeck wrote: >>>> >>>> On 8/1/25 08:30, Lad, Prabhakar wrote: >>>>> Hi Guenter, >>>>> >>>>> On Fri, Aug 1, 2025 at 2:52 PM Guenter Roeck wrote: >>>>>> >>>>>> On 8/1/25 04:05, Lad, Prabhakar wrote: >>>>>>> Hi Wolfram, >>>>>>> >>>>>>> Thank you for the review. >>>>>>> >>>>>>> On Fri, Aug 1, 2025 at 5:10 AM Wolfram Sang >>>>>>> wrote: >>>>>>>> >>>>>>>> On Tue, Jul 29, 2025 at 04:59:13PM +0100, Prabhakar wrote: >>>>>>>>> From: Lad Prabhakar >>>>>>>>> >>>>>>>>> Update the watchdog minimum timeout value to be derived from >>>>>>>>> `max_hw_heartbeat_ms` using `DIV_ROUND_UP()` to ensure a valid and >>>>>>>>> consistent minimum timeout in seconds. >>>>>>>> >>>>>>>> I don't understand this change. Why is the _minimum_ timeout based on >>>>>>>> the _maximum_ heartbeat? >>>>>>>> >>>>>>> The reason for deriving min_timeout from max_hw_heartbeat_ms is to >>>>>>> ensure the minimum watchdog period (in seconds) is compatible with the >>>>>>> underlying hardware. >>>>>>> >>>>>>> max_hw_heartbeat_ms is calculated as: >>>>>>> max_hw_heartbeat_ms = (1000 * 16384 * cks_div) / clk_rate; >>>>>>> >>>>>>> This value varies by SoC: >>>>>>> RZ/T2H: cks_div = 8192, clk ≈ 62.5 MHz -> max_hw_heartbeat_ms ~ 2147ms >>>>>>> RZ/V2H: cks_div = 256, clk ≈ 240 MHz -> max_hw_heartbeat_ms ~ 174ms >>>>>>> >>>>>>> Since min_timeout is in seconds, setting it to: >>>>>>> min_timeout = DIV_ROUND_UP(max_hw_heartbeat_ms, 1000); >>>>>>> >>>>>>> ensures: >>>>>>> The minimum timeout period is never less than what the hardware can support. >>>>>>> - For T2H, this results in a min_timeout of 3s (2147ms -> 3s). >>>>>>> - For V2H, it’s just 1s (174ms -> 1s). >>>>>>> >>>>>> >>>>>> Sorry, I completely fail to understand the logic. >>>>>> >>>>>> If the maximum timeout is, say, 2 seconds, why would the hardware >>>>>> not be able to support a timeout of 1 second ? >>>>>> >>>>> The watchdog timer on RZ/V2H (and RZ/T2H) is a 14 bit down counter. On >>>>> initialization the down counters on the SoCs are configured to the max >>>>> down counter. On RZ/V2H down counter value 4194304 (which evaluates to >>>>> 174ms) is and on RZ/T2H is 134217728 (which evaluates to 2147ms). The >>>>> board will be reset when we get an underflow error. >>>>> >>>>> So for example on T2H consider this example: >>>>> - down counter is 134217728 >>>>> - min_timeout is set to 1 in the driver >>>>> - When set WDIOC_SETTIMEOUT to 1 >>>>> In this case the board will be reset after 2147ms, i.e. incorrect >>>>> behaviour as we expect the board to be reset after 1 sec. Hence the >>>>> min_timeout is set to 3s (2147ms -> 3s). >>>>> >>>>> Please let me know if my understanding of min_timeout is incorrect here. >>>>> >>>> >>>> The driver is missing a set_timeout function. It should set RZ/T2H >>>> to 62514079 if a timeout of 1 second is configured. >>>> >>> Ok, you mean to handle the 1sec case, introduce the set_timeout for RZ/T2H SoC. >>> >>> Although we cannot achieve the exact 1sec case as we can have only 4 >>> timeout period options (number of cycles): >>> >>> 1] For TIMEOUT_CYCLES = 1024 >>> - (1000×1024×8192)/62500000 = 134.22 ms >>> 2] For TIMEOUT_CYCLES = 4096 >>> - (1000×4096×8192)/62500000 = 536.87 ms >>> 3] For TIMEOUT_CYCLES = 8192 >>> - (1000×8192×8192)/62500000 = 1,073.74 ms >>> 4] For TIMEOUT_CYCLES = 16384 >>> - (1000×16384×8192)/62500000 = 2,147.48 ms >>> >>> So to handle the 1sec case I'll set the timeout period to 8192 with >>> which we get a timeout of 1,073.74 ms. >>> >> >> Just four possible values to set the hardware timeout ? That is an odd >> hardware. In that case, you could also set the period to 1024 or 4096 >> and set max_hw_heartbeat_ms accordingly. That would avoid the rounding >> error. >> > Yes sadly we have four timeout periods only. To clarify, you mean to > set `max_hw_heartbeat_ms` in set_timeout? > No, during initialization, and have no set_timeout function. max_hw_heartbeat_ms is not supposed to change during runtime. If you do change it, the results are undefined. Guenter