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

Commit 060f60c4 authored by Mahesh Sivasubramanian's avatar Mahesh Sivasubramanian
Browse files

drivers: cpuidle: lpm-levels: Remove unused code



All QTI chips support firmware configuration of Sleep modes through
PSCI. Remove any legacy code not required for newer ARM targets.

Change-Id: I414e90be54db8c86492e2d77ef02e226ac7c42e4
Signed-off-by: default avatarMahesh Sivasubramanian <msivasub@codeaurora.org>
parent c29e5a41
Loading
Loading
Loading
Loading
+45 −73
Original line number Original line Diff line number Diff line
@@ -21,7 +21,6 @@
#include <linux/moduleparam.h>
#include <linux/moduleparam.h>
#include "lpm-levels.h"
#include "lpm-levels.h"


bool use_psci;
enum lpm_type {
enum lpm_type {
	IDLE = 0,
	IDLE = 0,
	SUSPEND,
	SUSPEND,
@@ -431,7 +430,6 @@ static int parse_cluster_params(struct device_node *node,
		return ret;
		return ret;
	}
	}


	if (use_psci) {
	key = "qcom,psci-mode-shift";
	key = "qcom,psci-mode-shift";
	ret = of_property_read_u32(node, key,
	ret = of_property_read_u32(node, key,
			&c->psci_mode_shift);
			&c->psci_mode_shift);
@@ -453,8 +451,6 @@ static int parse_cluster_params(struct device_node *node,
	/* Set ndevice to 1 as default */
	/* Set ndevice to 1 as default */
	c->ndevices = 1;
	c->ndevices = 1;


	} else
		pr_warn("Target supports PSCI only\n");
	return 0;
	return 0;
}
}


@@ -503,21 +499,13 @@ static int parse_cluster_level(struct device_node *node,
	if (ret)
	if (ret)
		goto failed;
		goto failed;


	if (use_psci) {
	key = "qcom,psci-mode";
		char *k = "qcom,psci-mode";


		ret = of_property_read_u32(node, k, &level->psci_id);
	ret = of_property_read_u32(node, key, &level->psci_id);
	if (ret)
	if (ret)
		goto failed;
		goto failed;


	level->is_reset = of_property_read_bool(node, "qcom,is-reset");
	level->is_reset = of_property_read_bool(node, "qcom,is-reset");
	} else
		pr_warn("Build supports PSCI targets only");

	key = "label";
	ret = of_property_read_string(node, key, &level->level_name);
	if (ret)
		goto failed;


	if (cluster->nlevels != cluster->default_level) {
	if (cluster->nlevels != cluster->default_level) {
		key = "min child idx";
		key = "min child idx";
@@ -531,10 +519,6 @@ static int parse_cluster_level(struct device_node *node,
	}
	}


	level->notify_rpm = of_property_read_bool(node, "qcom,notify-rpm");
	level->notify_rpm = of_property_read_bool(node, "qcom,notify-rpm");
	level->disable_dynamic_routing = of_property_read_bool(node,
					"qcom,disable-dynamic-int-routing");
	level->last_core_only = of_property_read_bool(node,
					"qcom,last-core-only");


	key = "parse_power_params";
	key = "parse_power_params";
	ret = parse_power_params(node, &level->pwr);
	ret = parse_power_params(node, &level->pwr);
@@ -569,9 +553,7 @@ static int parse_cpu_mode(struct device_node *n, struct lpm_cpu_level *l)
		return ret;
		return ret;
	}
	}


	if (use_psci) {
	key = "qcom,psci-cpu-mode";
	key = "qcom,psci-cpu-mode";

	ret = of_property_read_u32(n, key, &l->psci_id);
	ret = of_property_read_u32(n, key, &l->psci_id);
	if (ret) {
	if (ret) {
		pr_err("Failed reading %s on device %s\n", key,
		pr_err("Failed reading %s on device %s\n", key,
@@ -581,8 +563,6 @@ static int parse_cpu_mode(struct device_node *n, struct lpm_cpu_level *l)
	key = "qcom,hyp-psci";
	key = "qcom,hyp-psci";


	l->hyp_psci = of_property_read_bool(n, key);
	l->hyp_psci = of_property_read_bool(n, key);
	} else
		pr_warn("Build supports PSCI targets only");
	return 0;
	return 0;


}
}
@@ -651,7 +631,6 @@ static int parse_cpu_levels(struct device_node *node, struct lpm_cluster *c)
		return ret;
		return ret;


	c->cpu->parent = c;
	c->cpu->parent = c;
	if (use_psci) {


	key = "qcom,psci-mode-shift";
	key = "qcom,psci-mode-shift";


@@ -669,7 +648,6 @@ static int parse_cpu_levels(struct device_node *node, struct lpm_cluster *c)
				node->name);
				node->name);
		return ret;
		return ret;
	}
	}
	}
	for_each_child_of_node(node, n) {
	for_each_child_of_node(node, n) {
		struct lpm_cpu_level *l = &c->cpu->levels[c->cpu->nlevels];
		struct lpm_cpu_level *l = &c->cpu->levels[c->cpu->nlevels];


@@ -753,10 +731,8 @@ void free_cluster_node(struct lpm_cluster *cluster)
	}
	}
	kfree(cluster->cpu);
	kfree(cluster->cpu);
	kfree(cluster->name);
	kfree(cluster->name);
	kfree(cluster->lpm_dev);
	cluster->cpu = NULL;
	cluster->cpu = NULL;
	cluster->name = NULL;
	cluster->name = NULL;
	cluster->lpm_dev = NULL;
	cluster->ndevices = 0;
	cluster->ndevices = 0;
}
}


