* [PATCH v4 01/19] microblaze: remove undefined of_get_cpu_node declaration
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 02/19] openrisc: " Sudeep KarkadaNagesha
` (17 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
This patch removes the declaration of the function 'of_get_cpu_node'
which is not defined for microblaze. This is in preparation to move
it's definition from PPC to DT common code.
Michal Simek says: "it was just there because Microblaze
was based on powerpc code"
Acked-by: Michal Simek <monstr@monstr.eu>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
arch/microblaze/include/asm/prom.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/microblaze/include/asm/prom.h b/arch/microblaze/include/a=
sm/prom.h
index 20c5e8e..9977816 100644
--- a/arch/microblaze/include/asm/prom.h
+++ b/arch/microblaze/include/asm/prom.h
@@ -50,9 +50,6 @@ void of_parse_dma_window(struct device_node *dn, const vo=
id *dma_window_prop,
=20
extern void kdump_move_device_tree(void);
=20
-/* CPU OF node matching */
-struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
-
#endif /* __ASSEMBLY__ */
#endif /* __KERNEL__ */
=20
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 02/19] openrisc: remove undefined of_get_cpu_node declaration
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 01/19] microblaze: remove undefined of_get_cpu_node declaration Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 03/19] powerpc: refactor of_get_cpu_node to support other architectures Sudeep KarkadaNagesha
` (16 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
This patch removes the declaration of the function 'of_get_cpu_node'
which is not defined for openrisc. This is in preparation to move
it's definition from PPC to DT common code.
Again it could be there as it was originally copied from powerpc.
Cc: Jonas Bonn <jonas@southpole.se>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
arch/openrisc/include/asm/prom.h | 3 ---
1 file changed, 3 deletions(-)
diff --git a/arch/openrisc/include/asm/prom.h b/arch/openrisc/include/asm/p=
rom.h
index bbb34e5..eb59bfe 100644
--- a/arch/openrisc/include/asm/prom.h
+++ b/arch/openrisc/include/asm/prom.h
@@ -44,9 +44,6 @@ void of_parse_dma_window(struct device_node *dn, const vo=
id *dma_window_prop,
=20
extern void kdump_move_device_tree(void);
=20
-/* CPU OF node matching */
-struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
-
/* Get the MAC address */
extern const void *of_get_mac_address(struct device_node *np);
=20
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 03/19] powerpc: refactor of_get_cpu_node to support other architectures
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 01/19] microblaze: remove undefined of_get_cpu_node declaration Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 02/19] openrisc: " Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 12:27 ` Rafael J. Wysocki
2013-08-22 6:15 ` Benjamin Herrenschmidt
2013-08-20 9:30 ` [PATCH v4 04/19] of: move of_get_cpu_node implementation to DT core library Sudeep KarkadaNagesha
` (15 subsequent siblings)
18 siblings, 2 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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.
PowerPC has it's own implementation to get the cpu node for a given
logical index.
This patch refactors the current implementation of of_get_cpu_node.
This in preparation to move the implementation to DT core library.
It separates out the logical to physical mapping so that a default
matching of the physical id to the logical cpu index can be added
when moved to common code. Architecture specific code can override it.
Cc: Rob Herring <rob.herring@calxeda.com>
Cc: Grant Likely <grant.likely@linaro.org>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
arch/powerpc/kernel/prom.c | 76 ++++++++++++++++++++++++++++--------------=
----
1 file changed, 47 insertions(+), 29 deletions(-)
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index eb23ac9..f7b8c0b 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -865,45 +865,63 @@ static int __init prom_reconfig_setup(void)
__initcall(prom_reconfig_setup);
#endif
=20
+bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
+{
+=09return (int)phys_id =3D=3D get_hard_smp_processor_id(cpu);
+}
+
+static bool __of_find_n_match_cpu_property(struct device_node *cpun,
+=09=09=09const char *prop_name, int cpu, unsigned int *thread)
+{
+=09const __be32 *cell;
+=09int ac, prop_len, tid;
+=09u64 hwid;
+
+=09ac =3D of_n_addr_cells(cpun);
+=09cell =3D of_get_property(cpun, prop_name, &prop_len);
+=09if (!cell)
+=09=09return false;
+=09prop_len /=3D sizeof(*cell);
+=09for (tid =3D 0; tid < prop_len; tid++) {
+=09=09hwid =3D of_read_number(cell, ac);
+=09=09if (arch_match_cpu_phys_id(cpu, hwid)) {
+=09=09=09if (thread)
+=09=09=09=09*thread =3D tid;
+=09=09=09return true;
+=09=09}
+=09=09cell +=3D ac;
+=09}
+=09return false;
+}
+
/* Find the device node for a given logical cpu number, also returns the c=
pu
* local thread number (index in ibm,interrupt-server#s) if relevant and
* asked for (non NULL)
*/
struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
{
-=09int hardid;
-=09struct device_node *np;
+=09struct device_node *cpun, *cpus;
=20
-=09hardid =3D get_hard_smp_processor_id(cpu);
+=09cpus =3D of_find_node_by_path("/cpus");
+=09if (!cpus) {
+=09=09pr_warn("Missing cpus node, bailing out\n");
+=09=09return NULL;
+=09}
=20
-=09for_each_node_by_type(np, "cpu") {
-=09=09const u32 *intserv;
-=09=09unsigned int plen, t;
+=09for_each_child_of_node(cpus, cpun) {
+=09=09if (of_node_cmp(cpun->type, "cpu"))
+=09=09=09continue;
=20
-=09=09/* Check for ibm,ppc-interrupt-server#s. If it doesn't exist
-=09=09 * fallback to "reg" property and assume no threads
+=09=09/* Check for non-standard "ibm,ppc-interrupt-server#s" property
+=09=09 * for thread ids on PowerPC. If it doesn't exist fallback to
+=09=09 * standard "reg" property.
=09=09 */
-=09=09intserv =3D of_get_property(np, "ibm,ppc-interrupt-server#s",
-=09=09=09=09&plen);
-=09=09if (intserv =3D=3D NULL) {
-=09=09=09const u32 *reg =3D of_get_property(np, "reg", NULL);
-=09=09=09if (reg =3D=3D NULL)
-=09=09=09=09continue;
-=09=09=09if (*reg =3D=3D hardid) {
-=09=09=09=09if (thread)
-=09=09=09=09=09*thread =3D 0;
-=09=09=09=09return np;
-=09=09=09}
-=09=09} else {
-=09=09=09plen /=3D sizeof(u32);
-=09=09=09for (t =3D 0; t < plen; t++) {
-=09=09=09=09if (hardid =3D=3D intserv[t]) {
-=09=09=09=09=09if (thread)
-=09=09=09=09=09=09*thread =3D t;
-=09=09=09=09=09return np;
-=09=09=09=09}
-=09=09=09}
-=09=09}
+=09=09if (__of_find_n_match_cpu_property(cpun,
+=09=09=09=09"ibm,ppc-interrupt-server#s", cpu, thread))
+=09=09=09return cpun;
+
+=09=09if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
+=09=09=09return cpun;
=09}
=09return NULL;
}
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* Re: [PATCH v4 03/19] powerpc: refactor of_get_cpu_node to support other architectures
2013-08-20 9:30 ` [PATCH v4 03/19] powerpc: refactor of_get_cpu_node to support other architectures Sudeep KarkadaNagesha
@ 2013-08-20 12:27 ` Rafael J. Wysocki
2013-08-20 12:22 ` Sudeep KarkadaNagesha
2013-08-22 6:15 ` Benjamin Herrenschmidt
1 sibling, 1 reply; 66+ messages in thread
From: Rafael J. Wysocki @ 2013-08-20 12:27 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm,
Sudeep KarkadaNagesha, Viresh Kumar, linux-kernel, Rob Herring,
Greg Kroah-Hartman, Grant Likely, linuxppc-dev, linux-arm-kernel
On Tuesday, August 20, 2013 10:30:05 AM 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.
>
> PowerPC has it's own implementation to get the cpu node for a given
> logical index.
>
> This patch refactors the current implementation of of_get_cpu_node.
> This in preparation to move the implementation to DT core library.
> It separates out the logical to physical mapping so that a default
> matching of the physical id to the logical cpu index can be added
> when moved to common code. Architecture specific code can override it.
>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Grant Likely <grant.likely@linaro.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
This needs an ACK from Ben to go anywhere.
Thanks,
Rafael
> ---
> arch/powerpc/kernel/prom.c | 76 ++++++++++++++++++++++++++++------------------
> 1 file changed, 47 insertions(+), 29 deletions(-)
>
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index eb23ac9..f7b8c0b 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -865,45 +865,63 @@ static int __init prom_reconfig_setup(void)
> __initcall(prom_reconfig_setup);
> #endif
>
> +bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
> +{
> + return (int)phys_id == get_hard_smp_processor_id(cpu);
> +}
> +
> +static bool __of_find_n_match_cpu_property(struct device_node *cpun,
> + const char *prop_name, int cpu, unsigned int *thread)
> +{
> + const __be32 *cell;
> + int ac, prop_len, tid;
> + u64 hwid;
> +
> + ac = of_n_addr_cells(cpun);
> + cell = of_get_property(cpun, prop_name, &prop_len);
> + if (!cell)
> + return false;
> + prop_len /= sizeof(*cell);
> + for (tid = 0; tid < prop_len; tid++) {
> + hwid = of_read_number(cell, ac);
> + if (arch_match_cpu_phys_id(cpu, hwid)) {
> + if (thread)
> + *thread = tid;
> + return true;
> + }
> + cell += ac;
> + }
> + return false;
> +}
> +
> /* Find the device node for a given logical cpu number, also returns the cpu
> * local thread number (index in ibm,interrupt-server#s) if relevant and
> * asked for (non NULL)
> */
> struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
> {
> - int hardid;
> - struct device_node *np;
> + struct device_node *cpun, *cpus;
>
> - hardid = get_hard_smp_processor_id(cpu);
> + cpus = of_find_node_by_path("/cpus");
> + if (!cpus) {
> + pr_warn("Missing cpus node, bailing out\n");
> + return NULL;
> + }
>
> - for_each_node_by_type(np, "cpu") {
> - const u32 *intserv;
> - unsigned int plen, t;
> + for_each_child_of_node(cpus, cpun) {
> + if (of_node_cmp(cpun->type, "cpu"))
> + continue;
>
> - /* Check for ibm,ppc-interrupt-server#s. If it doesn't exist
> - * fallback to "reg" property and assume no threads
> + /* Check for non-standard "ibm,ppc-interrupt-server#s" property
> + * for thread ids on PowerPC. If it doesn't exist fallback to
> + * standard "reg" property.
> */
> - intserv = of_get_property(np, "ibm,ppc-interrupt-server#s",
> - &plen);
> - if (intserv == NULL) {
> - const u32 *reg = of_get_property(np, "reg", NULL);
> - if (reg == NULL)
> - continue;
> - if (*reg == hardid) {
> - if (thread)
> - *thread = 0;
> - return np;
> - }
> - } else {
> - plen /= sizeof(u32);
> - for (t = 0; t < plen; t++) {
> - if (hardid == intserv[t]) {
> - if (thread)
> - *thread = t;
> - return np;
> - }
> - }
> - }
> + if (__of_find_n_match_cpu_property(cpun,
> + "ibm,ppc-interrupt-server#s", cpu, thread))
> + return cpun;
> +
> + if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
> + return cpun;
> }
> return NULL;
> }
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 66+ messages in thread
* Re: [PATCH v4 03/19] powerpc: refactor of_get_cpu_node to support other architectures
2013-08-20 12:27 ` Rafael J. Wysocki
@ 2013-08-20 12:22 ` Sudeep KarkadaNagesha
2013-08-20 21:48 ` Benjamin Herrenschmidt
0 siblings, 1 reply; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 12:22 UTC (permalink / raw)
To: Rafael J. Wysocki, Benjamin Herrenschmidt
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm,
Sudeep KarkadaNagesha, Viresh Kumar, linux-kernel, rob.herring,
Greg Kroah-Hartman, grant.likely, linuxppc-dev, linux-arm-kernel
On 20/08/13 13:27, Rafael J. Wysocki wrote:
> On Tuesday, August 20, 2013 10:30:05 AM 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.
>>
>> PowerPC has it's own implementation to get the cpu node for a given
>> logical index.
>>
>> This patch refactors the current implementation of of_get_cpu_node.
>> This in preparation to move the implementation to DT core library.
>> It separates out the logical to physical mapping so that a default
>> matching of the physical id to the logical cpu index can be added
>> when moved to common code. Architecture specific code can override it.
>>
>> Cc: Rob Herring <rob.herring@calxeda.com>
>> Cc: Grant Likely <grant.likely@linaro.org>
>> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>=20
> This needs an ACK from Ben to go anywhere.
>=20
Hi Rafael,
Correct, he has reviewed but I am waiting for his ACK before I could
sent you pull request. Hopefully I should be able to send pull request
tomorrow with his ACK.
Hi Ben,
If this is patch is fine, can I have your ACK ?
Regards,
Sudeep
^ permalink raw reply [flat|nested] 66+ messages in thread
* Re: [PATCH v4 03/19] powerpc: refactor of_get_cpu_node to support other architectures
2013-08-20 12:22 ` Sudeep KarkadaNagesha
@ 2013-08-20 21:48 ` Benjamin Herrenschmidt
0 siblings, 0 replies; 66+ messages in thread
From: Benjamin Herrenschmidt @ 2013-08-20 21:48 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm, Viresh Kumar,
linux-kernel, rob.herring, Rafael J. Wysocki, Greg Kroah-Hartman,
grant.likely, linuxppc-dev, linux-arm-kernel
On Tue, 2013-08-20 at 13:22 +0100, Sudeep KarkadaNagesha wrote:
> Correct, he has reviewed but I am waiting for his ACK before I could
> sent you pull request. Hopefully I should be able to send pull request
> tomorrow with his ACK.
>
> Hi Ben,
>
> If this is patch is fine, can I have your ACK ?
I just want to test it (just in case...), will give an Ack then.
Cheers,
Ben.
^ permalink raw reply [flat|nested] 66+ messages in thread
* Re: [PATCH v4 03/19] powerpc: refactor of_get_cpu_node to support other architectures
2013-08-20 9:30 ` [PATCH v4 03/19] powerpc: refactor of_get_cpu_node to support other architectures Sudeep KarkadaNagesha
2013-08-20 12:27 ` Rafael J. Wysocki
@ 2013-08-22 6:15 ` Benjamin Herrenschmidt
2013-08-22 13:29 ` Sudeep KarkadaNagesha
1 sibling, 1 reply; 66+ messages in thread
From: Benjamin Herrenschmidt @ 2013-08-22 6:15 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm, Viresh Kumar,
linux-kernel, Rob Herring, Rafael J. Wysocki, Greg Kroah-Hartman,
Grant Likely, linuxppc-dev, linux-arm-kernel
On Tue, 2013-08-20 at 10:30 +0100, 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.
>
> PowerPC has it's own implementation to get the cpu node for a given
> logical index.
>
> This patch refactors the current implementation of of_get_cpu_node.
> This in preparation to move the implementation to DT core library.
> It separates out the logical to physical mapping so that a default
> matching of the physical id to the logical cpu index can be added
> when moved to common code. Architecture specific code can override it.
So the patch unfortunately collides with other changes in powerpc -next,
though it's not a huge deal and not hard to fixup, but expect Linus
to tick unless we sort it out some other way.
Appart from that, it's fine, builds on all my test configs and doesn't
seem to negatively impact things as far as I can tell so far...
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Rob Herring <rob.herring@calxeda.com>
> Cc: Grant Likely <grant.likely@linaro.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
> ---
> arch/powerpc/kernel/prom.c | 76 ++++++++++++++++++++++++++++------------------
> 1 file changed, 47 insertions(+), 29 deletions(-)
>
> diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
> index eb23ac9..f7b8c0b 100644
> --- a/arch/powerpc/kernel/prom.c
> +++ b/arch/powerpc/kernel/prom.c
> @@ -865,45 +865,63 @@ static int __init prom_reconfig_setup(void)
> __initcall(prom_reconfig_setup);
> #endif
>
> +bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
> +{
> + return (int)phys_id == get_hard_smp_processor_id(cpu);
> +}
> +
> +static bool __of_find_n_match_cpu_property(struct device_node *cpun,
> + const char *prop_name, int cpu, unsigned int *thread)
> +{
> + const __be32 *cell;
> + int ac, prop_len, tid;
> + u64 hwid;
> +
> + ac = of_n_addr_cells(cpun);
> + cell = of_get_property(cpun, prop_name, &prop_len);
> + if (!cell)
> + return false;
> + prop_len /= sizeof(*cell);
> + for (tid = 0; tid < prop_len; tid++) {
> + hwid = of_read_number(cell, ac);
> + if (arch_match_cpu_phys_id(cpu, hwid)) {
> + if (thread)
> + *thread = tid;
> + return true;
> + }
> + cell += ac;
> + }
> + return false;
> +}
> +
> /* Find the device node for a given logical cpu number, also returns the cpu
> * local thread number (index in ibm,interrupt-server#s) if relevant and
> * asked for (non NULL)
> */
> struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
> {
> - int hardid;
> - struct device_node *np;
> + struct device_node *cpun, *cpus;
>
> - hardid = get_hard_smp_processor_id(cpu);
> + cpus = of_find_node_by_path("/cpus");
> + if (!cpus) {
> + pr_warn("Missing cpus node, bailing out\n");
> + return NULL;
> + }
>
> - for_each_node_by_type(np, "cpu") {
> - const u32 *intserv;
> - unsigned int plen, t;
> + for_each_child_of_node(cpus, cpun) {
> + if (of_node_cmp(cpun->type, "cpu"))
> + continue;
>
> - /* Check for ibm,ppc-interrupt-server#s. If it doesn't exist
> - * fallback to "reg" property and assume no threads
> + /* Check for non-standard "ibm,ppc-interrupt-server#s" property
> + * for thread ids on PowerPC. If it doesn't exist fallback to
> + * standard "reg" property.
> */
> - intserv = of_get_property(np, "ibm,ppc-interrupt-server#s",
> - &plen);
> - if (intserv == NULL) {
> - const u32 *reg = of_get_property(np, "reg", NULL);
> - if (reg == NULL)
> - continue;
> - if (*reg == hardid) {
> - if (thread)
> - *thread = 0;
> - return np;
> - }
> - } else {
> - plen /= sizeof(u32);
> - for (t = 0; t < plen; t++) {
> - if (hardid == intserv[t]) {
> - if (thread)
> - *thread = t;
> - return np;
> - }
> - }
> - }
> + if (__of_find_n_match_cpu_property(cpun,
> + "ibm,ppc-interrupt-server#s", cpu, thread))
> + return cpun;
> +
> + if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
> + return cpun;
> }
> return NULL;
> }
^ permalink raw reply [flat|nested] 66+ messages in thread
* Re: [PATCH v4 03/19] powerpc: refactor of_get_cpu_node to support other architectures
2013-08-22 6:15 ` Benjamin Herrenschmidt
@ 2013-08-22 13:29 ` Sudeep KarkadaNagesha
0 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-22 13:29 UTC (permalink / raw)
To: Benjamin Herrenschmidt
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm,
Sudeep KarkadaNagesha, Viresh Kumar, linux-kernel, rob.herring,
Rafael J. Wysocki, Greg Kroah-Hartman, grant.likely,
linuxppc-dev, linux-arm-kernel
On 22/08/13 07:15, Benjamin Herrenschmidt wrote:
> On Tue, 2013-08-20 at 10:30 +0100, 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.
>>
>> PowerPC has it's own implementation to get the cpu node for a given
>> logical index.
>>
>> This patch refactors the current implementation of of_get_cpu_node.
>> This in preparation to move the implementation to DT core library.
>> It separates out the logical to physical mapping so that a default
>> matching of the physical id to the logical cpu index can be added
>> when moved to common code. Architecture specific code can override it.
>=20
> So the patch unfortunately collides with other changes in powerpc -next,
> though it's not a huge deal and not hard to fixup, but expect Linus
> to tick unless we sort it out some other way.
>=20
> Appart from that, it's fine, builds on all my test configs and doesn't
> seem to negatively impact things as far as I can tell so far...
>=20
> Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
>=20
Hi Ben,
Thanks a lot for testing and ACK.
I will check with Rafael about these (trivial) conflicts.
Regards,
Sudeep
^ permalink raw reply [flat|nested] 66+ messages in thread
* [PATCH v4 04/19] of: move of_get_cpu_node implementation to DT core library
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (2 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 03/19] powerpc: refactor of_get_cpu_node to support other architectures Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 05/19] ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id Sudeep KarkadaNagesha
` (14 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
This patch moves the generalized implementation of of_get_cpu_node from
PowerPC to DT core library, thereby adding support for retrieving cpu
node for a given logical cpu index on any architecture.
The CPU subsystem can now use this function to assign of_node in the
cpu device while registering CPUs.
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.
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Grant Likely <grant.likely@linaro.org>
Acked-by: Rob Herring <rob.herring@calxeda.com>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
arch/powerpc/include/asm/prom.h | 3 --
arch/powerpc/kernel/prom.c | 57 -------------------------
drivers/of/base.c | 95 +++++++++++++++++++++++++++++++++++++=
++++
include/linux/cpu.h | 1 +
include/linux/of.h | 7 +++
5 files changed, 103 insertions(+), 60 deletions(-)
diff --git a/arch/powerpc/include/asm/prom.h b/arch/powerpc/include/asm/pro=
m.h
index bc2da15..ac204e0 100644
--- a/arch/powerpc/include/asm/prom.h
+++ b/arch/powerpc/include/asm/prom.h
@@ -43,9 +43,6 @@ void of_parse_dma_window(struct device_node *dn, const vo=
id *dma_window_prop,
=20
extern void kdump_move_device_tree(void);
=20
-/* CPU OF node matching */
-struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
-
/* cache lookup */
struct device_node *of_find_next_cache_node(struct device_node *np);
=20
diff --git a/arch/powerpc/kernel/prom.c b/arch/powerpc/kernel/prom.c
index f7b8c0b..1c14cd4 100644
--- a/arch/powerpc/kernel/prom.c
+++ b/arch/powerpc/kernel/prom.c
@@ -870,63 +870,6 @@ bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
=09return (int)phys_id =3D=3D get_hard_smp_processor_id(cpu);
}
=20
-static bool __of_find_n_match_cpu_property(struct device_node *cpun,
-=09=09=09const char *prop_name, int cpu, unsigned int *thread)
-{
-=09const __be32 *cell;
-=09int ac, prop_len, tid;
-=09u64 hwid;
-
-=09ac =3D of_n_addr_cells(cpun);
-=09cell =3D of_get_property(cpun, prop_name, &prop_len);
-=09if (!cell)
-=09=09return false;
-=09prop_len /=3D sizeof(*cell);
-=09for (tid =3D 0; tid < prop_len; tid++) {
-=09=09hwid =3D of_read_number(cell, ac);
-=09=09if (arch_match_cpu_phys_id(cpu, hwid)) {
-=09=09=09if (thread)
-=09=09=09=09*thread =3D tid;
-=09=09=09return true;
-=09=09}
-=09=09cell +=3D ac;
-=09}
-=09return false;
-}
-
-/* Find the device node for a given logical cpu number, also returns the c=
pu
- * local thread number (index in ibm,interrupt-server#s) if relevant and
- * asked for (non NULL)
- */
-struct device_node *of_get_cpu_node(int cpu, unsigned int *thread)
-{
-=09struct device_node *cpun, *cpus;
-
-=09cpus =3D of_find_node_by_path("/cpus");
-=09if (!cpus) {
-=09=09pr_warn("Missing cpus node, bailing out\n");
-=09=09return NULL;
-=09}
-
-=09for_each_child_of_node(cpus, cpun) {
-=09=09if (of_node_cmp(cpun->type, "cpu"))
-=09=09=09continue;
-
-=09=09/* Check for non-standard "ibm,ppc-interrupt-server#s" property
-=09=09 * for thread ids on PowerPC. If it doesn't exist fallback to
-=09=09 * standard "reg" property.
-=09=09 */
-=09=09if (__of_find_n_match_cpu_property(cpun,
-=09=09=09=09"ibm,ppc-interrupt-server#s", cpu, thread))
-=09=09=09return cpun;
-
-=09=09if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
-=09=09=09return cpun;
-=09}
-=09return NULL;
-}
-EXPORT_SYMBOL(of_get_cpu_node);
-
#if defined(CONFIG_DEBUG_FS) && defined(DEBUG)
static struct debugfs_blob_wrapper flat_dt_blob;
=20
diff --git a/drivers/of/base.c b/drivers/of/base.c
index 5c54279..605afa9 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,100 @@ const void *of_get_property(const struct device_node =
*np, const char *name,
}
EXPORT_SYMBOL(of_get_property);
=20
+/*
+ * arch_match_cpu_phys_id - Match the given logical CPU and physical id
+ *
+ * @cpu: logical cpu index of a core/thread
+ * @phys_id: physical identifier of a core/thread
+ *
+ * CPU logical to physical index mapping is architecture specific.
+ * However this __weak function provides a default match of physical
+ * id to logical cpu index. phys_id provided here is usually values read
+ * from the device tree which must match the hardware internal registers.
+ *
+ * Returns true if the physical identifier and the logical cpu index
+ * correspond to the same core/thread, false otherwise.
+ */
+bool __weak arch_match_cpu_phys_id(int cpu, u64 phys_id)
+{
+=09return (u32)phys_id =3D=3D cpu;
+}
+
+/**
+ * Checks if the given "prop_name" property holds the physical id of the
+ * core/thread corresponding to the logical cpu 'cpu'. If 'thread' is not
+ * NULL, local thread number within the core is returned in it.
+ */
+static bool __of_find_n_match_cpu_property(struct device_node *cpun,
+=09=09=09const char *prop_name, int cpu, unsigned int *thread)
+{
+=09const __be32 *cell;
+=09int ac, prop_len, tid;
+=09u64 hwid;
+
+=09ac =3D of_n_addr_cells(cpun);
+=09cell =3D of_get_property(cpun, prop_name, &prop_len);
+=09if (!cell)
+=09=09return false;
+=09prop_len /=3D sizeof(*cell);
+=09for (tid =3D 0; tid < prop_len; tid++) {
+=09=09hwid =3D of_read_number(cell, ac);
+=09=09if (arch_match_cpu_phys_id(cpu, hwid)) {
+=09=09=09if (thread)
+=09=09=09=09*thread =3D tid;
+=09=09=09return true;
+=09=09}
+=09=09cell +=3D ac;
+=09}
+=09return false;
+}
+
+/**
+ * of_get_cpu_node - Get device node associated with the given logical CPU
+ *
+ * @cpu: CPU number(logical index) for which device node is required
+ * @thread: if not NULL, local thread number within the physical core is
+ * returned
+ *
+ * The main purpose of this function is to retrieve the device node for th=
e
+ * 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 b=
uilt
+ * 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, unsigned int *thread)
+{
+=09struct device_node *cpun, *cpus;
+
+=09cpus =3D of_find_node_by_path("/cpus");
+=09if (!cpus) {
+=09=09pr_warn("Missing cpus node, bailing out\n");
+=09=09return NULL;
+=09}
+
+=09for_each_child_of_node(cpus, cpun) {
+=09=09if (of_node_cmp(cpun->type, "cpu"))
+=09=09=09continue;
+=09=09/* Check for non-standard "ibm,ppc-interrupt-server#s" property
+=09=09 * for thread ids on PowerPC. If it doesn't exist fallback to
+=09=09 * standard "reg" property.
+=09=09 */
+=09=09if (IS_ENABLED(CONFIG_PPC) &&
+=09=09=09__of_find_n_match_cpu_property(cpun,
+=09=09=09=09"ibm,ppc-interrupt-server#s", cpu, thread))
+=09=09=09return cpun;
+=09=09if (__of_find_n_match_cpu_property(cpun, "reg", cpu, thread))
+=09=09=09return cpun;
+=09}
+=09return NULL;
+}
+EXPORT_SYMBOL(of_get_cpu_node);
+
/** 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..3dfed2b 100644
--- a/include/linux/cpu.h
+++ b/include/linux/cpu.h
@@ -28,6 +28,7 @@ struct cpu {
extern int register_cpu(struct cpu *cpu, int num);
extern struct device *get_cpu_device(unsigned cpu);
extern bool cpu_is_hotpluggable(unsigned cpu);
+extern bool arch_match_cpu_phys_id(int cpu, u64 phys_id);
=20
extern int cpu_add_dev_attr(struct device_attribute *attr);
extern void cpu_remove_dev_attr(struct device_attribute *attr);
diff --git a/include/linux/of.h b/include/linux/of.h
index 1fd08ca..c0bb2f1 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -266,6 +266,7 @@ extern int of_device_is_available(const struct device_n=
ode *device);
extern const void *of_get_property(const struct device_node *node,
=09=09=09=09const char *name,
=09=09=09=09int *lenp);
+extern struct device_node *of_get_cpu_node(int cpu, unsigned int *thread);
#define for_each_property_of_node(dn, pp) \
=09for (pp =3D dn->properties; pp !=3D NULL; pp =3D pp->next)
=20
@@ -459,6 +460,12 @@ static inline const void *of_get_property(const struct=
device_node *node,
=09return NULL;
}
=20
+static inline struct device_node *of_get_cpu_node(int cpu,
+=09=09=09=09=09unsigned int *thread)
+{
+=09return NULL;
+}
+
static inline int of_property_read_u64(const struct device_node *np,
=09=09=09=09 const char *propname, u64 *out_value)
{
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 05/19] ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (3 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 04/19] of: move of_get_cpu_node implementation to DT core library Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 06/19] driver/core: cpu: initialize of_node in cpu's device struture Sudeep KarkadaNagesha
` (13 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Lorenzo Pieralisi, Russell King,
Greg Kroah-Hartman, Sudeep KarkadaNagesha, Viresh Kumar,
Rob Herring, Rafael J. Wysocki, Grant Likely
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>
Acked-by: Nicolas Pitre <nico@linaro.org>
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)
=09}
}
=20
+bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
+{
+=09return (phys_id & MPIDR_HWID_BITMASK) =3D=3D cpu_logical_map(cpu);
+}
+
/**
* setup_machine_fdt - Machine setup when an dtb was passed to the kernel
* @dt_phys: physical address of dt blob
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 06/19] driver/core: cpu: initialize of_node in cpu's device struture
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (4 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 05/19] ARM: DT/kernel: define ARM specific arch_match_cpu_phys_id Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 12:28 ` Rafael J. Wysocki
2013-08-20 15:18 ` Greg Kroah-Hartman
2013-08-20 9:30 ` [PATCH v4 07/19] of/device: add helper to get cpu device node from logical cpu index Sudeep KarkadaNagesha
` (12 subsequent siblings)
18 siblings, 2 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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..4cf0717 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>
=20
#include "base.h"
=20
@@ -289,6 +290,7 @@ int register_cpu(struct cpu *cpu, int num)
=09cpu->dev.release =3D cpu_device_release;
=09cpu->dev.offline_disabled =3D !cpu->hotpluggable;
=09cpu->dev.offline =3D !cpu_online(num);
+=09cpu->dev.of_node =3D of_get_cpu_node(num, NULL);
#ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE
=09cpu->dev.bus->uevent =3D arch_cpu_uevent;
#endif
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* Re: [PATCH v4 06/19] driver/core: cpu: initialize of_node in cpu's device struture
2013-08-20 9:30 ` [PATCH v4 06/19] driver/core: cpu: initialize of_node in cpu's device struture Sudeep KarkadaNagesha
@ 2013-08-20 12:28 ` Rafael J. Wysocki
2013-08-20 15:18 ` Greg Kroah-Hartman
1 sibling, 0 replies; 66+ messages in thread
From: Rafael J. Wysocki @ 2013-08-20 12:28 UTC (permalink / raw)
To: Sudeep KarkadaNagesha, Greg Kroah-Hartman
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm,
Sudeep KarkadaNagesha, Viresh Kumar, linux-kernel, Rob Herring,
Grant Likely, linuxppc-dev, linux-arm-kernel
On Tuesday, August 20, 2013 10:30:08 AM 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>
Hi Greg,
I this one fine with you?
Rafael
> ---
> drivers/base/cpu.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
> index 4c358bc..4cf0717 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, NULL);
> #ifdef CONFIG_ARCH_HAS_CPU_AUTOPROBE
> cpu->dev.bus->uevent = arch_cpu_uevent;
> #endif
>
--
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
^ permalink raw reply [flat|nested] 66+ messages in thread
* Re: [PATCH v4 06/19] driver/core: cpu: initialize of_node in cpu's device struture
2013-08-20 9:30 ` [PATCH v4 06/19] driver/core: cpu: initialize of_node in cpu's device struture Sudeep KarkadaNagesha
2013-08-20 12:28 ` Rafael J. Wysocki
@ 2013-08-20 15:18 ` Greg Kroah-Hartman
1 sibling, 0 replies; 66+ messages in thread
From: Greg Kroah-Hartman @ 2013-08-20 15:18 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm, Viresh Kumar,
linux-kernel, Rob Herring, Rafael J. Wysocki, Grant Likely,
linuxppc-dev, linux-arm-kernel
On Tue, Aug 20, 2013 at 10:30:08AM +0100, 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>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
^ permalink raw reply [flat|nested] 66+ messages in thread
* [PATCH v4 07/19] of/device: add helper to get cpu device node from logical cpu index
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (5 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 06/19] driver/core: cpu: initialize of_node in cpu's device struture Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 08/19] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity Sudeep KarkadaNagesha
` (11 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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.
Acked-by: 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
=20
+#include <linux/cpu.h>
#include <linux/platform_device.h>
#include <linux/of_platform.h> /* temporary until merge */
=20
@@ -43,6 +44,15 @@ static inline void of_device_node_put(struct device *dev=
)
=09of_node_put(dev->of_node);
}
=20
+static inline struct device_node *of_cpu_device_node_get(int cpu)
+{
+=09struct device *cpu_dev;
+=09cpu_dev =3D get_cpu_device(cpu);
+=09if (!cpu_dev)
+=09=09return NULL;
+=09return of_node_get(cpu_dev->of_node);
+}
+
#else /* CONFIG_OF */
=20
static inline int of_driver_match_device(struct device *dev,
@@ -67,6 +77,11 @@ static inline const struct of_device_id *of_match_device=
(
{
=09return NULL;
}
+
+static inline struct device_node *of_cpu_device_node_get(int cpu)
+{
+=09return NULL;
+}
#endif /* CONFIG_OF */
=20
#endif /* _LINUX_OF_DEVICE_H */
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 08/19] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (6 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 07/19] of/device: add helper to get cpu device node from logical cpu index Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 09/19] ARM: mvebu: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
` (10 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Lorenzo Pieralisi, Russell King,
Greg Kroah-Hartman, Sudeep KarkadaNagesha, Viresh Kumar,
Rob Herring, Rafael J. Wysocki, Grant Likely
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>
Acked-by: Nicolas Pitre <nico@linaro.org>
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..85a8737 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -74,12 +74,8 @@ struct cpu_efficiency table_efficiency[] =3D {
=09{NULL, },
};
=20
-struct cpu_capacity {
-=09unsigned long hwid;
-=09unsigned long capacity;
-};
-
-struct cpu_capacity *cpu_capacity;
+unsigned long *__cpu_capacity;
+#define cpu_capacity(cpu)=09__cpu_capacity[cpu]
=20
unsigned long middle_capacity =3D 1;
=20
@@ -100,15 +96,19 @@ static void __init parse_dt_topology(void)
=09unsigned long capacity =3D 0;
=09int alloc_size, cpu =3D 0;
=20
-=09alloc_size =3D nr_cpu_ids * sizeof(struct cpu_capacity);
-=09cpu_capacity =3D kzalloc(alloc_size, GFP_NOWAIT);
+=09alloc_size =3D nr_cpu_ids * sizeof(*__cpu_capacity);
+=09__cpu_capacity =3D kzalloc(alloc_size, GFP_NOWAIT);
=20
-=09while ((cn =3D of_find_node_by_type(cn, "cpu"))) {
-=09=09const u32 *rate, *reg;
+=09for_each_possible_cpu(cpu) {
+=09=09const u32 *rate;
=09=09int len;
=20
-=09=09if (cpu >=3D num_possible_cpus())
-=09=09=09break;
+=09=09/* too early to use cpu->of_node */
+=09=09cn =3D of_get_cpu_node(cpu, NULL);
+=09=09if (!cn) {
+=09=09=09pr_err("missing device node for CPU %d\n", cpu);
+=09=09=09continue;
+=09=09}
=20
=09=09for (cpu_eff =3D table_efficiency; cpu_eff->compatible; cpu_eff++)
=09=09=09if (of_device_is_compatible(cn, cpu_eff->compatible))
@@ -124,12 +124,6 @@ static void __init parse_dt_topology(void)
=09=09=09continue;
=09=09}
=20
-=09=09reg =3D of_get_property(cn, "reg", &len);
-=09=09if (!reg || len !=3D 4) {
-=09=09=09pr_err("%s missing reg property\n", cn->full_name);
-=09=09=09continue;
-=09=09}
-
=09=09capacity =3D ((be32_to_cpup(rate)) >> 20) * cpu_eff->efficiency;
=20
=09=09/* Save min capacity of the system */
@@ -140,13 +134,9 @@ static void __init parse_dt_topology(void)
=09=09if (capacity > max_capacity)
=09=09=09max_capacity =3D capacity;
=20
-=09=09cpu_capacity[cpu].capacity =3D capacity;
-=09=09cpu_capacity[cpu++].hwid =3D be32_to_cpup(reg);
+=09=09cpu_capacity(cpu) =3D capacity;
=09}
=20
-=09if (cpu < num_possible_cpus())
-=09=09cpu_capacity[cpu].hwid =3D (unsigned long)(-1);
-
=09/* If min and max capacities are equals, we bypass the update of the
=09 * cpu_scale because all CPUs have the same capacity. Otherwise, we
=09 * compute a middle_capacity factor that will ensure that the capacity
@@ -154,9 +144,7 @@ static void __init parse_dt_topology(void)
=09 * SCHED_POWER_SCALE, which is the default value, but with the
=09 * constraint explained near table_efficiency[].
=09 */
-=09if (min_capacity =3D=3D max_capacity)
-=09=09cpu_capacity[0].hwid =3D (unsigned long)(-1);
-=09else if (4*max_capacity < (3*(max_capacity + min_capacity)))
+=09if (4*max_capacity < (3*(max_capacity + min_capacity)))
=09=09middle_capacity =3D (min_capacity + max_capacity)
=09=09=09=09>> (SCHED_POWER_SHIFT+1);
=09else
@@ -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)
{
-=09unsigned int idx =3D 0;
-
-=09/* look for the cpu's hwid in the cpu capacity table */
-=09for (idx =3D 0; idx < num_possible_cpus(); idx++) {
-=09=09if (cpu_capacity[idx].hwid =3D=3D hwid)
-=09=09=09break;
-
-=09=09if (cpu_capacity[idx].hwid =3D=3D -1)
-=09=09=09return;
-=09}
-
-=09if (idx =3D=3D num_possible_cpus())
+=09if (!cpu_capacity(cpu))
=09=09return;
=20
-=09set_power_scale(cpu, cpu_capacity[idx].capacity / middle_capacity);
+=09set_power_scale(cpu, cpu_capacity(cpu) / middle_capacity);
=20
=09printk(KERN_INFO "CPU%u: update cpu_power %lu\n",
=09=09cpu, arch_scale_freq_power(NULL, cpu));
@@ -194,7 +171,7 @@ void update_cpu_power(unsigned int cpu, unsigned long h=
wid)
=20
#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
=20
/*
@@ -281,7 +258,7 @@ void store_cpu_topology(unsigned int cpuid)
=20
=09update_siblings_masks(cpuid);
=20
-=09update_cpu_power(cpuid, mpidr & MPIDR_HWID_BITMASK);
+=09update_cpu_power(cpuid);
=20
=09printk(KERN_INFO "CPU%u: thread %d, cpu %d, socket %d, mpidr %x\n",
=09=09cpuid, cpu_topology[cpuid].thread_id,
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 09/19] ARM: mvebu: remove device tree parsing for cpu nodes
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (7 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 08/19] ARM: topology: remove hwid/MPIDR dependency from cpu_capacity Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 10/19] drivers/bus: arm-cci: avoid parsing DT for cpu device nodes Sudeep KarkadaNagesha
` (9 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Andrew Lunn, Michal Simek, Jason Cooper,
Greg Kroah-Hartman, Sudeep KarkadaNagesha, Viresh Kumar,
Rob Herring, Rafael J. Wysocki, Grant Likely
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: Andrew Lunn <andrew@lunn.ch>
Cc: Jason Cooper <jason@lakedaemon.net>
Acked-by: Gregory Clement <gregory.clement@free-electrons.com>
Signed-off-by: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
---
arch/arm/mach-mvebu/platsmp.c | 51 +++++++++++++++++++--------------------=
----
1 file changed, 23 insertions(+), 28 deletions(-)
diff --git a/arch/arm/mach-mvebu/platsmp.c b/arch/arm/mach-mvebu/platsmp.c
index ce81d30..594b63d 100644
--- a/arch/arm/mach-mvebu/platsmp.c
+++ b/arch/arm/mach-mvebu/platsmp.c
@@ -29,45 +29,40 @@
#include "pmsu.h"
#include "coherency.h"
=20
+static struct clk *__init get_cpu_clk(int cpu)
+{
+=09struct clk *cpu_clk;
+=09struct device_node *np =3D of_get_cpu_node(cpu, NULL);
+
+=09if (WARN(!np, "missing cpu node\n"))
+=09=09return NULL;
+=09cpu_clk =3D of_clk_get(np, 0);
+=09if (WARN_ON(IS_ERR(cpu_clk)))
+=09=09return NULL;
+=09return cpu_clk;
+}
+
void __init set_secondary_cpus_clock(void)
{
-=09int thiscpu;
+=09int thiscpu, cpu;
=09unsigned long rate;
-=09struct clk *cpu_clk =3D NULL;
-=09struct device_node *np =3D NULL;
+=09struct clk *cpu_clk;
=20
=09thiscpu =3D smp_processor_id();
-=09for_each_node_by_type(np, "cpu") {
-=09=09int err;
-=09=09int cpu;
-
-=09=09err =3D of_property_read_u32(np, "reg", &cpu);
-=09=09if (WARN_ON(err))
-=09=09=09return;
-
-=09=09if (cpu =3D=3D thiscpu) {
-=09=09=09cpu_clk =3D of_clk_get(np, 0);
-=09=09=09break;
-=09=09}
-=09}
-=09if (WARN_ON(IS_ERR(cpu_clk)))
+=09cpu_clk =3D get_cpu_clk(thiscpu);
+=09if (!cpu_clk)
=09=09return;
=09clk_prepare_enable(cpu_clk);
=09rate =3D clk_get_rate(cpu_clk);
=20
=09/* set all the other CPU clk to the same rate than the boot CPU */
-=09for_each_node_by_type(np, "cpu") {
-=09=09int err;
-=09=09int cpu;
-
-=09=09err =3D of_property_read_u32(np, "reg", &cpu);
-=09=09if (WARN_ON(err))
+=09for_each_possible_cpu(cpu) {
+=09=09if (cpu =3D=3D thiscpu)
+=09=09=09continue;
+=09=09cpu_clk =3D get_cpu_clk(cpu);
+=09=09if (!cpu_clk)
=09=09=09return;
-
-=09=09if (cpu !=3D thiscpu) {
-=09=09=09cpu_clk =3D of_clk_get(np, 0);
-=09=09=09clk_set_rate(cpu_clk, rate);
-=09=09}
+=09=09clk_set_rate(cpu_clk, rate);
=09}
}
=20
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 10/19] drivers/bus: arm-cci: avoid parsing DT for cpu device nodes
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (8 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 09/19] ARM: mvebu: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 11/19] cpufreq: imx6q-cpufreq: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
` (8 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Lorenzo Pieralisi, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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>
Acked-by: Nicolas Pitre <nico@linaro.org>
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..2009266 100644
--- a/drivers/bus/arm-cci.c
+++ b/drivers/bus/arm-cci.c
@@ -122,17 +122,8 @@ EXPORT_SYMBOL_GPL(cci_ace_get_port);
=20
static void __init cci_ace_init_ports(void)
{
-=09int port, ac, cpu;
-=09u64 hwid;
-=09const u32 *cell;
-=09struct device_node *cpun, *cpus;
-
-=09cpus =3D of_find_node_by_path("/cpus");
-=09if (WARN(!cpus, "Missing cpus node, bailing out\n"))
-=09=09return;
-
-=09if (WARN_ON(of_property_read_u32(cpus, "#address-cells", &ac)))
-=09=09ac =3D of_n_addr_cells(cpus);
+=09int port, cpu;
+=09struct device_node *cpun;
=20
=09/*
=09 * Port index look-up speeds up the function disabling ports by CPU,
@@ -141,18 +132,13 @@ static void __init cci_ace_init_ports(void)
=09 * The stashed index array is initialized for all possible CPUs
=09 * at probe time.
=09 */
-=09for_each_child_of_node(cpus, cpun) {
-=09=09if (of_node_cmp(cpun->type, "cpu"))
-=09=09=09continue;
-=09=09cell =3D of_get_property(cpun, "reg", NULL);
-=09=09if (WARN(!cell, "%s: missing reg property\n", cpun->full_name))
-=09=09=09continue;
-
-=09=09hwid =3D of_read_number(cell, ac);
-=09=09cpu =3D get_logical_index(hwid & MPIDR_HWID_BITMASK);
+=09for_each_possible_cpu(cpu) {
+=09=09/* too early to use cpu->of_node */
+=09=09cpun =3D of_get_cpu_node(cpu, NULL);
=20
-=09=09if (cpu < 0 || !cpu_possible(cpu))
+=09=09if (WARN(!cpun, "Missing cpu device node\n"))
=09=09=09continue;
+
=09=09port =3D __cci_ace_get_port(cpun, ACE_PORT);
=09=09if (port < 0)
=09=09=09continue;
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 11/19] cpufreq: imx6q-cpufreq: remove device tree parsing for cpu nodes
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (9 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 10/19] drivers/bus: arm-cci: avoid parsing DT for cpu device nodes Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 12/19] cpufreq: cpufreq-cpu0: " Sudeep KarkadaNagesha
` (7 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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)
{
=09struct device_node *np;
=20
-=09np =3D of_find_node_by_path("/cpus/cpu@0");
+=09np =3D of_node_get(cpu_dev->of_node);
=09if (!np) {
=09=09pr_warn("failed to find cpu0 node\n");
=09=09return;
=09}
=20
-=09cpu_dev->of_node =3D np;
=09if (of_init_opp_table(cpu_dev)) {
=09=09pr_warn("failed to init OPP table\n");
=09=09goto put_node;
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufre=
q.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)
=20
=09cpu_dev =3D &pdev->dev;
=20
-=09np =3D of_find_node_by_path("/cpus/cpu@0");
+=09np =3D of_node_get(cpu_dev->of_node);
=09if (!np) {
=09=09dev_err(cpu_dev, "failed to find cpu0 node\n");
=09=09return -ENOENT;
=09}
=20
-=09cpu_dev->of_node =3D np;
-
=09arm_clk =3D devm_clk_get(cpu_dev, "arm");
=09pll1_sys_clk =3D devm_clk_get(cpu_dev, "pll1_sys");
=09pll1_sw_clk =3D devm_clk_get(cpu_dev, "pll1_sw");
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 12/19] cpufreq: cpufreq-cpu0: remove device tree parsing for cpu nodes
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (10 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 11/19] cpufreq: imx6q-cpufreq: remove device tree parsing for cpu nodes Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-09-06 13:44 ` Guennadi Liakhovetski
2013-08-20 9:30 ` [PATCH v4 13/19] cpufreq: highbank-cpufreq: " Sudeep KarkadaNagesha
` (6 subsequent siblings)
18 siblings, 1 reply; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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 =3D =
{
=20
static int cpu0_cpufreq_probe(struct platform_device *pdev)
{
-=09struct device_node *np, *parent;
+=09struct device_node *np;
=09int ret;
=20
-=09parent =3D of_find_node_by_path("/cpus");
-=09if (!parent) {
-=09=09pr_err("failed to find OF /cpus\n");
-=09=09return -ENOENT;
-=09}
-
-=09for_each_child_of_node(parent, np) {
-=09=09if (of_get_property(np, "operating-points", NULL))
-=09=09=09break;
-=09}
+=09cpu_dev =3D &pdev->dev;
=20
+=09np =3D of_node_get(cpu_dev->of_node);
=09if (!np) {
=09=09pr_err("failed to find cpu0 node\n");
-=09=09ret =3D -ENOENT;
-=09=09goto out_put_parent;
+=09=09return -ENOENT;
=09}
=20
-=09cpu_dev =3D &pdev->dev;
-=09cpu_dev->of_node =3D np;
-
=09cpu_reg =3D devm_regulator_get(cpu_dev, "cpu0");
=09if (IS_ERR(cpu_reg)) {
=09=09/*
@@ -269,15 +257,12 @@ static int cpu0_cpufreq_probe(struct platform_device =
*pdev)
=09}
=20
=09of_node_put(np);
-=09of_node_put(parent);
=09return 0;
=20
out_free_table:
=09opp_free_cpufreq_table(cpu_dev, &freq_table);
out_put_node:
=09of_node_put(np);
-out_put_parent:
-=09of_node_put(parent);
=09return ret;
}
=20
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* Re: [PATCH v4 12/19] cpufreq: cpufreq-cpu0: remove device tree parsing for cpu nodes
2013-08-20 9:30 ` [PATCH v4 12/19] cpufreq: cpufreq-cpu0: " Sudeep KarkadaNagesha
@ 2013-09-06 13:44 ` Guennadi Liakhovetski
2013-09-09 9:24 ` Sudeep KarkadaNagesha
0 siblings, 1 reply; 66+ messages in thread
From: Guennadi Liakhovetski @ 2013-09-06 13:44 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm, Viresh Kumar,
linux-kernel, Rob Herring, Rafael J. Wysocki, Greg Kroah-Hartman,
Grant Likely, linuxppc-dev, linux-arm-kernel
Hi
On Tue, 20 Aug 2013, 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.
>
> 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 =3D =
> {
> =20
> static int cpu0_cpufreq_probe(struct platform_device *pdev)
> {
> -=09struct device_node *np, *parent;
> +=09struct device_node *np;
> =09int ret;
> =20
> -=09parent =3D of_find_node_by_path("/cpus");
> -=09if (!parent) {
> -=09=09pr_err("failed to find OF /cpus\n");
> -=09=09return -ENOENT;
> -=09}
> -
> -=09for_each_child_of_node(parent, np) {
> -=09=09if (of_get_property(np, "operating-points", NULL))
> -=09=09=09break;
> -=09}
> +=09cpu_dev =3D &pdev->dev;
> =20
> +=09np =3D of_node_get(cpu_dev->of_node);
Has this actually been tested? This seems to break cpufreq-cpu0. The
reason is, that this probe function is called not for the DT CPU node, but
for a special virtual cpufreq-cpu0 platform device, typically created by
platforms, using
platform_device_register_simple("cpufreq-cpu0", -1, NULL, 0);
which then of course doesn't have on .of_node associated with it.
Thanks
Guennadi
> =09if (!np) {
> =09=09pr_err("failed to find cpu0 node\n");
> -=09=09ret =3D -ENOENT;
> -=09=09goto out_put_parent;
> +=09=09return -ENOENT;
> =09}
> =20
> -=09cpu_dev =3D &pdev->dev;
> -=09cpu_dev->of_node =3D np;
> -
> =09cpu_reg =3D devm_regulator_get(cpu_dev, "cpu0");
> =09if (IS_ERR(cpu_reg)) {
> =09=09/*
> @@ -269,15 +257,12 @@ static int cpu0_cpufreq_probe(struct platform_device =
> *pdev)
> =09}
> =20
> =09of_node_put(np);
> -=09of_node_put(parent);
> =09return 0;
> =20
> out_free_table:
> =09opp_free_cpufreq_table(cpu_dev, &freq_table);
> out_put_node:
> =09of_node_put(np);
> -out_put_parent:
> -=09of_node_put(parent);
> =09return ret;
> }
> =20
> --=20
> 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/
>
---
Guennadi Liakhovetski, Ph.D.
Freelance Open-Source Software Developer
http://www.open-technology.de/
^ permalink raw reply [flat|nested] 66+ messages in thread
* Re: [PATCH v4 12/19] cpufreq: cpufreq-cpu0: remove device tree parsing for cpu nodes
2013-09-06 13:44 ` Guennadi Liakhovetski
@ 2013-09-09 9:24 ` Sudeep KarkadaNagesha
2013-09-09 14:32 ` Shawn Guo
0 siblings, 1 reply; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-09-09 9:24 UTC (permalink / raw)
To: Guennadi Liakhovetski, Shawn Guo
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm,
Sudeep KarkadaNagesha, Viresh Kumar, linux-kernel, rob.herring,
Rafael J. Wysocki, Greg Kroah-Hartman, grant.likely,
linuxppc-dev, linux-arm-kernel
On 06/09/13 14:44, Guennadi Liakhovetski wrote:
> Hi
>=20
> On Tue, 20 Aug 2013, Sudeep KarkadaNagesha wrote:
>=20
>> From: Sudeep KarkadaNagesha <sudeep.karkadanagesha@arm.com>
>>
>> Now that the cpu device registration initialises the of_node(if availabl=
e)
>> 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-cp=
u0.=3D
>> 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 =
=3D3D =3D
>> {
>> =3D20
>> static int cpu0_cpufreq_probe(struct platform_device *pdev)
>> {
>> -=3D09struct device_node *np, *parent;
>> +=3D09struct device_node *np;
>> =3D09int ret;
>> =3D20
>> -=3D09parent =3D3D of_find_node_by_path("/cpus");
>> -=3D09if (!parent) {
>> -=3D09=3D09pr_err("failed to find OF /cpus\n");
>> -=3D09=3D09return -ENOENT;
>> -=3D09}
>> -
>> -=3D09for_each_child_of_node(parent, np) {
>> -=3D09=3D09if (of_get_property(np, "operating-points", NULL))
>> -=3D09=3D09=3D09break;
>> -=3D09}
>> +=3D09cpu_dev =3D3D &pdev->dev;
>> =3D20
>> +=3D09np =3D3D of_node_get(cpu_dev->of_node);
>=20
> Has this actually been tested? This seems to break cpufreq-cpu0. The=20
> reason is, that this probe function is called not for the DT CPU node, bu=
t=20
> for a special virtual cpufreq-cpu0 platform device, typically created by=
=20
> platforms, using
>=20
> =09platform_device_register_simple("cpufreq-cpu0", -1, NULL, 0);
>=20
> which then of course doesn't have on .of_node associated with it.
>=20
Hi Guennadi,
Based on my understanding of the original code:
cpu_dev =3D &pdev->dev;
=09...
=09ret =3D of_init_opp_table(cpu_dev);
of_init_opp_table needs cpu_dev to be get_cpu_device(0). My
understanding was that platform using cpufreq-cpu0 sets &pdev->dev to
get_cpu_device(0). But looks like that's not the case.
Hi Shawn,
Can you please clarify ? The fix would be as below but I would like to
know if setting cpu_dev to get_cpu_device(0) instead of &pdev->dev has
any impact on other parts of code using cpu_dev ?
diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.=
c
index cbfffa9..871c336 100644
--- a/drivers/cpufreq/cpufreq-cpu0.c
+++ b/drivers/cpufreq/cpufreq-cpu0.c
@@ -177,7 +177,7 @@ static int cpu0_cpufreq_probe(struct platform_device
*pdev)
struct device_node *np;
int ret;
- cpu_dev =3D &pdev->dev;
+ cpu_dev =3D get_cpu_device(0);
np =3D of_node_get(cpu_dev->of_node);
if (!np) {
Regards,
Sudeep
^ permalink raw reply related [flat|nested] 66+ messages in thread
* Re: [PATCH v4 12/19] cpufreq: cpufreq-cpu0: remove device tree parsing for cpu nodes
2013-09-09 9:24 ` Sudeep KarkadaNagesha
@ 2013-09-09 14:32 ` Shawn Guo
2013-09-09 15:24 ` Sudeep KarkadaNagesha
0 siblings, 1 reply; 66+ messages in thread
From: Shawn Guo @ 2013-09-09 14:32 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm, Viresh Kumar,
linux-kernel, rob.herring, Rafael J. Wysocki, Greg Kroah-Hartman,
grant.likely, linuxppc-dev, Guennadi Liakhovetski,
linux-arm-kernel
Hi Sudeep,
On Mon, Sep 09, 2013 at 10:24:39AM +0100, Sudeep KarkadaNagesha wrote:
> Hi Shawn,
>
> Can you please clarify ? The fix would be as below but I would like to
> know if setting cpu_dev to get_cpu_device(0) instead of &pdev->dev has
> any impact on other parts of code using cpu_dev ?
I'm sorry. I should have given it a test on hardware before ACKing the
changes.
The fix below should not have other impact except the prefix of dev_err
[info, dbg] message output ('cpufreq-cpu0:' to 'cpu cpu0:'), which
shouldn't be a problem.
>
> diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cpu0.c
> index cbfffa9..871c336 100644
> --- a/drivers/cpufreq/cpufreq-cpu0.c
> +++ b/drivers/cpufreq/cpufreq-cpu0.c
> @@ -177,7 +177,7 @@ static int cpu0_cpufreq_probe(struct platform_device
> *pdev)
> struct device_node *np;
> int ret;
>
> - cpu_dev = &pdev->dev;
> + cpu_dev = get_cpu_device(0);
>
> np = of_node_get(cpu_dev->of_node);
> if (!np) {
>
The imx6q-cpufreq driver needs a similar fixing. Please include the
following changes into your fixing patches. Thanks.
Shawn
---8<---------
diff --git a/arch/arm/mach-imx/mach-imx6q.c b/arch/arm/mach-imx/mach-imx6q.c
index 85a1b51..69fd4b6 100644
--- a/arch/arm/mach-imx/mach-imx6q.c
+++ b/arch/arm/mach-imx/mach-imx6q.c
@@ -233,9 +233,10 @@ put_node:
of_node_put(np);
}
-static void __init imx6q_opp_init(struct device *cpu_dev)
+static void __init imx6q_opp_init(void)
{
struct device_node *np;
+ struct device *cpu_dev = get_cpu_device(0);
np = of_node_get(cpu_dev->of_node);
if (!np) {
@@ -268,7 +269,7 @@ static void __init imx6q_init_late(void)
imx6q_cpuidle_init();
if (IS_ENABLED(CONFIG_ARM_IMX6Q_CPUFREQ)) {
- imx6q_opp_init(&imx6q_cpufreq_pdev.dev);
+ imx6q_opp_init();
platform_device_register(&imx6q_cpufreq_pdev);
}
}
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c
index 3e39654..d7ebd91 100644
--- a/drivers/cpufreq/imx6q-cpufreq.c
+++ b/drivers/cpufreq/imx6q-cpufreq.c
@@ -7,6 +7,7 @@
*/
#include <linux/clk.h>
+#include <linux/cpu.h>
#include <linux/cpufreq.h>
#include <linux/delay.h>
#include <linux/err.h>
@@ -202,7 +203,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev)
unsigned long min_volt, max_volt;
int num, ret;
- cpu_dev = &pdev->dev;
+ cpu_dev = get_cpu_device(0);
np = of_node_get(cpu_dev->of_node);
if (!np) {
^ permalink raw reply related [flat|nested] 66+ messages in thread
* Re: [PATCH v4 12/19] cpufreq: cpufreq-cpu0: remove device tree parsing for cpu nodes
2013-09-09 14:32 ` Shawn Guo
@ 2013-09-09 15:24 ` Sudeep KarkadaNagesha
2013-09-10 2:44 ` Shawn Guo
0 siblings, 1 reply; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-09-09 15:24 UTC (permalink / raw)
To: Shawn Guo
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm,
Sudeep KarkadaNagesha, Viresh Kumar, linux-kernel, rob.herring,
Rafael J. Wysocki, Greg Kroah-Hartman, grant.likely,
linuxppc-dev, Guennadi Liakhovetski, linux-arm-kernel
On 09/09/13 15:32, Shawn Guo wrote:
> Hi Sudeep,
>=20
> On Mon, Sep 09, 2013 at 10:24:39AM +0100, Sudeep KarkadaNagesha wrote:
>> Hi Shawn,
>>
>> Can you please clarify ? The fix would be as below but I would like to
>> know if setting cpu_dev to get_cpu_device(0) instead of &pdev->dev has
>> any impact on other parts of code using cpu_dev ?
>=20
> I'm sorry. I should have given it a test on hardware before ACKing the
> changes.
>=20
> The fix below should not have other impact except the prefix of dev_err
> [info, dbg] message output ('cpufreq-cpu0:' to 'cpu cpu0:'), which
> shouldn't be a problem.
>
Hi Shawn,
Ok. But I am bit suspicious about devm_clk_get(cpu_dev, NULL).
I don't understand completely as how the clock are registered(whether
with dev_id or with connection_id).
A quick grep revealed that i.mx and shmobile is using conection id while
registering. If the clock is registered with connection id and retrieved
with cpu_dev(now dev_id is cpu0 and not cpufreq-cpu0), IIUC that would
break. If we pass pdev->dev for clk_get, it should be fine but again
IIUC it breaks highbank which gets all the information from DT.
So only solution I can think of is to continue to have the code
assigning (&pdev->dev)->of_node with cpu device node which is not clean
and arguable as incorrect since there is no DT node for cpufreq-cpu0.
I don't have a strong opinion though.
Let me know how would you like to fix this.
>>
>> diff --git a/drivers/cpufreq/cpufreq-cpu0.c b/drivers/cpufreq/cpufreq-cp=
u0.c
>> index cbfffa9..871c336 100644
>> --- a/drivers/cpufreq/cpufreq-cpu0.c
>> +++ b/drivers/cpufreq/cpufreq-cpu0.c
>> @@ -177,7 +177,7 @@ static int cpu0_cpufreq_probe(struct platform_device
>> *pdev)
>> struct device_node *np;
>> int ret;
>>
>> - cpu_dev =3D &pdev->dev;
>> + cpu_dev =3D get_cpu_device(0);
>>
>> np =3D of_node_get(cpu_dev->of_node);
>> if (!np) {
>>
>=20
> The imx6q-cpufreq driver needs a similar fixing. Please include the
> following changes into your fixing patches. Thanks.
>=20
Ok no problem I can post the fix based on response for the above question.
Regard,
Sudeep
^ permalink raw reply [flat|nested] 66+ messages in thread
* Re: [PATCH v4 12/19] cpufreq: cpufreq-cpu0: remove device tree parsing for cpu nodes
2013-09-09 15:24 ` Sudeep KarkadaNagesha
@ 2013-09-10 2:44 ` Shawn Guo
2013-09-10 10:56 ` Sudeep KarkadaNagesha
0 siblings, 1 reply; 66+ messages in thread
From: Shawn Guo @ 2013-09-10 2:44 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm, Viresh Kumar,
linux-kernel, rob.herring, Rafael J. Wysocki, Greg Kroah-Hartman,
grant.likely, linuxppc-dev, Guennadi Liakhovetski,
linux-arm-kernel
On Mon, Sep 09, 2013 at 04:24:18PM +0100, Sudeep KarkadaNagesha wrote:
> Hi Shawn,
>
> Ok. But I am bit suspicious about devm_clk_get(cpu_dev, NULL).
> I don't understand completely as how the clock are registered(whether
> with dev_id or with connection_id).
As the connection_id of devm_clk_get() call here is NULL, the clock
lookup should be registered with a proper dev_id in clk_register_clkdev()
call. And that's what you have seen with imx and shmobile code.
> A quick grep revealed that i.mx and shmobile is using conection id while
> registering.
They are using dev_id.
> If the clock is registered with connection id and retrieved
> with cpu_dev(now dev_id is cpu0 and not cpufreq-cpu0), IIUC that would
> break. If we pass pdev->dev for clk_get, it should be fine but again
> IIUC it breaks highbank which gets all the information from DT.
If the clock lookup is from DT, we should be just fine, since it will
work as long as the DT node with 'clocks' property (/cpus/cpu@0 in this
case) is attached to the struct device pointer of devm_clk_get() call.
> So only solution I can think of is to continue to have the code
> assigning (&pdev->dev)->of_node with cpu device node which is not clean
> and arguable as incorrect since there is no DT node for cpufreq-cpu0.
> I don't have a strong opinion though.
>
> Let me know how would you like to fix this.
So we only need to change all clkdev registration to use "cpu0" as
dev_id intstead of "cpufreq-cpu0.0", something like below.
And for imx, it should work even without the changes, because we have
device tree lookup ready there, and those clk_register_clkdev() calls
can just be removed now. But I prefer to include the change and leave
the cleanup to another patch for keeping the change log clear.
Shawn
---8<----------
diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.c
index c3cfa41..c6b40f3 100644
--- a/arch/arm/mach-imx/clk-imx27.c
+++ b/arch/arm/mach-imx/clk-imx27.c
@@ -285,7 +285,7 @@ int __init mx27_clocks_init(unsigned long fref)
clk_register_clkdev(clk[ata_ahb_gate], "ata", NULL);
clk_register_clkdev(clk[rtc_ipg_gate], NULL, "imx21-rtc");
clk_register_clkdev(clk[scc_ipg_gate], "scc", NULL);
- clk_register_clkdev(clk[cpu_div], NULL, "cpufreq-cpu0.0");
+ clk_register_clkdev(clk[cpu_div], NULL, "cpu0");
clk_register_clkdev(clk[emi_ahb_gate], "emi_ahb" , NULL);
mxc_timer_init(MX27_IO_ADDRESS(MX27_GPT1_BASE_ADDR), MX27_INT_GPT1);
diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-imx51-imx53.c
index 1a56a33..de1964c 100644
--- a/arch/arm/mach-imx/clk-imx51-imx53.c
+++ b/arch/arm/mach-imx/clk-imx51-imx53.c
@@ -328,7 +328,7 @@ static void __init mx5_clocks_common_init(unsigned long rate_ckil,
clk_register_clkdev(clk[ssi2_ipg_gate], NULL, "imx-ssi.1");
clk_register_clkdev(clk[ssi3_ipg_gate], NULL, "imx-ssi.2");
clk_register_clkdev(clk[sdma_gate], NULL, "imx35-sdma");
- clk_register_clkdev(clk[cpu_podf], NULL, "cpufreq-cpu0.0");
+ clk_register_clkdev(clk[cpu_podf], NULL, "cpu0");
clk_register_clkdev(clk[iim_gate], "iim", NULL);
clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.0");
clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.1");
diff --git a/arch/arm/mach-shmobile/clock-r8a73a4.c b/arch/arm/mach-shmobile/clock-r8a73a4.c
index 8ea5ef6..5bd2e85 100644
--- a/arch/arm/mach-shmobile/clock-r8a73a4.c
+++ b/arch/arm/mach-shmobile/clock-r8a73a4.c
@@ -555,7 +555,7 @@ static struct clk_lookup lookups[] = {
CLKDEV_CON_ID("pll2h", &pll2h_clk),
/* CPU clock */
- CLKDEV_DEV_ID("cpufreq-cpu0", &z_clk),
+ CLKDEV_DEV_ID("cpu0", &z_clk),
/* DIV6 */
CLKDEV_CON_ID("zb", &div6_clks[DIV6_ZB]),
diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobile/clock-sh73a0.c
index 1942eae..c92c023 100644
--- a/arch/arm/mach-shmobile/clock-sh73a0.c
+++ b/arch/arm/mach-shmobile/clock-sh73a0.c
@@ -616,7 +616,7 @@ static struct clk_lookup lookups[] = {
CLKDEV_DEV_ID("smp_twd", &twd_clk), /* smp_twd */
/* DIV4 clocks */
- CLKDEV_DEV_ID("cpufreq-cpu0", &div4_clks[DIV4_Z]),
+ CLKDEV_DEV_ID("cpu0", &div4_clks[DIV4_Z]),
/* DIV6 clocks */
CLKDEV_CON_ID("vck1_clk", &div6_clks[DIV6_VCK1]),
^ permalink raw reply related [flat|nested] 66+ messages in thread
* Re: [PATCH v4 12/19] cpufreq: cpufreq-cpu0: remove device tree parsing for cpu nodes
2013-09-10 2:44 ` Shawn Guo
@ 2013-09-10 10:56 ` Sudeep KarkadaNagesha
2013-09-10 11:19 ` Shawn Guo
0 siblings, 1 reply; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-09-10 10:56 UTC (permalink / raw)
To: Shawn Guo
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm,
Sudeep KarkadaNagesha, Viresh Kumar, linux-kernel, rob.herring,
Rafael J. Wysocki, Greg Kroah-Hartman, grant.likely,
linuxppc-dev, Guennadi Liakhovetski, linux-arm-kernel
On 10/09/13 03:44, Shawn Guo wrote:
> On Mon, Sep 09, 2013 at 04:24:18PM +0100, Sudeep KarkadaNagesha wrote:
>> Hi Shawn,
>>
>> Ok. But I am bit suspicious about devm_clk_get(cpu_dev, NULL).
>> I don't understand completely as how the clock are registered(whether
>> with dev_id or with connection_id).
>=20
> As the connection_id of devm_clk_get() call here is NULL, the clock
> lookup should be registered with a proper dev_id in clk_register_clkdev()
> call. And that's what you have seen with imx and shmobile code.
>=20
>
>> A quick grep revealed that i.mx and shmobile is using conection id while
>> registering.
>=20
> They are using dev_id.
>=20
Yes correct. I misunderstood, was expecting caller to pass dev and clk
layer extract dev_name so that even when device name is changed the clk
registration need not be changed.
>> If the clock is registered with connection id and retrieved
>> with cpu_dev(now dev_id is cpu0 and not cpufreq-cpu0), IIUC that would
>> break. If we pass pdev->dev for clk_get, it should be fine but again
>> IIUC it breaks highbank which gets all the information from DT.
>=20
> If the clock lookup is from DT, we should be just fine, since it will
> work as long as the DT node with 'clocks' property (/cpus/cpu@0 in this
> case) is attached to the struct device pointer of devm_clk_get() call.
>=20
This can be ignored if we are registering with "cpu0" as below in your
patch.
>> So only solution I can think of is to continue to have the code
>> assigning (&pdev->dev)->of_node with cpu device node which is not clean
>> and arguable as incorrect since there is no DT node for cpufreq-cpu0.
>> I don't have a strong opinion though.
>>
>> Let me know how would you like to fix this.
>=20
> So we only need to change all clkdev registration to use "cpu0" as
> dev_id intstead of "cpufreq-cpu0.0", something like below.
>=20
> And for imx, it should work even without the changes, because we have
> device tree lookup ready there, and those clk_register_clkdev() calls
> can just be removed now. But I prefer to include the change and leave
> the cleanup to another patch for keeping the change log clear.
>=20
Ok makes sense, do you want me to include this patch also as fix.
I can send a series to fix this if you OK:
1. Fix in cpufreq-cpu0
2. Fix in i.MX driver and platform file
3. Patch below
Regards,
Sudeep
>=20
> ---8<----------
>=20
> diff --git a/arch/arm/mach-imx/clk-imx27.c b/arch/arm/mach-imx/clk-imx27.=
c
> index c3cfa41..c6b40f3 100644
> --- a/arch/arm/mach-imx/clk-imx27.c
> +++ b/arch/arm/mach-imx/clk-imx27.c
> @@ -285,7 +285,7 @@ int __init mx27_clocks_init(unsigned long fref)
> =09clk_register_clkdev(clk[ata_ahb_gate], "ata", NULL);
> =09clk_register_clkdev(clk[rtc_ipg_gate], NULL, "imx21-rtc");
> =09clk_register_clkdev(clk[scc_ipg_gate], "scc", NULL);
> -=09clk_register_clkdev(clk[cpu_div], NULL, "cpufreq-cpu0.0");
> +=09clk_register_clkdev(clk[cpu_div], NULL, "cpu0");
> =09clk_register_clkdev(clk[emi_ahb_gate], "emi_ahb" , NULL);
> =20
> =09mxc_timer_init(MX27_IO_ADDRESS(MX27_GPT1_BASE_ADDR), MX27_INT_GPT1);
> diff --git a/arch/arm/mach-imx/clk-imx51-imx53.c b/arch/arm/mach-imx/clk-=
imx51-imx53.c
> index 1a56a33..de1964c 100644
> --- a/arch/arm/mach-imx/clk-imx51-imx53.c
> +++ b/arch/arm/mach-imx/clk-imx51-imx53.c
> @@ -328,7 +328,7 @@ static void __init mx5_clocks_common_init(unsigned lo=
ng rate_ckil,
> =09clk_register_clkdev(clk[ssi2_ipg_gate], NULL, "imx-ssi.1");
> =09clk_register_clkdev(clk[ssi3_ipg_gate], NULL, "imx-ssi.2");
> =09clk_register_clkdev(clk[sdma_gate], NULL, "imx35-sdma");
> -=09clk_register_clkdev(clk[cpu_podf], NULL, "cpufreq-cpu0.0");
> +=09clk_register_clkdev(clk[cpu_podf], NULL, "cpu0");
> =09clk_register_clkdev(clk[iim_gate], "iim", NULL);
> =09clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.0");
> =09clk_register_clkdev(clk[dummy], NULL, "imx2-wdt.1");
> diff --git a/arch/arm/mach-shmobile/clock-r8a73a4.c b/arch/arm/mach-shmob=
ile/clock-r8a73a4.c
> index 8ea5ef6..5bd2e85 100644
> --- a/arch/arm/mach-shmobile/clock-r8a73a4.c
> +++ b/arch/arm/mach-shmobile/clock-r8a73a4.c
> @@ -555,7 +555,7 @@ static struct clk_lookup lookups[] =3D {
> =09CLKDEV_CON_ID("pll2h",=09=09=09&pll2h_clk),
> =20
> =09/* CPU clock */
> -=09CLKDEV_DEV_ID("cpufreq-cpu0",=09=09&z_clk),
> +=09CLKDEV_DEV_ID("cpu0",=09=09=09&z_clk),
> =20
> =09/* DIV6 */
> =09CLKDEV_CON_ID("zb",=09=09=09&div6_clks[DIV6_ZB]),
> diff --git a/arch/arm/mach-shmobile/clock-sh73a0.c b/arch/arm/mach-shmobi=
le/clock-sh73a0.c
> index 1942eae..c92c023 100644
> --- a/arch/arm/mach-shmobile/clock-sh73a0.c
> +++ b/arch/arm/mach-shmobile/clock-sh73a0.c
> @@ -616,7 +616,7 @@ static struct clk_lookup lookups[] =3D {
> =09CLKDEV_DEV_ID("smp_twd", &twd_clk), /* smp_twd */
> =20
> =09/* DIV4 clocks */
> -=09CLKDEV_DEV_ID("cpufreq-cpu0", &div4_clks[DIV4_Z]),
> +=09CLKDEV_DEV_ID("cpu0", &div4_clks[DIV4_Z]),
> =20
> =09/* DIV6 clocks */
> =09CLKDEV_CON_ID("vck1_clk", &div6_clks[DIV6_VCK1]),
>=20
>=20
^ permalink raw reply [flat|nested] 66+ messages in thread
* Re: [PATCH v4 12/19] cpufreq: cpufreq-cpu0: remove device tree parsing for cpu nodes
2013-09-10 10:56 ` Sudeep KarkadaNagesha
@ 2013-09-10 11:19 ` Shawn Guo
0 siblings, 0 replies; 66+ messages in thread
From: Shawn Guo @ 2013-09-10 11:19 UTC (permalink / raw)
To: Sudeep KarkadaNagesha
Cc: Jonas Bonn, devicetree, Michal Simek, linux-pm, Viresh Kumar,
linux-kernel, rob.herring, Rafael J. Wysocki, Greg Kroah-Hartman,
grant.likely, linuxppc-dev, Guennadi Liakhovetski,
linux-arm-kernel
On Tue, Sep 10, 2013 at 11:56:17AM +0100, Sudeep KarkadaNagesha wrote:
> > So we only need to change all clkdev registration to use "cpu0" as
> > dev_id intstead of "cpufreq-cpu0.0", something like below.
> >
> > And for imx, it should work even without the changes, because we have
> > device tree lookup ready there, and those clk_register_clkdev() calls
> > can just be removed now. But I prefer to include the change and leave
> > the cleanup to another patch for keeping the change log clear.
> >
> Ok makes sense, do you want me to include this patch also as fix.
> I can send a series to fix this if you OK:
> 1. Fix in cpufreq-cpu0
> 2. Fix in i.MX driver and platform file
> 3. Patch below
Yes, please. Thanks.
Shawn
^ permalink raw reply [flat|nested] 66+ messages in thread
* [PATCH v4 13/19] cpufreq: highbank-cpufreq: remove device tree parsing for cpu nodes
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (11 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 12/19] cpufreq: cpufreq-cpu0: " Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 14/19] cpufreq: spear-cpufreq: " Sudeep KarkadaNagesha
` (5 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Mark Langsdorf, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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)
=09if (!of_machine_is_compatible("calxeda,highbank"))
=09=09return -ENODEV;
=20
-=09for_each_child_of_node(of_find_node_by_path("/cpus"), np)
-=09=09if (of_get_property(np, "operating-points", NULL))
-=09=09=09break;
-
-=09if (!np) {
-=09=09pr_err("failed to find highbank cpufreq node\n");
-=09=09return -ENOENT;
-=09}
-
=09cpu_dev =3D get_cpu_device(0);
=09if (!cpu_dev) {
=09=09pr_err("failed to get highbank cpufreq device\n");
-=09=09ret =3D -ENODEV;
-=09=09goto out_put_node;
+=09=09return -ENODEV;
=09}
=20
-=09cpu_dev->of_node =3D np;
+=09np =3D of_node_get(cpu_dev->of_node);
+=09if (!np) {
+=09=09pr_err("failed to find highbank cpufreq node\n");
+=09=09return -ENOENT;
+=09}
=20
=09cpu_clk =3D clk_get(cpu_dev, NULL);
=09if (IS_ERR(cpu_clk)) {
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 14/19] cpufreq: spear-cpufreq: remove device tree parsing for cpu nodes
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (12 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 13/19] cpufreq: highbank-cpufreq: " Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 15/19] cpufreq: kirkwood-cpufreq: " Sudeep KarkadaNagesha
` (4 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Deepak Sikri, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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 <sikrid@qti.qualcomm.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-cpufre=
q.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>
=20
@@ -223,7 +223,7 @@ static int spear_cpufreq_driver_init(void)
=09const __be32 *val;
=09int cnt, i, ret;
=20
-=09np =3D of_find_node_by_path("/cpus/cpu@0");
+=09np =3D of_cpu_device_node_get(0);
=09if (!np) {
=09=09pr_err("No cpu node found");
=09=09return -ENODEV;
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 15/19] cpufreq: kirkwood-cpufreq: remove device tree parsing for cpu nodes
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (13 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 14/19] cpufreq: spear-cpufreq: " Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 16/19] cpufreq: arm_big_little: " Sudeep KarkadaNagesha
` (3 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Jason Cooper, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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: Jason Cooper <jason@lakedaemon.net>
Acked-by: Andrew Lunn <andrew@lunn.ch>
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_devi=
ce *pdev)
=09if (IS_ERR(priv.base))
=09=09return PTR_ERR(priv.base);
=20
-=09np =3D of_find_node_by_path("/cpus/cpu@0");
-=09if (!np)
+=09np =3D of_cpu_device_node_get(0);
+=09if (!np) {
+=09=09dev_err(&pdev->dev, "failed to get cpu device node\n");
=09=09return -ENODEV;
+=09}
=20
=09priv.cpu_clk =3D of_clk_get_by_name(np, "cpu_clk");
=09if (IS_ERR(priv.cpu_clk)) {
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 16/19] cpufreq: arm_big_little: remove device tree parsing for cpu nodes
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (14 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 15/19] cpufreq: kirkwood-cpufreq: " Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 17/19] cpufreq: maple-cpufreq: " Sudeep KarkadaNagesha
` (2 subsequent siblings)
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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 @@
=20
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
=20
-#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)
{
-=09struct device_node *np =3D NULL, *parent;
-=09int count =3D 0;
+=09struct device_node *np =3D of_cpu_device_node_get(cpu);
=20
-=09parent =3D of_find_node_by_path("/cpus");
-=09if (!parent) {
-=09=09pr_err("failed to find OF /cpus\n");
-=09=09return NULL;
+=09if (!of_get_property(np, "operating-points", NULL)) {
+=09=09of_node_put(np);
+=09=09np =3D NULL;
=09}
=20
-=09for_each_child_of_node(parent, np) {
-=09=09if (count++ !=3D cpu)
-=09=09=09continue;
-=09=09if (!of_get_property(np, "operating-points", NULL)) {
-=09=09=09of_node_put(np);
-=09=09=09np =3D NULL;
-=09=09}
-
-=09=09break;
-=09}
-
-=09of_node_put(parent);
=09return np;
}
=20
@@ -63,11 +48,12 @@ static int dt_init_opp_table(struct device *cpu_dev)
=09struct device_node *np;
=09int ret;
=20
-=09np =3D get_cpu_node_with_valid_op(cpu_dev->id);
-=09if (!np)
-=09=09return -ENODATA;
+=09np =3D of_node_get(cpu_dev->of_node);
+=09if (!np) {
+=09=09pr_err("failed to find cpu%d node\n", cpu_dev->id);
+=09=09return -ENOENT;
+=09}
=20
-=09cpu_dev->of_node =3D np;
=09ret =3D of_init_opp_table(cpu_dev);
=09of_node_put(np);
=20
@@ -79,9 +65,11 @@ static int dt_get_transition_latency(struct device *cpu_=
dev)
=09struct device_node *np;
=09u32 transition_latency =3D CPUFREQ_ETERNAL;
=20
-=09np =3D get_cpu_node_with_valid_op(cpu_dev->id);
-=09if (!np)
+=09np =3D of_node_get(cpu_dev->of_node);
+=09if (!np) {
+=09=09pr_info("Failed to find cpu node. Use CPUFREQ_ETERNAL transition lat=
ency\n");
=09=09return CPUFREQ_ETERNAL;
+=09}
=20
=09of_property_read_u32(np, "clock-latency", &transition_latency);
=09of_node_put(np);
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 17/19] cpufreq: maple-cpufreq: remove device tree parsing for cpu nodes
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (15 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 16/19] cpufreq: arm_big_little: " Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 18/19] cpufreq: pmac64-cpufreq: " Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 19/19] cpufreq: pmac32-cpufreq: " Sudeep KarkadaNagesha
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Dmitry Eremin-Solenikov, Grant Likely
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-cpufre=
q.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>
=20
#define DBG(fmt...) pr_debug(fmt)
=20
@@ -201,7 +201,6 @@ static struct cpufreq_driver maple_cpufreq_driver =3D {
=20
static int __init maple_cpufreq_init(void)
{
-=09struct device_node *cpus;
=09struct device_node *cpunode;
=09unsigned int psize;
=09unsigned long max_freq;
@@ -217,24 +216,11 @@ static int __init maple_cpufreq_init(void)
=09 !of_machine_is_compatible("Momentum,Apache"))
=09=09return 0;
=20
-=09cpus =3D of_find_node_by_path("/cpus");
-=09if (cpus =3D=3D NULL) {
-=09=09DBG("No /cpus node !\n");
-=09=09return -ENODEV;
-=09}
-
=09/* Get first CPU node */
-=09for (cpunode =3D NULL;
-=09 (cpunode =3D of_get_next_child(cpus, cpunode)) !=3D NULL;) {
-=09=09const u32 *reg =3D of_get_property(cpunode, "reg", NULL);
-=09=09if (reg =3D=3D NULL || (*reg) !=3D 0)
-=09=09=09continue;
-=09=09if (!strcmp(cpunode->type, "cpu"))
-=09=09=09break;
-=09}
+=09cpunode =3D of_cpu_device_node_get(0);
=09if (cpunode =3D=3D NULL) {
=09=09printk(KERN_ERR "cpufreq: Can't find any CPU 0 node\n");
-=09=09goto bail_cpus;
+=09=09goto bail_noprops;
=09}
=20
=09/* Check 970FX for now */
@@ -290,14 +276,11 @@ static int __init maple_cpufreq_init(void)
=09rc =3D cpufreq_register_driver(&maple_cpufreq_driver);
=20
=09of_node_put(cpunode);
-=09of_node_put(cpus);
=20
=09return rc;
=20
bail_noprops:
=09of_node_put(cpunode);
-bail_cpus:
-=09of_node_put(cpus);
=20
=09return rc;
}
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 18/19] cpufreq: pmac64-cpufreq: remove device tree parsing for cpu nodes
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (16 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 17/19] cpufreq: maple-cpufreq: " Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
2013-08-20 9:30 ` [PATCH v4 19/19] cpufreq: pmac32-cpufreq: " Sudeep KarkadaNagesha
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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-cpuf=
req.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 =3D {
=20
#ifdef CONFIG_PMAC_SMU
=20
-static int __init g5_neo2_cpufreq_init(struct device_node *cpus)
+static int __init g5_neo2_cpufreq_init(struct device_node *cpunode)
{
-=09struct device_node *cpunode;
=09unsigned int psize, ssize;
=09unsigned long max_freq;
=09char *freq_method, *volt_method;
@@ -405,20 +405,6 @@ static int __init g5_neo2_cpufreq_init(struct device_n=
ode *cpus)
=09else
=09=09return -ENODEV;
=20
-=09/* Get first CPU node */
-=09for (cpunode =3D NULL;
-=09 (cpunode =3D of_get_next_child(cpus, cpunode)) !=3D NULL;) {
-=09=09const u32 *reg =3D of_get_property(cpunode, "reg", NULL);
-=09=09if (reg =3D=3D NULL || (*reg) !=3D 0)
-=09=09=09continue;
-=09=09if (!strcmp(cpunode->type, "cpu"))
-=09=09=09break;
-=09}
-=09if (cpunode =3D=3D NULL) {
-=09=09printk(KERN_ERR "cpufreq: Can't find any CPU 0 node\n");
-=09=09return -ENODEV;
-=09}
-
=09/* Check 970FX for now */
=09valp =3D of_get_property(cpunode, "cpu-version", NULL);
=09if (!valp) {
@@ -537,9 +523,9 @@ static int __init g5_neo2_cpufreq_init(struct device_no=
de *cpus)
#endif /* CONFIG_PMAC_SMU */
=20
=20
-static int __init g5_pm72_cpufreq_init(struct device_node *cpus)
+static int __init g5_pm72_cpufreq_init(struct device_node *cpunode)
{
-=09struct device_node *cpuid =3D NULL, *hwclock =3D NULL, *cpunode =3D NUL=
L;
+=09struct device_node *cpuid =3D NULL, *hwclock =3D NULL;
=09const u8 *eeprom =3D NULL;
=09const u32 *valp;
=09u64 max_freq, min_freq, ih, il;
@@ -548,17 +534,6 @@ static int __init g5_pm72_cpufreq_init(struct device_n=
ode *cpus)
=09DBG("cpufreq: Initializing for PowerMac7,2, PowerMac7,3 and"
=09 " RackMac3,1...\n");
=20
-=09/* Get first CPU node */
-=09for (cpunode =3D NULL;
-=09 (cpunode =3D of_get_next_child(cpus, cpunode)) !=3D NULL;) {
-=09=09if (!strcmp(cpunode->type, "cpu"))
-=09=09=09break;
-=09}
-=09if (cpunode =3D=3D NULL) {
-=09=09printk(KERN_ERR "cpufreq: Can't find any CPU node\n");
-=09=09return -ENODEV;
-=09}
-
=09/* Lookup the cpuid eeprom node */
cpuid =3D of_find_node_by_path("/u3@0,f8000000/i2c@f8001000/cpuid@=
a0");
=09if (cpuid !=3D NULL)
@@ -718,25 +693,25 @@ static int __init g5_pm72_cpufreq_init(struct device_=
node *cpus)
=20
static int __init g5_cpufreq_init(void)
{
-=09struct device_node *cpus;
+=09struct device_node *cpunode;
=09int rc =3D 0;
=20
-=09cpus =3D of_find_node_by_path("/cpus");
-=09if (cpus =3D=3D NULL) {
-=09=09DBG("No /cpus node !\n");
+=09/* Get first CPU node */
+=09cpunode =3D of_cpu_device_node_get(0);
+=09if (cpunode =3D=3D NULL) {
+=09=09pr_err("cpufreq: Can't find any CPU node\n");
=09=09return -ENODEV;
=09}
=20
=09if (of_machine_is_compatible("PowerMac7,2") ||
=09 of_machine_is_compatible("PowerMac7,3") ||
=09 of_machine_is_compatible("RackMac3,1"))
-=09=09rc =3D g5_pm72_cpufreq_init(cpus);
+=09=09rc =3D g5_pm72_cpufreq_init(cpunode);
#ifdef CONFIG_PMAC_SMU
=09else
-=09=09rc =3D g5_neo2_cpufreq_init(cpus);
+=09=09rc =3D g5_neo2_cpufreq_init(cpunode);
#endif /* CONFIG_PMAC_SMU */
=20
-=09of_node_put(cpus);
=09return rc;
}
=20
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread
* [PATCH v4 19/19] cpufreq: pmac32-cpufreq: remove device tree parsing for cpu nodes
2013-08-20 9:30 ` [PATCH v4 00/19] DT/core: update cpu device of_node Sudeep KarkadaNagesha
` (17 preceding siblings ...)
2013-08-20 9:30 ` [PATCH v4 18/19] cpufreq: pmac64-cpufreq: " Sudeep KarkadaNagesha
@ 2013-08-20 9:30 ` Sudeep KarkadaNagesha
18 siblings, 0 replies; 66+ messages in thread
From: Sudeep KarkadaNagesha @ 2013-08-20 9:30 UTC (permalink / raw)
To: linux-arm-kernel, linux-kernel, linux-pm, devicetree, linuxppc-dev
Cc: Jonas Bonn, Michal Simek, Greg Kroah-Hartman,
Sudeep KarkadaNagesha, Viresh Kumar, Rob Herring,
Rafael J. Wysocki, Grant Likely
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-cpuf=
req.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)
=09if (strstr(cmd_line, "nocpufreq"))
=09=09return 0;
=20
-=09/* Assume only one CPU */
-=09cpunode =3D of_find_node_by_type(NULL, "cpu");
+=09/* Get first CPU node */
+=09cpunode =3D of_cpu_device_node_get(0);
=09if (!cpunode)
=09=09goto out;
=20
--=20
1.8.1.2
^ permalink raw reply related [flat|nested] 66+ messages in thread