The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] ASoC: tegra: tegra210-mixer: Use div_u64() for 64-bit division
@ 2026-05-07 23:21 Rosen Penev
  2026-05-08  0:52 ` Mark Brown
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Rosen Penev @ 2026-05-07 23:21 UTC (permalink / raw)
  To: linux-sound
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Thierry Reding, Jonathan Hunter, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt,
	open list:TEGRA ARCHITECTURE SUPPORT, open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

A MIPS allmodconfig build with LLVM fails during modpost:

  ERROR: modpost: "__udivdi3"
  [sound/soc/tegra/snd-soc-tegra210-mixer.ko] undefined!

tegra210_mixer_configure_gain() divides a 64-bit BIT_ULL() value by the
fade duration. On 32-bit MIPS, clang emits a call to __udivdi3 for that
plain C division, but that compiler helper is not exported to modules.

Use div_u64() for the inverse duration calculation so the driver uses the
kernel's 64-bit division helper instead of emitting a compiler runtime
call.

Assisted-by: Codex:GPT-5.5
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 sound/soc/tegra/tegra210_mixer.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/sound/soc/tegra/tegra210_mixer.c b/sound/soc/tegra/tegra210_mixer.c
index f05617b5f433..bfdd457f740c 100644
--- a/sound/soc/tegra/tegra210_mixer.c
+++ b/sound/soc/tegra/tegra210_mixer.c
@@ -7,6 +7,7 @@
 #include <linux/clk.h>
 #include <linux/device.h>
 #include <linux/io.h>
+#include <linux/math64.h>
 #include <linux/mod_devicetable.h>
 #include <linux/module.h>
 #include <linux/platform_device.h>
@@ -157,8 +158,8 @@ static int tegra210_mixer_configure_gain(struct snd_soc_component *cmpnt,
 			if (i == DURATION_N3_ID)
 				val = mixer->duration[id];
 			else if (i == DURATION_INV_N3_ID)
-				val = (u32)(BIT_ULL(31 + TEGRA210_MIXER_PRESCALAR) /
-					    mixer->duration[id]);
+				val = div_u64(BIT_ULL(31 + TEGRA210_MIXER_PRESCALAR),
+					      mixer->duration[id]);
 			else
 				val = gain_params.duration[i];
 		}
-- 
2.54.0


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

* Re: [PATCH] ASoC: tegra: tegra210-mixer: Use div_u64() for 64-bit division
  2026-05-07 23:21 [PATCH] ASoC: tegra: tegra210-mixer: Use div_u64() for 64-bit division Rosen Penev
@ 2026-05-08  0:52 ` Mark Brown
  2026-05-08 12:33 ` Nathan Chancellor
  2026-05-08 13:22 ` Thierry Reding
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2026-05-08  0:52 UTC (permalink / raw)
  To: linux-sound, Rosen Penev
  Cc: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Thierry Reding,
	Jonathan Hunter, Nathan Chancellor, Nick Desaulniers,
	Bill Wendling, Justin Stitt, linux-tegra, linux-kernel, llvm

On Thu, 07 May 2026 16:21:31 -0700, Rosen Penev wrote:
> ASoC: tegra: tegra210-mixer: Use div_u64() for 64-bit division

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-7.2

Thanks!

[1/1] ASoC: tegra: tegra210-mixer: Use div_u64() for 64-bit division
      https://git.kernel.org/broonie/sound/c/04b8f96b1088

All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.

You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.

If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.

Please add any relevant lists and maintainers to the CCs when replying
to this mail.

Thanks,
Mark


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

