public inbox for linux-arm-kernel@lists.infradead.org 
 help / color / mirror / Atom feed
From: robherring2@gmail•com (Rob Herring)
To: linux-arm-kernel@lists•infradead.org
Subject: [PATCH 2/3] ARM: convert platform hotplug inline assembly to C
Date: Thu, 17 Jan 2013 08:18:23 -0600	[thread overview]
Message-ID: <50F8082F.1050906@gmail.com> (raw)
In-Reply-To: <alpine.LFD.2.02.1301162338420.6300@xanadu.home>

On 01/16/2013 10:40 PM, Nicolas Pitre wrote:
> On Wed, 16 Jan 2013, Rob Herring wrote:
> 
>> From: Rob Herring <rob.herring@calxeda•com>
>>
>> With the addition of set_auxcr/get_auxcr, all the hotplug inline assembly
>> code for exynos, imx, realview, spear13xx and vexpress can be converted to
>> C code.
> 
> That might not be all safe.  Please see
> http://article.gmane.org/gmane.linux.ports.arm.kernel/209584

Other than the OR/AND operations, it's all just inline assembly
functions that are called, so it gets compiled to the same code. Perhaps
I should put noinline on the functions so they stay of limited
complexity. If you don't think doing this in C is okay, then there is
probably no point in having the set_auxcr/get_auxcr functions.

Alternatively, we could create common enter/exit coherency functions.

Rob

