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

Commit 7bd75c97 authored by Mahesh Sivasubramanian's avatar Mahesh Sivasubramanian Committed by Matt Wagantall
Browse files

msm: spm_devices: Do not use predetermined logical ids for CPUs



The logical ids of CPUs can be altered during boot up in the linux
bootloaders and the drivers cannot rely on logical CPUids hardcoded into
the device tree.  Remove support "qcom,core-id" and "qcom,vctl-cpu-mask",
    which were used for on targets where CPU phandles weren't available.

These targets are not longer supported with the existing code base and the
driver expects phandles to identify the CPU that is associated with a CPU.
In scenarios where the CPU phandle isn't associated with a physical CPU,
   these devices are ignored and not probed.

CRs-fixed: 756327
Change-Id: I5fc06c04636ada085002135f92c629ab6b629644
Signed-off-by: default avatarMahesh Sivasubramanian <msivasub@codeaurora.org>
Signed-off-by: default avatarMurali Nalajala <mnalajal@codeaurora.org>
parent 657d7175
Loading
Loading
Loading
Loading
+4 −8
Original line number Diff line number Diff line
@@ -12,13 +12,9 @@ Required properties

- compatible: "qcom,spm-v2"
- reg: The physical address and the size of the SPM's memory mapped registers
- qcom,cpu: phandle for the CPU that the SPM block is attached to. On targets
	that dont support CPU phandles the driver would support qcom,core-id.
	This field is required on only for SPMs that control the CPU.
- qcom, core-id: This property will be deprecated once all targets start
	supporting CPU phandles. This field will be used to identify SPMs
	that control the CPU.
	{0..n} for cores {0..n}
- qcom,cpu: phandle for the CPU that the SPM block is attached to.  This field
is required on only for SPMs that control the CPU. This field is not required
for SPMs that control L2/CCI/L3
- qcom,saw2-ver-reg: The location of the version register
- qcom,saw2-cfg: SAW2 configuration register
- qcom,saw2-spm-ctl: The SPM control register
@@ -138,7 +134,7 @@ Example 2:
		#address-cells = <1>;
		#size-cells = <1>;
		reg = <0xf9089000 0x1000>;
		qcom,core-id = <0>;
		qcom,cpu = <&CPU0>;
		qcom,saw2-ver-reg = <0xfd0>;
		qcom,saw2-cfg = <0x1b>;
		qcom,saw2-avs-ctl = <0>;
+11 −28
Original line number Diff line number Diff line
@@ -569,7 +569,6 @@ static int get_cpu_id(struct device_node *node)
{
	struct device_node *cpu_node;
	u32 cpu;
	int ret = -EINVAL;
	char *key = "qcom,cpu";

	cpu_node = of_parse_phandle(node, key, 0);
@@ -578,14 +577,10 @@ static int get_cpu_id(struct device_node *node)
			if (of_get_cpu_node(cpu, NULL) == cpu_node)
				return cpu;
		}
	} else {
		char *key = "qcom,core-id";
	} else
		return num_possible_cpus();

		ret = of_property_read_u32(node, key, &cpu);
		if (!ret)
			return cpu;
	}
	return ret;
	return -EINVAL;
}

static struct msm_spm_device *msm_spm_get_device(struct platform_device *pdev)
@@ -597,7 +592,7 @@ static struct msm_spm_device *msm_spm_get_device(struct platform_device *pdev)

	if ((cpu >= 0) && cpu < num_possible_cpus())
		dev = &per_cpu(msm_cpu_spm_device, cpu);
	else if ((cpu == 0xffff) || (cpu < 0))
	else if (cpu == num_possible_cpus())
		dev = devm_kzalloc(&pdev->dev, sizeof(struct msm_spm_device),
					GFP_KERNEL);

@@ -617,34 +612,19 @@ static struct msm_spm_device *msm_spm_get_device(struct platform_device *pdev)

static void get_cpumask(struct device_node *node, struct cpumask *mask)
{
	unsigned long vctl_mask = 0;
	unsigned c = 0;
	unsigned c;
	int idx = 0;
	struct device_node *cpu_node = NULL;
	int ret = 0;
	struct device_node *cpu_node;
	char *key = "qcom,cpu-vctl-list";
	bool found = false;

	cpu_node = of_parse_phandle(node, key, idx++);
	while (cpu_node) {
		found = true;
		for_each_possible_cpu(c) {
			if (of_get_cpu_node(c, NULL) == cpu_node)
				cpumask_set_cpu(c, mask);
		}
		cpu_node = of_parse_phandle(node, key, idx++);
	};

	if (found)
		return;

	key = "qcom,cpu-vctl-mask";
	ret = of_property_read_u32(node, key, (u32 *) &vctl_mask);
	if (!ret) {
		for_each_set_bit(c, &vctl_mask, num_possible_cpus()) {
			cpumask_set_cpu(c, mask);
		}
	}
}

static int msm_spm_dev_probe(struct platform_device *pdev)
@@ -702,8 +682,11 @@ static int msm_spm_dev_probe(struct platform_device *pdev)

	dev = msm_spm_get_device(pdev);
	if (!dev) {
		ret = -ENOMEM;
		goto fail;
		/*
		 * For partial goods support some CPUs might not be available
		 * in which case, shouldn't throw an error
		 */
		return 0;
	}
	get_cpumask(node, &dev->mask);