* [PATCH v3 01/16] of: add support for retrieving cpu node for a given logical cpu index
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-22 14:14 ` Nicolas Pitre
2013-08-15 11:32 ` Tomasz Figa
2013-07-22 11:32 ` [PATCH v3 02/16] ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id Sudeep KarkadaNagesha
` (15 subsequent siblings)
16 siblings, 2 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Currently different drivers requiring to access cpu device node are
parsing the device tree themselves. Since the ordering in the DT need
not match the logical cpu ordering, the parsing logic needs to consider
that. However, this has resulted in lots of code duplication and in some
cases even incorrect logic.
It's better to consolidate them by adding support for getting cpu
device node for a given logical cpu index in DT core library. However
logical to physical index mapping can be architecture specific.
This patch adds of_get_cpu_node to retrieve a cpu device node for a
given logical cpu index. The default matching of the physical id to the
logical cpu index can be overridden by architecture specific code.
It is recommended to use these helper function only in pre-SMP/early
initialisation stages to retrieve CPU device node pointers in logical
ordering. Once the cpu devices are registered, it can be retrieved easily
from cpu device of_node which avoids unnecessary parsing and matching.
Acked-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/of/base.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/of.h | 6 +++++
2 files changed, 78 insertions(+)
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 5c54279..1e690bf 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -230,6 +230,78 @@ const void *of_get_property(const struct device_node *np, const char *name,
}
EXPORT_SYMBOL(of_get_property);
+/*
+ * arch_match_cpu_phys_id - Match the given logical CPU and physical id
+ *
+ * @cpu: logical index of a cpu
+ * @phys_id: physical identifier of a cpu
+ *
+ * CPU logical to physical index mapping is architecture specific.
+ * However this __weak function provides a default match of physical
+ * id to logical cpu index.
+ *
+ * Returns true if the physical identifier and the logical index correspond
+ * to the same cpu, false otherwise.
+ */
+bool __weak arch_match_cpu_phys_id(int cpu, u64 phys_id)
+{
+ return (u32)phys_id == cpu;
+}
+
+/**
+ * of_get_cpu_node - Get device node associated with the given logical CPU
+ *
+ * @cpu: CPU number(logical index) for which device node is required
+ *
+ * The main purpose of this function is to retrieve the device node for the
+ * given logical CPU index. It should be used to intialize the of_node in
+ * cpu device. Once of_node in cpu device is populated, all the further
+ * references can use that instead.
+ *
+ * CPU logical to physical index mapping is architecture specific and is built
+ * before booting secondary cores. This function uses arch_match_cpu_phys_id
+ * which can be overridden by architecture specific implementation.
+ *
+ * Returns a node pointer for the logical cpu if found, else NULL.
+ */
+struct device_node *of_get_cpu_node(int cpu)
+{
+ struct device_node *cpun, *cpus;
+ const __be32 *cell;
+ u64 hwid;
+ int ac, prop_len;
+
+ cpus = of_find_node_by_path("/cpus");
+ if (!cpus) {
+ pr_warn("Missing cpus node, bailing out\n");
+ return NULL;
+ }
+
+ if (of_property_read_u32(cpus, "#address-cells", &ac)) {
+ pr_warn("%s: missing #address-cells\n", cpus->full_name);
+ ac = of_n_addr_cells(cpus);
+ }
+
+ for_each_child_of_node(cpus, cpun) {
+ if (of_node_cmp(cpun->type, "cpu"))
+ continue;
+ cell = of_get_property(cpun, "reg", &prop_len);
+ if (!cell) {
+ pr_warn("%s: missing reg property\n", cpun->full_name);
+ continue;
+ }
+ prop_len /= sizeof(*cell);
+ while (prop_len) {
+ hwid = of_read_number(cell, ac);
+ prop_len -= ac;
+ if (arch_match_cpu_phys_id(cpu, hwid))
+ return cpun;
+ }
+ }
+
+ return NULL;
+}
+
/** Checks if the given "compat" string matches one of the strings in
* the device's "compatible" property
*/
diff --git a/include/linux/of.h b/include/linux/of.h
index 1fd08ca..9e82812 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -266,6 +266,7 @@ extern int of_device_is_available(const struct device_node *device);
extern const void *of_get_property(const struct device_node *node,
const char *name,
int *lenp);
+extern struct device_node *of_get_cpu_node(int cpu);
#define for_each_property_of_node(dn, pp) \
for (pp = dn->properties; pp != NULL; pp = pp->next)
@@ -459,6 +460,11 @@ static inline const void *of_get_property(const struct device_node *node,
return NULL;
}
+static inline struct device_node *of_get_cpu_node(int cpu)
+{
+ return NULL;
+}
+
static inline int of_property_read_u64(const struct device_node *np,
const char *propname, u64 *out_value)
{
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* Re: [PATCH v3 01/16] of: add support for retrieving cpu node for a given logical cpu index
2013-07-22 11:32 ` [PATCH v3 01/16] of: add support for retrieving cpu node for a given logical cpu index Sudeep KarkadaNagesha
@ 2013-07-22 14:14 ` Nicolas Pitre
2013-07-22 15:07 ` Sudeep KarkadaNagesha
2013-08-15 11:32 ` Tomasz Figa
1 sibling, 1 reply; 61+ messages in thread
From: Nicolas Pitre @ 2013-07-22 14:14 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree,
Russell King, Shawn Guo, Gregory Clement, Greg Kroah-Hartman,
Viresh Kumar, Rafael J. Wysocki, Grant Likely, Rob Herring,
Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann
On Mon, 22 Jul 2013, Sudeep KarkadaNagesha wrote:
> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> Currently different drivers requiring to access cpu device node are
> parsing the device tree themselves. Since the ordering in the DT need
> not match the logical cpu ordering, the parsing logic needs to consider
> that. However, this has resulted in lots of code duplication and in some
> cases even incorrect logic.
>
> It's better to consolidate them by adding support for getting cpu
> device node for a given logical cpu index in DT core library. However
> logical to physical index mapping can be architecture specific.
>
> This patch adds of_get_cpu_node to retrieve a cpu device node for a
> given logical cpu index. The default matching of the physical id to the
> logical cpu index can be overridden by architecture specific code.
>
> It is recommended to use these helper function only in pre-SMP/early
> initialisation stages to retrieve CPU device node pointers in logical
> ordering. Once the cpu devices are registered, it can be retrieved easily
> from cpu device of_node which avoids unnecessary parsing and matching.
>
> Acked-by: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Minor nits below. Otherwise...
Acked-by: Nicolas Pitre <nico@linaro.org>
> ---
> drivers/of/base.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> include/linux/of.h | 6 +++++
> 2 files changed, 78 insertions(+)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 5c54279..1e690bf 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -230,6 +230,78 @@ const void *of_get_property(const struct device_node *np, const char *name,
> }
> EXPORT_SYMBOL(of_get_property);
>
> +/*
> + * arch_match_cpu_phys_id - Match the given logical CPU and physical id
> + *
> + * @cpu: logical index of a cpu
> + * @phys_id: physical identifier of a cpu
> + *
> + * CPU logical to physical index mapping is architecture specific.
> + * However this __weak function provides a default match of physical
> + * id to logical cpu index.
> + *
> + * Returns true if the physical identifier and the logical index correspond
> + * to the same cpu, false otherwise.
> + */
> +bool __weak arch_match_cpu_phys_id(int cpu, u64 phys_id)
Maybe a prototype declaration for this function should be added to
include/linux/of.h to avoid mismatch with architecture provided
versions.
> +{
> + return (u32)phys_id == cpu;
> +}
> +
> +/**
> + * of_get_cpu_node - Get device node associated with the given logical CPU
> + *
> + * @cpu: CPU number(logical index) for which device node is required
> + *
> + * The main purpose of this function is to retrieve the device node for the
> + * given logical CPU index. It should be used to intialize the of_node in
s/intialize/initialize/
Nicolas
^ permalink raw reply [flat|nested] 61+ messages in thread* Re: [PATCH v3 01/16] of: add support for retrieving cpu node for a given logical cpu index
2013-07-22 14:14 ` Nicolas Pitre
@ 2013-07-22 15:07 ` Sudeep KarkadaNagesha
2013-07-23 10:54 ` Sudeep KarkadaNagesha
0 siblings, 1 reply; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 15:07 UTC (permalink / raw)
To: Nicolas Pitre
Cc: Sudeep KarkadaNagesha, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
Russell King, Shawn Guo, Gregory Clement, Greg Kroah-Hartman,
Viresh Kumar, Rafael J. Wysocki, grant.likely@linaro.org,
rob.herring@calxeda.com, Lorenzo Pieralisi, Olof Johansson,
Arnd Bergmann
Hi Nico,
On 22/07/13 15:14, Nicolas Pitre wrote:
> On Mon, 22 Jul 2013, Sudeep KarkadaNagesha wrote:
>
>> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>
>> Currently different drivers requiring to access cpu device node are
>> parsing the device tree themselves. Since the ordering in the DT need
>> not match the logical cpu ordering, the parsing logic needs to consider
>> that. However, this has resulted in lots of code duplication and in some
>> cases even incorrect logic.
>>
>> It's better to consolidate them by adding support for getting cpu
>> device node for a given logical cpu index in DT core library. However
>> logical to physical index mapping can be architecture specific.
>>
>> This patch adds of_get_cpu_node to retrieve a cpu device node for a
>> given logical cpu index. The default matching of the physical id to the
>> logical cpu index can be overridden by architecture specific code.
>>
>> It is recommended to use these helper function only in pre-SMP/early
>> initialisation stages to retrieve CPU device node pointers in logical
>> ordering. Once the cpu devices are registered, it can be retrieved easily
>> from cpu device of_node which avoids unnecessary parsing and matching.
>>
>> Acked-by: Rob Herring <rob.herring@calxeda.com>
>> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> Minor nits below. Otherwise...
>
> Acked-by: Nicolas Pitre <nico@linaro.org>
>
Thanks for all the Acks.
>> ---
>> drivers/of/base.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> include/linux/of.h | 6 +++++
>> 2 files changed, 78 insertions(+)
>>
>> diff --git a/drivers/of/base.c b/drivers/of/base.c
>> index 5c54279..1e690bf 100644
>> --- a/drivers/of/base.c
>> +++ b/drivers/of/base.c
>> @@ -230,6 +230,78 @@ const void *of_get_property(const struct device_node *np, const char *name,
>> }
>> EXPORT_SYMBOL(of_get_property);
>>
>> +/*
>> + * arch_match_cpu_phys_id - Match the given logical CPU and physical id
>> + *
>> + * @cpu: logical index of a cpu
>> + * @phys_id: physical identifier of a cpu
>> + *
>> + * CPU logical to physical index mapping is architecture specific.
>> + * However this __weak function provides a default match of physical
>> + * id to logical cpu index.
>> + *
>> + * Returns true if the physical identifier and the logical index correspond
>> + * to the same cpu, false otherwise.
>> + */
>> +bool __weak arch_match_cpu_phys_id(int cpu, u64 phys_id)
>
> Maybe a prototype declaration for this function should be added to
> include/linux/of.h to avoid mismatch with architecture provided
> versions.
>
Agreed, but include/linux/of.h doesn't seem to be right choice for me as
this function is not really related to OF/DT. I can't choose any better
place either. I don't have a strong opinion on that, just a thought.
Regards,
Sudeep
^ permalink raw reply [flat|nested] 61+ messages in thread
* [PATCH v3 01/16] of: add support for retrieving cpu node for a given logical cpu index
2013-07-22 15:07 ` Sudeep KarkadaNagesha
@ 2013-07-23 10:54 ` Sudeep KarkadaNagesha
0 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-23 10:54 UTC (permalink / raw)
To: Nicolas Pitre
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree,
Sudeep KarkadaNagesha
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Currently different drivers requiring to access cpu device node are
parsing the device tree themselves. Since the ordering in the DT need
not match the logical cpu ordering, the parsing logic needs to consider
that. However, this has resulted in lots of code duplication and in some
cases even incorrect logic.
It's better to consolidate them by adding support for getting cpu
device node for a given logical cpu index in DT core library. However
logical to physical index mapping can be architecture specific.
This patch adds of_get_cpu_node to retrieve a cpu device node for a
given logical cpu index. The default matching of the physical id to the
logical cpu index can be overridden by architecture specific code.
It is recommended to use these helper function only in pre-SMP/early
initialisation stages to retrieve CPU device node pointers in logical
ordering. Once the cpu devices are registered, it can be retrieved easily
from cpu device of_node which avoids unnecessary parsing and matching.
Acked-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/of/base.c | 73 +++++++++++++++++++++++++++++++++++++++++++++++++++++
include/linux/cpu.h | 1 +
include/linux/of.h | 6 +++++
3 files changed, 80 insertions(+)
----------------->8--------------------------
Hi Nico,
I found include/linux/cpu.h is more appropriate for this.
Is that fine ?
Regards,
Sudeep
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 5c54279..052b4b2 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -18,6 +18,7 @@
* 2 of the License, or (at your option) any later version.
*/
#include <linux/ctype.h>
+#include <linux/cpu.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/spinlock.h>
@@ -230,6 +231,78 @@ const void *of_get_property(const struct device_node *np, const char *name,
}
EXPORT_SYMBOL(of_get_property);
+/*
+ * arch_match_cpu_phys_id - Match the given logical CPU and physical id
+ *
+ * @cpu: logical index of a cpu
+ * @phys_id: physical identifier of a cpu
+ *
+ * CPU logical to physical index mapping is architecture specific.
+ * However this __weak function provides a default match of physical
+ * id to logical cpu index.
+ *
+ * Returns true if the physical identifier and the logical index correspond
+ * to the same cpu, false otherwise.
+ */
+bool __weak arch_match_cpu_phys_id(int cpu, u64 phys_id)
+{
+ return (u32)phys_id == cpu;
+}
+
+/**
+ * of_get_cpu_node - Get device node associated with the given logical CPU
+ *
+ * @cpu: CPU number(logical index) for which device node is required
+ *
+ * The main purpose of this function is to retrieve the device node for the
+ * given logical CPU index. It should be used to initialize the of_node in
+ * cpu device. Once of_node in cpu device is populated, all the further
+ * references can use that instead.
+ *
+ * CPU logical to physical index mapping is architecture specific and is built
+ * before booting secondary cores. This function uses arch_match_cpu_phys_id
+ * which can be overridden by architecture specific implementation.
+ *
+ * Returns a node pointer for the logical cpu if found, else NULL.
+ */
+struct device_node *of_get_cpu_node(int cpu)
+{
+ struct device_node *cpun, *cpus;
+ const __be32 *cell;
+ u64 hwid;
+ int ac, prop_len;
+
+ cpus = of_find_node_by_path("/cpus");
+ if (!cpus) {
+ pr_warn("Missing cpus node, bailing out\n");
+ return NULL;
+ }
+
+ if (of_property_read_u32(cpus, "#address-cells", &ac)) {
+ pr_warn("%s: missing #address-cells\n", cpus->full_name);
+ ac = of_n_addr_cells(cpus);
+ }
+
+ for_each_child_of_node(cpus, cpun) {
+ if (of_node_cmp(cpun->type, "cpu"))
+ continue;
+ cell = of_get_property(cpun, "reg", &prop_len);
+ if (!cell) {
+ pr_warn("%s: missing reg property\n", cpun->full_name);
+ continue;
+ }
+ prop_len /= sizeof(*cell);
+ while (prop_len) {
+ hwid = of_read_number(cell, ac);
+ prop_len -= ac;
+ if (arch_match_cpu_phys_id(cpu, hwid))
+ return cpun;
+ }
+ }
+
+ return NULL;
+}
+
/** Checks if the given "compat" string matches one of the strings in
* the device's "compatible" property
*/
diff --git a/include/linux/cpu.h b/include/linux/cpu.h
index ab0eade..d0c8204 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -34,6 +34,7 @@ extern void cpu_remove_dev_attr(struct device_attribute *attr);
extern int cpu_add_dev_attr_group(struct attribute_group *attrs);
extern void cpu_remove_dev_attr_group(struct attribute_group *attrs);
+extern bool arch_match_cpu_phys_id(int cpu, u64 phys_id);
#ifdef CONFIG_HOTPLUG_CPU
extern void unregister_cpu(struct cpu *cpu);
diff --git a/include/linux/of.h b/include/linux/of.h
index 1fd08ca..9e82812 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -266,6 +266,7 @@ extern int of_device_is_available(const struct device_node *device);
extern const void *of_get_property(const struct device_node *node,
const char *name,
int *lenp);
+extern struct device_node *of_get_cpu_node(int cpu);
#define for_each_property_of_node(dn, pp) \
for (pp = dn->properties; pp != NULL; pp = pp->next)
@@ -459,6 +460,11 @@ static inline const void *of_get_property(const struct device_node *node,
return NULL;
}
+static inline struct device_node *of_get_cpu_node(int cpu)
+{
+ return NULL;
+}
+
static inline int of_property_read_u64(const struct device_node *np,
const char *propname, u64 *out_value)
{
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread
* Re: [PATCH v3 01/16] of: add support for retrieving cpu node for a given logical cpu index
2013-07-22 11:32 ` [PATCH v3 01/16] of: add support for retrieving cpu node for a given logical cpu index Sudeep KarkadaNagesha
2013-07-22 14:14 ` Nicolas Pitre
@ 2013-08-15 11:32 ` Tomasz Figa
2013-08-15 14:59 ` Sudeep KarkadaNagesha
1 sibling, 1 reply; 61+ messages in thread
From: Tomasz Figa @ 2013-08-15 11:32 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Sudeep KarkadaNagesha, linux-kernel, cpufreq, linux-pm,
devicetree, Lorenzo Pieralisi, Russell King, Arnd Bergmann,
Sudeep KarkadaNagesha, Viresh Kumar, Olof Johansson, Rob Herring,
Rafael J. Wysocki, Grant Likely, Greg Kroah-Hartman,
Gregory Clement, Shawn Guo
[-- Attachment #1: Type: text/plain, Size: 5388 bytes --]
Hi Sudeep,
I don't like this constant DT parsing every time a node of given CPU is
required, but I believe it was correctly discussed with people that are
more into CPU topologies and similar things than me. (My idea would be to
make a lookup array with logical ID to struct device_node * mapping.)
Let me just review this from DT parsing perspective.
On Monday 22 of July 2013 12:32:12 Sudeep KarkadaNagesha wrote:
> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> Currently different drivers requiring to access cpu device node are
> parsing the device tree themselves. Since the ordering in the DT need
> not match the logical cpu ordering, the parsing logic needs to consider
> that. However, this has resulted in lots of code duplication and in some
> cases even incorrect logic.
>
> It's better to consolidate them by adding support for getting cpu
> device node for a given logical cpu index in DT core library. However
> logical to physical index mapping can be architecture specific.
>
> This patch adds of_get_cpu_node to retrieve a cpu device node for a
> given logical cpu index. The default matching of the physical id to the
> logical cpu index can be overridden by architecture specific code.
>
> It is recommended to use these helper function only in pre-SMP/early
> initialisation stages to retrieve CPU device node pointers in logical
> ordering. Once the cpu devices are registered, it can be retrieved
> easily from cpu device of_node which avoids unnecessary parsing and
> matching.
>
> Acked-by: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> ---
> drivers/of/base.c | 72
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> include/linux/of.h | 6 +++++
> 2 files changed, 78 insertions(+)
>
> diff --git a/drivers/of/base.c b/drivers/of/base.c
> index 5c54279..1e690bf 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -230,6 +230,78 @@ const void *of_get_property(const struct
> device_node *np, const char *name, }
> EXPORT_SYMBOL(of_get_property);
>
> +/*
> + * arch_match_cpu_phys_id - Match the given logical CPU and physical id
> + *
> + * @cpu: logical index of a cpu
> + * @phys_id: physical identifier of a cpu
> + *
> + * CPU logical to physical index mapping is architecture specific.
> + * However this __weak function provides a default match of physical
> + * id to logical cpu index.
> + *
> + * Returns true if the physical identifier and the logical index
> correspond + * to the same cpu, false otherwise.
> + */
> +bool __weak arch_match_cpu_phys_id(int cpu, u64 phys_id)
> +{
> + return (u32)phys_id == cpu;
> +}
> +
> +/**
> + * of_get_cpu_node - Get device node associated with the given logical
> CPU + *
> + * @cpu: CPU number(logical index) for which device node is required
> + *
> + * The main purpose of this function is to retrieve the device node for
> the + * given logical CPU index. It should be used to intialize the
> of_node in + * cpu device. Once of_node in cpu device is populated, all
> the further + * references can use that instead.
> + *
> + * CPU logical to physical index mapping is architecture specific and
> is built + * before booting secondary cores. This function uses
> arch_match_cpu_phys_id + * which can be overridden by architecture
> specific implementation. + *
> + * Returns a node pointer for the logical cpu if found, else NULL.
> + */
> +struct device_node *of_get_cpu_node(int cpu)
> +{
> + struct device_node *cpun, *cpus;
> + const __be32 *cell;
> + u64 hwid;
> + int ac, prop_len;
> +
> + cpus = of_find_node_by_path("/cpus");
> + if (!cpus) {
> + pr_warn("Missing cpus node, bailing out\n");
> + return NULL;
> + }
> +
> + if (of_property_read_u32(cpus, "#address-cells", &ac)) {
> + pr_warn("%s: missing #address-cells\n", cpus->full_name);
> + ac = of_n_addr_cells(cpus);
I'm not sure this fallback is appropriate. According to ePAPR:
"The #address-cells and #size-cells properties are not inherited from
ancestors in the device tree. They shall be explicitly defined."
In addition:
If missing, a client program should assume a default value of 2 for
#address-cells, and a value of 1 for #size-cells.
This also leaves in question the correctness of of_n_addr_cells() and
of_n_size_cells().
> + }
> +
> + for_each_child_of_node(cpus, cpun) {
> + if (of_node_cmp(cpun->type, "cpu"))
> + continue;
> + cell = of_get_property(cpun, "reg", &prop_len);
> + if (!cell) {
> + pr_warn("%s: missing reg property\n", cpun-
>full_name);
> + continue;
> + }
> + prop_len /= sizeof(*cell);
> + while (prop_len) {
> + hwid = of_read_number(cell, ac);
> + prop_len -= ac;
> + if (arch_match_cpu_phys_id(cpu, hwid))
> + return cpun;
This is a nice potential infinite loop. Consider following example:
cpus {
#address-cells = <2>; /* A typo. Should be 1. */
#size-cells = <0>;
cpu@0 {
/* ... */
reg = <0>;
};
};
In this case prop_len will start with 1, while ac will be 2. After first
iteration of the loop (when the phys id doesn't match) you will end up
with prop_len = -1 and each iteration will decrement it even more.
By the way, I'm not sure why the whole loop is here. IMHO it should be
something like:
if (prop_len != ac) {
pr_warn(...); // or whatever
continue;
}
hwid = of_read_number(cell, ac);
// ...
Best regards,
Tomasz
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 61+ messages in thread* Re: [PATCH v3 01/16] of: add support for retrieving cpu node for a given logical cpu index
2013-08-15 11:32 ` Tomasz Figa
@ 2013-08-15 14:59 ` Sudeep KarkadaNagesha
0 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-15 14:59 UTC (permalink / raw)
To: Tomasz Figa
Cc: linux-arm-kernel@lists.infradead.org, Sudeep KarkadaNagesha,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
Lorenzo Pieralisi, Russell King, Arnd Bergmann, Viresh Kumar,
Olof Johansson, rob.herring@calxeda.com, Rafael J. Wysocki,
grant.likely@linaro.org, Greg Kroah-Hartman, Gregory Clement,
Shawn Guo
On 15/08/13 12:32, Tomasz Figa wrote:
> Hi Sudeep,
>
> I don't like this constant DT parsing every time a node of given CPU is
> required, but I believe it was correctly discussed with people that are
> more into CPU topologies and similar things than me. (My idea would be to
> make a lookup array with logical ID to struct device_node * mapping.)
>
Yes that's the idea, see the last paragraph in the commit log.
> Let me just review this from DT parsing perspective.
>
> On Monday 22 of July 2013 12:32:12 Sudeep KarkadaNagesha wrote:
>> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>
>> Currently different drivers requiring to access cpu device node are
>> parsing the device tree themselves. Since the ordering in the DT need
>> not match the logical cpu ordering, the parsing logic needs to consider
>> that. However, this has resulted in lots of code duplication and in some
>> cases even incorrect logic.
>>
>> It's better to consolidate them by adding support for getting cpu
>> device node for a given logical cpu index in DT core library. However
>> logical to physical index mapping can be architecture specific.
>>
>> This patch adds of_get_cpu_node to retrieve a cpu device node for a
>> given logical cpu index. The default matching of the physical id to the
>> logical cpu index can be overridden by architecture specific code.
>>
>> It is recommended to use these helper function only in pre-SMP/early
>> initialisation stages to retrieve CPU device node pointers in logical
>> ordering. Once the cpu devices are registered, it can be retrieved
>> easily from cpu device of_node which avoids unnecessary parsing and
>> matching.
>>
Here we go, do I need to emphasis this recommendation more ?
>> Acked-by: Rob Herring <rob.herring@calxeda.com>
>> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>> ---
>> drivers/of/base.c | 72
>> ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> include/linux/of.h | 6 +++++
>> 2 files changed, 78 insertions(+)
>>
>> diff --git a/drivers/of/base.c b/drivers/of/base.c
>> index 5c54279..1e690bf 100644
>> --- a/drivers/of/base.c
>> +++ b/drivers/of/base.c
>> @@ -230,6 +230,78 @@ const void *of_get_property(const struct
>> device_node *np, const char *name, }
>> EXPORT_SYMBOL(of_get_property);
>>
>> +/*
>> + * arch_match_cpu_phys_id - Match the given logical CPU and physical id
>> + *
>> + * @cpu: logical index of a cpu
>> + * @phys_id: physical identifier of a cpu
>> + *
>> + * CPU logical to physical index mapping is architecture specific.
>> + * However this __weak function provides a default match of physical
>> + * id to logical cpu index.
>> + *
>> + * Returns true if the physical identifier and the logical index
>> correspond + * to the same cpu, false otherwise.
>> + */
>> +bool __weak arch_match_cpu_phys_id(int cpu, u64 phys_id)
>> +{
>> + return (u32)phys_id == cpu;
>> +}
>> +
>> +/**
>> + * of_get_cpu_node - Get device node associated with the given logical
>> CPU + *
>> + * @cpu: CPU number(logical index) for which device node is required
>> + *
>> + * The main purpose of this function is to retrieve the device node for
>> the + * given logical CPU index. It should be used to intialize the
>> of_node in + * cpu device. Once of_node in cpu device is populated, all
>> the further + * references can use that instead.
>> + *
>> + * CPU logical to physical index mapping is architecture specific and
>> is built + * before booting secondary cores. This function uses
>> arch_match_cpu_phys_id + * which can be overridden by architecture
>> specific implementation. + *
>> + * Returns a node pointer for the logical cpu if found, else NULL.
>> + */
>> +struct device_node *of_get_cpu_node(int cpu)
>> +{
>> + struct device_node *cpun, *cpus;
>> + const __be32 *cell;
>> + u64 hwid;
>> + int ac, prop_len;
>> +
>> + cpus = of_find_node_by_path("/cpus");
>> + if (!cpus) {
>> + pr_warn("Missing cpus node, bailing out\n");
>> + return NULL;
>> + }
>> +
>> + if (of_property_read_u32(cpus, "#address-cells", &ac)) {
>> + pr_warn("%s: missing #address-cells\n", cpus->full_name);
>> + ac = of_n_addr_cells(cpus);
>
> I'm not sure this fallback is appropriate. According to ePAPR:
>
> "The #address-cells and #size-cells properties are not inherited from
> ancestors in the device tree. They shall be explicitly defined."
>
> In addition:
>
> If missing, a client program should assume a default value of 2 for
> #address-cells, and a value of 1 for #size-cells.
>
> This also leaves in question the correctness of of_n_addr_cells() and
> of_n_size_cells().
>
Yes agreed. We can discus that and fix it separately as it might affect
multiple users.
>> + }
>> +
>> + for_each_child_of_node(cpus, cpun) {
>> + if (of_node_cmp(cpun->type, "cpu"))
>> + continue;
>> + cell = of_get_property(cpun, "reg", &prop_len);
>> + if (!cell) {
>> + pr_warn("%s: missing reg property\n", cpun-
>> full_name);
>> + continue;
>> + }
>> + prop_len /= sizeof(*cell);
>> + while (prop_len) {
>> + hwid = of_read_number(cell, ac);
>> + prop_len -= ac;
>> + if (arch_match_cpu_phys_id(cpu, hwid))
>> + return cpun;
>
> This is a nice potential infinite loop. Consider following example:
>
Good point, but based on the other discussion recently with PPC guys to
support thread ids, I have changed this loop differently, it should not
have this issue.
Regards,
Sudeep
> cpus {
> #address-cells = <2>; /* A typo. Should be 1. */
> #size-cells = <0>;
>
> cpu@0 {
> /* ... */
> reg = <0>;
> };
> };
>
> In this case prop_len will start with 1, while ac will be 2. After first
> iteration of the loop (when the phys id doesn't match) you will end up
> with prop_len = -1 and each iteration will decrement it even more.
>
> By the way, I'm not sure why the whole loop is here. IMHO it should be
> something like:
>
> if (prop_len != ac) {
> pr_warn(...); // or whatever
> continue;
> }
>
> hwid = of_read_number(cell, ac);
> // ...
>
> Best regards,
> Tomasz
>
^ permalink raw reply [flat|nested] 61+ messages in thread
* [PATCH v3 02/16] ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 01/16] of: add support for retrieving cpu node for a given logical cpu index Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-22 14:14 ` Nicolas Pitre
2013-07-22 11:32 ` [PATCH v3 03/16] driver/core: cpu: initialize of_node in cpu's device struture Sudeep KarkadaNagesha
` (14 subsequent siblings)
16 siblings, 1 reply; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
OF/DT core library now provides architecture specific hook to match the
logical cpu index with the corresponding physical identifier. Most of the
cpu DT node parsing and initialisation is contained in devtree.c. So it's
better to define ARM specific arch_match_cpu_phys_id there.
This mainly helps to avoid replication of the code doing CPU node parsing
and physical(MPIDR) to logical mapping.
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
arch/arm/kernel/devtree.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
index 5859c8b..2ee8a17 100644
--- a/arch/arm/kernel/devtree.c
+++ b/arch/arm/kernel/devtree.c
@@ -169,6 +169,11 @@ void __init arm_dt_init_cpu_maps(void)
}
}
+bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
+{
+ return (phys_id & MPIDR_HWID_BITMASK) == cpu_logical_map(cpu);
+}
+
/**
* setup_machine_fdt - Machine setup when an dtb was passed to the kernel
* @dt_phys: physical address of dt blob
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* Re: [PATCH v3 02/16] ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id
2013-07-22 11:32 ` [PATCH v3 02/16] ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id Sudeep KarkadaNagesha
@ 2013-07-22 14:14 ` Nicolas Pitre
0 siblings, 0 replies; 61+ messages in thread
From: Nicolas Pitre @ 2013-07-22 14:14 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree,
Russell King, Shawn Guo, Gregory Clement, Greg Kroah-Hartman,
Viresh Kumar, Rafael J. Wysocki, Grant Likely, Rob Herring,
Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann
On Mon, 22 Jul 2013, Sudeep KarkadaNagesha wrote:
> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> OF/DT core library now provides architecture specific hook to match the
> logical cpu index with the corresponding physical identifier. Most of the
> cpu DT node parsing and initialisation is contained in devtree.c. So it's
> better to define ARM specific arch_match_cpu_phys_id there.
>
> This mainly helps to avoid replication of the code doing CPU node parsing
> and physical(MPIDR) to logical mapping.
>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Acked-by: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
> ---
> arch/arm/kernel/devtree.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/arch/arm/kernel/devtree.c b/arch/arm/kernel/devtree.c
> index 5859c8b..2ee8a17 100644
> --- a/arch/arm/kernel/devtree.c
> +++ b/arch/arm/kernel/devtree.c
> @@ -169,6 +169,11 @@ void __init arm_dt_init_cpu_maps(void)
> }
> }
>
> +bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
> +{
> + return (phys_id & MPIDR_HWID_BITMASK) == cpu_logical_map(cpu);
> +}
> +
> /**
> * setup_machine_fdt - Machine setup when an dtb was passed to the kernel
> * @dt_phys: physical address of dt blob
> --
> 1.8.1.2
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 61+ messages in thread
* [PATCH v3 03/16] driver/core: cpu: initialize of_node in cpu's device struture
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 01/16] of: add support for retrieving cpu node for a given logical cpu index Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 02/16] ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-08-15 11:35 ` Tomasz Figa
2013-07-22 11:32 ` [PATCH v3 04/16] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity Sudeep KarkadaNagesha
` (13 subsequent siblings)
16 siblings, 1 reply; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
CPUs are also registered as devices but the of_node in these cpu
devices are not initialized. Currently different drivers requiring
to access cpu device node are parsing the nodes themselves and
initialising the of_node in cpu device.
The of_node in all the cpu devices needs to be initialized properly
and at one place. The best place to update this is CPU subsystem
driver when registering the cpu devices.
The OF/DT core library now provides of_get_cpu_node to retrieve a cpu
device node for a given logical index by abstracting the architecture
specific details.
This patch uses of_get_cpu_node to assign of_node when registering the
cpu devices.
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/base/cpu.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 4c358bc..ea51c6d 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -14,6 +14,7 @@
#include <linux/slab.h>
#include <linux/percpu.h>
#include <linux/acpi.h>
+#include <linux/of.h>
#include "base.h"
@@ -289,6 +290,7 @@ int register_cpu(struct cpu *cpu, int num)
cpu->dev.release = cpu_device_release;
cpu->dev.offline_disabled = !cpu->hotpluggable;
cpu->dev.offline = !cpu_online(num);
+ cpu->dev.of_node = of_get_cpu_node(num);
#ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE
cpu->dev.bus->uevent = arch_cpu_uevent;
#endif
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* Re: [PATCH v3 03/16] driver/core: cpu: initialize of_node in cpu's device struture
2013-07-22 11:32 ` [PATCH v3 03/16] driver/core: cpu: initialize of_node in cpu's device struture Sudeep KarkadaNagesha
@ 2013-08-15 11:35 ` Tomasz Figa
2013-08-15 15:13 ` Sudeep KarkadaNagesha
0 siblings, 1 reply; 61+ messages in thread
From: Tomasz Figa @ 2013-08-15 11:35 UTC (permalink / raw)
To: linux-arm-kernel
Cc: Sudeep KarkadaNagesha, linux-kernel, cpufreq, linux-pm,
devicetree, Lorenzo Pieralisi, Russell King, Arnd Bergmann,
Sudeep KarkadaNagesha, Viresh Kumar, Olof Johansson, Rob Herring,
Rafael J. Wysocki, Grant Likely, Greg Kroah-Hartman,
Gregory Clement, Shawn Guo
[-- Attachment #1: Type: text/plain, Size: 1968 bytes --]
Hi Sudeep,
On Monday 22 of July 2013 12:32:14 Sudeep KarkadaNagesha wrote:
> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> CPUs are also registered as devices but the of_node in these cpu
> devices are not initialized. Currently different drivers requiring
> to access cpu device node are parsing the nodes themselves and
> initialising the of_node in cpu device.
>
> The of_node in all the cpu devices needs to be initialized properly
> and at one place. The best place to update this is CPU subsystem
> driver when registering the cpu devices.
>
> The OF/DT core library now provides of_get_cpu_node to retrieve a cpu
> device node for a given logical index by abstracting the architecture
> specific details.
>
> This patch uses of_get_cpu_node to assign of_node when registering the
> cpu devices.
>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Acked-by: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> ---
> drivers/base/cpu.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> index 4c358bc..ea51c6d 100644
> --- a/drivers/base/cpu.c
> +++ b/drivers/base/cpu.c
> @@ -14,6 +14,7 @@
> #include <linux/slab.h>
> #include <linux/percpu.h>
> #include <linux/acpi.h>
> +#include <linux/of.h>
>
> #include "base.h"
>
> @@ -289,6 +290,7 @@ int register_cpu(struct cpu *cpu, int num)
> cpu->dev.release = cpu_device_release;
> cpu->dev.offline_disabled = !cpu->hotpluggable;
> cpu->dev.offline = !cpu_online(num);
> + cpu->dev.of_node = of_get_cpu_node(num);
Aha, so this would be the only place where of_get_cpu_node() gets called,
so the parsing would be done only once and then any code that needs CPU DT
node would just simply grab it from CPU dev. Fair enough.
Not sure if this makes the need for such helper to be globally available
in of/base.c, but I guess this won't hurt.
Best regards,
Tomasz
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 61+ messages in thread
* Re: [PATCH v3 03/16] driver/core: cpu: initialize of_node in cpu's device struture
2013-08-15 11:35 ` Tomasz Figa
@ 2013-08-15 15:13 ` Sudeep KarkadaNagesha
0 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-15 15:13 UTC (permalink / raw)
To: Tomasz Figa
Cc: linux-arm-kernel@lists.infradead.org, Sudeep KarkadaNagesha,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
Lorenzo Pieralisi, Russell King, Arnd Bergmann, Viresh Kumar,
Olof Johansson, rob.herring@calxeda.com, Rafael J. Wysocki,
grant.likely@linaro.org, Greg Kroah-Hartman, Gregory Clement,
Shawn Guo
On 15/08/13 12:35, Tomasz Figa wrote:
> Hi Sudeep,
>
> On Monday 22 of July 2013 12:32:14 Sudeep KarkadaNagesha wrote:
>> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>
>> CPUs are also registered as devices but the of_node in these cpu
>> devices are not initialized. Currently different drivers requiring
>> to access cpu device node are parsing the nodes themselves and
>> initialising the of_node in cpu device.
>>
>> The of_node in all the cpu devices needs to be initialized properly
>> and at one place. The best place to update this is CPU subsystem
>> driver when registering the cpu devices.
>>
>> The OF/DT core library now provides of_get_cpu_node to retrieve a cpu
>> device node for a given logical index by abstracting the architecture
>> specific details.
>>
>> This patch uses of_get_cpu_node to assign of_node when registering the
>> cpu devices.
>>
>> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
>> Acked-by: Rob Herring <rob.herring@calxeda.com>
>> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>> ---
>> drivers/base/cpu.c | 2 ++
>> 1 file changed, 2 insertions(+)
>>
>> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
>> index 4c358bc..ea51c6d 100644
>> --- a/drivers/base/cpu.c
>> +++ b/drivers/base/cpu.c
>> @@ -14,6 +14,7 @@
>> #include <linux/slab.h>
>> #include <linux/percpu.h>
>> #include <linux/acpi.h>
>> +#include <linux/of.h>
>>
>> #include "base.h"
>>
>> @@ -289,6 +290,7 @@ int register_cpu(struct cpu *cpu, int num)
>> cpu->dev.release = cpu_device_release;
>> cpu->dev.offline_disabled = !cpu->hotpluggable;
>> cpu->dev.offline = !cpu_online(num);
>> + cpu->dev.of_node = of_get_cpu_node(num);
>
> Aha, so this would be the only place where of_get_cpu_node() gets called,
> so the parsing would be done only once and then any code that needs CPU DT
> node would just simply grab it from CPU dev. Fair enough.
>
> Not sure if this makes the need for such helper to be globally available
> in of/base.c, but I guess this won't hurt.
>
Ah, you found it out yourself. Sorry responded to your earlier mail.
Yes but there may be uses cases which need cpu of_node before CPUs get
registered. I believe PATCH 4-6 in the series is good examples as why we
need this helper to be global.
Move over now we need to extend support to PowerPC where DT is scanned
needlessly always to fetch cpu of_node. Of course they need to fix it,
use cpu->of_node instead.
Regards,
Sudeep
^ permalink raw reply [flat|nested] 61+ messages in thread
* [PATCH v3 04/16] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (2 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 03/16] driver/core: cpu: initialize of_node in cpu's device struture Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-22 14:25 ` Nicolas Pitre
2013-07-22 11:32 ` [PATCH v3 05/16] ARM: mvebu: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
` (12 subsequent siblings)
16 siblings, 1 reply; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Lorenzo Pieralisi, Russell King, Arnd Bergmann,
Sudeep KarkadaNagesha, Viresh Kumar, Olof Johansson, Rob Herring,
Rafael J. Wysocki, Grant Likely, Greg Kroah-Hartman,
Gregory Clement, Shawn Guo
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Currently the topology code computes cpu capacity and stores it in
the list along with hwid(which is MPIDR) as it parses the CPU nodes
in the device tree. This is required as it needs to be mapped to the
logical CPU later.
Since the CPU device nodes can be retrieved in the logical ordering
using DT/OF helpers, its possible to store cpu_capacity also in logical
ordering and avoid storing hwid for each entry.
This patch removes hwid by making use of of_get_cpu_node.
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
arch/arm/kernel/topology.c | 61 +++++++++++++++-------------------------------
1 file changed, 19 insertions(+), 42 deletions(-)
diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index c5a5954..28ef27a 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -74,12 +74,8 @@ struct cpu_efficiency table_efficiency[] = {
{NULL, },
};
-struct cpu_capacity {
- unsigned long hwid;
- unsigned long capacity;
-};
-
-struct cpu_capacity *cpu_capacity;
+unsigned long *__cpu_capacity;
+#define cpu_capacity(cpu) __cpu_capacity[cpu]
unsigned long middle_capacity = 1;
@@ -100,15 +96,19 @@ static void __init parse_dt_topology(void)
unsigned long capacity = 0;
int alloc_size, cpu = 0;
- alloc_size = nr_cpu_ids * sizeof(struct cpu_capacity);
- cpu_capacity = kzalloc(alloc_size, GFP_NOWAIT);
+ alloc_size = nr_cpu_ids * sizeof(*__cpu_capacity);
+ __cpu_capacity = kzalloc(alloc_size, GFP_NOWAIT);
- while ((cn = of_find_node_by_type(cn, "cpu"))) {
- const u32 *rate, *reg;
+ for_each_possible_cpu(cpu) {
+ const u32 *rate;
int len;
- if (cpu >= num_possible_cpus())
- break;
+ /* too early to use cpu->of_node */
+ cn = of_get_cpu_node(cpu);
+ if (!cn) {
+ pr_err("missing device node for CPU %d\n", cpu);
+ continue;
+ }
for (cpu_eff = table_efficiency; cpu_eff->compatible; cpu_eff++)
if (of_device_is_compatible(cn, cpu_eff->compatible))
@@ -124,12 +124,6 @@ static void __init parse_dt_topology(void)
continue;
}
- reg = of_get_property(cn, "reg", &len);
- if (!reg || len != 4) {
- pr_err("%s missing reg property\n", cn->full_name);
- continue;
- }
-
capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;
/* Save min capacity of the system */
@@ -140,13 +134,9 @@ static void __init parse_dt_topology(void)
if (capacity > max_capacity)
max_capacity = capacity;
- cpu_capacity[cpu].capacity = capacity;
- cpu_capacity[cpu++].hwid = be32_to_cpup(reg);
+ cpu_capacity(cpu) = capacity;
}
- if (cpu < num_possible_cpus())
- cpu_capacity[cpu].hwid = (unsigned long)(-1);
-
/* If min and max capacities are equals, we bypass the update of the
* cpu_scale because all CPUs have the same capacity. Otherwise, we
* compute a middle_capacity factor that will ensure that the capacity
@@ -154,9 +144,7 @@ static void __init parse_dt_topology(void)
* SCHED_POWER_SCALE, which is the default value, but with the
* constraint explained near table_efficiency[].
*/
- if (min_capacity == max_capacity)
- cpu_capacity[0].hwid = (unsigned long)(-1);
- else if (4*max_capacity < (3*(max_capacity + min_capacity)))
+ if (4*max_capacity < (3*(max_capacity + min_capacity)))
middle_capacity = (min_capacity + max_capacity)
>> (SCHED_POWER_SHIFT+1);
else
@@ -170,23 +158,12 @@ static void __init parse_dt_topology(void)
* boot. The update of all CPUs is in O(n^2) for heteregeneous system but the
* function returns directly for SMP system.
*/
-void update_cpu_power(unsigned int cpu, unsigned long hwid)
+void update_cpu_power(unsigned int cpu)
{
- unsigned int idx = 0;
-
- /* look for the cpu's hwid in the cpu capacity table */
- for (idx = 0; idx < num_possible_cpus(); idx++) {
- if (cpu_capacity[idx].hwid == hwid)
- break;
-
- if (cpu_capacity[idx].hwid == -1)
- return;
- }
-
- if (idx == num_possible_cpus())
+ if (!cpu_capacity(cpu))
return;
- set_power_scale(cpu, cpu_capacity[idx].capacity / middle_capacity);
+ set_power_scale(cpu, cpu_capacity(cpu) / middle_capacity);
printk(KERN_INFO "CPU%u: update cpu_power %lu\n",
cpu, arch_scale_freq_power(NULL, cpu));
@@ -194,7 +171,7 @@ void update_cpu_power(unsigned int cpu, unsigned long hwid)
#else
static inline void parse_dt_topology(void) {}
-static inline void update_cpu_power(unsigned int cpuid, unsigned int mpidr) {}
+static inline void update_cpu_power(unsigned int cpuid) {}
#endif
/*
@@ -281,7 +258,7 @@ void store_cpu_topology(unsigned int cpuid)
update_siblings_masks(cpuid);
- update_cpu_power(cpuid, mpidr & MPIDR_HWID_BITMASK);
+ update_cpu_power(cpuid);
printk(KERN_INFO "CPU%u: thread %d, cpu %d, socket %d, mpidr %x\n",
cpuid, cpu_topology[cpuid].thread_id,
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* Re: [PATCH v3 04/16] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity
2013-07-22 11:32 ` [PATCH v3 04/16] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity Sudeep KarkadaNagesha
@ 2013-07-22 14:25 ` Nicolas Pitre
0 siblings, 0 replies; 61+ messages in thread
From: Nicolas Pitre @ 2013-07-22 14:25 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree,
Russell King, Shawn Guo, Gregory Clement, Greg Kroah-Hartman,
Viresh Kumar, Rafael J. Wysocki, Grant Likely, Rob Herring,
Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann
On Mon, 22 Jul 2013, Sudeep KarkadaNagesha wrote:
> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> Currently the topology code computes cpu capacity and stores it in
> the list along with hwid(which is MPIDR) as it parses the CPU nodes
> in the device tree. This is required as it needs to be mapped to the
> logical CPU later.
>
> Since the CPU device nodes can be retrieved in the logical ordering
> using DT/OF helpers, its possible to store cpu_capacity also in logical
> ordering and avoid storing hwid for each entry.
>
> This patch removes hwid by making use of of_get_cpu_node.
>
> Cc: Russell King <linux@arm.linux.org.uk>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Acked-by: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
> ---
> arch/arm/kernel/topology.c | 61 +++++++++++++++-------------------------------
> 1 file changed, 19 insertions(+), 42 deletions(-)
>
> diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
> index c5a5954..28ef27a 100644
> --- a/arch/arm/kernel/topology.c
> +++ b/arch/arm/kernel/topology.c
> @@ -74,12 +74,8 @@ struct cpu_efficiency table_efficiency[] = {
> {NULL, },
> };
>
> -struct cpu_capacity {
> - unsigned long hwid;
> - unsigned long capacity;
> -};
> -
> -struct cpu_capacity *cpu_capacity;
> +unsigned long *__cpu_capacity;
> +#define cpu_capacity(cpu) __cpu_capacity[cpu]
>
> unsigned long middle_capacity = 1;
>
> @@ -100,15 +96,19 @@ static void __init parse_dt_topology(void)
> unsigned long capacity = 0;
> int alloc_size, cpu = 0;
>
> - alloc_size = nr_cpu_ids * sizeof(struct cpu_capacity);
> - cpu_capacity = kzalloc(alloc_size, GFP_NOWAIT);
> + alloc_size = nr_cpu_ids * sizeof(*__cpu_capacity);
> + __cpu_capacity = kzalloc(alloc_size, GFP_NOWAIT);
>
> - while ((cn = of_find_node_by_type(cn, "cpu"))) {
> - const u32 *rate, *reg;
> + for_each_possible_cpu(cpu) {
> + const u32 *rate;
> int len;
>
> - if (cpu >= num_possible_cpus())
> - break;
> + /* too early to use cpu->of_node */
> + cn = of_get_cpu_node(cpu);
> + if (!cn) {
> + pr_err("missing device node for CPU %d\n", cpu);
> + continue;
> + }
>
> for (cpu_eff = table_efficiency; cpu_eff->compatible; cpu_eff++)
> if (of_device_is_compatible(cn, cpu_eff->compatible))
> @@ -124,12 +124,6 @@ static void __init parse_dt_topology(void)
> continue;
> }
>
> - reg = of_get_property(cn, "reg", &len);
> - if (!reg || len != 4) {
> - pr_err("%s missing reg property\n", cn->full_name);
> - continue;
> - }
> -
> capacity = ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;
>
> /* Save min capacity of the system */
> @@ -140,13 +134,9 @@ static void __init parse_dt_topology(void)
> if (capacity > max_capacity)
> max_capacity = capacity;
>
> - cpu_capacity[cpu].capacity = capacity;
> - cpu_capacity[cpu++].hwid = be32_to_cpup(reg);
> + cpu_capacity(cpu) = capacity;
> }
>
> - if (cpu < num_possible_cpus())
> - cpu_capacity[cpu].hwid = (unsigned long)(-1);
> -
> /* If min and max capacities are equals, we bypass the update of the
> * cpu_scale because all CPUs have the same capacity. Otherwise, we
> * compute a middle_capacity factor that will ensure that the capacity
> @@ -154,9 +144,7 @@ static void __init parse_dt_topology(void)
> * SCHED_POWER_SCALE, which is the default value, but with the
> * constraint explained near table_efficiency[].
> */
> - if (min_capacity == max_capacity)
> - cpu_capacity[0].hwid = (unsigned long)(-1);
> - else if (4*max_capacity < (3*(max_capacity + min_capacity)))
> + if (4*max_capacity < (3*(max_capacity + min_capacity)))
> middle_capacity = (min_capacity + max_capacity)
> >> (SCHED_POWER_SHIFT+1);
> else
> @@ -170,23 +158,12 @@ static void __init parse_dt_topology(void)
> * boot. The update of all CPUs is in O(n^2) for heteregeneous system but the
> * function returns directly for SMP system.
> */
> -void update_cpu_power(unsigned int cpu, unsigned long hwid)
> +void update_cpu_power(unsigned int cpu)
> {
> - unsigned int idx = 0;
> -
> - /* look for the cpu's hwid in the cpu capacity table */
> - for (idx = 0; idx < num_possible_cpus(); idx++) {
> - if (cpu_capacity[idx].hwid == hwid)
> - break;
> -
> - if (cpu_capacity[idx].hwid == -1)
> - return;
> - }
> -
> - if (idx == num_possible_cpus())
> + if (!cpu_capacity(cpu))
> return;
>
> - set_power_scale(cpu, cpu_capacity[idx].capacity / middle_capacity);
> + set_power_scale(cpu, cpu_capacity(cpu) / middle_capacity);
>
> printk(KERN_INFO "CPU%u: update cpu_power %lu\n",
> cpu, arch_scale_freq_power(NULL, cpu));
> @@ -194,7 +171,7 @@ void update_cpu_power(unsigned int cpu, unsigned long hwid)
>
> #else
> static inline void parse_dt_topology(void) {}
> -static inline void update_cpu_power(unsigned int cpuid, unsigned int mpidr) {}
> +static inline void update_cpu_power(unsigned int cpuid) {}
> #endif
>
> /*
> @@ -281,7 +258,7 @@ void store_cpu_topology(unsigned int cpuid)
>
> update_siblings_masks(cpuid);
>
> - update_cpu_power(cpuid, mpidr & MPIDR_HWID_BITMASK);
> + update_cpu_power(cpuid);
>
> printk(KERN_INFO "CPU%u: thread %d, cpu %d, socket %d, mpidr %x\n",
> cpuid, cpu_topology[cpuid].thread_id,
> --
> 1.8.1.2
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 61+ messages in thread
* [PATCH v3 05/16] ARM: mvebu: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (3 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 04/16] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-08-01 9:54 ` Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 06/16] drivers/bus: arm-cci: avoid parsing DT for cpu device nodes Sudeep KarkadaNagesha
` (11 subsequent siblings)
16 siblings, 1 reply; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha, Andrew Lunn, Jason Cooper
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Currently set_secondary_cpus_clock assume the CPU logical ordering
and the MPDIR in DT are same, which is incorrect.
Since the CPU device nodes can be retrieved in the logical ordering
using the DT helper, we can remove the devices tree parsing.
This patch removes DT parsing by making use of of_get_cpu_node.
Cc: Gregory Clement <gregory.clement@free-electrons.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Jason Cooper <jason@lakedaemon.net>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
arch/arm/mach-mvebu/platsmp.c | 52 ++++++++++++++++++++-----------------------
1 file changed, 24 insertions(+), 28 deletions(-)
diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c
index ce81d30..001dd42 100644
--- a/arch/arm/mach-mvebu/platsmp.c
+++ b/arch/arm/mach-mvebu/platsmp.c
@@ -23,51 +23,47 @@
#include <linux/of.h>
#include <linux/mbus.h>
#include <asm/cacheflush.h>
+#include <asm/prom.h>
#include <asm/smp_plat.h>
#include "common.h"
#include "armada-370-xp.h"
#include "pmsu.h"
#include "coherency.h"
+static struct clk *__init get_cpu_clk(int cpu)
+{
+ struct clk *cpu_clk;
+ struct device_node *np = of_get_cpu_node(cpu);
+
+ if (WARN(!np, "missing cpu node\n"))
+ return NULL;
+ cpu_clk = of_clk_get(np, 0);
+ if (WARN_ON(IS_ERR(cpu_clk)))
+ return NULL;
+ return cpu_clk;
+}
+
void __init set_secondary_cpus_clock(void)
{
- int thiscpu;
+ int thiscpu, cpu;
unsigned long rate;
- struct clk *cpu_clk = NULL;
- struct device_node *np = NULL;
+ struct clk *cpu_clk;
thiscpu = smp_processor_id();
- for_each_node_by_type(np, "cpu") {
- int err;
- int cpu;
-
- err = of_property_read_u32(np, "reg", &cpu);
- if (WARN_ON(err))
- return;
-
- if (cpu == thiscpu) {
- cpu_clk = of_clk_get(np, 0);
- break;
- }
- }
- if (WARN_ON(IS_ERR(cpu_clk)))
+ cpu_clk = get_cpu_clk(thiscpu);
+ if (!cpu_clk)
return;
clk_prepare_enable(cpu_clk);
rate = clk_get_rate(cpu_clk);
/* set all the other CPU clk to the same rate than the boot CPU */
- for_each_node_by_type(np, "cpu") {
- int err;
- int cpu;
-
- err = of_property_read_u32(np, "reg", &cpu);
- if (WARN_ON(err))
+ for_each_possible_cpu(cpu) {
+ if (cpu == thiscpu)
+ continue;
+ cpu_clk = get_cpu_clk(cpu);
+ if (!cpu_clk)
return;
-
- if (cpu != thiscpu) {
- cpu_clk = of_clk_get(np, 0);
- clk_set_rate(cpu_clk, rate);
- }
+ clk_set_rate(cpu_clk, rate);
}
}
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* Re: [PATCH v3 05/16] ARM: mvebu: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 05/16] ARM: mvebu: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
@ 2013-08-01 9:54 ` Sudeep KarkadaNagesha
2013-08-01 12:02 ` Jason Cooper
0 siblings, 1 reply; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-01 9:54 UTC (permalink / raw)
To: Sudeep KarkadaNagesha, Gregory Clement, Andrew Lunn, Jason Cooper
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
Russell King, Shawn Guo, Greg Kroah-Hartman, Viresh Kumar,
Rafael J. Wysocki, grant.likely@linaro.org,
rob.herring@calxeda.com, Lorenzo Pieralisi, Olof Johansson,
Arnd Bergmann
On 22/07/13 12:32, Sudeep KarkadaNagesha wrote:
> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> Currently set_secondary_cpus_clock assume the CPU logical ordering
> and the MPDIR in DT are same, which is incorrect.
>
> Since the CPU device nodes can be retrieved in the logical ordering
> using the DT helper, we can remove the devices tree parsing.
>
> This patch removes DT parsing by making use of of_get_cpu_node.
>
> Cc: Gregory Clement <gregory.clement@free-electrons.com>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Jason Cooper <jason@lakedaemon.net>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Hi Gregory/Andrew/Jason,
Does this change look fine for mvebu?
If yes, can I have your ACKs ?
Regards,
Sudeep
> ---
> arch/arm/mach-mvebu/platsmp.c | 52 ++++++++++++++++++++-----------------------
> 1 file changed, 24 insertions(+), 28 deletions(-)
>
> diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c
> index ce81d30..001dd42 100644
> --- a/arch/arm/mach-mvebu/platsmp.c
> +++ b/arch/arm/mach-mvebu/platsmp.c
> @@ -23,51 +23,47 @@
> #include <linux/of.h>
> #include <linux/mbus.h>
> #include <asm/cacheflush.h>
> +#include <asm/prom.h>
> #include <asm/smp_plat.h>
> #include "common.h"
> #include "armada-370-xp.h"
> #include "pmsu.h"
> #include "coherency.h"
>
> +static struct clk *__init get_cpu_clk(int cpu)
> +{
> + struct clk *cpu_clk;
> + struct device_node *np = of_get_cpu_node(cpu);
> +
> + if (WARN(!np, "missing cpu node\n"))
> + return NULL;
> + cpu_clk = of_clk_get(np, 0);
> + if (WARN_ON(IS_ERR(cpu_clk)))
> + return NULL;
> + return cpu_clk;
> +}
> +
> void __init set_secondary_cpus_clock(void)
> {
> - int thiscpu;
> + int thiscpu, cpu;
> unsigned long rate;
> - struct clk *cpu_clk = NULL;
> - struct device_node *np = NULL;
> + struct clk *cpu_clk;
>
> thiscpu = smp_processor_id();
> - for_each_node_by_type(np, "cpu") {
> - int err;
> - int cpu;
> -
> - err = of_property_read_u32(np, "reg", &cpu);
> - if (WARN_ON(err))
> - return;
> -
> - if (cpu == thiscpu) {
> - cpu_clk = of_clk_get(np, 0);
> - break;
> - }
> - }
> - if (WARN_ON(IS_ERR(cpu_clk)))
> + cpu_clk = get_cpu_clk(thiscpu);
> + if (!cpu_clk)
> return;
> clk_prepare_enable(cpu_clk);
> rate = clk_get_rate(cpu_clk);
>
> /* set all the other CPU clk to the same rate than the boot CPU */
> - for_each_node_by_type(np, "cpu") {
> - int err;
> - int cpu;
> -
> - err = of_property_read_u32(np, "reg", &cpu);
> - if (WARN_ON(err))
> + for_each_possible_cpu(cpu) {
> + if (cpu == thiscpu)
> + continue;
> + cpu_clk = get_cpu_clk(cpu);
> + if (!cpu_clk)
> return;
> -
> - if (cpu != thiscpu) {
> - cpu_clk = of_clk_get(np, 0);
> - clk_set_rate(cpu_clk, rate);
> - }
> + clk_set_rate(cpu_clk, rate);
> }
> }
>
>
^ permalink raw reply [flat|nested] 61+ messages in thread* Re: [PATCH v3 05/16] ARM: mvebu: remove device tree parsing for cpu nodes
2013-08-01 9:54 ` Sudeep KarkadaNagesha
@ 2013-08-01 12:02 ` Jason Cooper
2013-08-05 16:28 ` Sudeep KarkadaNagesha
0 siblings, 1 reply; 61+ messages in thread
From: Jason Cooper @ 2013-08-01 12:02 UTC (permalink / raw)
To: Sudeep KarkadaNagesha, Gregory CLEMENT
Cc: Andrew Lunn, linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
Russell King, Shawn Guo, Greg Kroah-Hartman, Viresh Kumar,
Rafael J. Wysocki, grant.likely@linaro.org,
rob.herring@calxeda.com, Lorenzo Pieralisi, Olof Johansson,
Arnd Bergmann
Sudeep,
On Thu, Aug 01, 2013 at 10:54:44AM +0100, Sudeep KarkadaNagesha wrote:
> On 22/07/13 12:32, Sudeep KarkadaNagesha wrote:
> > From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> >
> > Currently set_secondary_cpus_clock assume the CPU logical ordering
> > and the MPDIR in DT are same, which is incorrect.
> >
> > Since the CPU device nodes can be retrieved in the logical ordering
> > using the DT helper, we can remove the devices tree parsing.
> >
> > This patch removes DT parsing by making use of of_get_cpu_node.
> >
> > Cc: Gregory Clement <gregory.clement@free-electrons.com>
> > Cc: Andrew Lunn <andrew@lunn.ch>
> > Cc: Jason Cooper <jason@lakedaemon.net>
> > Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> Hi Gregory/Andrew/Jason,
>
> Does this change look fine for mvebu?
> If yes, can I have your ACKs ?
Gregory is the one best suited to review/Ack this. He'll be back on
Monday.
thx,
Jason.
>
> Regards,
> Sudeep
> > ---
> > arch/arm/mach-mvebu/platsmp.c | 52 ++++++++++++++++++++-----------------------
> > 1 file changed, 24 insertions(+), 28 deletions(-)
> >
> > diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c
> > index ce81d30..001dd42 100644
> > --- a/arch/arm/mach-mvebu/platsmp.c
> > +++ b/arch/arm/mach-mvebu/platsmp.c
> > @@ -23,51 +23,47 @@
> > #include <linux/of.h>
> > #include <linux/mbus.h>
> > #include <asm/cacheflush.h>
> > +#include <asm/prom.h>
> > #include <asm/smp_plat.h>
> > #include "common.h"
> > #include "armada-370-xp.h"
> > #include "pmsu.h"
> > #include "coherency.h"
> >
> > +static struct clk *__init get_cpu_clk(int cpu)
> > +{
> > + struct clk *cpu_clk;
> > + struct device_node *np = of_get_cpu_node(cpu);
> > +
> > + if (WARN(!np, "missing cpu node\n"))
> > + return NULL;
> > + cpu_clk = of_clk_get(np, 0);
> > + if (WARN_ON(IS_ERR(cpu_clk)))
> > + return NULL;
> > + return cpu_clk;
> > +}
> > +
> > void __init set_secondary_cpus_clock(void)
> > {
> > - int thiscpu;
> > + int thiscpu, cpu;
> > unsigned long rate;
> > - struct clk *cpu_clk = NULL;
> > - struct device_node *np = NULL;
> > + struct clk *cpu_clk;
> >
> > thiscpu = smp_processor_id();
> > - for_each_node_by_type(np, "cpu") {
> > - int err;
> > - int cpu;
> > -
> > - err = of_property_read_u32(np, "reg", &cpu);
> > - if (WARN_ON(err))
> > - return;
> > -
> > - if (cpu == thiscpu) {
> > - cpu_clk = of_clk_get(np, 0);
> > - break;
> > - }
> > - }
> > - if (WARN_ON(IS_ERR(cpu_clk)))
> > + cpu_clk = get_cpu_clk(thiscpu);
> > + if (!cpu_clk)
> > return;
> > clk_prepare_enable(cpu_clk);
> > rate = clk_get_rate(cpu_clk);
> >
> > /* set all the other CPU clk to the same rate than the boot CPU */
> > - for_each_node_by_type(np, "cpu") {
> > - int err;
> > - int cpu;
> > -
> > - err = of_property_read_u32(np, "reg", &cpu);
> > - if (WARN_ON(err))
> > + for_each_possible_cpu(cpu) {
> > + if (cpu == thiscpu)
> > + continue;
> > + cpu_clk = get_cpu_clk(cpu);
> > + if (!cpu_clk)
> > return;
> > -
> > - if (cpu != thiscpu) {
> > - cpu_clk = of_clk_get(np, 0);
> > - clk_set_rate(cpu_clk, rate);
> > - }
> > + clk_set_rate(cpu_clk, rate);
> > }
> > }
> >
> >
>
>
^ permalink raw reply [flat|nested] 61+ messages in thread* Re: [PATCH v3 05/16] ARM: mvebu: remove device tree parsing for cpu nodes
2013-08-01 12:02 ` Jason Cooper
@ 2013-08-05 16:28 ` Sudeep KarkadaNagesha
2013-08-06 8:25 ` Gregory CLEMENT
0 siblings, 1 reply; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-05 16:28 UTC (permalink / raw)
To: Gregory CLEMENT
Cc: Jason Cooper, Sudeep KarkadaNagesha, Andrew Lunn,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
Russell King, Shawn Guo, Greg Kroah-Hartman, Viresh Kumar,
Rafael J. Wysocki, grant.likely@linaro.org,
rob.herring@calxeda.com, Lorenzo Pieralisi, Olof Johansson,
Arnd Bergmann
On 01/08/13 13:02, Jason Cooper wrote:
> Sudeep,
>
> On Thu, Aug 01, 2013 at 10:54:44AM +0100, Sudeep KarkadaNagesha wrote:
>> On 22/07/13 12:32, Sudeep KarkadaNagesha wrote:
>>> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>>
>>> Currently set_secondary_cpus_clock assume the CPU logical ordering
>>> and the MPDIR in DT are same, which is incorrect.
>>>
>>> Since the CPU device nodes can be retrieved in the logical ordering
>>> using the DT helper, we can remove the devices tree parsing.
>>>
>>> This patch removes DT parsing by making use of of_get_cpu_node.
>>>
>>> Cc: Gregory Clement <gregory.clement@free-electrons.com>
>>> Cc: Andrew Lunn <andrew@lunn.ch>
>>> Cc: Jason Cooper <jason@lakedaemon.net>
>>> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>
>> Hi Gregory/Andrew/Jason,
>>
>> Does this change look fine for mvebu?
>> If yes, can I have your ACKs ?
>
> Gregory is the one best suited to review/Ack this. He'll be back on
> Monday.
>
Hi Gregory,
Can you please review this patch ?
Regards,
Sudeep
>>> ---
>>> arch/arm/mach-mvebu/platsmp.c | 52 ++++++++++++++++++++-----------------------
>>> 1 file changed, 24 insertions(+), 28 deletions(-)
>>>
>>> diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c
>>> index ce81d30..001dd42 100644
>>> --- a/arch/arm/mach-mvebu/platsmp.c
>>> +++ b/arch/arm/mach-mvebu/platsmp.c
>>> @@ -23,51 +23,47 @@
>>> #include <linux/of.h>
>>> #include <linux/mbus.h>
>>> #include <asm/cacheflush.h>
>>> +#include <asm/prom.h>
>>> #include <asm/smp_plat.h>
>>> #include "common.h"
>>> #include "armada-370-xp.h"
>>> #include "pmsu.h"
>>> #include "coherency.h"
>>>
>>> +static struct clk *__init get_cpu_clk(int cpu)
>>> +{
>>> + struct clk *cpu_clk;
>>> + struct device_node *np = of_get_cpu_node(cpu);
>>> +
>>> + if (WARN(!np, "missing cpu node\n"))
>>> + return NULL;
>>> + cpu_clk = of_clk_get(np, 0);
>>> + if (WARN_ON(IS_ERR(cpu_clk)))
>>> + return NULL;
>>> + return cpu_clk;
>>> +}
>>> +
>>> void __init set_secondary_cpus_clock(void)
>>> {
>>> - int thiscpu;
>>> + int thiscpu, cpu;
>>> unsigned long rate;
>>> - struct clk *cpu_clk = NULL;
>>> - struct device_node *np = NULL;
>>> + struct clk *cpu_clk;
>>>
>>> thiscpu = smp_processor_id();
>>> - for_each_node_by_type(np, "cpu") {
>>> - int err;
>>> - int cpu;
>>> -
>>> - err = of_property_read_u32(np, "reg", &cpu);
>>> - if (WARN_ON(err))
>>> - return;
>>> -
>>> - if (cpu == thiscpu) {
>>> - cpu_clk = of_clk_get(np, 0);
>>> - break;
>>> - }
>>> - }
>>> - if (WARN_ON(IS_ERR(cpu_clk)))
>>> + cpu_clk = get_cpu_clk(thiscpu);
>>> + if (!cpu_clk)
>>> return;
>>> clk_prepare_enable(cpu_clk);
>>> rate = clk_get_rate(cpu_clk);
>>>
>>> /* set all the other CPU clk to the same rate than the boot CPU */
>>> - for_each_node_by_type(np, "cpu") {
>>> - int err;
>>> - int cpu;
>>> -
>>> - err = of_property_read_u32(np, "reg", &cpu);
>>> - if (WARN_ON(err))
>>> + for_each_possible_cpu(cpu) {
>>> + if (cpu == thiscpu)
>>> + continue;
>>> + cpu_clk = get_cpu_clk(cpu);
>>> + if (!cpu_clk)
>>> return;
>>> -
>>> - if (cpu != thiscpu) {
>>> - cpu_clk = of_clk_get(np, 0);
>>> - clk_set_rate(cpu_clk, rate);
>>> - }
>>> + clk_set_rate(cpu_clk, rate);
>>> }
>>> }
>>>
>>>
>>
>>
>
^ permalink raw reply [flat|nested] 61+ messages in thread* Re: [PATCH v3 05/16] ARM: mvebu: remove device tree parsing for cpu nodes
2013-08-05 16:28 ` Sudeep KarkadaNagesha
@ 2013-08-06 8:25 ` Gregory CLEMENT
2013-08-06 9:02 ` Sudeep KarkadaNagesha
0 siblings, 1 reply; 61+ messages in thread
From: Gregory CLEMENT @ 2013-08-06 8:25 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: Andrew Lunn, Lorenzo Pieralisi, Russell King, Jason Cooper,
Arnd Bergmann, linux-pm@vger.kernel.org, Greg Kroah-Hartman,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
Rafael J. Wysocki, grant.likely@linaro.org,
devicetree@vger.kernel.org, rob.herring@calxeda.com, Viresh Kumar,
Olof Johansson, Shawn Guo, linux-arm-kernel@lists.infradead.org
On 05/08/2013 18:28, Sudeep KarkadaNagesha wrote:
> On 01/08/13 13:02, Jason Cooper wrote:
>> Sudeep,
>>
>> On Thu, Aug 01, 2013 at 10:54:44AM +0100, Sudeep KarkadaNagesha wrote:
>>> On 22/07/13 12:32, Sudeep KarkadaNagesha wrote:
>>>> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>>>
>>>> Currently set_secondary_cpus_clock assume the CPU logical ordering
>>>> and the MPDIR in DT are same, which is incorrect.
>>>>
>>>> Since the CPU device nodes can be retrieved in the logical ordering
>>>> using the DT helper, we can remove the devices tree parsing.
>>>>
>>>> This patch removes DT parsing by making use of of_get_cpu_node.
>>>>
>>>> Cc: Gregory Clement <gregory.clement@free-electrons.com>
>>>> Cc: Andrew Lunn <andrew@lunn.ch>
>>>> Cc: Jason Cooper <jason@lakedaemon.net>
>>>> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>>
>>> Hi Gregory/Andrew/Jason,
>>>
>>> Does this change look fine for mvebu?
>>> If yes, can I have your ACKs ?
>>
>> Gregory is the one best suited to review/Ack this. He'll be back on
>> Monday.
>>
> Hi Gregory,
>
> Can you please review this patch ?
Your patch is a nice improvement, I reviewed it and I also tested it on the
Armada XP DB board.
You can add my:
Acked-by: Gregory Clement <gregory.clement@free-electrons.com>
>
> Regards,
> Sudeep
>>>> ---
>>>> arch/arm/mach-mvebu/platsmp.c | 52 ++++++++++++++++++++-----------------------
>>>> 1 file changed, 24 insertions(+), 28 deletions(-)
>>>>
>>>> diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c
>>>> index ce81d30..001dd42 100644
>>>> --- a/arch/arm/mach-mvebu/platsmp.c
>>>> +++ b/arch/arm/mach-mvebu/platsmp.c
>>>> @@ -23,51 +23,47 @@
>>>> #include <linux/of.h>
>>>> #include <linux/mbus.h>
>>>> #include <asm/cacheflush.h>
>>>> +#include <asm/prom.h>
>>>> #include <asm/smp_plat.h>
>>>> #include "common.h"
>>>> #include "armada-370-xp.h"
>>>> #include "pmsu.h"
>>>> #include "coherency.h"
>>>>
>>>> +static struct clk *__init get_cpu_clk(int cpu)
>>>> +{
>>>> + struct clk *cpu_clk;
>>>> + struct device_node *np = of_get_cpu_node(cpu);
>>>> +
>>>> + if (WARN(!np, "missing cpu node\n"))
>>>> + return NULL;
>>>> + cpu_clk = of_clk_get(np, 0);
>>>> + if (WARN_ON(IS_ERR(cpu_clk)))
>>>> + return NULL;
>>>> + return cpu_clk;
>>>> +}
>>>> +
>>>> void __init set_secondary_cpus_clock(void)
>>>> {
>>>> - int thiscpu;
>>>> + int thiscpu, cpu;
>>>> unsigned long rate;
>>>> - struct clk *cpu_clk = NULL;
>>>> - struct device_node *np = NULL;
>>>> + struct clk *cpu_clk;
>>>>
>>>> thiscpu = smp_processor_id();
>>>> - for_each_node_by_type(np, "cpu") {
>>>> - int err;
>>>> - int cpu;
>>>> -
>>>> - err = of_property_read_u32(np, "reg", &cpu);
>>>> - if (WARN_ON(err))
>>>> - return;
>>>> -
>>>> - if (cpu == thiscpu) {
>>>> - cpu_clk = of_clk_get(np, 0);
>>>> - break;
>>>> - }
>>>> - }
>>>> - if (WARN_ON(IS_ERR(cpu_clk)))
>>>> + cpu_clk = get_cpu_clk(thiscpu);
>>>> + if (!cpu_clk)
>>>> return;
>>>> clk_prepare_enable(cpu_clk);
>>>> rate = clk_get_rate(cpu_clk);
>>>>
>>>> /* set all the other CPU clk to the same rate than the boot CPU */
>>>> - for_each_node_by_type(np, "cpu") {
>>>> - int err;
>>>> - int cpu;
>>>> -
>>>> - err = of_property_read_u32(np, "reg", &cpu);
>>>> - if (WARN_ON(err))
>>>> + for_each_possible_cpu(cpu) {
>>>> + if (cpu == thiscpu)
>>>> + continue;
>>>> + cpu_clk = get_cpu_clk(cpu);
>>>> + if (!cpu_clk)
>>>> return;
>>>> -
>>>> - if (cpu != thiscpu) {
>>>> - cpu_clk = of_clk_get(np, 0);
>>>> - clk_set_rate(cpu_clk, rate);
>>>> - }
>>>> + clk_set_rate(cpu_clk, rate);
>>>> }
>>>> }
>>>>
>>>>
>>>
>>>
>>
>
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>
--
Gregory Clement, Free Electrons
Kernel, drivers, real-time and embedded Linux
development, consulting, training and support.
http://free-electrons.com
^ permalink raw reply [flat|nested] 61+ messages in thread* Re: [PATCH v3 05/16] ARM: mvebu: remove device tree parsing for cpu nodes
2013-08-06 8:25 ` Gregory CLEMENT
@ 2013-08-06 9:02 ` Sudeep KarkadaNagesha
0 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-06 9:02 UTC (permalink / raw)
To: Gregory CLEMENT
Cc: Sudeep KarkadaNagesha, Andrew Lunn, Lorenzo Pieralisi,
Russell King, Jason Cooper, Arnd Bergmann,
linux-pm@vger.kernel.org, Greg Kroah-Hartman,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
Rafael J. Wysocki, Olof Johansson, devicetree@vger.kernel.org,
rob.herring@calxeda.com, Viresh Kumar, grant.likely@linaro.org,
Shawn Guo, linux-arm-kernel@lists.infradead.org
On 06/08/13 09:25, Gregory CLEMENT wrote:
> On 05/08/2013 18:28, Sudeep KarkadaNagesha wrote:
>> On 01/08/13 13:02, Jason Cooper wrote:
>>> Sudeep,
>>>
>>> On Thu, Aug 01, 2013 at 10:54:44AM +0100, Sudeep KarkadaNagesha wrote:
>>>> On 22/07/13 12:32, Sudeep KarkadaNagesha wrote:
>>>>> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>>>>
>>>>> Currently set_secondary_cpus_clock assume the CPU logical ordering
>>>>> and the MPDIR in DT are same, which is incorrect.
>>>>>
>>>>> Since the CPU device nodes can be retrieved in the logical ordering
>>>>> using the DT helper, we can remove the devices tree parsing.
>>>>>
>>>>> This patch removes DT parsing by making use of of_get_cpu_node.
>>>>>
>>>>> Cc: Gregory Clement <gregory.clement@free-electrons.com>
>>>>> Cc: Andrew Lunn <andrew@lunn.ch>
>>>>> Cc: Jason Cooper <jason@lakedaemon.net>
>>>>> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>>>
>>>> Hi Gregory/Andrew/Jason,
>>>>
>>>> Does this change look fine for mvebu?
>>>> If yes, can I have your ACKs ?
>>>
>>> Gregory is the one best suited to review/Ack this. He'll be back on
>>> Monday.
>>>
>> Hi Gregory,
>>
>> Can you please review this patch ?
>
> Your patch is a nice improvement, I reviewed it and I also tested it on the
> Armada XP DB board.
>
> You can add my:
> Acked-by: Gregory Clement <gregory.clement@free-electrons.com>
Thanks Gregory.
Regards,
Sudeep
^ permalink raw reply [flat|nested] 61+ messages in thread
* [PATCH v3 06/16] drivers/bus: arm-cci: avoid parsing DT for cpu device nodes
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (4 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 05/16] ARM: mvebu: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-22 14:37 ` Nicolas Pitre
2013-07-22 11:32 ` [PATCH v3 07/16] of/device: add helper to get cpu device node from logical cpu index Sudeep KarkadaNagesha
` (10 subsequent siblings)
16 siblings, 1 reply; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Since the CPU device nodes can be retrieved using arch_of_get_cpu_node,
we can use it to avoid parsing the cpus node searching the cpu nodes and
mapping to logical index.
This patch removes parsing DT for cpu nodes by using of_get_cpu_node.
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/bus/arm-cci.c | 28 +++++++---------------------
1 file changed, 7 insertions(+), 21 deletions(-)
diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
index 7332889..7dd891c 100644
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -122,17 +122,8 @@ EXPORT_SYMBOL_GPL(cci_ace_get_port);
static void __init cci_ace_init_ports(void)
{
- int port, ac, cpu;
- u64 hwid;
- const u32 *cell;
- struct device_node *cpun, *cpus;
-
- cpus = of_find_node_by_path("/cpus");
- if (WARN(!cpus, "Missing cpus node, bailing out\n"))
- return;
-
- if (WARN_ON(of_property_read_u32(cpus, "#address-cells", &ac)))
- ac = of_n_addr_cells(cpus);
+ int port, cpu;
+ struct device_node *cpun;
/*
* Port index look-up speeds up the function disabling ports by CPU,
@@ -141,18 +132,13 @@ static void __init cci_ace_init_ports(void)
* The stashed index array is initialized for all possible CPUs
* at probe time.
*/
- for_each_child_of_node(cpus, cpun) {
- if (of_node_cmp(cpun->type, "cpu"))
- continue;
- cell = of_get_property(cpun, "reg", NULL);
- if (WARN(!cell, "%s: missing reg property\n", cpun->full_name))
- continue;
-
- hwid = of_read_number(cell, ac);
- cpu = get_logical_index(hwid & MPIDR_HWID_BITMASK);
+ for_each_possible_cpu(cpu) {
+ /* too early to use cpu->of_node */
+ cpun = of_get_cpu_node(cpu);
- if (cpu < 0 || !cpu_possible(cpu))
+ if (WARN(!cpun, "Missing cpu device node\n"))
continue;
+
port = __cci_ace_get_port(cpun, ACE_PORT);
if (port < 0)
continue;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* Re: [PATCH v3 06/16] drivers/bus: arm-cci: avoid parsing DT for cpu device nodes
2013-07-22 11:32 ` [PATCH v3 06/16] drivers/bus: arm-cci: avoid parsing DT for cpu device nodes Sudeep KarkadaNagesha
@ 2013-07-22 14:37 ` Nicolas Pitre
0 siblings, 0 replies; 61+ messages in thread
From: Nicolas Pitre @ 2013-07-22 14:37 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree,
Russell King, Shawn Guo, Gregory Clement, Greg Kroah-Hartman,
Viresh Kumar, Rafael J. Wysocki, Grant Likely, Rob Herring,
Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann
On Mon, 22 Jul 2013, Sudeep KarkadaNagesha wrote:
> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> Since the CPU device nodes can be retrieved using arch_of_get_cpu_node,
> we can use it to avoid parsing the cpus node searching the cpu nodes and
> mapping to logical index.
>
> This patch removes parsing DT for cpu nodes by using of_get_cpu_node.
>
> Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Acked-by: Nicolas Pitre <nico@linaro.org>
> ---
> drivers/bus/arm-cci.c | 28 +++++++---------------------
> 1 file changed, 7 insertions(+), 21 deletions(-)
>
> diff --git a/drivers/bus/arm-cci.c b/drivers/bus/arm-cci.c
> index 7332889..7dd891c 100644
> --- a/drivers/bus/arm-cci.c
> +++ b/drivers/bus/arm-cci.c
> @@ -122,17 +122,8 @@ EXPORT_SYMBOL_GPL(cci_ace_get_port);
>
> static void __init cci_ace_init_ports(void)
> {
> - int port, ac, cpu;
> - u64 hwid;
> - const u32 *cell;
> - struct device_node *cpun, *cpus;
> -
> - cpus = of_find_node_by_path("/cpus");
> - if (WARN(!cpus, "Missing cpus node, bailing out\n"))
> - return;
> -
> - if (WARN_ON(of_property_read_u32(cpus, "#address-cells", &ac)))
> - ac = of_n_addr_cells(cpus);
> + int port, cpu;
> + struct device_node *cpun;
>
> /*
> * Port index look-up speeds up the function disabling ports by CPU,
> @@ -141,18 +132,13 @@ static void __init cci_ace_init_ports(void)
> * The stashed index array is initialized for all possible CPUs
> * at probe time.
> */
> - for_each_child_of_node(cpus, cpun) {
> - if (of_node_cmp(cpun->type, "cpu"))
> - continue;
> - cell = of_get_property(cpun, "reg", NULL);
> - if (WARN(!cell, "%s: missing reg property\n", cpun->full_name))
> - continue;
> -
> - hwid = of_read_number(cell, ac);
> - cpu = get_logical_index(hwid & MPIDR_HWID_BITMASK);
> + for_each_possible_cpu(cpu) {
> + /* too early to use cpu->of_node */
> + cpun = of_get_cpu_node(cpu);
>
> - if (cpu < 0 || !cpu_possible(cpu))
> + if (WARN(!cpun, "Missing cpu device node\n"))
> continue;
> +
> port = __cci_ace_get_port(cpun, ACE_PORT);
> if (port < 0)
> continue;
> --
> 1.8.1.2
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
>
^ permalink raw reply [flat|nested] 61+ messages in thread
* [PATCH v3 07/16] of/device: add helper to get cpu device node from logical cpu index
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (5 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 06/16] drivers/bus: arm-cci: avoid parsing DT for cpu device nodes Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-26 17:01 ` Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 08/16] cpufreq: imx6q-cpufreq: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
` (9 subsequent siblings)
16 siblings, 1 reply; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Lorenzo Pieralisi, Russell King, Arnd Bergmann,
Sudeep KarkadaNagesha, Viresh Kumar, Olof Johansson, Rob Herring,
Rafael J. Wysocki, Grant Likely, Greg Kroah-Hartman,
Gregory Clement, Shawn Guo
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Multiple drivers need to get the cpu device node from the cpu logical
index and then access the of_node.
This patch adds helper function to fetch the device node directly.
Cc: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
include/linux/of_device.h | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/include/linux/of_device.h b/include/linux/of_device.h
index 9d27475..82ce324 100644
--- a/include/linux/of_device.h
+++ b/include/linux/of_device.h
@@ -1,6 +1,7 @@
#ifndef _LINUX_OF_DEVICE_H
#define _LINUX_OF_DEVICE_H
+#include <linux/cpu.h>
#include <linux/platform_device.h>
#include <linux/of_platform.h> /* temporary until merge */
@@ -43,6 +44,15 @@ static inline void of_device_node_put(struct device *dev)
of_node_put(dev->of_node);
}
+static inline struct device_node *of_cpu_device_node_get(int cpu)
+{
+ struct device *cpu_dev;
+ cpu_dev = get_cpu_device(cpu);
+ if (!cpu_dev)
+ return NULL;
+ return of_node_get(cpu_dev->of_node);
+}
+
#else /* CONFIG_OF */
static inline int of_driver_match_device(struct device *dev,
@@ -67,6 +77,11 @@ static inline const struct of_device_id *of_match_device(
{
return NULL;
}
+
+static inline struct device_node *of_cpu_device_node_get(int cpu)
+{
+ return NULL;
+}
#endif /* CONFIG_OF */
#endif /* _LINUX_OF_DEVICE_H */
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* Re: [PATCH v3 07/16] of/device: add helper to get cpu device node from logical cpu index
2013-07-22 11:32 ` [PATCH v3 07/16] of/device: add helper to get cpu device node from logical cpu index Sudeep KarkadaNagesha
@ 2013-07-26 17:01 ` Sudeep KarkadaNagesha
2013-07-26 18:55 ` Rob Herring
0 siblings, 1 reply; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-26 17:01 UTC (permalink / raw)
To: rob.herring@calxeda.com
Cc: devicetree@vger.kernel.org, Lorenzo Pieralisi, Russell King,
Arnd Bergmann, linux-pm@vger.kernel.org, Sudeep KarkadaNagesha,
Greg Kroah-Hartman, Olof Johansson, linux-kernel@vger.kernel.org,
cpufreq@vger.kernel.org, Rafael J. Wysocki,
grant.likely@linaro.org, Viresh Kumar, Gregory Clement, Shawn Guo,
linux-arm-kernel@lists.infradead.org
Rob,
On 22/07/13 12:32, Sudeep KarkadaNagesha wrote:
> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> Multiple drivers need to get the cpu device node from the cpu logical
> index and then access the of_node.
>
> This patch adds helper function to fetch the device node directly.
>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
If you have no objections with this patch, can I add your ACK ?
Regards,
Sudeep
> ---
> include/linux/of_device.h | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
>
> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
> index 9d27475..82ce324 100644
> --- a/include/linux/of_device.h
> +++ b/include/linux/of_device.h
> @@ -1,6 +1,7 @@
> #ifndef _LINUX_OF_DEVICE_H
> #define _LINUX_OF_DEVICE_H
>
> +#include <linux/cpu.h>
> #include <linux/platform_device.h>
> #include <linux/of_platform.h> /* temporary until merge */
>
> @@ -43,6 +44,15 @@ static inline void of_device_node_put(struct device *dev)
> of_node_put(dev->of_node);
> }
>
> +static inline struct device_node *of_cpu_device_node_get(int cpu)
> +{
> + struct device *cpu_dev;
> + cpu_dev = get_cpu_device(cpu);
> + if (!cpu_dev)
> + return NULL;
> + return of_node_get(cpu_dev->of_node);
> +}
> +
> #else /* CONFIG_OF */
>
> static inline int of_driver_match_device(struct device *dev,
> @@ -67,6 +77,11 @@ static inline const struct of_device_id *of_match_device(
> {
> return NULL;
> }
> +
> +static inline struct device_node *of_cpu_device_node_get(int cpu)
> +{
> + return NULL;
> +}
> #endif /* CONFIG_OF */
>
> #endif /* _LINUX_OF_DEVICE_H */
>
-- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
^ permalink raw reply [flat|nested] 61+ messages in thread* Re: [PATCH v3 07/16] of/device: add helper to get cpu device node from logical cpu index
2013-07-26 17:01 ` Sudeep KarkadaNagesha
@ 2013-07-26 18:55 ` Rob Herring
0 siblings, 0 replies; 61+ messages in thread
From: Rob Herring @ 2013-07-26 18:55 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: rob.herring@calxeda.com, devicetree@vger.kernel.org,
Lorenzo Pieralisi, Russell King, Arnd Bergmann,
linux-pm@vger.kernel.org, Greg Kroah-Hartman, Olof Johansson,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
Rafael J. Wysocki, grant.likely@linaro.org, Viresh Kumar,
Gregory Clement, Shawn Guo, linux-arm-kernel@lists.infradead.org
On Fri, Jul 26, 2013 at 12:01 PM, Sudeep KarkadaNagesha
<Sudeep.KarkadaNagesha@arm.com> wrote:
> Rob,
>
> On 22/07/13 12:32, Sudeep KarkadaNagesha wrote:
>> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>
>> Multiple drivers need to get the cpu device node from the cpu logical
>> index and then access the of_node.
>>
>> This patch adds helper function to fetch the device node directly.
>>
>> Cc: Rob Herring <rob.herring@calxeda.com>
>> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> If you have no objections with this patch, can I add your ACK ?
Yes.
Acked-by: Rob Herring <rob.herring@calxeda.com>
>
> Regards,
> Sudeep
>
>> ---
>> include/linux/of_device.h | 15 +++++++++++++++
>> 1 file changed, 15 insertions(+)
>>
>> diff --git a/include/linux/of_device.h b/include/linux/of_device.h
>> index 9d27475..82ce324 100644
>> --- a/include/linux/of_device.h
>> +++ b/include/linux/of_device.h
>> @@ -1,6 +1,7 @@
>> #ifndef _LINUX_OF_DEVICE_H
>> #define _LINUX_OF_DEVICE_H
>>
>> +#include <linux/cpu.h>
>> #include <linux/platform_device.h>
>> #include <linux/of_platform.h> /* temporary until merge */
>>
>> @@ -43,6 +44,15 @@ static inline void of_device_node_put(struct device *dev)
>> of_node_put(dev->of_node);
>> }
>>
>> +static inline struct device_node *of_cpu_device_node_get(int cpu)
>> +{
>> + struct device *cpu_dev;
>> + cpu_dev = get_cpu_device(cpu);
>> + if (!cpu_dev)
>> + return NULL;
>> + return of_node_get(cpu_dev->of_node);
>> +}
>> +
>> #else /* CONFIG_OF */
>>
>> static inline int of_driver_match_device(struct device *dev,
>> @@ -67,6 +77,11 @@ static inline const struct of_device_id *of_match_device(
>> {
>> return NULL;
>> }
>> +
>> +static inline struct device_node *of_cpu_device_node_get(int cpu)
>> +{
>> + return NULL;
>> +}
>> #endif /* CONFIG_OF */
>>
>> #endif /* _LINUX_OF_DEVICE_H */
>>
>
>
> -- IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 61+ messages in thread
* [PATCH v3 08/16] cpufreq: imx6q-cpufreq: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (6 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 07/16] of/device: add helper to get cpu device node from logical cpu index Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 09/16] cpufreq: cpufreq-cpu0: " Sudeep KarkadaNagesha
` (8 subsequent siblings)
16 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Now that the cpu device registration initialises the of_node(if available)
appropriately for all the cpus, parsing here is redundant.
This patch removes all DT parsing and uses cpu->of_node instead.
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
arch/arm/mach-imx/mach-imx6q.c | 3 +--
drivers/cpufreq/imx6q-cpufreq.c | 4 +---
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 7be13f8..a02f275 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -254,13 +254,12 @@ static void __init imx6q_opp_init(struct device *cpu_dev)
{
struct device_node *np;
- np = of_find_node_by_path("/cpus/cpu@0");
+ np = of_node_get(cpu_dev->of_node);
if (!np) {
pr_warn("failed to find cpu0 node\n");
return;
}
- cpu_dev->of_node = np;
if (of_init_opp_table(cpu_dev)) {
pr_warn("failed to init OPP table\n");
goto put_node;
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index e37cdae..b16632b 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -221,14 +221,12 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
cpu_dev = &pdev->dev;
- np = of_find_node_by_path("/cpus/cpu@0");
+ np = of_node_get(cpu_dev->of_node);
if (!np) {
dev_err(cpu_dev, "failed to find cpu0 node\n");
return -ENOENT;
}
- cpu_dev->of_node = np;
-
arm_clk = devm_clk_get(cpu_dev, "arm");
pll1_sys_clk = devm_clk_get(cpu_dev, "pll1_sys");
pll1_sw_clk = devm_clk_get(cpu_dev, "pll1_sw");
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* [PATCH v3 09/16] cpufreq: cpufreq-cpu0: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (7 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 08/16] cpufreq: imx6q-cpufreq: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 10/16] cpufreq: highbank-cpufreq: " Sudeep KarkadaNagesha
` (7 subsequent siblings)
16 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Now that the cpu device registration initialises the of_node(if available)
appropriately for all the cpus, parsing here is redundant.
This patch removes all DT parsing and uses cpu->of_node instead.
Acked-by: Shawn Guo <shawn.guo@linaro.org>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/cpufreq/cpufreq-cpu0.c | 23 ++++-------------------
1 file changed, 4 insertions(+), 19 deletions(-)
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
index ad1fde2..5b05c26 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -174,29 +174,17 @@ static struct cpufreq_driver cpu0_cpufreq_driver = {
static int cpu0_cpufreq_probe(struct platform_device *pdev)
{
- struct device_node *np, *parent;
+ struct device_node *np;
int ret;
- parent = of_find_node_by_path("/cpus");
- if (!parent) {
- pr_err("failed to find OF /cpus\n");
- return -ENOENT;
- }
-
- for_each_child_of_node(parent, np) {
- if (of_get_property(np, "operating-points", NULL))
- break;
- }
+ cpu_dev = &pdev->dev;
+ np = of_node_get(cpu_dev->of_node);
if (!np) {
pr_err("failed to find cpu0 node\n");
- ret = -ENOENT;
- goto out_put_parent;
+ return -ENOENT;
}
- cpu_dev = &pdev->dev;
- cpu_dev->of_node = np;
-
cpu_reg = devm_regulator_get(cpu_dev, "cpu0");
if (IS_ERR(cpu_reg)) {
/*
@@ -269,15 +257,12 @@ static int cpu0_cpufreq_probe(struct platform_device *pdev)
}
of_node_put(np);
- of_node_put(parent);
return 0;
out_free_table:
opp_free_cpufreq_table(cpu_dev, &freq_table);
out_put_node:
of_node_put(np);
-out_put_parent:
- of_node_put(parent);
return ret;
}
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* [PATCH v3 10/16] cpufreq: highbank-cpufreq: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (8 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 09/16] cpufreq: cpufreq-cpu0: " Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 11/16] cpufreq: spear-cpufreq: " Sudeep KarkadaNagesha
` (6 subsequent siblings)
16 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha, Mark Langsdorf
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Now that the cpu device registration initialises the of_node(if available)
appropriately for all the cpus, parsing here is redundant.
This patch removes all DT parsing and uses cpu->of_node instead.
Cc: Mark Langsdorf <mark.langsdorf@calxeda.com>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/cpufreq/highbank-cpufreq.c | 18 ++++++------------
1 file changed, 6 insertions(+), 12 deletions(-)
diff --git a/drivers/cpufreq/highbank-cpufreq.c b/drivers/cpufreq/highbank-cpufreq.c
index b61b5a3..794123f 100644
--- a/drivers/cpufreq/highbank-cpufreq.c
+++ b/drivers/cpufreq/highbank-cpufreq.c
@@ -69,23 +69,17 @@ static int hb_cpufreq_driver_init(void)
if (!of_machine_is_compatible("calxeda,highbank"))
return -ENODEV;
- for_each_child_of_node(of_find_node_by_path("/cpus"), np)
- if (of_get_property(np, "operating-points", NULL))
- break;
-
- if (!np) {
- pr_err("failed to find highbank cpufreq node\n");
- return -ENOENT;
- }
-
cpu_dev = get_cpu_device(0);
if (!cpu_dev) {
pr_err("failed to get highbank cpufreq device\n");
- ret = -ENODEV;
- goto out_put_node;
+ return -ENODEV;
}
- cpu_dev->of_node = np;
+ np = of_node_get(cpu_dev->of_node);
+ if (!np) {
+ pr_err("failed to find highbank cpufreq node\n");
+ return -ENOENT;
+ }
cpu_clk = clk_get(cpu_dev, NULL);
if (IS_ERR(cpu_clk)) {
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* [PATCH v3 11/16] cpufreq: spear-cpufreq: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (9 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 10/16] cpufreq: highbank-cpufreq: " Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 12/16] cpufreq: kirkwood-cpufreq: " Sudeep KarkadaNagesha
` (5 subsequent siblings)
16 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha, Deepak Sikri
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Now that the cpu device registration initialises the of_node(if available)
appropriately for all the cpus, parsing here is redundant.
This patch removes all DT parsing and uses cpu->of_node instead.
Cc: Deepak Sikri <deepak.sikri@st.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/cpufreq/spear-cpufreq.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
index c3efa7f..19e364fa 100644
--- a/drivers/cpufreq/spear-cpufreq.c
+++ b/drivers/cpufreq/spear-cpufreq.c
@@ -18,7 +18,7 @@
#include <linux/err.h>
#include <linux/init.h>
#include <linux/module.h>
-#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/slab.h>
#include <linux/types.h>
@@ -223,7 +223,7 @@ static int spear_cpufreq_driver_init(void)
const __be32 *val;
int cnt, i, ret;
- np = of_find_node_by_path("/cpus/cpu@0");
+ np = of_cpu_device_node_get(0);
if (!np) {
pr_err("No cpu node found");
return -ENODEV;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* [PATCH v3 12/16] cpufreq: kirkwood-cpufreq: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (10 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 11/16] cpufreq: spear-cpufreq: " Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-23 9:25 ` Andrew Lunn
2013-07-22 11:32 ` [PATCH v3 13/16] cpufreq: arm_big_little: " Sudeep KarkadaNagesha
` (4 subsequent siblings)
16 siblings, 1 reply; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha, Andrew Lunn, Jason Cooper
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Now that the cpu device registration initialises the of_node(if available)
appropriately for all the cpus, parsing here is redundant.
This patch removes all DT parsing and uses cpu->of_node instead.
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Jason Cooper <jason@lakedaemon.net>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/cpufreq/kirkwood-cpufreq.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
index c233ea6..25ac2cb 100644
--- a/drivers/cpufreq/kirkwood-cpufreq.c
+++ b/drivers/cpufreq/kirkwood-cpufreq.c
@@ -14,7 +14,7 @@
#include <linux/clk.h>
#include <linux/clk-provider.h>
#include <linux/cpufreq.h>
-#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/io.h>
#include <asm/proc-fns.h>
@@ -175,9 +175,11 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
if (IS_ERR(priv.base))
return PTR_ERR(priv.base);
- np = of_find_node_by_path("/cpus/cpu@0");
- if (!np)
+ np = of_cpu_device_node_get(0);
+ if (!np) {
+ dev_err(&pdev->dev, "failed to get cpu device node\n");
return -ENODEV;
+ }
priv.cpu_clk = of_clk_get_by_name(np, "cpu_clk");
if (IS_ERR(priv.cpu_clk)) {
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* Re: [PATCH v3 12/16] cpufreq: kirkwood-cpufreq: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 12/16] cpufreq: kirkwood-cpufreq: " Sudeep KarkadaNagesha
@ 2013-07-23 9:25 ` Andrew Lunn
0 siblings, 0 replies; 61+ messages in thread
From: Andrew Lunn @ 2013-07-23 9:25 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree,
Russell King, Shawn Guo, Gregory Clement, Greg Kroah-Hartman,
Viresh Kumar, Rafael J. Wysocki, Grant Likely, Rob Herring,
Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann, Andrew Lunn,
Jason Cooper
On Mon, Jul 22, 2013 at 12:32:23PM +0100, Sudeep KarkadaNagesha wrote:
> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> Now that the cpu device registration initialises the of_node(if available)
> appropriately for all the cpus, parsing here is redundant.
>
> This patch removes all DT parsing and uses cpu->of_node instead.
>
> Cc: Andrew Lunn <andrew@lunn.ch>
> Cc: Jason Cooper <jason@lakedaemon.net>
> Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> ---
> drivers/cpufreq/kirkwood-cpufreq.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/cpufreq/kirkwood-cpufreq.c b/drivers/cpufreq/kirkwood-cpufreq.c
> index c233ea6..25ac2cb 100644
> --- a/drivers/cpufreq/kirkwood-cpufreq.c
> +++ b/drivers/cpufreq/kirkwood-cpufreq.c
> @@ -14,7 +14,7 @@
> #include <linux/clk.h>
> #include <linux/clk-provider.h>
> #include <linux/cpufreq.h>
> -#include <linux/of.h>
> +#include <linux/of_device.h>
> #include <linux/platform_device.h>
> #include <linux/io.h>
> #include <asm/proc-fns.h>
> @@ -175,9 +175,11 @@ static int kirkwood_cpufreq_probe(struct platform_device *pdev)
> if (IS_ERR(priv.base))
> return PTR_ERR(priv.base);
>
> - np = of_find_node_by_path("/cpus/cpu@0");
> - if (!np)
> + np = of_cpu_device_node_get(0);
> + if (!np) {
> + dev_err(&pdev->dev, "failed to get cpu device node\n");
> return -ENODEV;
> + }
>
> priv.cpu_clk = of_clk_get_by_name(np, "cpu_clk");
> if (IS_ERR(priv.cpu_clk)) {
> --
> 1.8.1.2
Hi Sudeep
I've not had chance to test it, but it looks O.K.
Acked-by: Andrew Lunn <andrew@lunn.ch>
Andrew
^ permalink raw reply [flat|nested] 61+ messages in thread
* [PATCH v3 13/16] cpufreq: arm_big_little: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (11 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 12/16] cpufreq: kirkwood-cpufreq: " Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 14/16] cpufreq: maple-cpufreq: " Sudeep KarkadaNagesha
` (3 subsequent siblings)
16 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Now that the cpu device registration initialises the of_node(if available)
appropriately for all the cpus, parsing here is redundant.
This patch removes all DT parsing and uses cpu->of_node instead.
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/cpufreq/arm_big_little_dt.c | 40 +++++++++++++------------------------
1 file changed, 14 insertions(+), 26 deletions(-)
diff --git a/drivers/cpufreq/arm_big_little_dt.c b/drivers/cpufreq/arm_big_little_dt.c
index fd9e3ea..480c0bd 100644
--- a/drivers/cpufreq/arm_big_little_dt.c
+++ b/drivers/cpufreq/arm_big_little_dt.c
@@ -19,12 +19,11 @@
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
-#include <linux/cpu.h>
#include <linux/cpufreq.h>
#include <linux/device.h>
#include <linux/export.h>
#include <linux/module.h>
-#include <linux/of.h>
+#include <linux/of_device.h>
#include <linux/opp.h>
#include <linux/platform_device.h>
#include <linux/slab.h>
@@ -34,27 +33,13 @@
/* get cpu node with valid operating-points */
static struct device_node *get_cpu_node_with_valid_op(int cpu)
{
- struct device_node *np = NULL, *parent;
- int count = 0;
+ struct device_node *np = of_cpu_device_node_get(cpu);
- parent = of_find_node_by_path("/cpus");
- if (!parent) {
- pr_err("failed to find OF /cpus\n");
- return NULL;
+ if (!of_get_property(np, "operating-points", NULL)) {
+ of_node_put(np);
+ np = NULL;
}
- for_each_child_of_node(parent, np) {
- if (count++ != cpu)
- continue;
- if (!of_get_property(np, "operating-points", NULL)) {
- of_node_put(np);
- np = NULL;
- }
-
- break;
- }
-
- of_node_put(parent);
return np;
}
@@ -63,11 +48,12 @@ static int dt_init_opp_table(struct device *cpu_dev)
struct device_node *np;
int ret;
- np = get_cpu_node_with_valid_op(cpu_dev->id);
- if (!np)
- return -ENODATA;
+ np = of_node_get(cpu_dev->of_node);
+ if (!np) {
+ pr_err("failed to find cpu%d node\n", cpu_dev->id);
+ return -ENOENT;
+ }
- cpu_dev->of_node = np;
ret = of_init_opp_table(cpu_dev);
of_node_put(np);
@@ -79,9 +65,11 @@ static int dt_get_transition_latency(struct device *cpu_dev)
struct device_node *np;
u32 transition_latency = CPUFREQ_ETERNAL;
- np = get_cpu_node_with_valid_op(cpu_dev->id);
- if (!np)
+ np = of_node_get(cpu_dev->of_node);
+ if (!np) {
+ pr_info("Failed to find cpu node. Use CPUFREQ_ETERNAL transition latency\n");
return CPUFREQ_ETERNAL;
+ }
of_property_read_u32(np, "clock-latency", &transition_latency);
of_node_put(np);
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* [PATCH v3 14/16] cpufreq: maple-cpufreq: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (12 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 13/16] cpufreq: arm_big_little: " Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 15/16] cpufreq: pmac64-cpufreq: " Sudeep KarkadaNagesha
` (2 subsequent siblings)
16 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha, Dmitry Eremin-Solenikov
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Now that the cpu device registration initialises the of_node(if available)
appropriately for all the cpus, parsing here is redundant.
This patch removes all DT parsing and uses cpu->of_node instead.
Cc: Dmitry Eremin-Solenikov <dbaryshkov@gmail.com>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/cpufreq/maple-cpufreq.c | 23 +++--------------------
1 file changed, 3 insertions(+), 20 deletions(-)
diff --git a/drivers/cpufreq/maple-cpufreq.c b/drivers/cpufreq/maple-cpufreq.c
index cdd6291..f071dc4 100644
--- a/drivers/cpufreq/maple-cpufreq.c
+++ b/drivers/cpufreq/maple-cpufreq.c
@@ -24,7 +24,7 @@
#include <linux/completion.h>
#include <linux/mutex.h>
#include <linux/time.h>
-#include <linux/of.h>
+#include <linux/of_device.h>
#define DBG(fmt...) pr_debug(fmt)
@@ -201,7 +201,6 @@ static struct cpufreq_driver maple_cpufreq_driver = {
static int __init maple_cpufreq_init(void)
{
- struct device_node *cpus;
struct device_node *cpunode;
unsigned int psize;
unsigned long max_freq;
@@ -217,24 +216,11 @@ static int __init maple_cpufreq_init(void)
!of_machine_is_compatible("Momentum,Apache"))
return 0;
- cpus = of_find_node_by_path("/cpus");
- if (cpus == NULL) {
- DBG("No /cpus node !\n");
- return -ENODEV;
- }
-
/* Get first CPU node */
- for (cpunode = NULL;
- (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) {
- const u32 *reg = of_get_property(cpunode, "reg", NULL);
- if (reg == NULL || (*reg) != 0)
- continue;
- if (!strcmp(cpunode->type, "cpu"))
- break;
- }
+ cpunode = of_cpu_device_node_get(0);
if (cpunode == NULL) {
printk(KERN_ERR "cpufreq: Can't find any CPU 0 node\n");
- goto bail_cpus;
+ goto bail_noprops;
}
/* Check 970FX for now */
@@ -290,14 +276,11 @@ static int __init maple_cpufreq_init(void)
rc = cpufreq_register_driver(&maple_cpufreq_driver);
of_node_put(cpunode);
- of_node_put(cpus);
return rc;
bail_noprops:
of_node_put(cpunode);
-bail_cpus:
- of_node_put(cpus);
return rc;
}
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* [PATCH v3 15/16] cpufreq: pmac64-cpufreq: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (13 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 14/16] cpufreq: maple-cpufreq: " Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-07-22 11:32 ` [PATCH v3 16/16] cpufreq: pmac32-cpufreq: " Sudeep KarkadaNagesha
2013-08-01 10:05 ` [PATCH v3 00/16] DT/core: update cpu device of_node Sudeep KarkadaNagesha
16 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha, Benjamin Herrenschmidt
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Now that the cpu device registration initialises the of_node(if available)
appropriately for all the cpus, parsing here is redundant.
This patch removes all DT parsing and uses cpu->of_node instead.
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/cpufreq/pmac64-cpufreq.c | 47 ++++++++++------------------------------
1 file changed, 11 insertions(+), 36 deletions(-)
diff --git a/drivers/cpufreq/pmac64-cpufreq.c b/drivers/cpufreq/pmac64-cpufreq.c
index 7ba4234..97b719f 100644
--- a/drivers/cpufreq/pmac64-cpufreq.c
+++ b/drivers/cpufreq/pmac64-cpufreq.c
@@ -22,6 +22,7 @@
#include <linux/init.h>
#include <linux/completion.h>
#include <linux/mutex.h>
+#include <linux/of_device.h>
#include <asm/prom.h>
#include <asm/machdep.h>
#include <asm/irq.h>
@@ -383,9 +384,8 @@ static struct cpufreq_driver g5_cpufreq_driver = {
#ifdef CONFIG_PMAC_SMU
-static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
+static int __init g5_neo2_cpufreq_init(struct device_node *cpunode)
{
- struct device_node *cpunode;
unsigned int psize, ssize;
unsigned long max_freq;
char *freq_method, *volt_method;
@@ -405,20 +405,6 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
else
return -ENODEV;
- /* Get first CPU node */
- for (cpunode = NULL;
- (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) {
- const u32 *reg = of_get_property(cpunode, "reg", NULL);
- if (reg == NULL || (*reg) != 0)
- continue;
- if (!strcmp(cpunode->type, "cpu"))
- break;
- }
- if (cpunode == NULL) {
- printk(KERN_ERR "cpufreq: Can't find any CPU 0 node\n");
- return -ENODEV;
- }
-
/* Check 970FX for now */
valp = of_get_property(cpunode, "cpu-version", NULL);
if (!valp) {
@@ -537,9 +523,9 @@ static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
#endif /* CONFIG_PMAC_SMU */
-static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
+static int __init g5_pm72_cpufreq_init(struct device_node *cpunode)
{
- struct device_node *cpuid = NULL, *hwclock = NULL, *cpunode = NULL;
+ struct device_node *cpuid = NULL, *hwclock = NULL;
const u8 *eeprom = NULL;
const u32 *valp;
u64 max_freq, min_freq, ih, il;
@@ -548,17 +534,6 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
DBG("cpufreq: Initializing for PowerMac7,2, PowerMac7,3 and"
" RackMac3,1...\n");
- /* Get first CPU node */
- for (cpunode = NULL;
- (cpunode = of_get_next_child(cpus, cpunode)) != NULL;) {
- if (!strcmp(cpunode->type, "cpu"))
- break;
- }
- if (cpunode == NULL) {
- printk(KERN_ERR "cpufreq: Can't find any CPU node\n");
- return -ENODEV;
- }
-
/* Lookup the cpuid eeprom node */
cpuid = of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/cpuid@a0");
if (cpuid != NULL)
@@ -718,25 +693,25 @@ static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
static int __init g5_cpufreq_init(void)
{
- struct device_node *cpus;
+ struct device_node *cpunode;
int rc = 0;
- cpus = of_find_node_by_path("/cpus");
- if (cpus == NULL) {
- DBG("No /cpus node !\n");
+ /* Get first CPU node */
+ cpunode = of_cpu_device_node_get(0);
+ if (cpunode == NULL) {
+ pr_err("cpufreq: Can't find any CPU node\n");
return -ENODEV;
}
if (of_machine_is_compatible("PowerMac7,2") ||
of_machine_is_compatible("PowerMac7,3") ||
of_machine_is_compatible("RackMac3,1"))
- rc = g5_pm72_cpufreq_init(cpus);
+ rc = g5_pm72_cpufreq_init(cpunode);
#ifdef CONFIG_PMAC_SMU
else
- rc = g5_neo2_cpufreq_init(cpus);
+ rc = g5_neo2_cpufreq_init(cpunode);
#endif /* CONFIG_PMAC_SMU */
- of_node_put(cpus);
return rc;
}
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* [PATCH v3 16/16] cpufreq: pmac32-cpufreq: remove device tree parsing for cpu nodes
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (14 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 15/16] cpufreq: pmac64-cpufreq: " Sudeep KarkadaNagesha
@ 2013-07-22 11:32 ` Sudeep KarkadaNagesha
2013-08-01 10:05 ` [PATCH v3 00/16] DT/core: update cpu device of_node Sudeep KarkadaNagesha
16 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-07-22 11:32 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, cpufreq, linux-pm, devicetree
Cc: Sudeep.KarkadaNagesha, Russell King, Shawn Guo, Gregory Clement,
Greg Kroah-Hartman, Viresh Kumar, Rafael J. Wysocki, Grant Likely,
Rob Herring, Lorenzo Pieralisi, Olof Johansson, Arnd Bergmann,
Sudeep KarkadaNagesha, Benjamin Herrenschmidt
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
Now that the cpu device registration initialises the of_node(if available)
appropriately for all the cpus, parsing here is redundant.
This patch removes DT parsing and uses cpu->of_node instead.
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
drivers/cpufreq/pmac32-cpufreq.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/pmac32-cpufreq.c b/drivers/cpufreq/pmac32-cpufreq.c
index 3104fad..56bfb6f 100644
--- a/drivers/cpufreq/pmac32-cpufreq.c
+++ b/drivers/cpufreq/pmac32-cpufreq.c
@@ -25,6 +25,7 @@
#include <linux/init.h>
#include <linux/device.h>
#include <linux/hardirq.h>
+#include <linux/of_device.h>
#include <asm/prom.h>
#include <asm/machdep.h>
#include <asm/irq.h>
@@ -649,8 +650,8 @@ static int __init pmac_cpufreq_setup(void)
if (strstr(cmd_line, "nocpufreq"))
return 0;
- /* Assume only one CPU */
- cpunode = of_find_node_by_type(NULL, "cpu");
+ /* Get first CPU node */
+ cpunode = of_cpu_device_node_get(0);
if (!cpunode)
goto out;
--
1.8.1.2
^ permalink raw reply related [flat|nested] 61+ messages in thread* Re: [PATCH v3 00/16] DT/core: update cpu device of_node
2013-07-22 11:32 ` [PATCH v3 00/16] " Sudeep KarkadaNagesha
` (15 preceding siblings ...)
2013-07-22 11:32 ` [PATCH v3 16/16] cpufreq: pmac32-cpufreq: " Sudeep KarkadaNagesha
@ 2013-08-01 10:05 ` Sudeep KarkadaNagesha
16 siblings, 0 replies; 61+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-01 10:05 UTC (permalink / raw)
To: Sudeep KarkadaNagesha, Viresh Kumar, Rafael J. Wysocki,
rob.herring@calxeda.com, Olof Johansson
Cc: linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, cpufreq@vger.kernel.org,
linux-pm@vger.kernel.org, devicetree@vger.kernel.org,
Russell King, Shawn Guo, Gregory Clement, Greg Kroah-Hartman,
grant.likely@linaro.org, Lorenzo Pieralisi, Arnd Bergmann
On 22/07/13 12:32, Sudeep KarkadaNagesha wrote:
> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>
> As more and more information is getting added into the cpu node, the number
> of drivers needing to parse the device tree for CPU nodes are increasing.
> Most of the time, the information needed from the cpu node is preferred
> in the logical CPU order. Hence many drivers first parse and search the
> CPU node, match them to logical index if needed and then search for the
> required property inside a particular cpu node. Some of them assume the
> logical and physical CPU ordering to be same which is incorrect.
>
> This patch series initialises the of_node in all the cpu devices when
> registering the CPU device.
> 1. This avoids different drivers having to parse the cpu nodes to obtain
> different attributes like operating points, latency,...etc.
> 2. This handles different physical and logical cpu ordering which is not
> the case in current code.
> 3. Also all the cpu nodes will have their of_node initialised correctly.
> Currently different drivers assign them partially and incorrectly.
> 4. Removes all the reduntant parsing in various drivers.
>
> Changes v2->v3:
> 1. Added new OF helper to get of_node from the cpu logical index.
> With the use of this help, removed lots of duplicated code from
> cpufreq drivers.
> 2. Fixed issue with property length calculation in of_get_cpu_node.
> (previously had assumed of_get_property returns number of cells)
> 3. Changed return type of arch_match_cpu_phys_id to bool(as suggested by Nico)
> 4. Re-ordered patch 2 and 3, and few typo fixes.
> 5. Rebased on v3.11-rc2(to avoid any conflicts with __cpuinit* deletion)
>
> Changes v1->v2:
> 1. Moved most of arch_of_get_cpu_node to OF/DT core as of_get_cpu_node
> adding a provision for architecture specific hooks for matching
> logical and physical ids.
> 2. Extended removal of DT cpu node parsing to PPC cpufreq drivers
> 3. Added Acks from Viresh and Shawn
>
> Regards,
> Sudeep
>
> Sudeep KarkadaNagesha (16):
Hi Rob,Olof,Rafael,
Since these changes are spread across multiple sub-systems, is it fine
if I split this and send pull request as below:
1. DT
of: add support for retrieving cpu node for a given logical cpu index
ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id
driver/core: cpu: initialize of_node in cpu's device struture
of/device: add helper to get cpu device node from logical cpu index
2. ARM SoC(clearly specifying dependency on 1)
ARM: topology: remove hwid/MPIDR dependency from cpu_capacity
ARM: mvebu: remove device tree parsing for cpu nodes
drivers/bus: arm-cci: avoid parsing DT for cpu device nodes
3. CPUFreq(clearly specifying dependency on 1)
cpufreq: imx6q-cpufreq: remove device tree parsing for cpu nodes
cpufreq: cpufreq-cpu0: remove device tree parsing for cpu nodes
cpufreq: highbank-cpufreq: remove device tree parsing for cpu nodes
cpufreq: spear-cpufreq: remove device tree parsing for cpu nodes
cpufreq: kirkwood-cpufreq: remove device tree parsing for cpu nodes
cpufreq: arm_big_little: remove device tree parsing for cpu nodes
cpufreq: maple-cpufreq: remove device tree parsing for cpu nodes
cpufreq: pmac64-cpufreq: remove device tree parsing for cpu nodes
cpufreq: pmac32-cpufreq: remove device tree parsing for cpu nodes
Regards,
Sudeep
> arch/arm/kernel/devtree.c | 5 +++
> arch/arm/kernel/topology.c | 61 ++++++++++---------------------
> arch/arm/mach-imx/mach-imx6q.c | 3 +-
> arch/arm/mach-mvebu/platsmp.c | 52 +++++++++++++--------------
> drivers/base/cpu.c | 2 ++
> drivers/bus/arm-cci.c | 28 ++++-----------
> drivers/cpufreq/arm_big_little_dt.c | 40 ++++++++-------------
> drivers/cpufreq/cpufreq-cpu0.c | 23 +++---------
> drivers/cpufreq/highbank-cpufreq.c | 18 ++++------
> drivers/cpufreq/imx6q-cpufreq.c | 4 +--
> drivers/cpufreq/kirkwood-cpufreq.c | 8 +++--
> drivers/cpufreq/maple-cpufreq.c | 23 ++----------
> drivers/cpufreq/pmac32-cpufreq.c | 5 +--
> drivers/cpufreq/pmac64-cpufreq.c | 47 ++++++------------------
> drivers/cpufreq/spear-cpufreq.c | 4 +--
> drivers/of/base.c | 72 +++++++++++++++++++++++++++++++++++++
> include/linux/of.h | 6 ++++
> include/linux/of_device.h | 15 ++++++++
> 18 files changed, 200 insertions(+), 216 deletions(-)
>
^ permalink raw reply [flat|nested] 61+ messages in thread