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

Commit bf5d008c authored by Maulik Shah's avatar Maulik Shah Committed by Gerrit - the friendly Code Review server
Browse files

drivers: cpuidle: lpm-levels: Remove non-psci code and workarounds



This change removes any unused non-psci code and chip specific
workarounds from LPM driver that are no more needed.

Update Documentation accordingly.

Change-Id: I9b8332c162d16b05e0b16e78b2049a5f843e5edc
Signed-off-by: default avatarMaulik Shah <mkshah@codeaurora.org>
parent 6d9675fe
Loading
Loading
Loading
Loading
+148 −195
Original line number Diff line number Diff line
@@ -19,15 +19,14 @@ Required properties:
[Node bindings for qcom,pm-cluster]
 Required properties:
	- reg - The numeric cluster id
	- label: Identifies the cluster name. The name will be
	used when reporting the stats for each low power mode.
	- qcom,spm-device-names: List of  SPM device names which control the
	low power modes for this driver. The lpm driver uses the device name
	to obtain a handle to the SPM driver that controls the cluster's low
	power mode. This is only required if "qcom,use-psci" is not defined.
	- qcom,default-level: The default low power level that a cluster is
	programmed. The SPM of the corresponding device is configured at this
	low power mode by default.
	- label: Identifies the cluster name. The name is used when reporting
	the stats for each low power mode.
	- qcom,psci-mode-shift: The property is used to determine with bit
	location of the cluster mode in the composite state ID used to define
	cluster low power modes in PSCI.
	- qcom,psci-mode-mask: The property is used to determine with bit
	mask of the cluster mode in the composite state ID used to define
	cluster low power modes in PSCI.

	qcom,pm-cluster contains qcom,pm-cluster-level nodes which identify
	the various low power modes that the cluster can enter. The
@@ -39,20 +38,7 @@ Required properties:
	- reg: The numeric cluster level id
	- label: Name to identify the low power mode in stats
	module.
	- qcom,spm-<device-name>-mode: For each SPM device defined in
	qcom,spm-devices-names, a corresponding entry identifying the low
	power mode is expected. For example, the qcom,pm-cluster node contains
	a SPM device by name "l2" then the cluster level should contain a
	qcom,spm-l2-mode.  When a cluster level is chosen ,the SPM device is
	programmed with its
	corresponding low power mode. The accepted values for this property
	are:
		- "active"
		- "wfi"
		- "retention"
		- "gdhs"
		- "pc"
		- "fpc"
	- qcom,psci-mode: ID to be passed into the PSCI firmware.
	- qcom,min-child-idx: The minimum level that a child CPU should be in
	before this level can be chosen. This property is required for all
        non-default level.
@@ -64,31 +50,13 @@ Required properties:
	this level in mWatts.uSec
	- qcom,time-overhead: The time spent in entering and exiting this
	level in uS

 Optional properties:
	- qcom,notify-rpm: When set, the driver flushes the RPM sleep set and
	configures the virtual MPM driver in prepration for a RPM assisted
	sleep.
	- qcom,last-level - When set, the cluster level is applied only when
	there is 1 online core.
	- qcom,disable-dynamic-int-routing: When set disables the dynamic
	routing of rpm-smd and mpm interrupts to next wake up core.
	- qcom,use-psci: This boolean property allows the LPM modules to
	terminate in PSCI to configure SPM for low power modes.
	- qcom,psci-mode-shift: The property is used to determine with bit
	location of the cluster mode in the composite state ID used to define
	cluster low power modes in PSCI v1.0. Required only if qcom,use-psci
	is defined at the lpm-levels root node.
	- qcom,psci-mode-mask: The property is used to determine with bit
	mask of the cluster mode in the composite state ID used to define
	cluster low power modes in PSCI v1.0. Required only if qcom,use-psci
	is defined at the lpm-levels root node.
	- qcom,psci-mode: ID to be passed into the PSCI firmware. Required
	only if qcom,use-psci is defined at the lpm-levels root node.
	- qcom,is-reset: This boolean property will tell whether
	cluster level need power management notifications to be sent out
	or not for the drivers to prepare for cluster collapse.
	- qcom,hyp-psci: This property is used to determine if the cpu
        enters the low power mode within hypervisor.
	- qcom,notify-rpm: When set, the driver configures the sleep and wake
	sets. It also configures the next wakeup time for APPS.
	- qcom,is-reset: This boolean property tells whether cluster level need
	power management notifications to be sent out or not for the drivers to
	prepare for cluster collapse.
	- qcom,reset-level: This property is used to determine in this
	low power mode only control logic power collapse happens or memory
	logic power collapse aswell happens or retention state.
