All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] m68k: hash: Use lower_16_bits() helper
@ 2026-06-04  7:54 Geert Uytterhoeven
  2026-06-04  8:40 ` Heiko Stuebner
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2026-06-04  7:54 UTC (permalink / raw)
  To: Greg Ungerer, Heiko Stuebner
  Cc: linux-m68k, linux-kernel, Geert Uytterhoeven, kernel test robot

When building for m68k with CONFIG_M68000=y and C=1:

    drivers/clk/rockchip/clk-rk3528.c: note: in included file (through include/linux/hash.h, include/linux/slab.h):
    arch/m68k/include/asm/hash.h:57:24: warning: cast truncates bits from constant value (18720 becomes 8720)
    arch/m68k/include/asm/hash.h:57:24: warning: cast truncates bits from constant value (1e8e8 becomes e8e8)

Sparse does not realize the truncation is intentional.
Make this explicit by using the lower_16_bits() helper instead, which
also masks the unwanted bits.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202605191434.PQkj2Rki-lkp@intel.com/
Reported-by: Heiko Stuebner <heiko@sntech.de>
Closes: https://lore.kernel.org/20260603213726.1025094-1-heiko@sntech.de/
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
---
No change in generated code.

 arch/m68k/include/asm/hash.h | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/m68k/include/asm/hash.h b/arch/m68k/include/asm/hash.h
index 6d0d0c893f16dd49..6dadf493706632f5 100644
--- a/arch/m68k/include/asm/hash.h
+++ b/arch/m68k/include/asm/hash.h
@@ -2,6 +2,8 @@
 #ifndef _ASM_HASH_H
 #define _ASM_HASH_H
 
+#include <linux/wordpart.h>
+
 /*
  * If CONFIG_M68000=y (original mc68000/010), this file is #included
  * to work around the lack of a MULU.L instruction.
@@ -54,7 +56,7 @@ static inline u32 __attribute_const__ __hash_32(u32 x)
 	: "=&d,d" (a), "=&r,r" (b)
 	: "r,roi?" (x));	/* a+b = x*0x8647 */
 
-	return ((u16)(x*0x61c8) << 16) + a + b;
+	return (lower_16_bits(x * 0x61c8) << 16) + a + b;
 }
 
 #endif	/* _ASM_HASH_H */
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] m68k: hash: Use lower_16_bits() helper
  2026-06-04  7:54 [PATCH] m68k: hash: Use lower_16_bits() helper Geert Uytterhoeven
@ 2026-06-04  8:40 ` Heiko Stuebner
  2026-06-04  8:57 ` Daniel Palmer
  2026-06-08 10:53 ` Greg Ungerer
  2 siblings, 0 replies; 5+ messages in thread
From: Heiko Stuebner @ 2026-06-04  8:40 UTC (permalink / raw)
  To: Greg Ungerer, Geert Uytterhoeven
  Cc: linux-m68k, linux-kernel, Geert Uytterhoeven, kernel test robot

Am Donnerstag, 4. Juni 2026, 09:54:23 Mitteleuropäische Sommerzeit schrieb Geert Uytterhoeven:
> When building for m68k with CONFIG_M68000=y and C=1:
> 
>     drivers/clk/rockchip/clk-rk3528.c: note: in included file (through include/linux/hash.h, include/linux/slab.h):
>     arch/m68k/include/asm/hash.h:57:24: warning: cast truncates bits from constant value (18720 becomes 8720)
>     arch/m68k/include/asm/hash.h:57:24: warning: cast truncates bits from constant value (1e8e8 becomes e8e8)
> 
> Sparse does not realize the truncation is intentional.
> Make this explicit by using the lower_16_bits() helper instead, which
> also masks the unwanted bits.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202605191434.PQkj2Rki-lkp@intel.com/
> Reported-by: Heiko Stuebner <heiko@sntech.de>
> Closes: https://lore.kernel.org/20260603213726.1025094-1-heiko@sntech.de/
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

While I have no clue about m68k, lower_16_bits() does the correct thing
it seems, so

Reviewed-by: Heiko Stuebner <heiko@sntech.de>

and thanks for providing the correct fix for the core issue, so
other compile-test cases also won't create those warning.


Heiko


> ---
> No change in generated code.
> 
>  arch/m68k/include/asm/hash.h | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/m68k/include/asm/hash.h b/arch/m68k/include/asm/hash.h
> index 6d0d0c893f16dd49..6dadf493706632f5 100644
> --- a/arch/m68k/include/asm/hash.h
> +++ b/arch/m68k/include/asm/hash.h
> @@ -2,6 +2,8 @@
>  #ifndef _ASM_HASH_H
>  #define _ASM_HASH_H
>  
> +#include <linux/wordpart.h>
> +
>  /*
>   * If CONFIG_M68000=y (original mc68000/010), this file is #included
>   * to work around the lack of a MULU.L instruction.
> @@ -54,7 +56,7 @@ static inline u32 __attribute_const__ __hash_32(u32 x)
>  	: "=&d,d" (a), "=&r,r" (b)
>  	: "r,roi?" (x));	/* a+b = x*0x8647 */
>  
> -	return ((u16)(x*0x61c8) << 16) + a + b;
> +	return (lower_16_bits(x * 0x61c8) << 16) + a + b;
>  }
>  
>  #endif	/* _ASM_HASH_H */
> 





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] m68k: hash: Use lower_16_bits() helper
  2026-06-04  7:54 [PATCH] m68k: hash: Use lower_16_bits() helper Geert Uytterhoeven
  2026-06-04  8:40 ` Heiko Stuebner
@ 2026-06-04  8:57 ` Daniel Palmer
  2026-06-08  9:19   ` Geert Uytterhoeven
  2026-06-08 10:53 ` Greg Ungerer
  2 siblings, 1 reply; 5+ messages in thread
