* [PATCH] ASoC: sophgo: fix 64-bit division build failure
@ 2026-02-02 9:53 Arnd Bergmann
2026-02-02 21:31 ` Alexander Sverdlin
2026-02-02 22:48 ` Mark Brown
0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2026-02-02 9:53 UTC (permalink / raw)
To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
Chen Wang, Inochi Amaoto, Anton D. Stavinskii
Cc: Arnd Bergmann, linux-sound, sophgo, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
cv1800b_adc_setbclk_div() does four 64-bit divisions in a row, which
is rather inefficient on 32-bit systems, and using the plain division
causes a build failure as a result:
ERROR: modpost: "__aeabi_uldivmod" [sound/soc/sophgo/cv1800b-sound-adc.ko] undefined!
Consolidate those into a single division using the div_u64() macro.
Fixes: 4cf8752a03e6 ("ASoC: sophgo: add CV1800B internal ADC codec driver")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
sound/soc/sophgo/cv1800b-sound-adc.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/sound/soc/sophgo/cv1800b-sound-adc.c b/sound/soc/sophgo/cv1800b-sound-adc.c
index 794030b713e9..b66761156b99 100644
--- a/sound/soc/sophgo/cv1800b-sound-adc.c
+++ b/sound/soc/sophgo/cv1800b-sound-adc.c
@@ -105,11 +105,8 @@ static int cv1800b_adc_setbclk_div(struct cv1800b_priv *priv, unsigned int rate)
if (!priv->mclk_rate || !rate)
return -EINVAL;
- tmp = priv->mclk_rate;
- tmp /= CV1800B_RXADC_WORD_LEN;
- tmp /= CV1800B_RXADC_CHANNELS;
- tmp /= rate;
- tmp /= 2;
+ tmp = div_u64(priv->mclk_rate, CV1800B_RXADC_WORD_LEN *
+ CV1800B_RXADC_CHANNELS * rate * 2);
if (!tmp) {
dev_err(priv->dev, "computed BCLK divider is zero\n");
--
2.39.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: sophgo: fix 64-bit division build failure
2026-02-02 9:53 [PATCH] ASoC: sophgo: fix 64-bit division build failure Arnd Bergmann
@ 2026-02-02 21:31 ` Alexander Sverdlin
2026-02-02 22:00 ` Arnd Bergmann
2026-02-02 22:48 ` Mark Brown
1 sibling, 1 reply; 5+ messages in thread
From: Alexander Sverdlin @ 2026-02-02 21:31 UTC (permalink / raw)
To: Arnd Bergmann, Chen Wang, Inochi Amaoto, Anton D. Stavinskii
Cc: Arnd Bergmann, linux-sound, sophgo, linux-kernel
Hi Arnd!
On Mon, 2026-02-02 at 10:53 +0100, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> cv1800b_adc_setbclk_div() does four 64-bit divisions in a row, which
3 of the 4 divisors are actually a power of two, so it would be a bug
in the compiler to issue a division for them...
Regarding the 64 bits: seems that the actual issue is the tmp variable that
is of u64 type for no reason, because priv->mclk_rate is only u32.
Maybe turning tmp into a u32 would avoid unnecessary 64-bit division
altogether?
> is rather inefficient on 32-bit systems, and using the plain division
> causes a build failure as a result:
>
> ERROR: modpost: "__aeabi_uldivmod" [sound/soc/sophgo/cv1800b-sound-adc.ko] undefined!
>
> Consolidate those into a single division using the div_u64() macro.
>
> Fixes: 4cf8752a03e6 ("ASoC: sophgo: add CV1800B internal ADC codec driver")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> sound/soc/sophgo/cv1800b-sound-adc.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/sound/soc/sophgo/cv1800b-sound-adc.c b/sound/soc/sophgo/cv1800b-sound-adc.c
> index 794030b713e9..b66761156b99 100644
> --- a/sound/soc/sophgo/cv1800b-sound-adc.c
> +++ b/sound/soc/sophgo/cv1800b-sound-adc.c
> @@ -105,11 +105,8 @@ static int cv1800b_adc_setbclk_div(struct cv1800b_priv *priv, unsigned int rate)
> if (!priv->mclk_rate || !rate)
> return -EINVAL;
>
> - tmp = priv->mclk_rate;
> - tmp /= CV1800B_RXADC_WORD_LEN;
> - tmp /= CV1800B_RXADC_CHANNELS;
> - tmp /= rate;
> - tmp /= 2;
> + tmp = div_u64(priv->mclk_rate, CV1800B_RXADC_WORD_LEN *
> + CV1800B_RXADC_CHANNELS * rate * 2);
>
> if (!tmp) {
> dev_err(priv->dev, "computed BCLK divider is zero\n");
--
Alexander Sverdlin.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: sophgo: fix 64-bit division build failure
2026-02-02 21:31 ` Alexander Sverdlin
@ 2026-02-02 22:00 ` Arnd Bergmann
0 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2026-02-02 22:00 UTC (permalink / raw)
To: Alexander Sverdlin, Arnd Bergmann, Chen Wang, Inochi Amaoto,
Anton Stavinsky
Cc: linux-sound, sophgo, linux-kernel
On Mon, Feb 2, 2026, at 22:31, Alexander Sverdlin wrote:
> Regarding the 64 bits: seems that the actual issue is the tmp variable that
> is of u64 type for no reason, because priv->mclk_rate is only u32.
>
> Maybe turning tmp into a u32 would avoid unnecessary 64-bit division
> altogether?
Ah, good point, sent v2 now.
Arnd
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] ASoC: sophgo: fix 64-bit division build failure
2026-02-02 9:53 [PATCH] ASoC: sophgo: fix 64-bit division build failure Arnd Bergmann
2026-02-02 21:31 ` Alexander Sverdlin
@ 2026-02-02 22:48 ` Mark Brown
2026-02-03 0:11 ` Chen Wang
1 sibling, 1 reply; 5+ messages in thread
From: Mark Brown @ 2026-02-02 22:48 UTC (permalink / raw)
To: Liam Girdwood, Jaroslav Kysela, Takashi Iwai, Chen Wang,
Inochi Amaoto, Anton D. Stavinskii, Arnd Bergmann
Cc: Arnd Bergmann, linux-sound, sophgo, linux-kernel
On Mon, 02 Feb 2026 10:53:14 +0100, Arnd Bergmann wrote:
> cv1800b_adc_setbclk_div() does four 64-bit divisions in a row, which
> is rather inefficient on 32-bit systems, and using the plain division
> causes a build failure as a result:
>
> ERROR: modpost: "__aeabi_uldivmod" [sound/soc/sophgo/cv1800b-sound-adc.ko] undefined!
>
> Consolidate those into a single division using the div_u64() macro.
>
> [...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/1] ASoC: sophgo: fix 64-bit division build failure
commit: cad9720dd7e4dcdaec8e854fb2c1d1d45fd6dbad
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] 5+ messages in thread
* Re: [PATCH] ASoC: sophgo: fix 64-bit division build failure
2026-02-02 22:48 ` Mark Brown
@ 2026-02-03 0:11 ` Chen Wang
0 siblings, 0 replies; 5+ messages in thread
From: Chen Wang @ 2026-02-03 0:11 UTC (permalink / raw)
To: Mark Brown, Liam Girdwood, Jaroslav Kysela, Takashi Iwai,
Inochi Amaoto, Anton D. Stavinskii, Arnd Bergmann
Cc: Arnd Bergmann, linux-sound, sophgo, linux-kernel
On 2/3/2026 6:48 AM, Mark Brown wrote:
> On Mon, 02 Feb 2026 10:53:14 +0100, Arnd Bergmann wrote:
>> cv1800b_adc_setbclk_div() does four 64-bit divisions in a row, which
>> is rather inefficient on 32-bit systems, and using the plain division
>> causes a build failure as a result:
>>
>> ERROR: modpost: "__aeabi_uldivmod" [sound/soc/sophgo/cv1800b-sound-adc.ko] undefined!
>>
>> Consolidate those into a single division using the div_u64() macro.
>>
>> [...]
> Applied to
>
> https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
>
> Thanks!
>
> [1/1] ASoC: sophgo: fix 64-bit division build failure
> commit: cad9720dd7e4dcdaec8e854fb2c1d1d45fd6dbad
>
> 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
>
Hi, Mark,
I noticed Arnd sent v2 for this patch, please see
https://lore.kernel.org/sophgo/20260202215956.2127414-1-arnd@kernel.org/.
Chen
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-02-03 0:12 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-02 9:53 [PATCH] ASoC: sophgo: fix 64-bit division build failure Arnd Bergmann
2026-02-02 21:31 ` Alexander Sverdlin
2026-02-02 22:00 ` Arnd Bergmann
2026-02-02 22:48 ` Mark Brown
2026-02-03 0:11 ` Chen Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox