All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
@ 2011-04-27 14:59 ` Stephen Warren
  0 siblings, 0 replies; 19+ messages in thread
From: Stephen Warren @ 2011-04-27 14:59 UTC (permalink / raw)
  To: Barry Song, broonie, lrg
  Cc: alsa-devel, Binghua Duan, Barry Song, linux-arm-kernel, 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] 19+ messages in thread

* [alsa-devel] [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
@ 2011-04-27 14:59 ` Stephen Warren
  0 siblings, 0 replies; 19+ messages in thread
From: Stephen Warren @ 2011-04-27 14:59 UTC (permalink / raw)
  To: linux-arm-kernel

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] 19+ messages in thread

* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
  2011-04-27 14:59 ` [alsa-devel] " Stephen Warren
@ 2011-04-27 15:06   ` Mark Brown
  -1 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2011-04-27 15:06 UTC (permalink / raw)
  To: Stephen Warren
  Cc: alsa-devel, Barry Song, Barry Song, Zhiwu Song, Binghua Duan,
	linux-arm-kernel, lrg

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] 19+ messages in thread

* [alsa-devel] [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
@ 2011-04-27 15:06   ` Mark Brown
  0 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2011-04-27 15:06 UTC (permalink / raw)
  To: linux-arm-kernel

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] 19+ messages in thread

* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
  2011-04-27 14:59 ` [alsa-devel] " Stephen Warren
@ 2011-04-27 15:09   ` Barry Song
  -1 siblings, 0 replies; 19+ messages in thread
From: Barry Song @ 2011-04-27 15:09 UTC (permalink / raw)
  To: Stephen Warren
  Cc: alsa-devel, Barry Song, broonie, Zhiwu Song, Binghua Duan,
	linux-arm-kernel, lrg

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] 19+ messages in thread

* [alsa-devel] [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
@ 2011-04-27 15:09   ` Barry Song
  0 siblings, 0 replies; 19+ messages in thread
From: Barry Song @ 2011-04-27 15:09 UTC (permalink / raw)
  To: linux-arm-kernel

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
>
>

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

* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
  2011-04-27 14:59 ` [alsa-devel] " Stephen Warren
@ 2011-04-27 15:45   ` Barry Song
  -1 siblings, 0 replies; 19+ messages in thread
From: Barry Song @ 2011-04-27 15:45 UTC (permalink / raw)
  To: Stephen Warren
  Cc: alsa-devel, Barry Song, broonie, Zhiwu Song, Binghua Duan,
	linux-arm-kernel, lrg

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] 19+ messages in thread

* [alsa-devel] [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
@ 2011-04-27 15:45   ` Barry Song
  0 siblings, 0 replies; 19+ messages in thread
From: Barry Song @ 2011-04-27 15:45 UTC (permalink / raw)
  To: linux-arm-kernel

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
>
>

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

* Re: [alsa-devel] [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
  2011-04-27 15:45   ` [alsa-devel] " Barry Song
@ 2011-04-27 17:10     ` Nicolas Pitre
  -1 siblings, 0 replies; 19+ messages in thread
From: Nicolas Pitre @ 2011-04-27 17:10 UTC (permalink / raw)
  To: Barry Song
  Cc: alsa-devel, Stephen Warren, Barry Song, broonie, Zhiwu Song,
	Binghua Duan, linux-arm-kernel, lrg

On Wed, 27 Apr 2011, Barry Song wrote:

> 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);

This is not the point.  uldivmod will not be implemented on purpose 
because this is a kernel policy _not_ to create any code that would 
require it.

And the description above is wrong too.  It's not about "the newest 
compiler can optimize ..." but rather "the newest compiler has a bug 
that leave a stray reference to __aeabi_uldivmod in the compiled 
object."  As far as I'm concerned, the code is fine as is.  It is the 
compiler that is wrong.


Nicolas

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

* [alsa-devel] [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
@ 2011-04-27 17:10     ` Nicolas Pitre
  0 siblings, 0 replies; 19+ messages in thread
From: Nicolas Pitre @ 2011-04-27 17:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, 27 Apr 2011, Barry Song wrote:

> 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);

This is not the point.  uldivmod will not be implemented on purpose 
because this is a kernel policy _not_ to create any code that would 
require it.

And the description above is wrong too.  It's not about "the newest 
compiler can optimize ..." but rather "the newest compiler has a bug 
that leave a stray reference to __aeabi_uldivmod in the compiled 
object."  As far as I'm concerned, the code is fine as is.  It is the 
compiler that is wrong.


