Re: [PATCH v2 1/2] ARM: topology: Use a clock if possible to get the CPU frequency

2 messages, 2 authors, 2014-06-30 · open the first message on its own page

Re: [PATCH v2 1/2] ARM: topology: Use a clock if possible to get the CPU frequency

From: Maxime Ripard <hidden>
Date: 2014-06-30 12:49:19

On Mon, Jun 30, 2014 at 12:39:26PM +0200, Vincent Guittot wrote:
On 30 June 2014 12:29, Russell King - ARM Linux [off-list ref] wrote:
quoted
On Mon, Jun 30, 2014 at 12:12:22PM +0200, Maxime Ripard wrote:
quoted
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 <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
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
quoted
---
 arch/arm/kernel/topology.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index 9d853189028b..268443d88094 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -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);
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

-- 
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

Re: [PATCH v2 1/2] ARM: topology: Use a clock if possible to get the CPU frequency

From: Vincent Guittot <hidden>
Date: 2014-06-30 13:27:21

On 30 June 2014 14:49, Maxime Ripard [off-list ref] wrote:
On Mon, Jun 30, 2014 at 12:39:26PM +0200, Vincent Guittot wrote:
quoted
On 30 June 2014 12:29, Russell King - ARM Linux [off-list ref] wrote:
quoted
On Mon, Jun 30, 2014 at 12:12:22PM +0200, Maxime Ripard wrote:
quoted
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 <maxime.ripard-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
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
quoted
quoted
---
 arch/arm/kernel/topology.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)
diff --git a/arch/arm/kernel/topology.c b/arch/arm/kernel/topology.c
index 9d853189028b..268443d88094 100644
--- a/arch/arm/kernel/topology.c
+++ b/arch/arm/kernel/topology.c
@@ -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);
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 ?

Vincent
Maxime

--
Maxime Ripard, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help