msm: pm-8x60: Move hotplug related code out of pm code.
Move hotplug related code into hotplug.c and compile hotplug.c only when
CONFIG_HOTPLUG_CPU is defined.
Signed-off-by: Mahesh Sivasubramanian <msivasub@codeaurora.org>
Change-Id: Ia9aa7a64e9831f52431c77c22f30fb64892efaea
diff --git a/arch/arm/mach-msm/Makefile b/arch/arm/mach-msm/Makefile
index 63fc803..44d9a74 100644
--- a/arch/arm/mach-msm/Makefile
+++ b/arch/arm/mach-msm/Makefile
@@ -39,6 +39,7 @@
endif
obj-$(CONFIG_SMP) += headsmp.o platsmp.o
+obj-$(CONFIG_HOTPLUG_CPU) += hotplug.o
obj-$(CONFIG_MSM_CPU_AVS) += avs.o
obj-$(CONFIG_MSM_AVS_HW) += avs_hw.o
@@ -155,7 +156,7 @@
obj-$(CONFIG_ARCH_MSM7X01A) += pm.o
obj-y += pm-boot.o
else
- obj-y += no-pm.o hotplug.o
+ obj-y += no-pm.o
endif
obj-$(CONFIG_MSM_SPM_V1) += spm.o
diff --git a/arch/arm/mach-msm/hotplug.c b/arch/arm/mach-msm/hotplug.c
index e8aa38e..86a2374 100644
--- a/arch/arm/mach-msm/hotplug.c
+++ b/arch/arm/mach-msm/hotplug.c
@@ -11,10 +11,22 @@
#include <linux/smp.h>
#include <asm/cacheflush.h>
+#include <asm/vfp.h>
-#ifdef CONFIG_SMP
+#include "qdss.h"
+#include "spm.h"
+#include "pm.h"
+
extern volatile int pen_release;
+struct msm_hotplug_device {
+ struct completion cpu_killed;
+ unsigned int warm_boot;
+};
+
+static DEFINE_PER_CPU_SHARED_ALIGNED(struct msm_hotplug_device,
+ msm_hotplug_devices);
+
static inline void cpu_enter_lowpower(void)
{
/* Just flush the cache. Changing the coherency is not yet
@@ -30,14 +42,8 @@
{
/* Just enter wfi for now. TODO: Properly shut off the cpu. */
for (;;) {
- /*
- * here's the WFI
- */
- asm("wfi"
- :
- :
- : "memory", "cc");
+ msm_pm_cpu_enter_lowpower(cpu);
if (pen_release == cpu) {
/*
* OK, proper wakeup, we're done
@@ -56,11 +62,13 @@
pr_debug("CPU%u: spurious wakeup call\n", cpu);
}
}
-#endif
int platform_cpu_kill(unsigned int cpu)
{
- return 1;
+ struct completion *killed =
+ &per_cpu(msm_hotplug_devices, cpu).cpu_killed;
+
+ return wait_for_completion_timeout(killed, HZ * 5);
}
/*
@@ -70,19 +78,20 @@
*/
void platform_cpu_die(unsigned int cpu)
{
-#ifdef CONFIG_SMP
+ if (unlikely(cpu != smp_processor_id())) {
+ pr_crit("%s: running on %u, should be %u\n",
+ __func__, smp_processor_id(), cpu);
+ BUG();
+ }
+ complete(&__get_cpu_var(msm_hotplug_devices).cpu_killed);
/*
* we're ready for shutdown now, so do it
*/
cpu_enter_lowpower();
platform_do_lowpower(cpu);
- /*
- * bring this CPU back into the world of cache
- * coherency, and then restore interrupts
- */
+ pr_notice("CPU%u: %s: normal wakeup\n", cpu, __func__);
cpu_leave_lowpower();
-#endif
}
int platform_cpu_disable(unsigned int cpu)
@@ -93,3 +102,23 @@
*/
return cpu == 0 ? -EPERM : 0;
}
+
+int msm_platform_secondary_init(unsigned int cpu)
+{
+ int ret;
+ struct msm_hotplug_device *dev = &__get_cpu_var(msm_hotplug_devices);
+
+ if (!dev->warm_boot) {
+ dev->warm_boot = 1;
+ init_completion(&dev->cpu_killed);
+ return 0;
+ }
+ etm_restore_reg_check();
+ msm_restore_jtag_debug();
+#ifdef CONFIG_VFP
+ vfp_reinit();
+#endif
+ ret = msm_spm_set_low_power_mode(MSM_SPM_MODE_CLOCK_GATING, false);
+
+ return ret;
+}
diff --git a/arch/arm/mach-msm/no-pm.c b/arch/arm/mach-msm/no-pm.c
index d6cdbe7..366b282 100644
--- a/arch/arm/mach-msm/no-pm.c
+++ b/arch/arm/mach-msm/no-pm.c
@@ -23,5 +23,13 @@
void msm_pm_set_platform_data(struct msm_pm_platform_data *data, int count)
{ }
+void msm_pm_cpu_enter_lowpower(unsigned cpu)
+{
+ asm("wfi"
+ :
+ :
+ : "memory", "cc");
+}
+
void msm_pm_set_max_sleep_time(int64_t max_sleep_time_ns) { }
EXPORT_SYMBOL(msm_pm_set_max_sleep_time);
diff --git a/arch/arm/mach-msm/platsmp.c b/arch/arm/mach-msm/platsmp.c
index 93624a3c..0838c2c 100644
--- a/arch/arm/mach-msm/platsmp.c
+++ b/arch/arm/mach-msm/platsmp.c
@@ -166,9 +166,7 @@
{
pr_debug("CPU%u: Booted secondary processor\n", cpu);
-#ifdef CONFIG_HOTPLUG_CPU
- WARN_ON(msm_pm_platform_secondary_init(cpu));
-#endif
+ WARN_ON(msm_platform_secondary_init(cpu));
trace_hardirqs_off();
diff --git a/arch/arm/mach-msm/pm-8x60.c b/arch/arm/mach-msm/pm-8x60.c
index f479daf..adf5471 100644
--- a/arch/arm/mach-msm/pm-8x60.c
+++ b/arch/arm/mach-msm/pm-8x60.c
@@ -620,15 +620,6 @@
*
*****************************************************************************/
-struct msm_pm_device {
- unsigned int cpu;
-#ifdef CONFIG_HOTPLUG_CPU
- struct completion cpu_killed;
- unsigned int warm_boot;
-#endif
-};
-
-static DEFINE_PER_CPU_SHARED_ALIGNED(struct msm_pm_device, msm_pm_devices);
static struct msm_rpmrs_limits *msm_pm_idle_rs_limits;
static void msm_pm_swfi(void)
@@ -656,7 +647,7 @@
#endif
static bool msm_pm_spm_power_collapse(
- struct msm_pm_device *dev, bool from_idle, bool notify_rpm)
+ unsigned int cpu, bool from_idle, bool notify_rpm)
{
void *entry;
bool collapsed = 0;
@@ -664,19 +655,19 @@
if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask)
pr_info("CPU%u: %s: notify_rpm %d\n",
- dev->cpu, __func__, (int) notify_rpm);
+ cpu, __func__, (int) notify_rpm);
ret = msm_spm_set_low_power_mode(
MSM_SPM_MODE_POWER_COLLAPSE, notify_rpm);
WARN_ON(ret);
- entry = (!dev->cpu || from_idle) ?
+ entry = (!cpu || from_idle) ?
msm_pm_collapse_exit : msm_secondary_startup;
- msm_pm_boot_config_before_pc(dev->cpu, virt_to_phys(entry));
+ msm_pm_boot_config_before_pc(cpu, virt_to_phys(entry));
if (MSM_PM_DEBUG_RESET_VECTOR & msm_pm_debug_mask)
pr_info("CPU%u: %s: program vector to %p\n",
- dev->cpu, __func__, entry);
+ cpu, __func__, entry);
#ifdef CONFIG_VFP
vfp_flush_context();
@@ -684,7 +675,7 @@
collapsed = msm_pm_l2x0_power_collapse();
- msm_pm_boot_config_after_pc(dev->cpu);
+ msm_pm_boot_config_after_pc(cpu);
if (collapsed) {
#ifdef CONFIG_VFP
@@ -698,7 +689,7 @@
if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask)
pr_info("CPU%u: %s: msm_pm_collapse returned, collapsed %d\n",
- dev->cpu, __func__, collapsed);
+ cpu, __func__, collapsed);
ret = msm_spm_set_low_power_mode(MSM_SPM_MODE_CLOCK_GATING, false);
WARN_ON(ret);
@@ -707,60 +698,60 @@
static bool msm_pm_power_collapse_standalone(bool from_idle)
{
- struct msm_pm_device *dev = &__get_cpu_var(msm_pm_devices);
+ unsigned int cpu = smp_processor_id();
unsigned int avsdscr_setting;
bool collapsed;
avsdscr_setting = avs_get_avsdscr();
avs_disable();
- collapsed = msm_pm_spm_power_collapse(dev, from_idle, false);
+ collapsed = msm_pm_spm_power_collapse(cpu, from_idle, false);
avs_reset_delays(avsdscr_setting);
return collapsed;
}
static bool msm_pm_power_collapse(bool from_idle)
{
- struct msm_pm_device *dev = &__get_cpu_var(msm_pm_devices);
+ unsigned int cpu = smp_processor_id();
unsigned long saved_acpuclk_rate;
unsigned int avsdscr_setting;
bool collapsed;
if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask)
pr_info("CPU%u: %s: idle %d\n",
- dev->cpu, __func__, (int)from_idle);
+ cpu, __func__, (int)from_idle);
msm_pm_config_hw_before_power_down();
if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask)
- pr_info("CPU%u: %s: pre power down\n", dev->cpu, __func__);
+ pr_info("CPU%u: %s: pre power down\n", cpu, __func__);
avsdscr_setting = avs_get_avsdscr();
avs_disable();
- if (cpu_online(dev->cpu))
+ if (cpu_online(cpu))
saved_acpuclk_rate = acpuclk_power_collapse();
else
saved_acpuclk_rate = 0;
if (MSM_PM_DEBUG_CLOCK & msm_pm_debug_mask)
pr_info("CPU%u: %s: change clock rate (old rate = %lu)\n",
- dev->cpu, __func__, saved_acpuclk_rate);
+ cpu, __func__, saved_acpuclk_rate);
- collapsed = msm_pm_spm_power_collapse(dev, from_idle, true);
+ collapsed = msm_pm_spm_power_collapse(cpu, from_idle, true);
if (MSM_PM_DEBUG_CLOCK & msm_pm_debug_mask)
pr_info("CPU%u: %s: restore clock rate to %lu\n",
- dev->cpu, __func__, saved_acpuclk_rate);
- if (acpuclk_set_rate(dev->cpu, saved_acpuclk_rate, SETRATE_PC) < 0)
+ cpu, __func__, saved_acpuclk_rate);
+ if (acpuclk_set_rate(cpu, saved_acpuclk_rate, SETRATE_PC) < 0)
pr_err("CPU%u: %s: failed to restore clock rate(%lu)\n",
- dev->cpu, __func__, saved_acpuclk_rate);
+ cpu, __func__, saved_acpuclk_rate);
avs_reset_delays(avsdscr_setting);
msm_pm_config_hw_after_power_up();
if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask)
- pr_info("CPU%u: %s: post power up\n", dev->cpu, __func__);
+ pr_info("CPU%u: %s: post power up\n", cpu, __func__);
if (MSM_PM_DEBUG_POWER_COLLAPSE & msm_pm_debug_mask)
- pr_info("CPU%u: %s: return\n", dev->cpu, __func__);
+ pr_info("CPU%u: %s: return\n", cpu, __func__);
return collapsed;
}
@@ -962,6 +953,31 @@
return 0;
}
+void msm_pm_cpu_enter_lowpower(unsigned int cpu)
+{
+ int i;
+ bool allow[MSM_PM_SLEEP_MODE_NR];
+
+ for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) {
+ struct msm_pm_platform_data *mode;
+
+ mode = &msm_pm_modes[MSM_PM_MODE(cpu, i)];
+ allow[i] = mode->suspend_supported && mode->suspend_enabled;
+ }
+
+ if (MSM_PM_DEBUG_HOTPLUG & msm_pm_debug_mask)
+ pr_notice("CPU%u: %s: shutting down cpu\n", cpu, __func__);
+
+ if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE])
+ msm_pm_power_collapse(false);
+ else if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE])
+ msm_pm_power_collapse_standalone(false);
+ else if (allow[MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT])
+ msm_pm_swfi();
+
+
+}
+
static int msm_pm_enter(suspend_state_t state)
{
bool allow[MSM_PM_SLEEP_MODE_NR];
@@ -1069,79 +1085,6 @@
.valid = suspend_valid_only_mem,
};
-#ifdef CONFIG_HOTPLUG_CPU
-int platform_cpu_disable(unsigned int cpu)
-{
- return cpu == 0 ? -EPERM : 0;
-}
-
-int platform_cpu_kill(unsigned int cpu)
-{
- struct completion *killed = &per_cpu(msm_pm_devices, cpu).cpu_killed;
- return wait_for_completion_timeout(killed, HZ * 5);
-}
-
-void platform_cpu_die(unsigned int cpu)
-{
- bool allow[MSM_PM_SLEEP_MODE_NR];
- int i;
-
- if (unlikely(cpu != smp_processor_id())) {
- pr_crit("%s: running on %u, should be %u\n",
- __func__, smp_processor_id(), cpu);
- BUG();
- }
-
- for (i = 0; i < MSM_PM_SLEEP_MODE_NR; i++) {
- struct msm_pm_platform_data *mode;
-
- mode = &msm_pm_modes[MSM_PM_MODE(cpu, i)];
- allow[i] = mode->suspend_supported && mode->suspend_enabled;
- }
-
- if (MSM_PM_DEBUG_HOTPLUG & msm_pm_debug_mask)
- pr_notice("CPU%u: %s: shutting down cpu\n", cpu, __func__);
- complete(&__get_cpu_var(msm_pm_devices).cpu_killed);
-
- flush_cache_all();
-
- for (;;) {
- if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE])
- msm_pm_power_collapse(false);
- else if (allow[MSM_PM_SLEEP_MODE_POWER_COLLAPSE_STANDALONE])
- msm_pm_power_collapse_standalone(false);
- else if (allow[MSM_PM_SLEEP_MODE_WAIT_FOR_INTERRUPT])
- msm_pm_swfi();
-
- if (pen_release == cpu) {
- /* OK, proper wakeup, we're done */
- break;
- }
- }
-
- pen_release = -1;
- pr_notice("CPU%u: %s: normal wakeup\n", cpu, __func__);
-}
-
-int msm_pm_platform_secondary_init(unsigned int cpu)
-{
- int ret;
- struct msm_pm_device *dev = &__get_cpu_var(msm_pm_devices);
-
- if (!dev->warm_boot) {
- dev->warm_boot = 1;
- return 0;
- }
- etm_restore_reg_check();
- msm_restore_jtag_debug();
-#ifdef CONFIG_VFP
- vfp_reinit();
-#endif
- ret = msm_spm_set_low_power_mode(MSM_SPM_MODE_CLOCK_GATING, false);
-
- return ret;
-}
-#endif /* CONFIG_HOTPLUG_CPU */
/******************************************************************************
* Initialization routine
@@ -1197,15 +1140,6 @@
return ret;
}
- for_each_possible_cpu(cpu) {
- struct msm_pm_device *dev = &per_cpu(msm_pm_devices, cpu);
-
- dev->cpu = cpu;
-#ifdef CONFIG_HOTPLUG_CPU
- init_completion(&dev->cpu_killed);
-#endif
- }
-
#ifdef CONFIG_MSM_IDLE_STATS
for_each_possible_cpu(cpu) {
struct msm_pm_time_stats *stats =
diff --git a/arch/arm/mach-msm/pm.h b/arch/arm/mach-msm/pm.h
index ad0bc7d..813ece1 100644
--- a/arch/arm/mach-msm/pm.h
+++ b/arch/arm/mach-msm/pm.h
@@ -22,7 +22,6 @@
#include <linux/cpuidle.h>
#ifdef CONFIG_SMP
-extern int pen_release;
extern void msm_secondary_startup(void);
#else
#define msm_secondary_startup NULL
@@ -55,13 +54,17 @@
void msm_pm_set_platform_data(struct msm_pm_platform_data *data, int count);
int msm_pm_idle_prepare(struct cpuidle_device *dev);
int msm_pm_idle_enter(enum msm_pm_sleep_mode sleep_mode);
+void msm_pm_cpu_enter_lowpower(unsigned int cpu);
#ifdef CONFIG_PM
void msm_pm_set_rpm_wakeup_irq(unsigned int irq);
-int msm_pm_platform_secondary_init(unsigned int cpu);
#else
static inline void msm_pm_set_rpm_wakeup_irq(unsigned int irq) {}
-static inline int msm_pm_platform_secondary_init(unsigned int cpu)
-{ return -ENOSYS; }
+#endif
+
+#ifdef CONFIG_HOTPLUG_CPU
+int msm_platform_secondary_init(unsigned int cpu);
+#else
+static inline int msm_platform_secondary_init(unsigned int cpu) { return 0; }
#endif
#endif /* __ARCH_ARM_MACH_MSM_PM_H */