> 
> 
>>
>> Signed-off-by: Rob Herring <rob.herring@calxeda•com>
>> Cc: Kukjin Kim <kgene.kim@samsung•com>
>> Cc: Russell King <linux@arm•linux.org.uk>
>> Cc: Sascha Hauer <kernel@pengutronix•de>
>> Cc: Viresh Kumar <viresh.linux@gmail•com>
>> Cc: Shiraz Hashim <shiraz.hashim@st•com>
>> ---
>>  arch/arm/mach-exynos/hotplug.c    |   57 ++++++-------------------------------
>>  arch/arm/mach-imx/hotplug.c       |   19 ++++---------
>>  arch/arm/mach-realview/hotplug.c  |   32 +++++----------------
>>  arch/arm/mach-spear13xx/hotplug.c |   32 +++++----------------
>>  arch/arm/mach-vexpress/hotplug.c  |   33 +++++----------------
>>  5 files changed, 35 insertions(+), 138 deletions(-)
>>
>> diff --git a/arch/arm/mach-exynos/hotplug.c b/arch/arm/mach-exynos/hotplug.c
>> index c3f825b..5548fa3 100644
>> --- a/arch/arm/mach-exynos/hotplug.c
>> +++ b/arch/arm/mach-exynos/hotplug.c
>> @@ -26,69 +26,30 @@
>>  
>>  static inline void cpu_enter_lowpower_a9(void)
>>  {
>> -	unsigned int v;
>> -
>>  	flush_cache_all();
>> -	asm volatile(
>> -	"	mcr	p15, 0, %1, c7, c5, 0\n"
>> -	"	mcr	p15, 0, %1, c7, c10, 4\n"
>> +	__flush_icache_all();
>> +	dsb();
>> +
>>  	/*
>>  	 * Turn off coherency
>>  	 */
>> -	"	mrc	p15, 0, %0, c1, c0, 1\n"
>> -	"	bic	%0, %0, %3\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 1\n"
>> -	"	mrc	p15, 0, %0, c1, c0, 0\n"
>> -	"	bic	%0, %0, %2\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 0\n"
>> -	  : "=&r" (v)
>> -	  : "r" (0), "Ir" (CR_C), "Ir" (0x40)
>> -	  : "cc");
>> +	set_auxcr(get_auxcr() & ~0x40);
>> +	set_cr(get_cr() & ~CR_C);
>>  }
>>  
>>  static inline void cpu_enter_lowpower_a15(void)
>>  {
>> -	unsigned int v;
>> -
>> -	asm volatile(
>> -	"	mrc	p15, 0, %0, c1, c0, 0\n"
>> -	"	bic	%0, %0, %1\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 0\n"
>> -	  : "=&r" (v)
>> -	  : "Ir" (CR_C)
>> -	  : "cc");
>> -
>> +	set_cr(get_cr() & ~CR_C);
>>  	flush_cache_louis();
>> +	set_auxcr(get_auxcr() & ~0x40);
>>  
>> -	asm volatile(
>> -	/*
>> -	* Turn off coherency
>> -	*/
>> -	"	mrc	p15, 0, %0, c1, c0, 1\n"
>> -	"	bic	%0, %0, %1\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 1\n"
>> -	: "=&r" (v)
>> -	: "Ir" (0x40)
>> -	: "cc");
>> -
>> -	isb();
>>  	dsb();
>>  }
>>  
>>  static inline void cpu_leave_lowpower(void)
>>  {
>> -	unsigned int v;
>> -
>> -	asm volatile(
>> -	"mrc	p15, 0, %0, c1, c0, 0\n"
>> -	"	orr	%0, %0, %1\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 0\n"
>> -	"	mrc	p15, 0, %0, c1, c0, 1\n"
>> -	"	orr	%0, %0, %2\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 1\n"
>> -	  : "=&r" (v)
>> -	  : "Ir" (CR_C), "Ir" (0x40)
>> -	  : "cc");
>> +	set_cr(get_cr() | CR_C);
>> +	set_auxcr(get_auxcr() | 0x40);
>>  }
>>  
>>  static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
>> diff --git a/arch/arm/mach-imx/hotplug.c b/arch/arm/mach-imx/hotplug.c
>> index 3dec962..1470c75 100644
>> --- a/arch/arm/mach-imx/hotplug.c
>> +++ b/arch/arm/mach-imx/hotplug.c
>> @@ -18,24 +18,15 @@
>>  
>>  static inline void cpu_enter_lowpower(void)
>>  {
>> -	unsigned int v;
>> -
>>  	flush_cache_all();
>> -	asm volatile(
>> -		"mcr	p15, 0, %1, c7, c5, 0\n"
>> -	"	mcr	p15, 0, %1, c7, c10, 4\n"
>> +	__flush_icache_all();
>> +	dsb();
>> +
>>  	/*
>>  	 * Turn off coherency
>>  	 */
>> -	"	mrc	p15, 0, %0, c1, c0, 1\n"
>> -	"	bic	%0, %0, %3\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 1\n"
>> -	"	mrc	p15, 0, %0, c1, c0, 0\n"
>> -	"	bic	%0, %0, %2\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 0\n"
>> -	  : "=&r" (v)
>> -	  : "r" (0), "Ir" (CR_C), "Ir" (0x40)
>> -	  : "cc");
>> +	set_auxcr(get_auxcr() & ~0x40);
>> +	set_cr(get_cr() & ~CR_C);
>>  }
>>  
>>  /*
>> diff --git a/arch/arm/mach-realview/hotplug.c b/arch/arm/mach-realview/hotplug.c
>> index 53818e5..c17c8c0 100644
>> --- a/arch/arm/mach-realview/hotplug.c
>> +++ b/arch/arm/mach-realview/hotplug.c
>> @@ -18,39 +18,21 @@
>>  
>>  static inline void cpu_enter_lowpower(void)
>>  {
>> -	unsigned int v;
>> -
>>  	flush_cache_all();
>> -	asm volatile(
>> -	"	mcr	p15, 0, %1, c7, c5, 0\n"
>> -	"	mcr	p15, 0, %1, c7, c10, 4\n"
>> +	__flush_icache_all();
>> +	dsb();
>> +
>>  	/*
>>  	 * Turn off coherency
>>  	 */
>> -	"	mrc	p15, 0, %0, c1, c0, 1\n"
>> -	"	bic	%0, %0, #0x20\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 1\n"
>> -	"	mrc	p15, 0, %0, c1, c0, 0\n"
>> -	"	bic	%0, %0, %2\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 0\n"
>> -	  : "=&r" (v)
>> -	  : "r" (0), "Ir" (CR_C)
>> -	  : "cc");
>> +	set_auxcr(get_auxcr() & ~0x40);
>> +	set_cr(get_cr() & ~CR_C);
>>  }
>>  
>>  static inline void cpu_leave_lowpower(void)
>>  {
>> -	unsigned int v;
>> -
>> -	asm volatile(	"mrc	p15, 0, %0, c1, c0, 0\n"
>> -	"	orr	%0, %0, %1\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 0\n"
>> -	"	mrc	p15, 0, %0, c1, c0, 1\n"
>> -	"	orr	%0, %0, #0x20\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 1\n"
>> -	  : "=&r" (v)
>> -	  : "Ir" (CR_C)
>> -	  : "cc");
>> +	set_cr(get_cr() | CR_C);
>> +	set_auxcr(get_auxcr() | 0x40);
>>  }
>>  
>>  static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
>> diff --git a/arch/arm/mach-spear13xx/hotplug.c b/arch/arm/mach-spear13xx/hotplug.c
>> index a7d2dd1..a38a087 100644
>> --- a/arch/arm/mach-spear13xx/hotplug.c
>> +++ b/arch/arm/mach-spear13xx/hotplug.c
>> @@ -19,39 +19,21 @@
>>  
>>  static inline void cpu_enter_lowpower(void)
>>  {
>> -	unsigned int v;
>> -
>>  	flush_cache_all();
>> -	asm volatile(
>> -	"	mcr	p15, 0, %1, c7, c5, 0\n"
>> -	"	dsb\n"
>> +	__flush_icache_all();
>> +	dsb();
>> +
>>  	/*
>>  	 * Turn off coherency
>>  	 */
>> -	"	mrc	p15, 0, %0, c1, c0, 1\n"
>> -	"	bic	%0, %0, #0x20\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 1\n"
>> -	"	mrc	p15, 0, %0, c1, c0, 0\n"
>> -	"	bic	%0, %0, %2\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 0\n"
>> -	: "=&r" (v)
>> -	: "r" (0), "Ir" (CR_C)
>> -	: "cc", "memory");
>> +	set_auxcr(get_auxcr() & ~0x40);
>> +	set_cr(get_cr() & ~CR_C);
>>  }
>>  
>>  static inline void cpu_leave_lowpower(void)
>>  {
>> -	unsigned int v;
>> -
>> -	asm volatile("mrc	p15, 0, %0, c1, c0, 0\n"
>> -	"	orr	%0, %0, %1\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 0\n"
>> -	"	mrc	p15, 0, %0, c1, c0, 1\n"
>> -	"	orr	%0, %0, #0x20\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 1\n"
>> -	: "=&r" (v)
>> -	: "Ir" (CR_C)
>> -	: "cc");
>> +	set_cr(get_cr() | CR_C);
>> +	set_auxcr(get_auxcr() | 0x40);
>>  }
>>  
>>  static inline void spear13xx_do_lowpower(unsigned int cpu, int *spurious)
>> diff --git a/arch/arm/mach-vexpress/hotplug.c b/arch/arm/mach-vexpress/hotplug.c
>> index a141b98..74a9eb5 100644
>> --- a/arch/arm/mach-vexpress/hotplug.c
>> +++ b/arch/arm/mach-vexpress/hotplug.c
>> @@ -18,40 +18,21 @@
>>  
>>  static inline void cpu_enter_lowpower(void)
>>  {
>> -	unsigned int v;
>> -
>>  	flush_cache_all();
>> -	asm volatile(
>> -		"mcr	p15, 0, %1, c7, c5, 0\n"
>> -	"	mcr	p15, 0, %1, c7, c10, 4\n"
>> +	__flush_icache_all();
>> +	dsb();
>> +
>>  	/*
>>  	 * Turn off coherency
>>  	 */
>> -	"	mrc	p15, 0, %0, c1, c0, 1\n"
>> -	"	bic	%0, %0, %3\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 1\n"
>> -	"	mrc	p15, 0, %0, c1, c0, 0\n"
>> -	"	bic	%0, %0, %2\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 0\n"
>> -	  : "=&r" (v)
>> -	  : "r" (0), "Ir" (CR_C), "Ir" (0x40)
>> -	  : "cc");
>> +	set_auxcr(get_auxcr() & ~0x40);
>> +	set_cr(get_cr() & ~CR_C);
>>  }
>>  
>>  static inline void cpu_leave_lowpower(void)
>>  {
>> -	unsigned int v;
>> -
>> -	asm volatile(
>> -		"mrc	p15, 0, %0, c1, c0, 0\n"
>> -	"	orr	%0, %0, %1\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 0\n"
>> -	"	mrc	p15, 0, %0, c1, c0, 1\n"
>> -	"	orr	%0, %0, %2\n"
>> -	"	mcr	p15, 0, %0, c1, c0, 1\n"
>> -	  : "=&r" (v)
>> -	  : "Ir" (CR_C), "Ir" (0x40)
>> -	  : "cc");
>> +	set_cr(get_cr() | CR_C);
>> +	set_auxcr(get_auxcr() | 0x40);
>>  }
>>  
>>  static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
>> -- 
>> 1.7.10.4
>>

  reply	other threads:[~2013-01-17 14:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-17  2:53 [PATCH 1/3] ARM: introduce common set_auxcr/get_auxcr functions Rob Herring
2013-01-17  2:53 ` [PATCH 2/3] ARM: convert platform hotplug inline assembly to C Rob Herring
2013-01-17  4:40   ` Nicolas Pitre
2013-01-17 14:18     ` Rob Herring [this message]
2013-01-17 15:42       ` Nicolas Pitre
2013-01-18  3:34         ` Rob Herring
2013-01-18  4:56           ` Nicolas Pitre
2013-01-17  2:53 ` [PATCH 3/3] ARM: omap2: use get_auxcr for aux ctrl register read Rob Herring
2013-01-17  4:41   ` Nicolas Pitre
2013-01-17  8:30   ` Santosh Shilimkar
2013-01-17 17:07     ` Tony Lindgren
2013-01-17  4:34 ` [PATCH 1/3] ARM: introduce common set_auxcr/get_auxcr functions Nicolas Pitre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=50F8082F.1050906@gmail.com \
    --to=robherring2@gmail$(echo .)com \
    --cc=linux-arm-kernel@lists$(echo .)infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox