[alsa-devel] [PATCH] ASoC: prevent compilers from optimising pll calculation into __aeabi__uldivmod
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;
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
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
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
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
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.
2011/4/27 Mark Brown broonie@opensource.wolfsonmicro.com
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.
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
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.
2011/4/27 Mark Brown broonie@opensource.wolfsonmicro.com:
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.
i am guessing it is a generic gcc issue since Michael posted it at http://gcc.gnu.org/bugzilla not Linaro's Launchpad. not sure :-)
2011/4/27 Barry Song 21cnbao@gmail.com:
2011/4/27 Mark Brown broonie@opensource.wolfsonmicro.com:
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.
i am guessing it is a generic gcc issue since Michael posted it at http://gcc.gnu.org/bugzilla not Linaro's Launchpad. not sure :-)
Linaro doesn't exist yet when the discussion happened at http://irclogs.ubuntu.com/2010/03/30/%23ubuntu-arm.txt discussion:
" [19:03] <nosse1> I got this while compiling: "ERROR: "__aeabi_uldivmod" [sound/soc/codecs/snd-soc-wm8974.ko] undefined!" [19:04] <nosse1> Now, I can disable the driver alltogether, but is this related to the CSL cross compiler? [19:04] <hrw> nosse1: google should give answer - common problem it was [19:04] <nosse1> hehe - sorry, you're right "
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.
-- Michael
On Thu, Apr 28, 2011 at 3:12 AM, Mark Brown broonie@opensource.wolfsonmicro.com wrote:
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.
linaro-toolchain mailing list linaro-toolchain@lists.linaro.org http://lists.linaro.org/mailman/listinfo/linaro-toolchain
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.
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.
participants (5)
-
Barry Song
-
Barry Song
-
Mark Brown
-
Michael Hope
-
Takashi Iwai