@@ -104,6 +72,8 @@ qcom,pm-cpu contains the low power modes that a cpu could enter and the CPUs
that share the parameters.It contains the following properties.
	- qcom,cpu: List of CPU phandles to identify the CPUs associated with
	this cluster.
	- qcom,psci-mode-shift: Same as cluster level fields.
	- qcom,psci-mode-mask: Same as cluster level fields.
	- qcom,pm-cpu-levels: The different low power modes that a CPU could
	enter. The following section explains the required properties of this
	node.
@@ -111,12 +81,8 @@ that share the parameters.It contains the following properties.
[Node bindings for qcom,pm-cpu-levels]
 Required properties:
	- reg: The numeric cpu level id
	- qcom,spm-cpu-mode: The sleep mode of the processor, values for the
	property are:
		"wfi" - Wait for Interrupt
		"retention" - Retention
		"standalone_pc" - Standalone power collapse
		"pc" - Power Collapse
	- label: Name to identify the low power mode in stats
	- qcom,psci-cpu-mode: ID to be passed into PSCI firmware.
	- qcom,latency-us: The latency in handling the interrupt if this level
	was chosen, in uSec
	- qcom,ss-power: The steady state power expelled when the processor is
@@ -125,201 +91,188 @@ that share the parameters.It contains the following properties.
	this level in mWatts.uSec
	- qcom,time-overhead: The time spent in entering and exiting this
	level in uS
	- qcom,use-broadcast-timer: Indicates that the timer gets reset during
	power collapse and the cpu relies on Broadcast timer for scheduled
	wakeups. Required only for states where the CPUs internal timer state
	is lost.

 Optional properties:
	- qcom,psci-mode-shift: Same as cluster level fields.
	- qcom,psci-mode-mask: Same as cluster level fields.
	- qcom,psci-cpu-mode: ID to be passed into PSCI firmware.
	- qcom,jtag-save-restore: A boolean specifying jtag registers save and restore
	required are not.
	- qcom,is-reset: This boolean property maps to "power state" bit in PSCI
	state_id configuration. This property will tell whether CPU get reset for
	a particular LPM or not. This property will also be used to notify the
	drivers in case of cpu reset.
	a particular LPM or not. This property is also used to notify the drivers
	in case of cpu reset.
	- qcom,use-broadcast-timer: Indicates that the timer gets reset during
	power collapse and the cpu relies on Broadcast timer for scheduled wakeups.
	Required only for states where the CPUs internal timer state is lost.

[Example dts]

	qcom,lpm-levels {
		compatible = "qcom,lpm-levels";
		#address-cells = <1>;
		#size-cells = <0>;
	compatible = "qcom,lpm-levels";

		qcom,pm-cluster@0 {
			reg = <0>;
			#address-cells = <1>;
			#size-cells = <0>;
		reg = <0>;
		label = "system";
		qcom,spm-device-names = "cci";
		qcom,default-level = <0>;
			label = "L3";
			qcom,psci-mode-shift = <4>;
			qcom,psci-mode-mask = <0xfff>;

		qcom,pm-cluster-level@0{
			qcom,pm-cluster-level@0 { /* D1 */
				reg = <0>;
			label = "system-cci-retention";
			qcom,spm-cci-mode = "retention";
			qcom,latency-us = <100>;
			qcom,ss-power = <1000>;
			qcom,energy-overhead = <300000>;
			qcom,time-overhead = <100>;
				label = "l3-wfi";
				qcom,psci-mode = <0x1>;
				qcom,latency-us = <51>;
				qcom,ss-power = <452>;
				qcom,energy-overhead = <69355>;
				qcom,time-overhead = <99>;
			};

		qcom,pm-cluster-level@2{
			qcom,pm-cluster-level@1 { /* D2 */
				reg = <1>;
			label = "system-cci-pc";
			qcom,spm-cci-mode = "pc";
			qcom,latency-us = <30000>;
			qcom,ss-power = <83>;
			qcom,energy-overhead = <2274420>;
			qcom,time-overhead = <6605>;
				label = "l3-dyn-ret";
				qcom,psci-mode = <0x2>;
				qcom,latency-us = <659>;
				qcom,ss-power = <434>;
				qcom,energy-overhead = <465725>;
				qcom,time-overhead = <976>;
				qcom,min-child-idx = <1>;
			qcom,notify-rpm;
			};

		qcom,pm-cluster@0{
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <0>;
			label = "a53";
			qcom,spm-device-names = "l2";
			qcom,default-level=<0>;
			qcom,pm-cluster-level@2 { /* D4, D3 is not supported */
				reg = <2>;
				label = "l3-pc";
				qcom,psci-mode = <0x4>;
				qcom,latency-us = <4562>;
				qcom,ss-power = <408>;
				qcom,energy-overhead = <2421840>;
				qcom,time-overhead = <5376>;
				qcom,min-child-idx = <2>;
				qcom,is-reset;
			};

			qcom,pm-cluster-level@0{
				reg = <0>;
				label = "a53-l2-retention";
				qcom,spm-l2-mode = "retention";
				qcom,latency-us = <100>;
				qcom,ss-power = <1000>;
				qcom,energy-overhead = <300000>;
				qcom,time-overhead = <100>;
			qcom,pm-cluster-level@3 { /* Cx off */
				reg = <3>;
				label = "cx-off";
				qcom,psci-mode = <0x224>;
				qcom,latency-us = <5562>;
				qcom,ss-power = <308>;
				qcom,energy-overhead = <2521840>;
				qcom,time-overhead = <6376>;
				qcom,min-child-idx = <3>;
				qcom,is-reset;
				qcom,notify-rpm;
			};

			qcom,pm-cluster-level@1{
				reg = <1>;
				label = "a53-l2-pc";
				qcom,spm-l2-mode = "pc";
				qcom,latency-us = <30000>;
				qcom,ss-power = <83>;
				qcom,energy-overhead = <2274420>;
				qcom,time-overhead = <6605>;
			qcom,pm-cluster-level@4 { /* LLCC off, AOSS sleep */
				reg = <4>;
				label = "llcc-off";
				qcom,psci-mode = <0xC24>;
				qcom,latency-us = <6562>;
				qcom,ss-power = <108>;
				qcom,energy-overhead = <2621840>;
				qcom,time-overhead = <7376>;
				qcom,min-child-idx = <3>;
				qcom,is-reset;
				qcom,notify-rpm;
			};

			qcom,pm-cpu {
			qcom,pm-cpu@0 {
				#address-cells = <1>;
				#size-cells = <0>;
				qcom,psci-mode-shift = <0>;
				qcom,psci-mode-mask = <0xf>;
				qcom,cpu = <&CPU0 &CPU1 &CPU2 &CPU3>;
				qcom,pm-cpu-level@0 {

				qcom,pm-cpu-level@0 { /* C1 */
					reg = <0>;
					qcom,spm-cpu-mode = "wfi";
					qcom,latency-us = <1>;
					qcom,ss-power = <715>;
					qcom,energy-overhead = <17700>;
					qcom,time-overhead = <2>;
					label = "wfi";
					qcom,psci-cpu-mode = <0x1>;
					qcom,latency-us = <43>;
					qcom,ss-power = <454>;
					qcom,energy-overhead = <38639>;
					qcom,time-overhead = <83>;
				};

				qcom,pm-cpu-level@1 {
				qcom,pm-cpu-level@1 { /* C2D */
					reg = <1>;
					qcom,spm-cpu-mode = "retention";
					qcom,latency-us = <35>;
					qcom,ss-power = <542>;
					qcom,energy-overhead = <34920>;
					qcom,time-overhead = <40>;
					label = "ret";
					qcom,psci-cpu-mode = <0x2>;
					qcom,latency-us = <86>;
					qcom,ss-power = <449>;
					qcom,energy-overhead = <78456>;
					qcom,time-overhead = <167>;
				};

				qcom,pm-cpu-level@2 {
				qcom,pm-cpu-level@2 {  /* C3 */
					reg = <2>;
					qcom,spm-cpu-mode = "standalone_pc";
					qcom,latency-us = <300>;
					qcom,ss-power = <476>;
					qcom,energy-overhead = <225300>;
					qcom,time-overhead = <350>;
					label = "pc";
					qcom,psci-cpu-mode = <0x3>;
					qcom,latency-us = <612>;
					qcom,ss-power = <436>;
					qcom,energy-overhead = <418225>;
					qcom,time-overhead = <885>;
					qcom,is-reset;
				};

				qcom,pm-cpu-level@3 {
				qcom,pm-cpu-level@3 {  /* C4 */
					reg = <3>;
					qcom,spm-cpu-mode = "pc";
					qcom,latency-us = <500>;
					qcom,ss-power = <163>;
					qcom,energy-overhead = <577736>;
					label = "rail-pc";
					qcom,psci-cpu-mode = <0x4>;
					qcom,latency-us = <700>;
					qcom,ss-power = <400>;
					qcom,energy-overhead = <428225>;
					qcom,time-overhead = <1000>;
					qcom,is-reset;
				};
			};
		};

		qcom,pm-cluster@1{
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <1>;
			label = "a57";
			qcom,spm-device-names = "l2";
			qcom,default-level=<0>;

			qcom,pm-cluster-level@0{
				reg = <0>;
				label = "a57-l2-retention";
				qcom,spm-l2-mode = "retention";
				qcom,latency-us = <100>;
				qcom,ss-power = <1000>;
				qcom,energy-overhead = <300000>;
				qcom,time-overhead = <100>;
			};

			qcom,pm-cluster-level@2{
				reg = <1>;
				label = "a57-l2-pc";
				qcom,spm-l2-mode = "pc";
				qcom,latency-us = <30000>;
				qcom,ss-power = <83>;
				qcom,energy-overhead = <2274420>;
				qcom,time-overhead = <6605>;
				qcom,min-child-idx = <3>;
			};

			qcom,pm-cpu {
			qcom,pm-cpu@1 {
				#address-cells = <1>;
				#size-cells = <0>;
				qcom,psci-mode-shift = <0>;
				qcom,psci-mode-mask = <0xf>;
				qcom,cpu = <&CPU4 &CPU5 &CPU6 &CPU7>;
				qcom,pm-cpu-level@0 {

				qcom,pm-cpu-level@0 { /* C1 */
					reg = <0>;
					qcom,spm-cpu-mode = "wfi";
					qcom,latency-us = <1>;
					qcom,ss-power = <715>;
					qcom,energy-overhead = <17700>;
					qcom,time-overhead = <2>;
					label = "wfi";
					qcom,psci-cpu-mode = <0x1>;
					qcom,latency-us = <43>;
					qcom,ss-power = <454>;
					qcom,energy-overhead = <38639>;
					qcom,time-overhead = <83>;
				};

				qcom,pm-cpu-level@1 {
				qcom,pm-cpu-level@1 { /* C2D */
					reg = <1>;
					qcom,spm-cpu-mode = "retention";
					qcom,latency-us = <35>;
					qcom,ss-power = <542>;
					qcom,energy-overhead = <34920>;
					qcom,time-overhead = <40>;
					label = "ret";
					qcom,psci-cpu-mode = <0x2>;
					qcom,latency-us = <86>;
					qcom,ss-power = <449>;
					qcom,energy-overhead = <78456>;
					qcom,time-overhead = <167>;
				};

				qcom,pm-cpu-level@2 {
				qcom,pm-cpu-level@2 {  /* C3 */
					reg = <2>;
					qcom,spm-cpu-mode = "standalone_pc";
					qcom,latency-us = <300>;
					qcom,ss-power = <476>;
					qcom,energy-overhead = <225300>;
					qcom,time-overhead = <350>;
					label = "pc";
					qcom,psci-cpu-mode = <0x3>;
					qcom,latency-us = <612>;
					qcom,ss-power = <436>;
					qcom,energy-overhead = <418225>;
					qcom,time-overhead = <885>;
					qcom,is-reset;
				};

				qcom,pm-cpu-level@3 {
				qcom,pm-cpu-level@3 {  /* C4 */
					reg = <3>;
					qcom,spm-cpu-mode = "pc";
					qcom,latency-us = <500>;
					qcom,ss-power = <163>;
					qcom,energy-overhead = <577736>;
					label = "rail-pc";
					qcom,psci-cpu-mode = <0x4>;
					qcom,latency-us = <700>;
					qcom,ss-power = <400>;
					qcom,energy-overhead = <428225>;
					qcom,time-overhead = <1000>;
					qcom,is-reset;
				};
			};
		};
	};


};
+75 −99
Original line number Diff line number Diff line
@@ -10,6 +10,9 @@
 * GNU General Public License for more details.
 *
 */

#define pr_fmt(fmt) "%s: " fmt, KBUILD_MODNAME

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/slab.h>
@@ -215,6 +218,7 @@ ssize_t lpm_enable_store(struct kobject *kobj, struct kobj_attribute *attr,
	avail = get_avail_ptr(kobj, attr);
	if (WARN_ON(!avail))
		return -EINVAL;

	kp.arg = get_enabled_ptr(attr, avail);
	ret = param_set_bool(buf, &kp);

@@ -398,7 +402,7 @@ int create_cluster_lvl_nodes(struct lpm_cluster *p, struct kobject *kobj)
			return ret;
	}

	return 0;
	return ret;
}

bool lpm_cpu_mode_allow(unsigned int cpu,
@@ -433,33 +437,27 @@ static int parse_cluster_params(struct device_node *node,

	key = "label";
	ret = of_property_read_string(node, key, &c->cluster_name);
	if (ret) {
		pr_err("%s(): Cannot read required param %s\n", __func__, key);
		return ret;
	}
	if (ret)
		goto fail;

	key = "qcom,psci-mode-shift";
	ret = of_property_read_u32(node, key,
			&c->psci_mode_shift);
	if (ret) {
		pr_err("%s(): Failed to read param: %s\n",
				__func__, key);
		return ret;
	}
	ret = of_property_read_u32(node, key, &c->psci_mode_shift);
	if (ret)
		goto fail;

	key = "qcom,psci-mode-mask";
	ret = of_property_read_u32(node, key,
			&c->psci_mode_mask);
	if (ret) {
		pr_err("%s(): Failed to read param: %s\n",
				__func__, key);
		return ret;
	}
	ret = of_property_read_u32(node, key, &c->psci_mode_mask);
	if (ret)
		goto fail;

	/* Set ndevice to 1 as default */
	c->ndevices = 1;
	/* Set default_level to 0 as default */
	c->default_level = 0;

	return 0;
	return ret;
fail:
	pr_err("Failed to read key: %s ret: %d\n", key, ret);

	return ret;
}

static int parse_power_params(struct device_node *node,
@@ -488,10 +486,10 @@ static int parse_power_params(struct device_node *node,
	if (ret)
		goto fail;

	return ret;
fail:
	if (ret)
		pr_err("%s(): %s Error reading %s\n", __func__, node->name,
				key);
	pr_err("Failed to read key: %s node: %s\n", key, node->name);

	return ret;
}

@@ -508,7 +506,6 @@ static int parse_cluster_level(struct device_node *node,
		goto failed;

	key = "qcom,psci-mode";

	ret = of_property_read_u32(node, key, &level->psci_id);
	if (ret)
		goto failed;
@@ -516,9 +513,8 @@ static int parse_cluster_level(struct device_node *node,
	level->is_reset = of_property_read_bool(node, "qcom,is-reset");

	if (cluster->nlevels != cluster->default_level) {
		key = "min child idx";
		ret = of_property_read_u32(node, "qcom,min-child-idx",
				&level->min_child_level);
		key = "qcom,min-child-idx";
		ret = of_property_read_u32(node, key, &level->min_child_level);
		if (ret)
			goto failed;

@@ -541,11 +537,11 @@ static int parse_cluster_level(struct device_node *node,
		goto failed;

	cluster->nlevels++;

	return 0;
failed:
	pr_err("Failed %s() key = %s ret = %d\n", __func__, key, ret);
	kfree(level->mode);
	level->mode = NULL;
	pr_err("Failed to read key: %s ret: %d\n", key, ret);

	return ret;
}

@@ -554,25 +550,21 @@ static int parse_cpu_mode(struct device_node *n, struct lpm_cpu_level *l)
	char *key;
	int ret;

	key = "qcom,spm-cpu-mode";
	key = "label";
	ret = of_property_read_string(n, key, &l->name);
	if (ret) {
		pr_err("Failed %s %d\n", n->name, __LINE__);
		return ret;
	}
	if (ret)
		goto fail;

	key = "qcom,psci-cpu-mode";
	ret = of_property_read_u32(n, key, &l->psci_id);
	if (ret) {
		pr_err("Failed reading %s on device %s\n", key,
				n->name);
		return ret;
	}
	key = "qcom,hyp-psci";
	if (ret)
		goto fail;

	l->hyp_psci = of_property_read_bool(n, key);
	return 0;
	return ret;
fail:
	pr_err("Failed to read key: %s level: %s\n", key, l->name);

	return ret;
}

static int get_cpumask_for_node(struct device_node *node, struct cpumask *mask)
@@ -618,8 +610,7 @@ static int calculate_residency(struct power_params *base_pwr,
	residency /= (int32_t)(base_pwr->ss_power  - next_pwr->ss_power);

	if (residency < 0) {
		pr_err("%s: residency < 0 for LPM\n",
				__func__);
		pr_err("Residency < 0 for LPM\n");
		return next_pwr->time_overhead_us;
	}

@@ -640,10 +631,8 @@ static int parse_cpu(struct device_node *node, struct lpm_cpu *cpu)
		cpu->nlevels++;

		ret = parse_cpu_mode(n, l);
		if (ret < 0) {
			pr_info("Failed %s\n", l->name);
		if (ret)
			return ret;
		}

		ret = parse_power_params(n, &l->pwr);
		if (ret)
@@ -652,10 +641,8 @@ static int parse_cpu(struct device_node *node, struct lpm_cpu *cpu)
		key = "qcom,use-broadcast-timer";
		l->use_bc_timer = of_property_read_bool(n, key);

		l->is_reset = of_property_read_bool(n, "qcom,is-reset");

		key = "qcom,jtag-save-restore";
		l->jtag_save_restore = of_property_read_bool(n, key);
		key = "qcom,is-reset";
		l->is_reset = of_property_read_bool(n, key);

		key = "qcom,reset-level";
		ret = of_property_read_u32(n, key, &l->reset_level);
@@ -664,6 +651,7 @@ static int parse_cpu(struct device_node *node, struct lpm_cpu *cpu)
		else if (ret)
			return ret;
	}

	for (i = 0; i < cpu->nlevels; i++) {
		for (j = 0; j < cpu->nlevels; j++) {
			if (i >= j) {
@@ -675,22 +663,23 @@ static int parse_cpu(struct device_node *node, struct lpm_cpu *cpu)
				calculate_residency(&cpu->levels[i].pwr,
						&cpu->levels[j].pwr);

			pr_err("%s: idx %d %u\n", __func__, j,
			pr_info("idx %d %u\n", j,
					cpu->levels[i].pwr.residencies[j]);
		}
	}

	for_each_cpu(i, &cpu->related_cpus) {

		per_cpu(max_residency, i) = devm_kzalloc(&lpm_pdev->dev,
				sizeof(uint32_t) * cpu->nlevels,
				GFP_KERNEL);
				sizeof(uint32_t) * cpu->nlevels, GFP_KERNEL);
		if (!per_cpu(max_residency, i))
			return -ENOMEM;
		per_cpu(min_residency, i) = devm_kzalloc(
				&lpm_pdev->dev,
				sizeof(uint32_t) * cpu->nlevels,
				GFP_KERNEL);

		per_cpu(min_residency, i) = devm_kzalloc(&lpm_pdev->dev,
				sizeof(uint32_t) * cpu->nlevels, GFP_KERNEL);
		if (!per_cpu(min_residency, i))
			return -ENOMEM;

		set_optimum_cpu_residency(cpu, i, true);
	}

@@ -699,13 +688,13 @@ static int parse_cpu(struct device_node *node, struct lpm_cpu *cpu)

static int parse_cpu_levels(struct device_node *node, struct lpm_cluster *c)
{
	int ret = -ENOMEM, i;
	int ret, i;
	char *key;
	struct lpm_cpu *cpu;

	cpu = devm_kzalloc(&lpm_pdev->dev, sizeof(*cpu), GFP_KERNEL);
	if (!cpu)
		return ret;
		return -ENOMEM;

	if (get_cpumask_for_node(node, &cpu->related_cpus))
		return -EINVAL;
@@ -714,32 +703,32 @@ static int parse_cpu_levels(struct device_node *node, struct lpm_cluster *c)

	key = "qcom,psci-mode-shift";
	ret = of_property_read_u32(node, key, &cpu->psci_mode_shift);
	if (ret) {
		pr_err("Failed reading %s on device %s\n", key,
				node->name);
		return ret;
	}
	key = "qcom,psci-mode-mask";
	if (ret)
		goto failed_parse_params;

	key = "qcom,psci-mode-mask";
	ret = of_property_read_u32(node, key, &cpu->psci_mode_mask);
	if (ret) {
		pr_err("Failed reading %s on device %s\n", key,
				node->name);
		return ret;
	}
	if (ret)
		goto failed_parse_params;

	key = "parse_cpu";
	ret = parse_cpu(node, cpu);
	if (ret)
		goto failed_parse_cpu;

	if (parse_cpu(node, cpu))
		goto failed;
	cpumask_or(&c->child_cpus, &c->child_cpus, &cpu->related_cpus);
	list_add(&cpu->list, &c->cpu);
	return 0;
failed:

	return ret;

failed_parse_cpu:
	for (i = 0; i < cpu->nlevels; i++) {
		kfree(cpu->levels[i].name);
		cpu->levels[i].name = NULL;
	}
	kfree(cpu);
	pr_err("%s(): Failed with error code:%d\n", __func__, ret);

failed_parse_params:
	pr_err("Failed to read key: %s node: %s\n", key, node->name);
	return ret;
}

@@ -766,13 +755,6 @@ void free_cluster_node(struct lpm_cluster *cluster)
		}
		list_del(list);
	}
	for (i = 0; i < cluster->nlevels; i++) {
		kfree(cluster->levels[i].mode);
		cluster->levels[i].mode = NULL;
	}
	kfree(cluster->name);
	cluster->name = NULL;
	cluster->ndevices = 0;
}

/*
@@ -795,7 +777,6 @@ struct lpm_cluster *parse_cluster(struct device_node *node,
		return ERR_PTR(-ENOMEM);

	ret = parse_cluster_params(node, c);

	if (ret)
		goto failed_parse_params;

@@ -809,6 +790,7 @@ struct lpm_cluster *parse_cluster(struct device_node *node,

		if (!n->name)
			continue;

		key = "qcom,pm-cluster-level";
		if (!of_node_cmp(n->name, key)) {
			if (parse_cluster_level(n, c))
@@ -837,7 +819,6 @@ struct lpm_cluster *parse_cluster(struct device_node *node,
				goto failed_parse_cluster;

			c->aff_level = 1;

		}
	}

@@ -867,7 +848,6 @@ struct lpm_cluster *parse_cluster(struct device_node *node,
failed_parse_params:
	c->parent = NULL;
	pr_err("Failed parse params\n");
	kfree(c);
	return NULL;
}
struct lpm_cluster *lpm_of_parse_cluster(struct platform_device *pdev)
@@ -901,19 +881,15 @@ void cluster_dt_walkthrough(struct lpm_cluster *cluster)

	for (i = 0; i < cluster->nlevels; i++) {
		struct lpm_cluster_level *l = &cluster->levels[i];

		pr_info("%d ndevices:%d\n", __LINE__, cluster->ndevices);
		for (j = 0; j < cluster->ndevices; j++)
			pr_info("%sDevice: %p id:%p\n", str,
					&cluster->name[j], &l->mode[i]);
		pr_info("cluster: %s \t level: %s\n", cluster->cluster_name,
							l->level_name);
	}

	list_for_each_entry(cpu, &cluster->cpu, list) {
		pr_info("%d\n", __LINE__);
		for (j = 0; j < cpu->nlevels; j++)
			pr_info("%s\tCPU mode: %s id:%d\n", str,
					cpu->levels[j].name,
					cpu->levels[j].mode);
			pr_info("%s\tCPU level name: %s\n", str,
						cpu->levels[j].name);
	}

	id++;
+39 −68

File changed.

Preview size limit exceeded, changes collapsed.

+0 −10
Original line number Diff line number Diff line
@@ -16,11 +16,6 @@
#define MAXSAMPLES 5
#define CLUST_SMPL_INVLD_TIME 40000

struct lpm_lookup_table {
	uint32_t modes;
	const char *mode_name;
};

struct power_params {
	uint32_t latency_us;		/* Enter + Exit latency */
	uint32_t ss_power;		/* Steady state power */
@@ -33,12 +28,10 @@ struct power_params {

struct lpm_cpu_level {
	const char *name;
	enum msm_pm_sleep_mode mode;
	bool use_bc_timer;
	struct power_params pwr;
	unsigned int psci_id;
	bool is_reset;
	bool jtag_save_restore;
	bool hyp_psci;
	int reset_level;
};
@@ -69,7 +62,6 @@ struct lpm_level_avail {

struct lpm_cluster_level {
	const char *level_name;
	int *mode;			/* SPM mode to enter */
	int min_child_level;
	struct cpumask num_cpu_votes;
	struct power_params pwr;
@@ -98,9 +90,7 @@ struct lpm_cluster {
	struct list_head list;
	struct list_head child;
	const char *cluster_name;
	const char **name;
	unsigned long aff_level; /* Affinity level of the node */
	int ndevices;
	struct lpm_cluster_level levels[NR_LPM_LEVELS];
	int nlevels;
	int min_child_level;
+0 −132

File changed.

Preview size limit exceeded, changes collapsed.