* Re: [PATCH] ASoC: tegra: tegra210-mixer: Use div_u64() for 64-bit division
  2026-05-07 23:21 [PATCH] ASoC: tegra: tegra210-mixer: Use div_u64() for 64-bit division Rosen Penev
  2026-05-08  0:52 ` Mark Brown
@ 2026-05-08 12:33 ` Nathan Chancellor
  2026-05-08 13:22 ` Thierry Reding
  2 siblings, 0 replies; 4+ messages in thread
From: Nathan Chancellor @ 2026-05-08 12:33 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-sound, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Thierry Reding, Jonathan Hunter, Nick Desaulniers,
	Bill Wendling, Justin Stitt, open list:TEGRA ARCHITECTURE SUPPORT,
	open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

On Thu, May 07, 2026 at 04:21:31PM -0700, Rosen Penev wrote:
> A MIPS allmodconfig build with LLVM fails during modpost:
> 
>   ERROR: modpost: "__udivdi3"
>   [sound/soc/tegra/snd-soc-tegra210-mixer.ko] undefined!
> 
> tegra210_mixer_configure_gain() divides a 64-bit BIT_ULL() value by the
> fade duration. On 32-bit MIPS, clang emits a call to __udivdi3 for that
> plain C division, but that compiler helper is not exported to modules.
> 
> Use div_u64() for the inverse duration calculation so the driver uses the
> kernel's 64-bit division helper instead of emitting a compiler runtime
> call.
> 
> Assisted-by: Codex:GPT-5.5
> Signed-off-by: Rosen Penev <rosenp@gmail.com>

This is neither a Clang nor MIPS specific issue, it will happen with any
32-bit target, as Arnd's patch shows:

  https://lore.kernel.org/20260508080031.4064272-1-arnd@kernel.org/

Regardless, this is obviously the correct fix.

Reviewed-by: Nathan Chancellor <nathan@kernel.org>

> ---
>  sound/soc/tegra/tegra210_mixer.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/sound/soc/tegra/tegra210_mixer.c b/sound/soc/tegra/tegra210_mixer.c
> index f05617b5f433..bfdd457f740c 100644
> --- a/sound/soc/tegra/tegra210_mixer.c
> +++ b/sound/soc/tegra/tegra210_mixer.c
> @@ -7,6 +7,7 @@
>  #include <linux/clk.h>
>  #include <linux/device.h>
>  #include <linux/io.h>
> +#include <linux/math64.h>
>  #include <linux/mod_devicetable.h>
>  #include <linux/module.h>
>  #include <linux/platform_device.h>
> @@ -157,8 +158,8 @@ static int tegra210_mixer_configure_gain(struct snd_soc_component *cmpnt,
>  			if (i == DURATION_N3_ID)
>  				val = mixer->duration[id];
>  			else if (i == DURATION_INV_N3_ID)
> -				val = (u32)(BIT_ULL(31 + TEGRA210_MIXER_PRESCALAR) /
> -					    mixer->duration[id]);
> +				val = div_u64(BIT_ULL(31 + TEGRA210_MIXER_PRESCALAR),
> +					      mixer->duration[id]);
>  			else
>  				val = gain_params.duration[i];
>  		}
> -- 
> 2.54.0
> 

-- 
Cheers,
Nathan

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

* Re: [PATCH] ASoC: tegra: tegra210-mixer: Use div_u64() for 64-bit division
  2026-05-07 23:21 [PATCH] ASoC: tegra: tegra210-mixer: Use div_u64() for 64-bit division Rosen Penev
  2026-05-08  0:52 ` Mark Brown
  2026-05-08 12:33 ` Nathan Chancellor
@ 2026-05-08 13:22 ` Thierry Reding
  2 siblings, 0 replies; 4+ messages in thread
From: Thierry Reding @ 2026-05-08 13:22 UTC (permalink / raw)
  To: Rosen Penev
  Cc: linux-sound, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, Thierry Reding, Jonathan Hunter, Nathan Chancellor,
	Nick Desaulniers, Bill Wendling, Justin Stitt,
	open list:TEGRA ARCHITECTURE SUPPORT, open list,
	open list:CLANG/LLVM BUILD SUPPORT:Keyword:b(?i:clang|llvm)b

[-- Attachment #1: Type: text/plain, Size: 850 bytes --]

On Thu, May 07, 2026 at 04:21:31PM -0700, Rosen Penev wrote:
> A MIPS allmodconfig build with LLVM fails during modpost:
> 
>   ERROR: modpost: "__udivdi3"
>   [sound/soc/tegra/snd-soc-tegra210-mixer.ko] undefined!
> 
> tegra210_mixer_configure_gain() divides a 64-bit BIT_ULL() value by the
> fade duration. On 32-bit MIPS, clang emits a call to __udivdi3 for that
> plain C division, but that compiler helper is not exported to modules.
> 
> Use div_u64() for the inverse duration calculation so the driver uses the
> kernel's 64-bit division helper instead of emitting a compiler runtime
> call.
> 
> Assisted-by: Codex:GPT-5.5
> Signed-off-by: Rosen Penev <rosenp@gmail.com>
> ---
>  sound/soc/tegra/tegra210_mixer.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Acked-by: Thierry Reding <treding@nvidia.com>

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2026-05-09  0:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-07 23:21 [PATCH] ASoC: tegra: tegra210-mixer: Use div_u64() for 64-bit division Rosen Penev
2026-05-08  0:52 ` Mark Brown
2026-05-08 12:33 ` Nathan Chancellor
2026-05-08 13:22 ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox