All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: nau8810: use 64-bit arithmetic instead of 32-bit
@ 2019-03-13  6:47 John Hsu
  2019-03-22  4:25 ` [PATCH] ASoC: nau8810: fix the issue of 64 bits division John Hsu
  0 siblings, 1 reply; 6+ messages in thread
From: John Hsu @ 2019-03-13  6:47 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, WTLI, John Hsu, lgirdwood, YHCHuang, CTLIN0

Add suffix ULL to constant 256 in order to give the compiler complete
information about the proper arithmetic to use.

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
---
 sound/soc/codecs/nau8810.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index bfd74b86c9d2..e7fd0b2645ea 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -505,7 +505,7 @@ static int nau88l0_calc_pll(unsigned int pll_in,
 	f2_max = 0;
 	scal_sel = ARRAY_SIZE(nau8810_mclk_scaler);
 	for (i = 0; i < ARRAY_SIZE(nau8810_mclk_scaler); i++) {
-		f2 = 256 * fs * 4 * nau8810_mclk_scaler[i] / 10;
+		f2 = 256ULL * fs * 4 * nau8810_mclk_scaler[i] / 10;
 		if (f2 > NAU_PLL_FREQ_MIN && f2 < NAU_PLL_FREQ_MAX &&
 			f2_max < f2) {
 			f2_max = f2;
-- 
2.18.0

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

* [PATCH] ASoC: nau8810: fix the issue of 64 bits division
  2019-03-13  6:47 [PATCH] ASoC: nau8810: use 64-bit arithmetic instead of 32-bit John Hsu
@ 2019-03-22  4:25 ` John Hsu
  2019-03-25 12:22   ` Applied "ASoC: nau8810: fix the issue of 64 bits division" to the asoc tree Mark Brown
  0 siblings, 1 reply; 6+ messages in thread
From: John Hsu @ 2019-03-22  4:25 UTC (permalink / raw)
  To: broonie; +Cc: alsa-devel, WTLI, John Hsu, lgirdwood, YHCHuang, CTLIN0

Do division with div_u64 for the PLL calculation.
These errors are fixed and list as follows:
1."__udivdi3" [sound/soc/codecs/snd-soc-nau8810.ko] undefined!
2."__aeabi_uldivmod" [sound/soc/codecs/snd-soc-nau8810.ko] undefined!
3. nau8810.c:(.text.nau8810_calc_pll+0xd8): undefined reference to
`__udivdi3'

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
---
 sound/soc/codecs/nau8810.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index 125e205e6687..dd82c65cfa7f 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -505,7 +505,8 @@ static int nau8810_calc_pll(unsigned int pll_in,
 	f2_max = 0;
 	scal_sel = ARRAY_SIZE(nau8810_mclk_scaler);
 	for (i = 0; i < ARRAY_SIZE(nau8810_mclk_scaler); i++) {
-		f2 = 256ULL * fs * 4 * nau8810_mclk_scaler[i] / 10;
+		f2 = 256ULL * fs * 4 * nau8810_mclk_scaler[i];
+		f2 = div_u64(f2, 10);
 		if (f2 > NAU_PLL_FREQ_MIN && f2 < NAU_PLL_FREQ_MAX &&
 			f2_max < f2) {
 			f2_max = f2;
-- 
2.18.0

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

* Applied "ASoC: nau8810: fix the issue of 64 bits division" to the asoc tree
  2019-03-22  4:25 ` [PATCH] ASoC: nau8810: fix the issue of 64 bits division John Hsu
@ 2019-03-25 12:22   ` Mark Brown
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Brown @ 2019-03-25 12:22 UTC (permalink / raw)
  To: John Hsu; +Cc: alsa-devel, WTLI, lgirdwood, YHCHuang, broonie, CTLIN0

The patch

   ASoC: nau8810: fix the issue of 64 bits division

has been applied to the asoc tree at

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

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

>From 3a9ce0f1b2961f6c3ad2a49dcf85449784c18bb5 Mon Sep 17 00:00:00 2001
From: John Hsu <KCHSU0@nuvoton.com>
Date: Fri, 22 Mar 2019 12:25:35 +0800
Subject: [PATCH] ASoC: nau8810: fix the issue of 64 bits division

Do division with div_u64 for the PLL calculation.
These errors are fixed and list as follows:
1."__udivdi3" [sound/soc/codecs/snd-soc-nau8810.ko] undefined!
2."__aeabi_uldivmod" [sound/soc/codecs/snd-soc-nau8810.ko] undefined!
3. nau8810.c:(.text.nau8810_calc_pll+0xd8): undefined reference to
`__udivdi3'

Signed-off-by: John Hsu <KCHSU0@nuvoton.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
 sound/soc/codecs/nau8810.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index 125e205e6687..dd82c65cfa7f 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -505,7 +505,8 @@ static int nau8810_calc_pll(unsigned int pll_in,
 	f2_max = 0;
 	scal_sel = ARRAY_SIZE(nau8810_mclk_scaler);
 	for (i = 0; i < ARRAY_SIZE(nau8810_mclk_scaler); i++) {
-		f2 = 256ULL * fs * 4 * nau8810_mclk_scaler[i] / 10;
+		f2 = 256ULL * fs * 4 * nau8810_mclk_scaler[i];
+		f2 = div_u64(f2, 10);
 		if (f2 > NAU_PLL_FREQ_MIN && f2 < NAU_PLL_FREQ_MAX &&
 			f2_max < f2) {
 			f2_max = f2;
-- 
2.20.1

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

* Re: [PATCH] ASoC: nau8810: use 64-bit arithmetic instead of 32-bit
  2018-07-05 15:14 [PATCH] ASoC: nau8810: use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
@ 2018-07-06 15:04   ` kbuild test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2018-07-06 15:04 UTC (permalink / raw)
  To: Gustavo A. R. Silva
  Cc: kbuild-all, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linux-kernel, Gustavo A. R. Silva

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

Hi Gustavo,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on v4.18-rc3 next-20180706]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Gustavo-A-R-Silva/ASoC-nau8810-use-64-bit-arithmetic-instead-of-32-bit/20180706-033309
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: m68k-allyesconfig (attached as .config)
compiler: m68k-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=m68k 

All errors (new ones prefixed by >>):

   sound/soc/codecs/nau8810.o: In function `nau8810_set_pll':
>> nau8810.c:(.text+0x53c): undefined reference to `__udivdi3'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 46101 bytes --]

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

* Re: [PATCH] ASoC: nau8810: use 64-bit arithmetic instead of 32-bit
@ 2018-07-06 15:04   ` kbuild test robot
  0 siblings, 0 replies; 6+ messages in thread
From: kbuild test robot @ 2018-07-06 15:04 UTC (permalink / raw)
  Cc: kbuild-all, Liam Girdwood, Mark Brown, Jaroslav Kysela,
	Takashi Iwai, alsa-devel, linux-kernel, Gustavo A. R. Silva

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

Hi Gustavo,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on asoc/for-next]
[also build test ERROR on v4.18-rc3 next-20180706]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Gustavo-A-R-Silva/ASoC-nau8810-use-64-bit-arithmetic-instead-of-32-bit/20180706-033309
base:   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
config: m68k-allyesconfig (attached as .config)
compiler: m68k-linux-gnu-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.2.0 make.cross ARCH=m68k 

All errors (new ones prefixed by >>):

   sound/soc/codecs/nau8810.o: In function `nau8810_set_pll':
>> nau8810.c:(.text+0x53c): undefined reference to `__udivdi3'

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 46101 bytes --]

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

* [PATCH] ASoC: nau8810: use 64-bit arithmetic instead of 32-bit
@ 2018-07-05 15:14 Gustavo A. R. Silva
  2018-07-06 15:04   ` kbuild test robot
  0 siblings, 1 reply; 6+ messages in thread
From: Gustavo A. R. Silva @ 2018-07-05 15:14 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai
  Cc: alsa-devel, linux-kernel, Gustavo A. R. Silva

Add suffix ULL to constant 256 in order to give the compiler complete
information about the proper arithmetic to use.

Notice that such constant is used in a context that expects an
expression of type u64 (64 bits, unsigned) and the following
expression is currently being evaluated using 32-bit arithmetic:

256 * fs * 4 * nau8810_mclk_scaler[i] / 10

Addresses-Coverity-ID: 1357595 ("Unintentional integer overflow")
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
 sound/soc/codecs/nau8810.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/soc/codecs/nau8810.c b/sound/soc/codecs/nau8810.c
index bfd74b8..e7fd0b2 100644
--- a/sound/soc/codecs/nau8810.c
+++ b/sound/soc/codecs/nau8810.c
@@ -505,7 +505,7 @@ static int nau88l0_calc_pll(unsigned int pll_in,
 	f2_max = 0;
 	scal_sel = ARRAY_SIZE(nau8810_mclk_scaler);
 	for (i = 0; i < ARRAY_SIZE(nau8810_mclk_scaler); i++) {
-		f2 = 256 * fs * 4 * nau8810_mclk_scaler[i] / 10;
+		f2 = 256ULL * fs * 4 * nau8810_mclk_scaler[i] / 10;
 		if (f2 > NAU_PLL_FREQ_MIN && f2 < NAU_PLL_FREQ_MAX &&
 			f2_max < f2) {
 			f2_max = f2;
-- 
2.7.4


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

end of thread, other threads:[~2019-03-25 12:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-13  6:47 [PATCH] ASoC: nau8810: use 64-bit arithmetic instead of 32-bit John Hsu
2019-03-22  4:25 ` [PATCH] ASoC: nau8810: fix the issue of 64 bits division John Hsu
2019-03-25 12:22   ` Applied "ASoC: nau8810: fix the issue of 64 bits division" to the asoc tree Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2018-07-05 15:14 [PATCH] ASoC: nau8810: use 64-bit arithmetic instead of 32-bit Gustavo A. R. Silva
2018-07-06 15:04 ` kbuild test robot
2018-07-06 15:04   ` kbuild test robot

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.