* [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 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
0 siblings, 1 reply; 17+ messages in thread
From: Takashi Iwai @ 2011-04-27 8:19 UTC (permalink / raw)
To: Barry Song; +Cc: alsa-devel, broonie, Barry Song, Zhiwu Song, Binghua Duan, lrg
At Wed, 27 Apr 2011 00:27:32 -0700,
Barry Song wrote:
>
> 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.
Don't do this in the low driver level. If any, we should fix do_div()
instead.
thanks,
Takashi
>
> 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
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
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:49 ` Mark Brown
0 siblings, 2 replies; 17+ messages in thread
From: Barry Song @ 2011-04-27 8:24 UTC (permalink / raw)
To: Takashi Iwai
Cc: alsa-devel, Barry Song, broonie, Zhiwu Song, Binghua Duan, lrg
2011/4/27 Takashi Iwai <tiwai@suse.de>:
> At Wed, 27 Apr 2011 00:27:32 -0700,
> Barry Song wrote:
>>
>> 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.
>
> Don't do this in the low driver level. If any, we should fix do_div()
> instead.
do_div is just a macro, it has no problem by itself. only while
working together with other more codes before do_div, gcc can make
some codes merging and cause problems.
if do_div is a function, we'd just fix it.
>
>
> thanks,
>
> Takashi
>
>>
>> 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
>> _______________________________________________
>> Alsa-devel mailing list
>> Alsa-devel@alsa-project.org
>> http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
>>
>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 17+ messages in thread* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
2011-04-27 8:24 ` Barry Song
@ 2011-04-27 8:41 ` Takashi Iwai
2011-04-27 8:50 ` Barry Song
2011-04-27 8:49 ` Mark Brown
1 sibling, 1 reply; 17+ messages in thread
From: Takashi Iwai @ 2011-04-27 8:41 UTC (permalink / raw)
To: Barry Song; +Cc: alsa-devel, Barry Song, broonie, Zhiwu Song, Binghua Duan, lrg
At Wed, 27 Apr 2011 16:24:44 +0800,
Barry Song wrote:
>
> 2011/4/27 Takashi Iwai <tiwai@suse.de>:
> > At Wed, 27 Apr 2011 00:27:32 -0700,
> > Barry Song wrote:
> >>
> >> 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.
> >
> > Don't do this in the low driver level. If any, we should fix do_div()
> > instead.
>
> do_div is just a macro, it has no problem by itself.
It has a problem by itself because it's a macro with a side-effect :)
Could we put an asm to do_div() itself? The asm statement can be
defined depending on the compiler version.
> only while
> working together with other more codes before do_div, gcc can make
> some codes merging and cause problems.
>
> if do_div is a function, we'd just fix it.
Better to ask this in LKML, then.
thanks,
Takashi
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
2011-04-27 8:41 ` Takashi Iwai
@ 2011-04-27 8:50 ` Barry Song
2011-04-27 14:30 ` Mark Brown
0 siblings, 1 reply; 17+ messages in thread
From: Barry Song @ 2011-04-27 8:50 UTC (permalink / raw)
To: Takashi Iwai
Cc: alsa-devel, Barry Song, broonie, Zhiwu Song, Binghua Duan, lrg
2011/4/27 Takashi Iwai <tiwai@suse.de>:
> At Wed, 27 Apr 2011 16:24:44 +0800,
> Barry Song wrote:
>>
>> 2011/4/27 Takashi Iwai <tiwai@suse.de>:
>> > At Wed, 27 Apr 2011 00:27:32 -0700,
>> > Barry Song wrote:
>> >>
>> >> 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.
>> >
>> > Don't do this in the low driver level. If any, we should fix do_div()
>> > instead.
>>
>> do_div is just a macro, it has no problem by itself.
>
> It has a problem by itself because it's a macro with a side-effect :)
>
> Could we put an asm to do_div() itself? The asm statement can be
> defined depending on the compiler version.
>
>> only while
>> working together with other more codes before do_div, gcc can make
>> some codes merging and cause problems.
>>
>> if do_div is a function, we'd just fix it.
>
> Better to ask this in LKML, then.
I must have been delaying a little from gcc. Michael Hope has thought
it as a gcc bug on 26 April,2011at:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48783
Marking pll_factors() as noinline or putting asm("" : "+r"(source)); before the
call to do_div() works around the problem.
>
>
> thanks,
>
> Takashi
>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [flat|nested] 17+ messages in thread
* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
2011-04-27 8:24 ` Barry Song
2011-04-27 8:41 ` Takashi Iwai
@ 2011-04-27 8:49 ` Mark Brown
1 sibling, 0 replies; 17+ messages in thread
From: Mark Brown @ 2011-04-27 8:49 UTC (permalink / raw)
To: Barry Song
Cc: alsa-devel, Barry Song, Takashi Iwai, Zhiwu Song, Binghua Duan,
lrg
On Wed, Apr 27, 2011 at 04:24:44PM +0800, Barry Song wrote:
> 2011/4/27 Takashi Iwai <tiwai@suse.de>:
> > Don't do this in the low driver level. If any, we should fix do_div()
> > instead.
> do_div is just a macro, it has no problem by itself. only while
> working together with other more codes before do_div, gcc can make
> some codes merging and cause problems.
> if do_div is a function, we'd just fix it.
It's a macro which expands to a problem so we should make it expand to
something which includes the fix as well rather than going round and
fixing each and every caller.
^ permalink raw reply [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* 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
2011-04-27 15:09 ` Barry Song
2011-04-27 15:45 ` Barry Song
2 siblings, 0 replies; 17+ messages in thread
From: Mark Brown @ 2011-04-27 15:06 UTC (permalink / raw)
To: Stephen Warren
Cc: alsa-devel@alsa-project.org, Barry Song, Barry Song, Zhiwu Song,
Binghua Duan, linux-arm-kernel@lists.infradead.org,
lrg@slimlogic.co.uk
On Wed, Apr 27, 2011 at 07:59:39AM -0700, Stephen Warren wrote:
> 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.
IIRC there's some intrinsics (usually for operations like divisions)
which GCC expects to be provided even in a free standing environment.
^ permalink raw reply [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
@ 2011-04-27 15:09 ` Barry Song
2011-04-27 15:45 ` Barry Song
2 siblings, 0 replies; 17+ messages in thread
From: Barry Song @ 2011-04-27 15:09 UTC (permalink / raw)
To: Stephen Warren
Cc: alsa-devel@alsa-project.org, Barry Song,
broonie@opensource.wolfsonmicro.com, Zhiwu Song, Binghua Duan,
linux-arm-kernel@lists.infradead.org, lrg@slimlogic.co.uk
2011/4/27 Stephen Warren <swarren@nvidia.com>:
> 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.
not real. it is right for gcc to call __aeabi_uldivmod while it think
it is good. most time, people change kernel codes to avoid this kind
of optimization:
http://comments.gmane.org/gmane.linux.kernel/965262
Another example is time.h:
{
ns += a->tv_nsec;
while(unlikely(ns >= NSEC_PER_SEC)) {
+ /* The following asm() prevents the compiler from
+ * optimising this loop into a modulo operation. */
+ asm("" : "+r"(ns));
+
ns -= NSEC_PER_SEC;
a->tv_sec++;
}
>
> 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
>
>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [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
2011-04-27 15:09 ` Barry Song
@ 2011-04-27 15:45 ` Barry Song
2 siblings, 0 replies; 17+ messages in thread
From: Barry Song @ 2011-04-27 15:45 UTC (permalink / raw)
To: Stephen Warren
Cc: alsa-devel@alsa-project.org, Barry Song,
broonie@opensource.wolfsonmicro.com, Zhiwu Song, Binghua Duan,
linux-arm-kernel@lists.infradead.org, lrg@slimlogic.co.uk
2011/4/27 Stephen Warren <swarren@nvidia.com>:
> 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?
__aeabi_uldivmod is not implemented by kernel, others are implemented
in arch/arm/lib/lib1funcs.S:
extern void __aeabi_idiv(void);
extern void __aeabi_idivmod(void);
extern void __aeabi_lasr(void);
extern void __aeabi_llsl(void);
extern void __aeabi_llsr(void);
extern void __aeabi_lmul(void);
extern void __aeabi_uidiv(void);
extern void __aeabi_uidivmod(void);
extern void __aeabi_ulcmp(void);
>
> 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
>
>
_______________________________________________
Alsa-devel mailing list
Alsa-devel@alsa-project.org
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
^ permalink raw reply [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.