[PATCH] delay: Fix ndelay() spuriously treated as udelay()

Frederic Weisbecker posted 1 patch 2 days, 11 hours ago
include/asm-generic/delay.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH] delay: Fix ndelay() spuriously treated as udelay()
Posted by Frederic Weisbecker 2 days, 11 hours ago
A recent rework on delay functions wrongly ended up calling __udelay()
instead of __ndelay() for nanosecond delays, increasing those by 1000.

As a result hangs have been observed on boot

Restore the right function calls.

Fixes: 19e2d91d8cb1 ("delay: Rework udelay and ndelay")
Reported-by: Chen-Yu Tsai <wenst@chromium.org>
Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
---
 include/asm-generic/delay.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/asm-generic/delay.h b/include/asm-generic/delay.h
index 76cf237b6e4c..03b0ec7afca6 100644
--- a/include/asm-generic/delay.h
+++ b/include/asm-generic/delay.h
@@ -75,11 +75,11 @@ static __always_inline void ndelay(unsigned long nsec)
 {
 	if (__builtin_constant_p(nsec)) {
 		if (nsec >= DELAY_CONST_MAX)
-			__bad_udelay();
+			__bad_ndelay();
 		else
 			__const_udelay(nsec * NDELAY_CONST_MULT);
 	} else {
-		__udelay(nsec);
+		__ndelay(nsec);
 	}
 }
 #define ndelay(x) ndelay(x)
-- 
2.46.0
Re: [PATCH] delay: Fix ndelay() spuriously treated as udelay()
Posted by Chen-Yu Tsai 1 day, 23 hours ago
On Thu, Nov 21, 2024 at 11:30 PM Frederic Weisbecker
<frederic@kernel.org> wrote:
>
> A recent rework on delay functions wrongly ended up calling __udelay()
> instead of __ndelay() for nanosecond delays, increasing those by 1000.
>
> As a result hangs have been observed on boot
>
> Restore the right function calls.
>
> Fixes: 19e2d91d8cb1 ("delay: Rework udelay and ndelay")
> Reported-by: Chen-Yu Tsai <wenst@chromium.org>
> Signed-off-by: Frederic Weisbecker <frederic@kernel.org>

Tested-by: Chen-Yu Tsai <wenst@chromium.org>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>

Thank you for the quick response! This fixed things for me.

> ---
>  include/asm-generic/delay.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/include/asm-generic/delay.h b/include/asm-generic/delay.h
> index 76cf237b6e4c..03b0ec7afca6 100644
> --- a/include/asm-generic/delay.h
> +++ b/include/asm-generic/delay.h
> @@ -75,11 +75,11 @@ static __always_inline void ndelay(unsigned long nsec)
>  {
>         if (__builtin_constant_p(nsec)) {
>                 if (nsec >= DELAY_CONST_MAX)
> -                       __bad_udelay();
> +                       __bad_ndelay();
>                 else
>                         __const_udelay(nsec * NDELAY_CONST_MULT);
>         } else {
> -               __udelay(nsec);
> +               __ndelay(nsec);
>         }
>  }
>  #define ndelay(x) ndelay(x)
> --
> 2.46.0
>