ARM: topology: Allow to set the frequency through a clock
Subsystems (3)
v2 cover ARM: topology: Allow to set the frequency through a clock
Hi,
This patch series add the possibility for the topology code to get the CPU frequency through a DT clock handle instead of needing a clock-frequency property.
Indeed, this information can be quite redundant if the clock tree defined in the DT is already describing the CPU parent clock.
Maxime
Changes from v1:
- Rebased on top of 3.16
- Reworked a bit the code in the first patch as requested by Rob Herring
Maxime Ripard (2):
ARM: topology: Use a clock if possible to get the CPU frequency
ARM: sunxi: Add clocks node to the CPU nodes
arch/arm/boot/dts/sun6i-a31.dtsi | 4 ++++ arch/arm/boot/dts/sun7i-a20.dtsi | 2 ++ arch/arm/kernel/topology.c | 25 ++++++++++++++++++------- 3 files changed, 24 insertions(+), 7 deletions(-)
Signature · 1 line
2.0.0
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
The Cortex-A7 and Cortex-A15 based SoCs need a clock-frequency property in the topology code.
Allow to use a clock to provide the same information.
--- arch/arm/kernel/topology.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)
arch/arm/kernel/topology.c +18 -7
@@ -11,6 +11,7 @@* for more details. */ +#include <linux/clk.h> #include <linux/cpu.h> #include <linux/cpumask.h> #include <linux/export.h>
@@ -100,8 +101,8 @@ static void __init parse_dt_topology(void) GFP_NOWAIT);for_each_possible_cpu (cpu) { -const u32 *rate; -int len; +struct clk *clk; +u32 rate =0 ;/* too early to use cpu->of_node */ cn =of_get_cpu_node (cpu,NULL );
@@ -117,14 +118,24 @@ static void __init parse_dt_topology(void)if (cpu_eff->compatible ==NULL )continue ; - rate =of_get_property (cn,"clock-frequency" , &len); -if (!rate || len !=4 ) { -pr_err ("%s missing clock-frequency property\n" , - cn->full_name); + clk =of_clk_get (cn,0 ); +if (!IS_ERR (clk)) + rate =clk_get_rate (clk); +else +of_property_read_u32 (cn,"clock-frequency" , &rate); + +if (!rate) { +pr_err ("%s missing clocks or clock-frequency properties\n" , + cn->full_name); +continue ; + } + +if (!rate) { +pr_err ("%s invalid CPU frequency" , cn->full_name);continue ; } - capacity = ((be32_to_cpup (rate)) >>20 ) * cpu_eff->efficiency; + capacity = ((rate) >>20 ) * cpu_eff->efficiency;/* Save min capacity of the system */ if (capacity < min_capacity)
Signature · 1 line
2.0.0
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 6 lines · Maxime Ripard
The Cortex-A7 and Cortex-A15 based SoCs need a clock-frequency property in the topology code.
Allow to use a clock to provide the same information.
Signed-off-by Maxime Ripard <[email protected]>
This looks fine to me, but I don't know this code. Maybe Vincent Guittot should be on the To: list (added)?
Quoted 60 lines
--- arch/arm/kernel/topology.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)arch/arm/kernel/topology.c +18
-7@@ -11,6 +11,7 @@* for more details. */ +#include <linux/clk.h> #include <linux/cpu.h> #include <linux/cpumask.h> #include <linux/export.h> @@ -100,8 +101,8 @@ static void __init parse_dt_topology(void) GFP_NOWAIT);for_each_possible_cpu (cpu) { -const u32 *rate; -int len; +struct clk *clk; +u32 rate =0 ;/* too early to use cpu->of_node */ cn =of_get_cpu_node (cpu,NULL );@@ -117,14 +118,24 @@ static void __init parse_dt_topology(void)if (cpu_eff->compatible ==NULL )continue ; - rate =of_get_property (cn,"clock-frequency" , &len); -if (!rate || len !=4 ) { -pr_err ("%s missing clock-frequency property\n" , - cn->full_name); + clk =of_clk_get (cn,0 ); +if (!IS_ERR (clk)) + rate =clk_get_rate (clk); +else +of_property_read_u32 (cn,"clock-frequency" , &rate); + +if (!rate) { +pr_err ("%s missing clocks or clock-frequency properties\n" , + cn->full_name); +continue ; + } + +if (!rate) { +pr_err ("%s invalid CPU frequency" , cn->full_name);continue ; } - capacity = ((be32_to_cpup (rate)) >>20 ) * cpu_eff->efficiency; + capacity = ((rate) >>20 ) * cpu_eff->efficiency;/* Save min capacity of the system */ if (capacity < min_capacity)Signature · 1 line
2.0.0
Signature · 2 lines
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly improving, and getting towards what was expected from it.
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 10 lines · Russell King - ARM Linux
Quoted 6 lines · Maxime Ripard
The Cortex-A7 and Cortex-A15 based SoCs need a clock-frequency property in the topology code.
Allow to use a clock to provide the same information.
Signed-off-by Maxime Ripard <[email protected]>This looks fine to me, but I don't know this code. Maybe Vincent Guittot should be on the To: list (added)?
Thanks
Quoted 32 lines
Quoted 32 lines
--- arch/arm/kernel/topology.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)arch/arm/kernel/topology.c +3
-2@@ -11,6 +11,7 @@* for more details. */ +#include <linux/clk.h> #include <linux/cpu.h> #include <linux/cpumask.h> #include <linux/export.h> @@ -100,8 +101,8 @@ static void __init parse_dt_topology(void) GFP_NOWAIT);for_each_possible_cpu (cpu) { -const u32 *rate; -int len; +struct clk *clk; +u32 rate =0 ;/* too early to use cpu->of_node */ cn =of_get_cpu_node (cpu,NULL );@@ -117,14 +118,24 @@ static void __init parse_dt_topology(void)if (cpu_eff->compatible ==NULL )continue ;
Quoted 7 lines
arch/arm/kernel/topology.c static void __init parse_dt_topology(void) · line 123
Quoted 7 lines
arch/arm/kernel/topology.c +3
-4- rate =of_get_property (cn,"clock-frequency" , &len); -if (!rate || len !=4 ) { -pr_err ("%s missing clock-frequency property\n" , - cn->full_name); + clk =of_clk_get (cn,0 ); +if (!IS_ERR (clk)) + rate =clk_get_rate (clk);
We need the max frequency as it will be used to weight the different CPUs capacity. How do you ensure that the current clock rate is the max one ?
Vincent
Quoted 26 lines
Quoted 20 lines
arch/arm/kernel/topology.c +12
-2+else +of_property_read_u32 (cn,"clock-frequency" , &rate); + +if (!rate) { +pr_err ("%s missing clocks or clock-frequency properties\n" , + cn->full_name); +continue ; + } + +if (!rate) { +pr_err ("%s invalid CPU frequency" , cn->full_name);continue ; } - capacity = ((be32_to_cpup (rate)) >>20 ) * cpu_eff->efficiency; + capacity = ((rate) >>20 ) * cpu_eff->efficiency;/* Save min capacity of the system */ if (capacity < min_capacity) --Quoted 2 lines
2.0.0
--
FTTC broadband for 0.8mile line: now at 9.7Mbps down 460kbps up... slowly improving, and getting towards what was expected from it.
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 5 lines · Vincent Guittot
Quoted 4 lines · Russell King - ARM Linux
Quoted 3 lines · Maxime Ripard
The Cortex-A7 and Cortex-A15 based SoCs need a clock-frequency property in the topology code.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Allow to use a clock to provide the same information.
Signed-off-by Maxime Ripard <[email protected]>This looks fine to me, but I don't know this code. Maybe Vincent Guittot should be on the To: list (added)?
Thanks
Ah, sorry for that.
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
--- arch/arm/kernel/topology.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)arch/arm/kernel/topology.c +3
-2@@ -11,6 +11,7 @@* for more details. */ +#include <linux/clk.h> #include <linux/cpu.h> #include <linux/cpumask.h> #include <linux/export.h> @@ -100,8 +101,8 @@ static void __init parse_dt_topology(void) GFP_NOWAIT);for_each_possible_cpu (cpu) { -const u32 *rate; -int len; +struct clk *clk; +u32 rate =0 ;/* too early to use cpu->of_node */ cn =of_get_cpu_node (cpu,NULL );@@ -117,14 +118,24 @@ static void __init parse_dt_topology(void)if (cpu_eff->compatible ==NULL )continue ;
Quoted 11 lines
Quoted 7 lines
arch/arm/kernel/topology.c static void __init parse_dt_topology(void) · line 123
Quoted 7 lines
arch/arm/kernel/topology.c +3
-4- rate =of_get_property (cn,"clock-frequency" , &len); -if (!rate || len !=4 ) { -pr_err ("%s missing clock-frequency property\n" , - cn->full_name); + clk =of_clk_get (cn,0 ); +if (!IS_ERR (clk)) + rate =clk_get_rate (clk);We need the max frequency as it will be used to weight the different CPUs capacity. How do you ensure that the current clock rate is the max one ?
Hmm, the clock-frequency attribute in the ePAPR is defined at the current CPU frequency, not the max one.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140630/72cfdc8d/attachment-0001.sig>
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 62 lines · Maxime Ripard
Quoted 5 lines · Vincent Guittot
Quoted 4 lines · Russell King - ARM Linux
Quoted 3 lines · Maxime Ripard
The Cortex-A7 and Cortex-A15 based SoCs need a clock-frequency property in the topology code.
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Allow to use a clock to provide the same information.
Signed-off-by Maxime Ripard <[email protected]>This looks fine to me, but I don't know this code. Maybe Vincent Guittot should be on the To: list (added)?
Thanks
Ah, sorry for that.
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
--- arch/arm/kernel/topology.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-)arch/arm/kernel/topology.c +3
-2@@ -11,6 +11,7 @@* for more details. */ +#include <linux/clk.h> #include <linux/cpu.h> #include <linux/cpumask.h> #include <linux/export.h> @@ -100,8 +101,8 @@ static void __init parse_dt_topology(void) GFP_NOWAIT);for_each_possible_cpu (cpu) { -const u32 *rate; -int len; +struct clk *clk; +u32 rate =0 ;/* too early to use cpu->of_node */ cn =of_get_cpu_node (cpu,NULL );@@ -117,14 +118,24 @@ static void __init parse_dt_topology(void)if (cpu_eff->compatible ==NULL )continue ;Quoted 11 lines
Quoted 7 lines
arch/arm/kernel/topology.c static void __init parse_dt_topology(void) · line 123
Quoted 7 lines
arch/arm/kernel/topology.c +3
-4- rate =of_get_property (cn,"clock-frequency" , &len); -if (!rate || len !=4 ) { -pr_err ("%s missing clock-frequency property\n" , - cn->full_name); + clk =of_clk_get (cn,0 ); +if (!IS_ERR (clk)) + rate =clk_get_rate (clk);We need the max frequency as it will be used to weight the different CPUs capacity. How do you ensure that the current clock rate is the max one ?
Quoted 2 lines
Hmm, the clock-frequency attribute in the ePAPR is defined at the current CPU frequency, not the max one.
What means current frequency in device tree when DVFS is involved ?
Vincent
Quoted 7 lines
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 8 lines · Vincent Guittot
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
arch/arm/kernel/topology.c +3
-4- rate =of_get_property (cn,"clock-frequency" , &len); -if (!rate || len !=4 ) { -pr_err ("%s missing clock-frequency property\n" , - cn->full_name); + clk =of_clk_get (cn,0 ); +if (!IS_ERR (clk)) + rate =clk_get_rate (clk);
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
We need the max frequency as it will be used to weight the different CPUs capacity. How do you ensure that the current clock rate is the max one ?
Hmm, the clock-frequency attribute in the ePAPR is defined at the current CPU frequency, not the max one.
What means current frequency in device tree when DVFS is involved ?
The ePAPR states that clock-frequency is supposed to be "the current clock speed of the CPU in Hertz". It's exactly what my patch add.
Now, you're right, DVFS would be an issue here with clock-frequency, but this patch actually makes it easier to deal with, since you only get a reference to a clock, and you can get its rate at any given time.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140630/3955e656/attachment.sig>
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 18 lines · Maxime Ripard
Quoted 8 lines · Vincent Guittot
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
arch/arm/kernel/topology.c +3
-4- rate =of_get_property (cn,"clock-frequency" , &len); -if (!rate || len !=4 ) { -pr_err ("%s missing clock-frequency property\n" , - cn->full_name); + clk =of_clk_get (cn,0 ); +if (!IS_ERR (clk)) + rate =clk_get_rate (clk);Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
We need the max frequency as it will be used to weight the different CPUs capacity. How do you ensure that the current clock rate is the max one ?
Hmm, the clock-frequency attribute in the ePAPR is defined at the current CPU frequency, not the max one.
What means current frequency in device tree when DVFS is involved ?
Quoted 7 lines
The ePAPR states that clock-frequency is supposed to be "the current clock speed of the CPU in Hertz". It's exactly what my patch add.
Now, you're right, DVFS would be an issue here with clock-frequency, but this patch actually makes it easier to deal with, since you only get a reference to a clock, and you can get its rate at any given time.
and what about using clk_round_rate(clk, ULONG_MAX) ?
We will not be dependent of when we parse DT
Vincent
Quoted 7 lines
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 22 lines · Vincent Guittot
Quoted 21 lines · Maxime Ripard
Quoted 8 lines · Vincent Guittot
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +3
-4- rate = of_get_property(cn, "clock-frequency", &len); - if (!rate || len != 4) { - pr_err("%s missing clock-frequency property\n", - cn->full_name); + clk = of_clk_get(cn, 0); + if (!IS_ERR(clk)) + rate = clk_get_rate(clk);Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
We need the max frequency as it will be used to weight the different CPUs capacity. How do you ensure that the current clock rate is the max one ?
Hmm, the clock-frequency attribute in the ePAPR is defined at the current CPU frequency, not the max one.
What means current frequency in device tree when DVFS is involved ?
The ePAPR states that clock-frequency is supposed to be "the current clock speed of the CPU in Hertz". It's exactly what my patch add.
Quoted 6 lines
Quoted 4 lines
Now, you're right, DVFS would be an issue here with clock-frequency, but this patch actually makes it easier to deal with, since you only get a reference to a clock, and you can get its rate at any given time.
and what about using
clk_round_rate(clk, ULONG_MAX)?
Well, the clock itself might generate a frequency higher that what the CPU can run at, so I'm not sure it's a valid assumption.
Quoted 1 line
We will not be dependent of when we parse DT
You lost me there. clk_round_rate and clk_get_rate are available at the same time in the boot process, aren't they?
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140630/6b84a52e/attachment.sig>
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 28 lines · Maxime Ripard
Quoted 27 lines · Vincent Guittot
Quoted 25 lines · Maxime Ripard
Quoted 8 lines · Vincent Guittot
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +3
-4- rate = of_get_property(cn, "clock-frequency", &len); - if (!rate || len != 4) { - pr_err("%s missing clock-frequency property\n", - cn->full_name); + clk = of_clk_get(cn, 0); + if (!IS_ERR(clk)) + rate = clk_get_rate(clk);Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
We need the max frequency as it will be used to weight the different CPUs capacity. How do you ensure that the current clock rate is the max one ?
Hmm, the clock-frequency attribute in the ePAPR is defined at the current CPU frequency, not the max one.
What means current frequency in device tree when DVFS is involved ?
The ePAPR states that clock-frequency is supposed to be "the current clock speed of the CPU in Hertz". It's exactly what my patch add.
Now, you're right, DVFS would be an issue here with clock-frequency, but this patch actually makes it easier to deal with, since you only get a reference to a clock, and you can get its rate at any given time.
Quoted 4 lines
Quoted 1 line
and what about using
clk_round_rate(clk, ULONG_MAX)?Well, the clock itself might generate a frequency higher that what the CPU can run at, so I'm not sure it's a valid assumption.
yes, you're right
Quoted 5 lines
Quoted 2 lines
We will not be dependent of when we parse DT
You lost me there.
clk_round_rateandclk_get_rateare available at the same time in the boot process, aren't they?
yes, but clk_round_rate(clk, ULONG_MAX) will return the max frequency and not the current one. But as you mentioned, it doesn't ensure that it's a possible frequency for the core
Quoted 7 lines
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 37 lines · Vincent Guittot
Quoted 28 lines · Maxime Ripard
Quoted 27 lines · Vincent Guittot
Quoted 25 lines · Maxime Ripard
Quoted 8 lines · Vincent Guittot
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +3
-4- rate = of_get_property(cn, "clock-frequency", &len); - if (!rate || len != 4) { - pr_err("%s missing clock-frequency property\n", - cn->full_name); + clk = of_clk_get(cn, 0); + if (!IS_ERR(clk)) + rate = clk_get_rate(clk);Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
We need the max frequency as it will be used to weight the different CPUs capacity. How do you ensure that the current clock rate is the max one ?
Hmm, the clock-frequency attribute in the ePAPR is defined at the current CPU frequency, not the max one.
What means current frequency in device tree when DVFS is involved ?
The ePAPR states that clock-frequency is supposed to be "the current clock speed of the CPU in Hertz". It's exactly what my patch add.
Now, you're right, DVFS would be an issue here with clock-frequency, but this patch actually makes it easier to deal with, since you only get a reference to a clock, and you can get its rate at any given time.
Quoted 4 lines
Quoted 1 line
and what about using
clk_round_rate(clk, ULONG_MAX)?Well, the clock itself might generate a frequency higher that what the CPU can run at, so I'm not sure it's a valid assumption.
yes, you're right
Quoted 1 line
Quoted 8 lines
Quoted 4 lines
Quoted 1 line
We will not be dependent of when we parse DT
You lost me there.
clk_round_rateandclk_get_rateare available at the same time in the boot process, aren't they?yes, but
clk_round_rate(clk, ULONG_MAX)will return the max frequency and not the current one. But as you mentioned, it doesn't ensure that it's a possible frequency for the core
Is this an Acked-by ?
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140703/491ce4a6/attachment.sig>
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 40 lines · Maxime Ripard
Quoted 39 lines · Vincent Guittot
Quoted 28 lines · Maxime Ripard
Quoted 27 lines · Vincent Guittot
Quoted 25 lines · Maxime Ripard
Quoted 8 lines · Vincent Guittot
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +3
-4- rate = of_get_property(cn, "clock-frequency", &len); - if (!rate || len != 4) { - pr_err("%s missing clock-frequency property\n", - cn->full_name); + clk = of_clk_get(cn, 0); + if (!IS_ERR(clk)) + rate = clk_get_rate(clk);Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
We need the max frequency as it will be used to weight the different CPUs capacity. How do you ensure that the current clock rate is the max one ?
Hmm, the clock-frequency attribute in the ePAPR is defined at the current CPU frequency, not the max one.
What means current frequency in device tree when DVFS is involved ?
The ePAPR states that clock-frequency is supposed to be "the current clock speed of the CPU in Hertz". It's exactly what my patch add.
Now, you're right, DVFS would be an issue here with clock-frequency, but this patch actually makes it easier to deal with, since you only get a reference to a clock, and you can get its rate at any given time.
Quoted 4 lines
Quoted 1 line
and what about using
clk_round_rate(clk, ULONG_MAX)?Well, the clock itself might generate a frequency higher that what the CPU can run at, so I'm not sure it's a valid assumption.
yes, you're right
Quoted 3 lines
Quoted 2 lines
We will not be dependent of when we parse DT
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
You lost me there.
clk_round_rateandclk_get_rateare available at the same time in the boot process, aren't they?yes, but
clk_round_rate(clk, ULONG_MAX)will return the max frequency and not the current one. But as you mentioned, it doesn't ensure that it's a possible frequency for the coreIs this an Acked-by ?
I still think that using the current rate with clk_get_rate is not a
good solution.
Could you give us more details about why you nee to use current clock ?
AFAICT, your patch only makes sense for HMP system which don't have DVFS, is it your case ?
Vincent
Quoted 7 lines
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 44 lines · Vincent Guittot
Quoted 43 lines · Maxime Ripard
Quoted 42 lines · Vincent Guittot
Quoted 28 lines · Maxime Ripard
Quoted 27 lines · Vincent Guittot
Quoted 25 lines · Maxime Ripard
Quoted 8 lines · Vincent Guittot
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +3
-4- rate = of_get_property(cn, "clock-frequency", &len); - if (!rate || len != 4) { - pr_err("%s missing clock-frequency property\n", - cn->full_name); + clk = of_clk_get(cn, 0); + if (!IS_ERR(clk)) + rate = clk_get_rate(clk);Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
We need the max frequency as it will be used to weight the different CPUs capacity. How do you ensure that the current clock rate is the max one ?
Hmm, the clock-frequency attribute in the ePAPR is defined at the current CPU frequency, not the max one.
What means current frequency in device tree when DVFS is involved ?
The ePAPR states that clock-frequency is supposed to be "the current clock speed of the CPU in Hertz". It's exactly what my patch add.
Now, you're right, DVFS would be an issue here with clock-frequency, but this patch actually makes it easier to deal with, since you only get a reference to a clock, and you can get its rate at any given time.
Quoted 4 lines
Quoted 1 line
and what about using
clk_round_rate(clk, ULONG_MAX)?Well, the clock itself might generate a frequency higher that what the CPU can run at, so I'm not sure it's a valid assumption.
yes, you're right
Quoted 5 lines
Quoted 2 lines
We will not be dependent of when we parse DT
You lost me there.
clk_round_rateandclk_get_rateare available at the same time in the boot process, aren't they?
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
yes, but
clk_round_rate(clk, ULONG_MAX)will return the max frequency and not the current one. But as you mentioned, it doesn't ensure that it's a possible frequency for the coreIs this an Acked-by ?
I still think that using the current rate with
clk_get_rateis not a
good solution.
Well, it's just as good as using clock-frequency, really. If you want the CPU max frequency, it's not the right property (plus, since the changed behaviour is not documented in Linux anywhere, the only reference we have is the ePAPR on this).
Quoted 1 line
Could you give us more details about why you nee to use current clock ?
Honestly, I just want to remove that big warning at boot on the A7-based SoCs we have :)
Quoted 2 lines
AFAICT, your patch only makes sense for HMP system which don't have DVFS, is it your case ?
Nope, it's just plain simple SMP.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140704/4224dc53/attachment.sig>
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 59 lines · Maxime Ripard
Quoted 44 lines · Vincent Guittot
Quoted 43 lines · Maxime Ripard
Quoted 42 lines · Vincent Guittot
Quoted 28 lines · Maxime Ripard
Quoted 27 lines · Vincent Guittot
Quoted 25 lines · Maxime Ripard
Quoted 8 lines · Vincent Guittot
Quoted 8 lines
Quoted 8 lines
Quoted 7 lines
Quoted 7 lines
(quoted diff) +3
-4- rate = of_get_property(cn, "clock-frequency", &len); - if (!rate || len != 4) { - pr_err("%s missing clock-frequency property\n", - cn->full_name); + clk = of_clk_get(cn, 0); + if (!IS_ERR(clk)) + rate = clk_get_rate(clk);Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
We need the max frequency as it will be used to weight the different CPUs capacity. How do you ensure that the current clock rate is the max one ?
Hmm, the clock-frequency attribute in the ePAPR is defined at the current CPU frequency, not the max one.
What means current frequency in device tree when DVFS is involved ?
The ePAPR states that clock-frequency is supposed to be "the current clock speed of the CPU in Hertz". It's exactly what my patch add.
Now, you're right, DVFS would be an issue here with clock-frequency, but this patch actually makes it easier to deal with, since you only get a reference to a clock, and you can get its rate at any given time.
Quoted 4 lines
Quoted 1 line
and what about using
clk_round_rate(clk, ULONG_MAX)?Well, the clock itself might generate a frequency higher that what the CPU can run at, so I'm not sure it's a valid assumption.
yes, you're right
Quoted 5 lines
Quoted 2 lines
We will not be dependent of when we parse DT
You lost me there.
clk_round_rateandclk_get_rateare available at the same time in the boot process, aren't they?Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
yes, but
clk_round_rate(clk, ULONG_MAX)will return the max frequency and not the current one. But as you mentioned, it doesn't ensure that it's a possible frequency for the coreIs this an Acked-by ?
I still think that using the current rate with
clk_get_rateis not a
good solution.Well, it's just as good as using clock-frequency, really. If you want the CPU max frequency, it's not the right property (plus, since the changed behaviour is not documented in Linux anywhere, the only reference we have is the ePAPR on this).
Quoted 4 lines
Quoted 1 line
Could you give us more details about why you nee to use current clock ?
Honestly, I just want to remove that big warning at boot on the A7-based SoCs we have :)
so Why not changing the log message ? It's clearly not an error to not have clock-frequency
Quoted 12 lines
Quoted 3 lines
AFAICT, your patch only makes sense for HMP system which don't have DVFS, is it your case ?
Nope, it's just plain simple SMP.
Maxime
--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
PATCH v2 1/2 ARM: topology: Use a clock if possible to get the CPU frequency
Quoted 8 lines · Vincent Guittot
Quoted 8 lines
Quoted 2 lines
I still think that using the current rate with
clk_get_rateis not a
good solution.Well, it's just as good as using clock-frequency, really. If you want the CPU max frequency, it's not the right property (plus, since the changed behaviour is not documented in Linux anywhere, the only reference we have is the ePAPR on this).
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Could you give us more details about why you nee to use current clock ?
Honestly, I just want to remove that big warning at boot on the A7-based SoCs we have :)
so Why not changing the log message ? It's clearly not an error to not have clock-frequency
Because the next SoCs we're going to support will be HMP, so we're only delaying the issue by a few month if we're doing so.
It doesn't fix the underlying issue where you're using a standard property for a (slightly) different usage.
Maxime
Signature · 10 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140708/32eb41b8/attachment.sig>
PATCH v2 2/2 ARM: sunxi: Add clocks node to the CPU nodes
In reply to Maxime RipardSetting the clock will make the topology code work, and will remove the following error at boot
[ 0.097194] /cpus/cpu at 0 missing clock-frequency property [ 0.103657] /cpus/cpu at 1 missing clock-frequency property [ 0.110698] /cpus/cpu at 2 missing clock-frequency property [ 0.117132] /cpus/cpu at 3 missing clock-frequency property
--- arch/arm/boot/dts/sun6i-a31.dtsi | 4 ++++ arch/arm/boot/dts/sun7i-a20.dtsi | 2 ++ 2 files changed, 6 insertions(+)
arch/arm/boot/dts/sun6i-a31.dtsi +4 -0
@@ -34,24 +34,28 @@ cpu at 0 { compatible = "arm,cortex-a7"; device_type = "cpu"; + clocks = <&cpu>; reg = <0>; }; cpu at 1 { compatible = "arm,cortex-a7"; device_type = "cpu"; + clocks = <&cpu>; reg = <1>; }; cpu at 2 { compatible = "arm,cortex-a7"; device_type = "cpu"; + clocks = <&cpu>; reg = <2>; }; cpu at 3 { compatible = "arm,cortex-a7"; device_type = "cpu"; + clocks = <&cpu>; reg = <3>; }; };
arch/arm/boot/dts/sun7i-a20.dtsi +2 -0
@@ -35,12 +35,14 @@ cpu at 0 { compatible = "arm,cortex-a7"; device_type = "cpu"; + clocks = <&cpu>; reg = <0>; }; cpu at 1 { compatible = "arm,cortex-a7"; device_type = "cpu"; + clocks = <&cpu>; reg = <1>; }; };
Signature · 1 line
2.0.0