* [PATCH 0/3] Use generic helper scu_power_mode()
@ 2012-10-25 10:58 Bastian Hecht
2012-10-25 10:58 ` [PATCH 1/3] ARM: shmobile: emev2: Replace modify_scu_cpu_psr with scu_power_mode Bastian Hecht
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Bastian Hecht @ 2012-10-25 10:58 UTC (permalink / raw)
To: linux-arm-kernel
Reposted to include the arch/arm mailing list.
The shmobile series implements its own code for setting the SCU power
register of the ARM MPCore. It uses 32-bit wide access and thus needs
locking as multiple CPUs might access it simultaneously for change. There is
already a small helper function that avoids the overhead by using 8-bit
wide access: As every CPU only accesses its own field we can drop the
lock and use it.
Bastian Hecht (3):
ARM: shmobile: emev2: Replace modify_scu_cpu_psr with scu_power_mode
ARM: shmobile: sh73a0: Replace modify_scu_cpu_psr with scu_power_mode
ARM: shmobile: r8a7779: Replace modify_scu_cpu_psr with
scu_power_mode
arch/arm/mach-shmobile/smp-emev2.c | 22 ++--------------------
arch/arm/mach-shmobile/smp-r8a7779.c | 25 +++----------------------
arch/arm/mach-shmobile/smp-sh73a0.c | 23 ++---------------------
3 files changed, 7 insertions(+), 63 deletions(-)
--
1.7.9.5
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] ARM: shmobile: emev2: Replace modify_scu_cpu_psr with scu_power_mode
2012-10-25 10:58 [PATCH 0/3] Use generic helper scu_power_mode() Bastian Hecht
@ 2012-10-25 10:58 ` Bastian Hecht
2012-10-25 10:58 ` [PATCH 2/3] ARM: shmobile: sh73a0: " Bastian Hecht
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Bastian Hecht @ 2012-10-25 10:58 UTC (permalink / raw)
To: linux-arm-kernel
We can remove the extra code of modify_scu_cpu_psr() and use the cleaner
generic ARM helper scu_power_mode(). As every CPU only deals with its
own power register and scu_power_mode() operates with 8-bit accesses,
we save the locking overhead too.
Signed-off-by: Bastian Hecht <hechtb@gmail.com>
---
arch/arm/mach-shmobile/smp-emev2.c | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)
diff --git a/arch/arm/mach-shmobile/smp-emev2.c b/arch/arm/mach-shmobile/smp-emev2.c
index f674562..535426c 100644
--- a/arch/arm/mach-shmobile/smp-emev2.c
+++ b/arch/arm/mach-shmobile/smp-emev2.c
@@ -32,24 +32,8 @@
#define EMEV2_SCU_BASE 0x1e000000
-static DEFINE_SPINLOCK(scu_lock);
static void __iomem *scu_base;
-static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
-{
- unsigned long tmp;
-
- /* we assume this code is running on a different cpu
- * than the one that is changing coherency setting */
- spin_lock(&scu_lock);
- tmp = readl(scu_base + 8);
- tmp &= ~clr;
- tmp |= set;
- writel(tmp, scu_base + 8);
- spin_unlock(&scu_lock);
-
-}
-
static unsigned int __init emev2_get_core_count(void)
{
if (!scu_base) {
@@ -95,7 +79,7 @@ static int __cpuinit emev2_boot_secondary(unsigned int cpu, struct task_struct *
cpu = cpu_logical_map(cpu);
/* enable cache coherency */
- modify_scu_cpu_psr(0, 3 << (cpu * 8));
+ scu_power_mode(scu_base, 0);
/* Tell ROM loader about our vector (in headsmp.S) */
emev2_set_boot_vector(__pa(shmobile_secondary_vector));
@@ -106,12 +90,10 @@ static int __cpuinit emev2_boot_secondary(unsigned int cpu, struct task_struct *
static void __init emev2_smp_prepare_cpus(unsigned int max_cpus)
{
- int cpu = cpu_logical_map(0);
-
scu_enable(scu_base);
/* enable cache coherency on CPU0 */
- modify_scu_cpu_psr(0, 3 << (cpu * 8));
+ scu_power_mode(scu_base, 0);
}
static void __init emev2_smp_init_cpus(void)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] ARM: shmobile: sh73a0: Replace modify_scu_cpu_psr with scu_power_mode
2012-10-25 10:58 [PATCH 0/3] Use generic helper scu_power_mode() Bastian Hecht
2012-10-25 10:58 ` [PATCH 1/3] ARM: shmobile: emev2: Replace modify_scu_cpu_psr with scu_power_mode Bastian Hecht
@ 2012-10-25 10:58 ` Bastian Hecht
2012-10-25 10:58 ` [PATCH 3/3] ARM: shmobile: r8a7779: " Bastian Hecht
2012-10-28 3:11 ` [PATCH 0/3] Use generic helper scu_power_mode() Simon Horman
3 siblings, 0 replies; 5+ messages in thread
From: Bastian Hecht @ 2012-10-25 10:58 UTC (permalink / raw)
To: linux-arm-kernel
We can remove the extra code of modify_scu_cpu_psr() and use the cleaner
generic ARM helper scu_power_mode(). As every CPU only deals with its
own power register and scu_power_mode() operates with 8-bit accesses,
we save the locking overhead too.
Signed-off-by: Bastian Hecht <hechtb@gmail.com>
---
arch/arm/mach-shmobile/smp-sh73a0.c | 23 ++---------------------
1 file changed, 2 insertions(+), 21 deletions(-)
diff --git a/arch/arm/mach-shmobile/smp-sh73a0.c b/arch/arm/mach-shmobile/smp-sh73a0.c
index 624f00f..96ddb97 100644
--- a/arch/arm/mach-shmobile/smp-sh73a0.c
+++ b/arch/arm/mach-shmobile/smp-sh73a0.c
@@ -41,9 +41,6 @@ static void __iomem *scu_base_addr(void)
return (void __iomem *)0xf0000000;
}
-static DEFINE_SPINLOCK(scu_lock);
-static unsigned long tmp;
-
#ifdef CONFIG_HAVE_ARM_TWD
static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 0xf0000600, 29);
void __init sh73a0_register_twd(void)
@@ -52,20 +49,6 @@ void __init sh73a0_register_twd(void)
}
#endif
-static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
-{
- void __iomem *scu_base = scu_base_addr();
-
- spin_lock(&scu_lock);
- tmp = __raw_readl(scu_base + 8);
- tmp &= ~clr;
- tmp |= set;
- spin_unlock(&scu_lock);
-
- /* disable cache coherency after releasing the lock */
- __raw_writel(tmp, scu_base + 8);
-}
-
static unsigned int __init sh73a0_get_core_count(void)
{
void __iomem *scu_base = scu_base_addr();
@@ -83,7 +66,7 @@ static int __cpuinit sh73a0_boot_secondary(unsigned int cpu, struct task_struct
cpu = cpu_logical_map(cpu);
/* enable cache coherency */
- modify_scu_cpu_psr(0, 3 << (cpu * 8));
+ scu_power_mode(scu_base_addr(), 0);
if (((__raw_readl(PSTR) >> (4 * cpu)) & 3) == 3)
__raw_writel(1 << cpu, WUPCR); /* wake up */
@@ -95,8 +78,6 @@ static int __cpuinit sh73a0_boot_secondary(unsigned int cpu, struct task_struct
static void __init sh73a0_smp_prepare_cpus(unsigned int max_cpus)
{
- int cpu = cpu_logical_map(0);
-
scu_enable(scu_base_addr());
/* Map the reset vector (in headsmp.S) */
@@ -104,7 +85,7 @@ static void __init sh73a0_smp_prepare_cpus(unsigned int max_cpus)
__raw_writel(__pa(shmobile_secondary_vector), SBAR);
/* enable cache coherency on CPU0 */
- modify_scu_cpu_psr(0, 3 << (cpu * 8));
+ scu_power_mode(scu_base_addr(), 0);
}
static void __init sh73a0_smp_init_cpus(void)
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] ARM: shmobile: r8a7779: Replace modify_scu_cpu_psr with scu_power_mode
2012-10-25 10:58 [PATCH 0/3] Use generic helper scu_power_mode() Bastian Hecht
2012-10-25 10:58 ` [PATCH 1/3] ARM: shmobile: emev2: Replace modify_scu_cpu_psr with scu_power_mode Bastian Hecht
2012-10-25 10:58 ` [PATCH 2/3] ARM: shmobile: sh73a0: " Bastian Hecht
@ 2012-10-25 10:58 ` Bastian Hecht
2012-10-28 3:11 ` [PATCH 0/3] Use generic helper scu_power_mode() Simon Horman
3 siblings, 0 replies; 5+ messages in thread
From: Bastian Hecht @ 2012-10-25 10:58 UTC (permalink / raw)
To: linux-arm-kernel
We can remove the extra code of modify_scu_cpu_psr() and use the cleaner
generic ARM helper scu_power_mode(). As every CPU only deals with its
own power register and scu_power_mode() operates with 8-bit accesses,
we save the locking overhead too.
Signed-off-by: Bastian Hecht <hechtb@gmail.com>
---
arch/arm/mach-shmobile/smp-r8a7779.c | 25 +++----------------------
1 file changed, 3 insertions(+), 22 deletions(-)
diff --git a/arch/arm/mach-shmobile/smp-r8a7779.c b/arch/arm/mach-shmobile/smp-r8a7779.c
index 2ce6af9..9def0f2 100644
--- a/arch/arm/mach-shmobile/smp-r8a7779.c
+++ b/arch/arm/mach-shmobile/smp-r8a7779.c
@@ -61,9 +61,6 @@ static void __iomem *scu_base_addr(void)
return (void __iomem *)0xf0000000;
}
-static DEFINE_SPINLOCK(scu_lock);
-static unsigned long tmp;
-
#ifdef CONFIG_HAVE_ARM_TWD
static DEFINE_TWD_LOCAL_TIMER(twd_local_timer, 0xf0000600, 29);
@@ -73,20 +70,6 @@ void __init r8a7779_register_twd(void)
}
#endif
-static void modify_scu_cpu_psr(unsigned long set, unsigned long clr)
-{
- void __iomem *scu_base = scu_base_addr();
-
- spin_lock(&scu_lock);
- tmp = __raw_readl(scu_base + 8);
- tmp &= ~clr;
- tmp |= set;
- spin_unlock(&scu_lock);
-
- /* disable cache coherency after releasing the lock */
- __raw_writel(tmp, scu_base + 8);
-}
-
static unsigned int __init r8a7779_get_core_count(void)
{
void __iomem *scu_base = scu_base_addr();
@@ -102,7 +85,7 @@ static int r8a7779_platform_cpu_kill(unsigned int cpu)
cpu = cpu_logical_map(cpu);
/* disable cache coherency */
- modify_scu_cpu_psr(3 << (cpu * 8), 0);
+ scu_power_mode(scu_base_addr(), 3);
if (cpu < ARRAY_SIZE(r8a7779_ch_cpu))
ch = r8a7779_ch_cpu[cpu];
@@ -145,7 +128,7 @@ static int __cpuinit r8a7779_boot_secondary(unsigned int cpu, struct task_struct
cpu = cpu_logical_map(cpu);
/* enable cache coherency */
- modify_scu_cpu_psr(0, 3 << (cpu * 8));
+ scu_power_mode(scu_base_addr(), 0);
if (cpu < ARRAY_SIZE(r8a7779_ch_cpu))
ch = r8a7779_ch_cpu[cpu];
@@ -158,15 +141,13 @@ static int __cpuinit r8a7779_boot_secondary(unsigned int cpu, struct task_struct
static void __init r8a7779_smp_prepare_cpus(unsigned int max_cpus)
{
- int cpu = cpu_logical_map(0);
-
scu_enable(scu_base_addr());
/* Map the reset vector (in headsmp.S) */
__raw_writel(__pa(shmobile_secondary_vector), AVECR);
/* enable cache coherency on CPU0 */
- modify_scu_cpu_psr(0, 3 << (cpu * 8));
+ scu_power_mode(scu_base_addr(), 0);
r8a7779_pm_init();
--
1.7.9.5
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 0/3] Use generic helper scu_power_mode()
2012-10-25 10:58 [PATCH 0/3] Use generic helper scu_power_mode() Bastian Hecht
` (2 preceding siblings ...)
2012-10-25 10:58 ` [PATCH 3/3] ARM: shmobile: r8a7779: " Bastian Hecht
@ 2012-10-28 3:11 ` Simon Horman
3 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2012-10-28 3:11 UTC (permalink / raw)
To: linux-arm-kernel
On Thu, Oct 25, 2012 at 12:58:19PM +0200, Bastian Hecht wrote:
> Reposted to include the arch/arm mailing list.
>
> The shmobile series implements its own code for setting the SCU power
> register of the ARM MPCore. It uses 32-bit wide access and thus needs
> locking as multiple CPUs might access it simultaneously for change. There is
> already a small helper function that avoids the overhead by using 8-bit
> wide access: As every CPU only accesses its own field we can drop the
> lock and use it.
Thanks,
these look good to me. I will push them to the boards branch once
its current pull request has been processed by the arm-soc people.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-10-28 3:11 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-10-25 10:58 [PATCH 0/3] Use generic helper scu_power_mode() Bastian Hecht
2012-10-25 10:58 ` [PATCH 1/3] ARM: shmobile: emev2: Replace modify_scu_cpu_psr with scu_power_mode Bastian Hecht
2012-10-25 10:58 ` [PATCH 2/3] ARM: shmobile: sh73a0: " Bastian Hecht
2012-10-25 10:58 ` [PATCH 3/3] ARM: shmobile: r8a7779: " Bastian Hecht
2012-10-28 3:11 ` [PATCH 0/3] Use generic helper scu_power_mode() Simon Horman
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).