Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9368026 authored by Raja Mallik's avatar Raja Mallik Committed by Chinkit Kumar,Kirti Kumar Parmar
Browse files

ARM: qcom: Add MSM Legacy hotplug low power mode APIs



Add low power mode support for hotplug CPUs.

Remove pen release logic, forloop & gic pending
irqs print from legacy hotplug code.

Remove vfp_resume call as current vfp module has
pm notifiers.

Add 'cpu_can_disable' smp callback to enable hotplug
support for bootcore CPU

Change-Id: Ic830bbea1260c34bd383d7c07e2c6fef05677ded
Signed-off-by: default avatarChinkit Kumar,Kirti Kumar Parmar <parma@codeaurora.org>
parent 9a2eb4b6
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
obj-$(CONFIG_USE_OF) += board-dt.o
obj-$(CONFIG_SMP)	+= platsmp.o
obj-$(CONFIG_MSM_PM_LEGACY)	+=hotplug.o
obj-$(CONFIG_ARCH_SDXPOORWILLS) += board-poorwills.o
obj-$(CONFIG_ARCH_MSM8953) += board-msm8953.o
obj-$(CONFIG_ARCH_MSM8937) += board-msm8937.o
+24 −63
Original line number Diff line number Diff line
@@ -12,18 +12,13 @@
#include <linux/errno.h>
#include <linux/smp.h>
#include <linux/cpu.h>
#include <linux/notifier.h>
#include <soc/qcom/spm.h>
#include <soc/qcom/pm.h>
#include <linux/irqchip/arm-gic.h>

#include <soc/qcom/pm-legacy.h>
#include <asm/smp_plat.h>
#include <asm/vfp.h>

#include "platsmp.h"
#include <soc/qcom/jtag.h>

static cpumask_t cpu_dying_mask;

static DEFINE_PER_CPU(unsigned int, warm_boot_flag);

static inline void cpu_enter_lowpower(void)
@@ -34,36 +29,18 @@ static inline void cpu_leave_lowpower(void)
{
}

static inline void platform_do_lowpower(unsigned int cpu, int *spurious)
static inline void platform_do_lowpower(unsigned int cpu)
{
	/* Just enter wfi for now. TODO: Properly shut off the cpu. */
	for (;;) {

	lpm_cpu_hotplug_enter(cpu);
		if (pen_release == cpu_logical_map(cpu)) {
	/*
			 * OK, proper wakeup, we're done
			 */
			break;
		}

		/*
		 * getting here, means that we have come out of WFI without
		 * having been woken up - this shouldn't happen
	 * getting here, means that we have come out of low power mode
	 * without having been woken up - this shouldn't happen
	 *
		 * The trouble is, letting people know about this is not really
		 * possible, since we are currently running incoherently, and
		 * therefore cannot safely call printk() or anything else
		 * Read the pending interrupts to understand why we woke up
	 */
#ifdef CONFIG_MSM_PM
		gic_show_pending_irq();
#endif
		(*spurious)++;
	}
	pr_err("%s: CPU%u has failed to Hotplug\n", __func__, cpu);
}