Nicolas

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

* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
  2011-04-27 22:30               ` [alsa-devel] " Michael Hope
@ 2011-04-28 11:40                 ` Mark Brown
  0 siblings, 0 replies; 19+ messages in thread
From: Mark Brown @ 2011-04-28 11:40 UTC (permalink / raw)
  To: Michael Hope
  Cc: alsa-devel, Takashi Iwai, Barry Song, linaro-toolchain,
	Zhiwu Song, Binghua Duan, lrg

On Thu, Apr 28, 2011 at 10:30:24AM +1200, Michael Hope wrote:

Don't top post!

> Hi Mark.  The fault exists in FSF GCC 4.5.2 and Linaro GCC
> 4.5-2011.04.  The fault does not exist in FSF GCC 4.6.0 or Linaro GCC
> 4.6-2011.04.

Given that nobody's reported it previously and there's already a new GCC
release I'm not sure it's worth worry about - it's a fairly clear
compiler bug.

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

* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
  2011-04-27 15:00           ` [alsa-devel] " Barry Song
@ 2011-04-27 15:12             ` Mark Brown
  2011-04-27 22:30               ` [alsa-devel] " Michael Hope
  0 siblings, 1 reply; 19+ messages in thread
From: Mark Brown @ 2011-04-27 15:12 UTC (permalink / raw)
  To: Barry Song
  Cc: alsa-devel, Barry Song, Takashi Iwai, linaro-toolchain,
	Zhiwu Song, Binghua Duan, lrg

On Wed, Apr 27, 2011 at 11:00:18PM +0800, Barry Song wrote:
> 2011/4/27 Mark Brown <broonie@opensource.wolfsonmicro.com>

> > If we do have to do something in the callers rather than in do_div() the
> > annotation seems substantially more taseful than inserting a random asm
> > into the code.

> I agree. for this patch which will not be applied, people can just get
> information about how to workaround the gcc issue while they have the
> same problem. google can find there are other people who failed to
> compile wm8974 module too. eg.
> http://irclogs.ubuntu.com/2010/03/30/%23ubuntu-arm.txt

> Andrew Stubbs, Michael Hope in Linaro's toolchain team are working
> hard on this gcc issue. there have been many update today:
> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48783

Is this just some Linaro toolchain that has the issue rather than a
vanilla GCC release?  If so and they fix the compiler bug it doesn't
seem terribly useful to bodge it in mainline.

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

* Re: [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
  2011-04-27  8:50       ` Barry Song
@ 2011-04-27 14:30         ` Mark Brown
  2011-04-27 15:00           ` [alsa-devel] " Barry Song
  0 siblings, 1 reply; 19+ messages in thread
From: Mark Brown @ 2011-04-27 14:30 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:50:12PM +0800, Barry Song wrote:

> Marking pll_factors() as noinline or putting asm("" : "+r"(source)); before the
> call to do_div() works around the problem.

If we do have to do something in the callers rather than in do_div() the
annotation seems substantially more taseful than inserting a random asm
into the code.

^ permalink raw reply	[flat|nested] 19+ 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; 19+ 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] 19+ 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; 19+ 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] 19+ 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; 19+ 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] 19+ 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; 19+ 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] 19+ messages in thread

* Re: [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
  2011-04-27  8:24   ` Barry Song
  0 siblings, 1 reply; 19+ 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] 19+ messages in thread

* [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; 19+ 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] 19+ messages in thread

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

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-04-27 14:59 [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod Stephen Warren
2011-04-27 14:59 ` [alsa-devel] " Stephen Warren
2011-04-27 15:06 ` Mark Brown
2011-04-27 15:06   ` [alsa-devel] " Mark Brown
2011-04-27 15:09 ` Barry Song
2011-04-27 15:09   ` [alsa-devel] " Barry Song
2011-04-27 15:45 ` Barry Song
2011-04-27 15:45   ` [alsa-devel] " Barry Song
2011-04-27 17:10   ` Nicolas Pitre
2011-04-27 17:10     ` Nicolas Pitre
  -- strict thread matches above, loose matches on Subject: below --
2011-04-27  7:27 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
2011-04-27 15:00           ` [alsa-devel] " Barry Song
2011-04-27 15:12             ` Mark Brown
2011-04-27 22:30               ` [alsa-devel] " Michael Hope
2011-04-28 11:40                 ` Mark Brown
2011-04-27  8:49     ` Mark Brown

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.