linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* cpu_relax in busy loops question
@ 2012-02-01 11:34 Daniel Lezcano
  2012-02-01 20:17 ` Linus Walleij
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Lezcano @ 2012-02-01 11:34 UTC (permalink / raw)
  To: linux-arm-kernel


Hi Linus,

While looking at the drivers/mfd/db8500-prcmu.c file I noticed:


  595         /* Grab the HW semaphore. */
  596         while ((readl(PRCM_SEM) & PRCM_SEM_PRCM_SEM) != 0)
  597                 cpu_relax();


I was wondering why is cpu_relax needed here as readl does a memory 
barrier ? I thought the cpu_relax function was related to the x86 to 
consume less power with an optimization of the "rep nop" loops or/and do 
a memory barrier.

Should a busy-loop be always with cpu_relax ?

Thanks
   -- Daniel


-- 
  <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

* cpu_relax in busy loops question
  2012-02-01 11:34 cpu_relax in busy loops question Daniel Lezcano
@ 2012-02-01 20:17 ` Linus Walleij
  2012-02-02  8:47   ` Daniel Lezcano
  0 siblings, 1 reply; 3+ messages in thread
From: Linus Walleij @ 2012-02-01 20:17 UTC (permalink / raw)
  To: linux-arm-kernel

On Wed, Feb 1, 2012 at 12:34 PM, Daniel Lezcano
<daniel.lezcano@linaro.org> wrote:
>
> Hi Linus,
>
> While looking at the drivers/mfd/db8500-prcmu.c file I noticed:
>
>
> ?595 ? ? ? ? /* Grab the HW semaphore. */
> ?596 ? ? ? ? while ((readl(PRCM_SEM) & PRCM_SEM_PRCM_SEM) != 0)
> ?597 ? ? ? ? ? ? ? ? cpu_relax();
>
>
> I was wondering why is cpu_relax needed here as readl does a memory barrier
> ? I thought the cpu_relax function was related to the x86 to consume less
> power with an optimization of the "rep nop" loops or/and do a memory
> barrier.
>
> Should a busy-loop be always with cpu_relax ?

Last time we discussed it ar LAKML I think we came to the conclusion
that while cpu_relax() has very little semantic meaning on ARM, it
is still nice to have from a readability and maintenance point of view,
since it is pretty clear what we're trying to do.

But I will stand corrected...

Yours,
Linus Walleij

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

* cpu_relax in busy loops question
  2012-02-01 20:17 ` Linus Walleij
@ 2012-02-02  8:47   ` Daniel Lezcano
  0 siblings, 0 replies; 3+ messages in thread
From: Daniel Lezcano @ 2012-02-02  8:47 UTC (permalink / raw)
  To: linux-arm-kernel

On 02/01/2012 09:17 PM, Linus Walleij wrote:
> On Wed, Feb 1, 2012 at 12:34 PM, Daniel Lezcano
> <daniel.lezcano@linaro.org>  wrote:
>>
>> Hi Linus,
>>
>> While looking at the drivers/mfd/db8500-prcmu.c file I noticed:
>>
>>
>>   595         /* Grab the HW semaphore. */
>>   596         while ((readl(PRCM_SEM)&  PRCM_SEM_PRCM_SEM) != 0)
>>   597                 cpu_relax();
>>
>>
>> I was wondering why is cpu_relax needed here as readl does a memory barrier
>> ? I thought the cpu_relax function was related to the x86 to consume less
>> power with an optimization of the "rep nop" loops or/and do a memory
>> barrier.
>>
>> Should a busy-loop be always with cpu_relax ?
>
> Last time we discussed it ar LAKML I think we came to the conclusion
> that while cpu_relax() has very little semantic meaning on ARM, it
> is still nice to have from a readability and maintenance point of view,
> since it is pretty clear what we're trying to do.

Ok, thanks Linus.

   -- Daniel




-- 
  <http://www.linaro.org/> Linaro.org ? Open source software for ARM SoCs

Follow Linaro:  <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog

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

end of thread, other threads:[~2012-02-02  8:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-01 11:34 cpu_relax in busy loops question Daniel Lezcano
2012-02-01 20:17 ` Linus Walleij
2012-02-02  8:47   ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).