[PATCH] sbsa_gwdt: Calculate timeout with 64-bit math

Darren Hart darren at os.amperecomputing.com
Sat Oct 14 02:12:29 PDT 2023


On Tue, Sep 26, 2023 at 05:45:13AM -0700, Guenter Roeck wrote:
> On Thu, Sep 21, 2023 at 02:02:36AM -0700, Darren Hart wrote:
> > Commit abd3ac7902fb ("watchdog: sbsa: Support architecture version 1")
> > introduced new timer math for watchdog revision 1 with the 48 bit offset
> > register.
> > 
> > The gwdt->clk and timeout are u32, but the argument being calculated is
> > u64. Without a cast, the compiler performs u32 operations, truncating
> > intermediate steps, resulting in incorrect values.
> > 
> > A watchdog revision 1 implementation with a gwdt->clk of 1GHz and a
> > timeout of 600s writes 3647256576 to the one shot watchdog instead of
> > 300000000000, resulting in the watchdog firing in 3.6s instead of 600s.
> > 
> > Force u64 math by casting the first argument (gwdt->clk) as a u64. Make
> > the order of operations explicit with parenthesis.
> > 
> > Fixes: abd3ac7902fb ("watchdog: sbsa: Support architecture version 1")
> > Reported-by: Vanshidhar Konda <vanshikonda at os.amperecomputing.com>
> > Signed-off-by: Darren Hart <darren at os.amperecomputing.com>
> > Cc: Wim Van Sebroeck <wim at linux-watchdog.org>
> > Cc: Guenter Roeck <linux at roeck-us.net>
> > Cc: linux-watchdog at vger.kernel.org
> > Cc: linux-kernel at vger.kernel.org
> > Cc: linux-arm-kernel at lists.infradead.org
> > Cc: <stable at vger.kernel.org> # 5.14.x
> 
> Reviewed-by: Guenter Roeck <linux at roeck-us.net>

Guenter or Wim, I haven't seen this land in the RCs or in next yet. Have
you already picked it up? Anything more needed from me?

Thanks,

-- 
Darren Hart
Ampere Computing / OS and Kernel



More information about the linux-arm-kernel mailing list