int msm_cpu_kill(unsigned int cpu)
int qcom_cpu_kill_legacy(unsigned int cpu)
{
	int ret = 0;

@@ -78,10 +55,8 @@ int msm_cpu_kill(unsigned int cpu)
 *
 * Called with IRQs disabled
 */
void __ref msm_cpu_die(unsigned int cpu)
void __ref qcom_cpu_die_legacy(unsigned int cpu)
{
	int spurious = 0;

	if (unlikely(cpu != smp_processor_id())) {
		pr_crit("%s: running on %u, should be %u\n",
			__func__, smp_processor_id(), cpu);
@@ -91,36 +66,16 @@ void __ref msm_cpu_die(unsigned int cpu)
	 * we're ready for shutdown now, so do it
	 */
	cpu_enter_lowpower();
	platform_do_lowpower(cpu, &spurious);
	platform_do_lowpower(cpu);

	pr_debug("CPU%u: %s: normal wakeup\n", cpu, __func__);
	cpu_leave_lowpower();

	if (spurious)
		pr_warn("CPU%u: %u spurious wakeup calls\n", cpu, spurious);
}

static int hotplug_dying_callback(struct notifier_block *nfb,
				unsigned long action, void *hcpu)
{
	switch (action & (~CPU_TASKS_FROZEN)) {
	case CPU_DYING:
		cpumask_set_cpu((unsigned long)hcpu, &cpu_dying_mask);
		break;
	default:
		break;
	}

	return NOTIFY_OK;
}
static struct notifier_block hotplug_dying_notifier = {
	.notifier_call = hotplug_dying_callback,
};

int msm_platform_secondary_init(unsigned int cpu)
{
	int ret;
	unsigned int *warm_boot = &__get_cpu_var(warm_boot_flag);
	unsigned int *warm_boot = this_cpu_ptr(&warm_boot_flag);

	if (!(*warm_boot)) {
		*warm_boot = 1;
@@ -133,16 +88,22 @@ int msm_platform_secondary_init(unsigned int cpu)
			return 0;
	}
	msm_jtag_restore_state();
#if defined(CONFIG_VFP) && defined(CONFIG_CPU_PM)
	vfp_pm_resume();
#endif
	ret = msm_spm_set_low_power_mode(MSM_SPM_MODE_CLOCK_GATING, false);

	return ret;
}

static int hotplug_dying_cpu(unsigned int cpu)
{
	cpumask_set_cpu(cpu, &cpu_dying_mask);
	return 0;
}

static int __init init_hotplug_dying(void)
{
	return register_hotcpu_notifier(&hotplug_dying_notifier);
	cpuhp_setup_state(CPUHP_AP_QCOM_SLEEP_STARTING,
		 "AP_QCOM_HOTPLUG_STARTING", NULL, hotplug_dying_cpu);

	return 0;
}
early_initcall(init_hotplug_dying);
+17 −0
Original line number Diff line number Diff line
@@ -22,6 +22,9 @@
#include <asm/smp_plat.h>
#include <asm/fixmap.h>
#include "platsmp.h"
#ifdef CONFIG_MSM_PM_LEGACY
#include <soc/qcom/pm-legacy.h>
#endif

#define MSM_APCS_IDR 0x0B011030

@@ -62,10 +65,18 @@ static void qcom_cpu_die(unsigned int cpu)
{
	wfi();
}

static bool qcom_cpu_can_disable(unsigned int cpu)
{
	return true; /*Hotplug of any CPU is supported */
}
#endif

static void qcom_secondary_init(unsigned int cpu)
{
#ifdef CONFIG_MSM_PM_LEGACY
	WARN_ON(msm_platform_secondary_init(cpu));
#endif
	/*
	 * Synchronise with the boot thread.
	 */
@@ -472,7 +483,13 @@ struct smp_operations msm8909_smp_ops __initdata = {
	.smp_secondary_init = qcom_secondary_init,
	.smp_boot_secondary = msm8909_boot_secondary,
#ifdef CONFIG_HOTPLUG_CPU
#ifdef CONFIG_MSM_PM_LEGACY
	.cpu_die		= qcom_cpu_die_legacy,
	.cpu_kill		= qcom_cpu_kill_legacy,
#else
	.cpu_die		= qcom_cpu_die,
#endif
	.cpu_can_disable	= qcom_cpu_can_disable,
#endif
};

+4 −0
Original line number Diff line number Diff line
@@ -179,9 +179,13 @@ static inline int lpm_get_latency(struct latency_level *level,
#endif

#ifdef CONFIG_HOTPLUG_CPU
void qcom_cpu_die_legacy(unsigned int cpu);
int qcom_cpu_kill_legacy(unsigned int cpu);
int msm_platform_secondary_init(unsigned int cpu);
#else
static inline int msm_platform_secondary_init(unsigned int cpu) { return 0; }
static inline void qcom_cpu_die_legacy(unsigned int cpu) {}
static inline int qcom_cpu_kill_legacy(unsigned int cpu) { return 0; }
#endif

enum msm_pm_time_stats_id {