@@ -795,7 +771,6 @@ struct lpm_cluster *parse_cluster(struct device_node *node,
			continue;
			continue;
		key = "qcom,pm-cluster-level";
		key = "qcom,pm-cluster-level";
		if (!of_node_cmp(n->name, key)) {
		if (!of_node_cmp(n->name, key)) {
			WARN_ON(!use_psci && c->no_saw_devices);
			if (parse_cluster_level(n, c))
			if (parse_cluster_level(n, c))
				goto failed_parse_cluster;
				goto failed_parse_cluster;
			continue;
			continue;
@@ -805,7 +780,6 @@ struct lpm_cluster *parse_cluster(struct device_node *node,
		if (!of_node_cmp(n->name, key)) {
		if (!of_node_cmp(n->name, key)) {
			struct lpm_cluster *child;
			struct lpm_cluster *child;


			WARN_ON(!use_psci && c->no_saw_devices);
			child = parse_cluster(n, c);
			child = parse_cluster(n, c);
			if (!child)
			if (!child)
				goto failed_parse_cluster;
				goto failed_parse_cluster;
@@ -883,8 +857,6 @@ struct lpm_cluster *lpm_of_parse_cluster(struct platform_device *pdev)
{
{
	struct device_node *top = NULL;
	struct device_node *top = NULL;


	use_psci = of_property_read_bool(pdev->dev.of_node, "qcom,use-psci");

	top = of_find_node_by_name(pdev->dev.of_node, "qcom,pm-cluster");
	top = of_find_node_by_name(pdev->dev.of_node, "qcom,pm-cluster");
	if (!top) {
	if (!top) {
		pr_err("Failed to find root node\n");
		pr_err("Failed to find root node\n");
+6 −154
Original line number Original line Diff line number Diff line
@@ -53,10 +53,8 @@
#include <trace/events/trace_msm_low_power.h>
#include <trace/events/trace_msm_low_power.h>


#define SCLK_HZ (32768)
#define SCLK_HZ (32768)
#define SCM_HANDOFF_LOCK_ID "S:7"
#define PSCI_POWER_STATE(reset) (reset << 30)
#define PSCI_POWER_STATE(reset) (reset << 30)
#define PSCI_AFFINITY_LEVEL(lvl) ((lvl & 0x3) << 24)
#define PSCI_AFFINITY_LEVEL(lvl) ((lvl & 0x3) << 24)
static remote_spinlock_t scm_handoff_lock;


enum {
enum {
	MSM_LPM_LVL_DBG_SUSPEND_LIMITS = BIT(0),
	MSM_LPM_LVL_DBG_SUSPEND_LIMITS = BIT(0),
@@ -414,22 +412,6 @@ static void msm_pm_set_timer(uint32_t modified_time_us)
	hrtimer_start(&lpm_hrtimer, modified_ktime, HRTIMER_MODE_REL_PINNED);
	hrtimer_start(&lpm_hrtimer, modified_ktime, HRTIMER_MODE_REL_PINNED);
}
}


static int set_device_mode(struct lpm_cluster *cluster, int ndevice,
		struct lpm_cluster_level *level)
{
	struct low_power_ops *ops;

	if (use_psci)
		return 0;

	ops = &cluster->lpm_dev[ndevice];
	if (ops && ops->set_mode)
		return ops->set_mode(ops, level->mode[ndevice],
				level->notify_rpm);
	else
		return -EINVAL;
}

static uint64_t lpm_cpuidle_predict(struct cpuidle_device *dev,
static uint64_t lpm_cpuidle_predict(struct cpuidle_device *dev,
		struct lpm_cpu *cpu, int *idx_restrict,
		struct lpm_cpu *cpu, int *idx_restrict,
		uint32_t *idx_restrict_time)
		uint32_t *idx_restrict_time)
@@ -953,10 +935,6 @@ static int cluster_select(struct lpm_cluster *cluster, bool from_idle,
		if (!lpm_cluster_mode_allow(cluster, i, from_idle))
		if (!lpm_cluster_mode_allow(cluster, i, from_idle))
			continue;
			continue;


		if (level->last_core_only &&
			cpumask_weight(cpu_online_mask) > 1)
			continue;

		if (!cpumask_equal(&cluster->num_children_in_sync,
		if (!cpumask_equal(&cluster->num_children_in_sync,
					&level->num_cpu_votes))
					&level->num_cpu_votes))
			continue;
			continue;
@@ -1001,7 +979,6 @@ static int cluster_configure(struct lpm_cluster *cluster, int idx,
		bool from_idle, int predicted)
		bool from_idle, int predicted)
{
{
	struct lpm_cluster_level *level = &cluster->levels[idx];
	struct lpm_cluster_level *level = &cluster->levels[idx];
	int ret, i;


	if (!cpumask_equal(&cluster->num_children_in_sync, &cluster->child_cpus)
	if (!cpumask_equal(&cluster->num_children_in_sync, &cluster->child_cpus)
			|| is_IPI_pending(&cluster->num_children_in_sync)) {
			|| is_IPI_pending(&cluster->num_children_in_sync)) {
@@ -1022,25 +999,12 @@ static int cluster_configure(struct lpm_cluster *cluster, int idx,
						ktime_to_us(ktime_get()));
						ktime_to_us(ktime_get()));
	}
	}


	for (i = 0; i < cluster->ndevices; i++) {
		ret = set_device_mode(cluster, i, level);
		if (ret)
			goto failed_set_mode;
	}
	if (level->notify_rpm) {
	if (level->notify_rpm) {
		struct cpumask nextcpu, *cpumask;
		uint64_t us;
		uint64_t us;
		uint32_t pred_us;
		uint32_t pred_us;


		us = get_cluster_sleep_time(cluster, &nextcpu,
		us = get_cluster_sleep_time(cluster, NULL, from_idle,
						from_idle, &pred_us);
				&pred_us);
		cpumask = level->disable_dynamic_routing ? NULL : &nextcpu;

		if (ret) {
			pr_info("Failed msm_rpm_enter_sleep() rc = %d\n", ret);
			goto failed_set_mode;
		}

		us = us + 1;
		us = us + 1;
		clear_predict_history();
		clear_predict_history();
		clear_cl_predict_history();
		clear_cl_predict_history();
@@ -1062,17 +1026,6 @@ static int cluster_configure(struct lpm_cluster *cluster, int idx,
	}
	}


	return 0;
	return 0;
failed_set_mode:

	for (i = 0; i < cluster->ndevices; i++) {
		int rc = 0;

		level = &cluster->levels[cluster->default_level];
		// rc = set_device_mode(cluster, i, level);
		WARN_ON(rc);
	}

	return ret;
}
}


static void cluster_prepare(struct lpm_cluster *cluster,
static void cluster_prepare(struct lpm_cluster *cluster,
@@ -1152,7 +1105,7 @@ static void cluster_unprepare(struct lpm_cluster *cluster,
{
{
	struct lpm_cluster_level *level;
	struct lpm_cluster_level *level;
	bool first_cpu;
	bool first_cpu;
	int last_level, i, ret;
	int last_level, i;


	if (!cluster)
	if (!cluster)
		return;
		return;
@@ -1202,13 +1155,8 @@ static void cluster_unprepare(struct lpm_cluster *cluster,
	last_level = cluster->last_level;
	last_level = cluster->last_level;
	cluster->last_level = cluster->default_level;
	cluster->last_level = cluster->default_level;


	for (i = 0; i < cluster->ndevices; i++) {
	for (i = 0; i < cluster->ndevices; i++)
		level = &cluster->levels[cluster->default_level];
		level = &cluster->levels[cluster->default_level];
		ret = set_device_mode(cluster, i, level);

		WARN_ON(ret);

	}


	cluster_notify(cluster, &cluster->levels[last_level], false);
	cluster_notify(cluster, &cluster->levels[last_level], false);


@@ -1305,8 +1253,8 @@ int get_cluster_id(struct lpm_cluster *cluster, int *aff_lvl)
	return state_id;
	return state_id;
}
}


#if !defined(CONFIG_CPU_V7)
static bool psci_enter_sleep(struct lpm_cluster *cluster, int idx,
bool psci_enter_sleep(struct lpm_cluster *cluster, int idx, bool from_idle)
		bool from_idle)
{
{
	int affinity_level = 0;
	int affinity_level = 0;
	int state_id = get_cluster_id(cluster, &affinity_level);
	int state_id = get_cluster_id(cluster, &affinity_level);
@@ -1336,41 +1284,6 @@ bool psci_enter_sleep(struct lpm_cluster *cluster, int idx, bool from_idle)
			success, 0xdeaffeed, true);
			success, 0xdeaffeed, true);
	return success;
	return success;
}
}
#elif defined(CONFIG_ARM_PSCI)
bool psci_enter_sleep(struct lpm_cluster *cluster, int idx, bool from_idle)
{
	int affinity_level = 0;
	int state_id = get_cluster_id(cluster, &affinity_level);
	int power_state =
		PSCI_POWER_STATE(cluster->cpu->levels[idx].is_reset);
	bool success = false;

	if (!idx) {
		stop_critical_timings();
		wfi();
		start_critical_timings();
		return 1;
	}

	affinity_level = PSCI_AFFINITY_LEVEL(affinity_level);
	state_id |= (power_state | affinity_level
			| cluster->cpu->levels[idx].psci_id);

	update_debug_pc_event(CPU_ENTER, state_id,
			0xdeaffeed, 0xdeaffeed, true);
	stop_critical_timings();
	success = !arm_cpuidle_suspend(state_id);
	start_critical_timings();
	update_debug_pc_event(CPU_EXIT, state_id,
			success, 0xdeaffeed, true);
}
#else
bool psci_enter_sleep(struct lpm_cluster *cluster, int idx, bool from_idle)
{
	WARN_ONCE(true, "PSCI cpu_suspend ops not supported\n");
	return false;
}
#endif


static int lpm_cpuidle_select(struct cpuidle_driver *drv,
static int lpm_cpuidle_select(struct cpuidle_driver *drv,
		struct cpuidle_device *dev)
		struct cpuidle_device *dev)
@@ -1444,7 +1357,6 @@ static int lpm_cpuidle_enter(struct cpuidle_device *dev,
	if (need_resched() || (idx < 0))
	if (need_resched() || (idx < 0))
		goto exit;
		goto exit;


	WARN_ON(!use_psci);
	success = psci_enter_sleep(cluster, idx, true);
	success = psci_enter_sleep(cluster, idx, true);


exit:
exit:
@@ -1689,7 +1601,6 @@ static int lpm_suspend_enter(suspend_state_t state)
	 * LPMs(XO and Vmin).
	 * LPMs(XO and Vmin).
	 */
	 */


	WARN_ON(!use_psci);
	psci_enter_sleep(cluster, idx, true);
	psci_enter_sleep(cluster, idx, true);


	if (idx > 0)
	if (idx > 0)
@@ -1737,14 +1648,6 @@ static int lpm_probe(struct platform_device *pdev)
	hrtimer_init(&histtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	hrtimer_init(&histtimer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
	cluster_timer_init(lpm_root_node);
	cluster_timer_init(lpm_root_node);


	ret = remote_spin_lock_init(&scm_handoff_lock, SCM_HANDOFF_LOCK_ID);
	if (ret) {
		pr_err("%s: Failed initializing scm_handoff_lock (%d)\n",
			__func__, ret);
		put_online_cpus();
		return ret;
	}

	size = num_dbg_elements * sizeof(struct lpm_debug);
	size = num_dbg_elements * sizeof(struct lpm_debug);
	lpm_debug = dma_alloc_coherent(&pdev->dev, size,
	lpm_debug = dma_alloc_coherent(&pdev->dev, size,
			&lpm_debug_phys, GFP_KERNEL);
			&lpm_debug_phys, GFP_KERNEL);
@@ -1813,54 +1716,3 @@ static int __init lpm_levels_module_init(void)
	return rc;
	return rc;
}
}
late_initcall(lpm_levels_module_init);
late_initcall(lpm_levels_module_init);

enum msm_pm_l2_scm_flag lpm_cpu_pre_pc_cb(unsigned int cpu)
{
	struct lpm_cluster *cluster = per_cpu(cpu_cluster, cpu);
	enum msm_pm_l2_scm_flag retflag = MSM_SCM_L2_ON;

	/*
	 * No need to acquire the lock if probe isn't completed yet
	 * In the event of the hotplug happening before lpm probe, we want to
	 * flush the cache to make sure that L2 is flushed. In particular, this
	 * could cause incoherencies for a cluster architecture. This wouldn't
	 * affect the idle case as the idle driver wouldn't be registered
	 * before the probe function
	 */
	if (!cluster)
		return MSM_SCM_L2_OFF;

	/*
	 * Assumes L2 only. What/How parameters gets passed into TZ will
	 * determine how this function reports this info back in msm-pm.c
	 */
	spin_lock(&cluster->sync_lock);

	if (!cluster->lpm_dev) {
		retflag = MSM_SCM_L2_OFF;
		goto unlock_and_return;
	}

	if (!cpumask_equal(&cluster->num_children_in_sync,
						&cluster->child_cpus))
		goto unlock_and_return;

	if (cluster->lpm_dev)
		retflag = cluster->lpm_dev->tz_flag;
	/*
	 * The scm_handoff_lock will be release by the secure monitor.
	 * It is used to serialize power-collapses from this point on,
	 * so that both Linux and the secure context have a consistent
	 * view regarding the number of running cpus (cpu_count).
	 *
	 * It must be acquired before releasing the cluster lock.
	 */
unlock_and_return:
	update_debug_pc_event(PRE_PC_CB, retflag, 0xdeadbeef, 0xdeadbeef,
			0xdeadbeef);
	trace_pre_pc_cb(retflag);
	remote_spin_lock_rlock_id(&scm_handoff_lock,
				  REMOTE_SPINLOCK_TID_START + cpu);
	spin_unlock(&cluster->sync_lock);
	return retflag;
}
+0 −16
Original line number Original line Diff line number Diff line
@@ -17,8 +17,6 @@
#define MAXSAMPLES 5
#define MAXSAMPLES 5
#define CLUST_SMPL_INVLD_TIME 40000
#define CLUST_SMPL_INVLD_TIME 40000


extern bool use_psci;

struct lpm_lookup_table {
struct lpm_lookup_table {
	uint32_t modes;
	uint32_t modes;
	const char *mode_name;
	const char *mode_name;
@@ -74,21 +72,13 @@ struct lpm_cluster_level {
	struct cpumask num_cpu_votes;
	struct cpumask num_cpu_votes;
	struct power_params pwr;
	struct power_params pwr;
	bool notify_rpm;
	bool notify_rpm;
	bool disable_dynamic_routing;
	bool sync_level;
	bool sync_level;
	bool last_core_only;
	struct lpm_level_avail available;
	struct lpm_level_avail available;
	unsigned int psci_id;
	unsigned int psci_id;
	bool is_reset;
	bool is_reset;
	int reset_level;
	int reset_level;
};
};


struct low_power_ops {
	struct msm_spm_device *spm;
	int (*set_mode)(struct low_power_ops *ops, int mode, bool notify_rpm);
	enum msm_pm_l2_scm_flag tz_flag;
};

struct cluster_history {
struct cluster_history {
	uint32_t resi[MAXSAMPLES];
	uint32_t resi[MAXSAMPLES];
	int mode[MAXSAMPLES];
	int mode[MAXSAMPLES];
@@ -108,11 +98,9 @@ struct lpm_cluster {
	const char *cluster_name;
	const char *cluster_name;
	const char **name;
	const char **name;
	unsigned long aff_level; /* Affinity level of the node */
	unsigned long aff_level; /* Affinity level of the node */
	struct low_power_ops *lpm_dev;
	int ndevices;
	int ndevices;
	struct lpm_cluster_level levels[NR_LPM_LEVELS];
	struct lpm_cluster_level levels[NR_LPM_LEVELS];
	int nlevels;
	int nlevels;
	enum msm_pm_l2_scm_flag l2_flag;
	int min_child_level;
	int min_child_level;
	int default_level;
	int default_level;
	int last_level;
	int last_level;
@@ -125,14 +113,10 @@ struct lpm_cluster {
	struct lpm_stats *stats;
	struct lpm_stats *stats;
	unsigned int psci_mode_shift;
	unsigned int psci_mode_shift;
	unsigned int psci_mode_mask;
	unsigned int psci_mode_mask;
	bool no_saw_devices;
	struct cluster_history history;
	struct cluster_history history;
	struct hrtimer histtimer;
	struct hrtimer histtimer;
};
};


int set_l2_mode(struct low_power_ops *ops, int mode, bool notify_rpm);
int set_system_mode(struct low_power_ops *ops, int mode, bool notify_rpm);
int set_l3_mode(struct low_power_ops *ops, int mode, bool notify_rpm);
void lpm_suspend_wake_time(uint64_t wakeup_time);
void lpm_suspend_wake_time(uint64_t wakeup_time);


struct lpm_cluster *lpm_of_parse_cluster(struct platform_device *pdev);
struct lpm_cluster *lpm_of_parse_cluster(struct platform_device *pdev);
+1 −11
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (C) 2007 Google, Inc.
 * Copyright (C) 2007 Google, Inc.
 * Copyright (c) 2009-2016, The Linux Foundation. All rights reserved.
 * Copyright (c) 2009-2017, The Linux Foundation. All rights reserved.
 * Author: San Mehat <san@android.com>
 * Author: San Mehat <san@android.com>
 *
 *
 * This software is licensed under the terms of the GNU General Public
 * This software is licensed under the terms of the GNU General Public
@@ -69,16 +69,6 @@ struct latency_level {
	const char *level_name;
	const char *level_name;
};
};


/**
 * lpm_cpu_pre_pc_cb(): API to get the L2 flag to pass to TZ
 *
 * @cpu: cpuid of the CPU going down.
 *
 * Returns the l2 flush flag enum that is passed down to TZ during power
 * collaps
 */
enum msm_pm_l2_scm_flag lpm_cpu_pre_pc_cb(unsigned int cpu);

/**
/**
 * msm_pm_sleep_mode_allow() - API to determine if sleep mode is allowed.
 * msm_pm_sleep_mode_allow() - API to determine if sleep mode is allowed.
 * @cpu:	CPU on which to check for the sleep mode.
 * @cpu:	CPU on which to check for the sleep mode.