From: Daniel Palmer @ 2026-06-04  8:57 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Greg Ungerer, Heiko Stuebner, linux-m68k, linux-kernel,
	kernel test robot

Hi Geert,

On Thu, 4 Jun 2026 at 17:00, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> No change in generated code.

To be expected since the generated code hasn't been changed but I
build and boot tested in my 68000 virt machine and it still works:

smolsh / > uname -a
uClinux smol 7.1.0-rc6-00147-g6896dcea2588 #140 Thu Jun  4 17:54:03
JST 2026 m68k nolibc/Linux
[    2.890000] uname (26) used greatest stack depth: 4744 bytes left
smolsh / > cat /proc/cpuinfo
CPU:            68000
MMU:            none
FPU:            none
Clocking:       3169.5MHz
BogoMips:       933.06
Calibration:    466534400 loops

FWIW:

Tested-by: Daniel Palmer <daniel@thingy.jp>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] m68k: hash: Use lower_16_bits() helper
  2026-06-04  8:57 ` Daniel Palmer
@ 2026-06-08  9:19   ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2026-06-08  9:19 UTC (permalink / raw)
  To: Daniel Palmer
  Cc: Greg Ungerer, Heiko Stuebner, linux-m68k, linux-kernel,
	kernel test robot

On Thu, 4 Jun 2026 at 10:58, Daniel Palmer <daniel@0x0f.com> wrote:
> On Thu, 4 Jun 2026 at 17:00, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> > No change in generated code.

> Tested-by: Daniel Palmer <daniel@thingy.jp>

Thanks, queued in the m68k tree for v7.2.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] m68k: hash: Use lower_16_bits() helper
  2026-06-04  7:54 [PATCH] m68k: hash: Use lower_16_bits() helper Geert Uytterhoeven
  2026-06-04  8:40 ` Heiko Stuebner
  2026-06-04  8:57 ` Daniel Palmer
@ 2026-06-08 10:53 ` Greg Ungerer
  2 siblings, 0 replies; 5+ messages in thread
From: Greg Ungerer @ 2026-06-08 10:53 UTC (permalink / raw)
  To: Geert Uytterhoeven, Heiko Stuebner
  Cc: linux-m68k, linux-kernel, kernel test robot

Hi Geert,

On 4/6/26 17:54, Geert Uytterhoeven wrote:
> When building for m68k with CONFIG_M68000=y and C=1:
> 
>      drivers/clk/rockchip/clk-rk3528.c: note: in included file (through include/linux/hash.h, include/linux/slab.h):
>      arch/m68k/include/asm/hash.h:57:24: warning: cast truncates bits from constant value (18720 becomes 8720)
>      arch/m68k/include/asm/hash.h:57:24: warning: cast truncates bits from constant value (1e8e8 becomes e8e8)
> 
> Sparse does not realize the truncation is intentional.
> Make this explicit by using the lower_16_bits() helper instead, which
> also masks the unwanted bits.
> 
> Reported-by: kernel test robot <lkp@intel.com>
> Closes: https://lore.kernel.org/oe-kbuild-all/202605191434.PQkj2Rki-lkp@intel.com/
> Reported-by: Heiko Stuebner <heiko@sntech.de>
> Closes: https://lore.kernel.org/20260603213726.1025094-1-heiko@sntech.de/
> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>

FWIW:

Acked-by: Greg Ungerer <gerg@linux-m68k.org>

Regards
Greg




> ---
> No change in generated code.
> 
>   arch/m68k/include/asm/hash.h | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/m68k/include/asm/hash.h b/arch/m68k/include/asm/hash.h
> index 6d0d0c893f16dd49..6dadf493706632f5 100644
> --- a/arch/m68k/include/asm/hash.h
> +++ b/arch/m68k/include/asm/hash.h
> @@ -2,6 +2,8 @@
>   #ifndef _ASM_HASH_H
>   #define _ASM_HASH_H
>   
> +#include <linux/wordpart.h>
> +
>   /*
>    * If CONFIG_M68000=y (original mc68000/010), this file is #included
>    * to work around the lack of a MULU.L instruction.
> @@ -54,7 +56,7 @@ static inline u32 __attribute_const__ __hash_32(u32 x)
>   	: "=&d,d" (a), "=&r,r" (b)
>   	: "r,roi?" (x));	/* a+b = x*0x8647 */
>   
> -	return ((u16)(x*0x61c8) << 16) + a + b;
> +	return (lower_16_bits(x * 0x61c8) << 16) + a + b;
>   }
>   
>   #endif	/* _ASM_HASH_H */


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-06-08 10:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04  7:54 [PATCH] m68k: hash: Use lower_16_bits() helper Geert Uytterhoeven
2026-06-04  8:40 ` Heiko Stuebner
2026-06-04  8:57 ` Daniel Palmer
2026-06-08  9:19   ` Geert Uytterhoeven
2026-06-08 10:53 ` Greg Ungerer

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.