All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
@ 2011-04-27  7:27 Barry Song
  2011-04-27  8:19 ` Takashi Iwai
  0 siblings, 1 reply; 17+ messages in thread
From: Barry Song @ 2011-04-27  7:27 UTC (permalink / raw)
  To: broonie, lrg; +Cc: alsa-devel, Binghua Duan, Barry Song, Zhiwu Song

From: Barry Song <21cnbao@gmail.com>

The newest compiliers can optimize pll calculation in several codecs into __aeabi__uldivmod which doesn't exist in kernel.
Then the link will fail:
ERROR: "__aeabi_uldivmod" [sound/soc/codecs/snd-soc-wm8974.ko] undefined!
ERROR: "__aeabi_uldivmod" [sound/soc/codecs/snd-soc-wm8940.ko] undefined!
ERROR: "__aeabi_uldivmod" [sound/soc/codecs/snd-soc-wm8510.ko] undefined!
This patch prevent the optimizaton by insert ASM.

Signed-off-by: Barry Song <21cnbao@gmail.com>
Cc: Zhiwu Song <zhiwu.song@csr.com>
Cc: Binghua Duan <binghua.duan@csr.com>
---
 sound/soc/codecs/wm8510.c |    6 ++++++
 sound/soc/codecs/wm8940.c |    6 ++++++
 sound/soc/codecs/wm8974.c |    6 ++++++
 3 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c
index db0dced..a636b15 100644
--- a/sound/soc/codecs/wm8510.c
+++ b/sound/soc/codecs/wm8510.c
@@ -258,6 +258,12 @@ static void pll_factors(unsigned int target, unsigned int source)
 	Nmod = target % source;
 	Kpart = FIXED_PLL_SIZE * (long long)Nmod;
 
+	/*
+	 * The following asm() prevents the compiler from optimising
+	 * into a standard EABI function __aeabi__uldivmod()
+	 */
+	asm("" : "+r"(source));
+
 	do_div(Kpart, source);
 
 	K = Kpart & 0xFFFFFFFF;
diff --git a/sound/soc/codecs/wm8940.c b/sound/soc/codecs/wm8940.c
index 25580e3..f6148af 100644
--- a/sound/soc/codecs/wm8940.c
+++ b/sound/soc/codecs/wm8940.c
@@ -520,6 +520,12 @@ static void pll_factors(unsigned int target, unsigned int source)
 	Nmod = target % source;
 	Kpart = FIXED_PLL_SIZE * (long long)Nmod;
 
+	/*
+	 * The following asm() prevents the compiler from optimising
+	 * into a standard EABI function __aeabi__uldivmod()
+	 */
+	asm("" : "+r"(source));
+
 	do_div(Kpart, source);
 
 	K = Kpart & 0xFFFFFFFF;
diff --git a/sound/soc/codecs/wm8974.c b/sound/soc/codecs/wm8974.c
index ca646a8..c9036d9 100644
--- a/sound/soc/codecs/wm8974.c
+++ b/sound/soc/codecs/wm8974.c
@@ -317,6 +317,12 @@ static void pll_factors(struct pll_ *pll_div,
 	Nmod = target % source;
 	Kpart = FIXED_PLL_SIZE * (long long)Nmod;
 
+	/*
+	 * The following asm() prevents the compiler from optimising
+	 * into a standard EABI function __aeabi__uldivmod()
+	 */
+	asm("" : "+r"(source));
+
 	do_div(Kpart, source);
 
 	K = Kpart & 0xFFFFFFFF;
-- 
1.7.1



Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom

^ permalink raw reply related	[flat|nested] 17+ messages in thread
* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
@ 2011-04-27 14:59 Stephen Warren
  2011-04-27 15:06 ` Mark Brown
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Stephen Warren @ 2011-04-27 14:59 UTC (permalink / raw)
  To: Barry Song, broonie@opensource.wolfsonmicro.com,
	lrg@slimlogic.co.uk
  Cc: alsa-devel@alsa-project.org, Binghua Duan, Barry Song,
	linux-arm-kernel@lists.infradead.org, Zhiwu Song

Barry Song wrote at Wednesday, April 27, 2011 1:28 AM:
> The newest compiliers can optimize pll calculation in several codecs into
> __aeabi__uldivmod which doesn't exist in kernel.
> Then the link will fail:
> ERROR: "__aeabi_uldivmod" [sound/soc/codecs/snd-soc-wm8974.ko] undefined!
> ERROR: "__aeabi_uldivmod" [sound/soc/codecs/snd-soc-wm8940.ko] undefined!
> ERROR: "__aeabi_uldivmod" [sound/soc/codecs/snd-soc-wm8510.ko] undefined!
> This patch prevent the optimizaton by insert ASM.

Aren't there compiler flags that tell gcc it isn't operating in a hosted(?)
environment, and hence not to emit calls to these functions? If so, I
imagine they should be added to the kernel's core (or ARM arch ) makefiles.

I doubt __aeabi_uldivmod is the only function of this type. How was this
solved for other such functions; does the kernel implement the AEABI
functions, and this implementation is simply missing?

But yes either way, ask on the main kernel or ARM kernel mailing list
(ARM now CC'd)

diff --git a/sound/soc/codecs/wm8510.c b/sound/soc/codecs/wm8510.c
index db0dced..a636b15 100644
--- a/sound/soc/codecs/wm8510.c
+++ b/sound/soc/codecs/wm8510.c
@@ -258,6 +258,12 @@ static void pll_factors(unsigned int target, unsigned int source)
 	Nmod = target % source;
 	Kpart = FIXED_PLL_SIZE * (long long)Nmod;
 
+	/*
+	 * The following asm() prevents the compiler from optimising
+	 * into a standard EABI function __aeabi__uldivmod()
+	 */
+	asm("" : "+r"(source));
+
 	do_div(Kpart, source);
 
 	K = Kpart & 0xFFFFFFFF;

-- 
nvpublic

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

end of thread, other threads:[~2011-04-28 11:40 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-27  7:27 [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod Barry Song
2011-04-27  8:19 ` Takashi Iwai
2011-04-27  8:24   ` Barry Song
2011-04-27  8:41     ` Takashi Iwai
2011-04-27  8:50       ` Barry Song
2011-04-27 14:30         ` Mark Brown
     [not found]           ` <20110427143002.GC31952-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2011-04-27 15:00             ` [alsa-devel] " Barry Song
2011-04-27 15:12               ` Mark Brown
     [not found]                 ` <20110427151249.GE31952-yzvPICuk2AATkU/dhu1WVueM+bqZidxxQQ4Iyu8u01E@public.gmane.org>
2011-04-27 15:23                   ` [alsa-devel] " Barry Song
     [not found]                     ` <BANLkTin4y192A0Jdujv2t5tjoccmUBzQMQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2011-04-27 15:28                       ` Barry Song
2011-04-27 22:30                   ` Michael Hope
2011-04-28 11:40                     ` Mark Brown
2011-04-27  8:49     ` Mark Brown
  -- strict thread matches above, loose matches on Subject: below --
2011-04-27 14:59 Stephen Warren
2011-04-27 15:06 ` Mark Brown
2011-04-27 15:09 ` Barry Song
2011-04-27 15:45 ` Barry Song

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.