Skip to contentSkip to conversation

cpufreq: tegra186: Share policy per cluster

PATCH In review Aaron Kling 5 participants 8 messages Feb 16, 2025 – Mar 10, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 cpufreq: tegra186: Share policy per cluster

This functionally brings tegra186 in line with tegra210 and tegra194, sharing a cpufreq policy between all cores in a cluster.

---
 drivers/cpufreq/tegra186-cpufreq.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/cpufreq/tegra186-cpufreq.c +7 -0
index c7761eb99f3cc..c832a1270e688 100644
@@ -73,11 +73,18 @@ static int tegra186_cpufreq_init(struct cpufreq_policy *policy)
 {
 	struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
 	unsigned int cluster = data->cpus[policy->cpu].bpmp_cluster_id;
+	u32 cpu;
 
 	policy->freq_table = data->clusters[cluster].table;
 	policy->cpuinfo.transition_latency = 300 * 1000;
 	policy->driver_data = NULL;
 
+	/* set same policy for all cpus in a cluster */
+	for (cpu = 0; cpu < (sizeof(tegra186_cpus)/sizeof(struct tegra186_cpufreq_cpu)); cpu++) {
+		if (data->cpus[cpu].bpmp_cluster_id == cluster)
+			cpumask_set_cpu(cpu, policy->cpus);
+	}
+
 	return 0;
 }
 
Signature · 1 line
2.48.1
maintainer
#1 lore raw
Quoted 20 lines · Aaron Kling

This functionally brings tegra186 in line with tegra210 and tegra194, sharing a cpufreq policy between all cores in a cluster.

---
 drivers/cpufreq/tegra186-cpufreq.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/cpufreq/tegra186-cpufreq.c +1 -0
index c7761eb99f3cc..c832a1270e688 100644
@@ -73,11 +73,18 @@ static int tegra186_cpufreq_init(struct cpufreq_policy *policy)
 {
 	struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
 	unsigned int cluster = data->cpus[policy->cpu].bpmp_cluster_id;
+	u32 cpu;
 
 	policy->freq_table = data->clusters[cluster].table;
 	policy->cpuinfo.transition_latency = 300 * 1000;

drivers/cpufreq/tegra186-cpufreq.c static int tegra186_cpufreq_init(struct cpufreq_policy *policy) · line 89

Quoted 10 lines
drivers/cpufreq/tegra186-cpufreq.c +6 -0
 	policy->driver_data = NULL;
 
+	/* set same policy for all cpus in a cluster */
+	for (cpu = 0; cpu < (sizeof(tegra186_cpus)/sizeof(struct tegra186_cpufreq_cpu)); cpu++) {
+		if (data->cpus[cpu].bpmp_cluster_id == cluster)
+			cpumask_set_cpu(cpu, policy->cpus);
+	}
+
 	return 0;
 }

Thierry / Jonathan,

Any inputs on this ?

Signature · 1 line
viresh
#2 lore raw
Quoted 34 lines · Viresh Kumar
Quoted 20 lines · Aaron Kling

This functionally brings tegra186 in line with tegra210 and tegra194, sharing a cpufreq policy between all cores in a cluster.

---
 drivers/cpufreq/tegra186-cpufreq.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/cpufreq/tegra186-cpufreq.c +1 -0
index c7761eb99f3cc..c832a1270e688 100644
@@ -73,11 +73,18 @@ static int tegra186_cpufreq_init(struct cpufreq_policy *policy)
 {
 	struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
 	unsigned int cluster = data->cpus[policy->cpu].bpmp_cluster_id;
+	u32 cpu;
 
 	policy->freq_table = data->clusters[cluster].table;
 	policy->cpuinfo.transition_latency = 300 * 1000;

drivers/cpufreq/tegra186-cpufreq.c static int tegra186_cpufreq_init(struct cpufreq_policy *policy) · line 89

Quoted 10 lines
drivers/cpufreq/tegra186-cpufreq.c +6 -0
 	policy->driver_data = NULL;
 
+	/* set same policy for all cpus in a cluster */
+	for (cpu = 0; cpu < (sizeof(tegra186_cpus)/sizeof(struct tegra186_cpufreq_cpu)); cpu++) {
+		if (data->cpus[cpu].bpmp_cluster_id == cluster)
+			cpumask_set_cpu(cpu, policy->cpus);
+	}
+
 	return 0;
 }

Thierry / Jonathan,

Quoted 1 line

Any inputs on this ?

Sumit,

does this look reasonable?

Thanks,
Thierry

Reviewed-by
#3 lore raw
Quoted 35 lines · Thierry Reding
Quoted 34 lines · Viresh Kumar
Quoted 20 lines · Aaron Kling

This functionally brings tegra186 in line with tegra210 and tegra194, sharing a cpufreq policy between all cores in a cluster.

---
  drivers/cpufreq/tegra186-cpufreq.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/cpufreq/tegra186-cpufreq.c +1 -0
index c7761eb99f3cc..c832a1270e688 100644
@@ -73,11 +73,18 @@ static int tegra186_cpufreq_init(struct cpufreq_policy *policy)
  {
  	struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
  	unsigned int cluster = data->cpus[policy->cpu].bpmp_cluster_id;
+	u32 cpu;
 
  	policy->freq_table = data->clusters[cluster].table;
  	policy->cpuinfo.transition_latency = 300 * 1000;

drivers/cpufreq/tegra186-cpufreq.c static int tegra186_cpufreq_init(struct cpufreq_policy *policy) · line 89

Quoted 10 lines
drivers/cpufreq/tegra186-cpufreq.c +6 -0
  	policy->driver_data = NULL;
 
+	/* set same policy for all cpus in a cluster */
+	for (cpu = 0; cpu < (sizeof(tegra186_cpus)/sizeof(struct tegra186_cpufreq_cpu)); cpu++) {
+		if (data->cpus[cpu].bpmp_cluster_id == cluster)
+			cpumask_set_cpu(cpu, policy->cpus);
+	}
+
  	return 0;
  }

Thierry / Jonathan,

Quoted 8 lines
Quoted 1 line

Any inputs on this ?

Sumit,

does this look reasonable?

Thanks,
Thierry

Looks good to me.

Best Regards,
Sumit Gupta

#4 lore raw
Quoted 40 lines · Sumit Gupta
Quoted 37 lines · Thierry Reding
Quoted 32 lines · Viresh Kumar
Quoted 18 lines · Aaron Kling

This functionally brings tegra186 in line with tegra210 and tegra194, sharing a cpufreq policy between all cores in a cluster.

---
  drivers/cpufreq/tegra186-cpufreq.c | 7 +++++++
  1 file changed, 7 insertions(+)
drivers/cpufreq/tegra186-cpufreq.c +1 -0
index c7761eb99f3cc..c832a1270e688 100644
@@ -73,11 +73,18 @@ static int tegra186_cpufreq_init(struct cpufreq_policy *policy)
  {
  	struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
  	unsigned int cluster = data->cpus[policy->cpu].bpmp_cluster_id;
+	u32 cpu;
  	policy->freq_table = data->clusters[cluster].table;

drivers/cpufreq/tegra186-cpufreq.c static int tegra186_cpufreq_init(struct cpufreq_policy *policy) · line 87

Quoted 10 lines
drivers/cpufreq/tegra186-cpufreq.c +6 -0
  	policy->cpuinfo.transition_latency = 300 * 1000;
  	policy->driver_data = NULL;
+	/* set same policy for all cpus in a cluster */
+	for (cpu = 0; cpu < (sizeof(tegra186_cpus)/sizeof(struct tegra186_cpufreq_cpu)); cpu++) {
+		if (data->cpus[cpu].bpmp_cluster_id == cluster)
+			cpumask_set_cpu(cpu, policy->cpus);
+	}
+
  	return 0;
  }

Thierry / Jonathan,

Quoted 1 line

Any inputs on this ?

Sumit,

Quoted 8 lines
Quoted 4 lines

does this look reasonable?

Thanks,
Thierry

Looks good to me.

Thanks, in that case:

maintainer
#5 lore raw
In reply to Aaron Kling
Quoted 14 lines · Aaron Kling

This functionally brings tegra186 in line with tegra210 and tegra194, sharing a cpufreq policy between all cores in a cluster.

---
 drivers/cpufreq/tegra186-cpufreq.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/cpufreq/tegra186-cpufreq.c +0 -0
index c7761eb99f3cc..c832a1270e688 100644
@@ -73,11 +73,18 @@ static int tegra186_cpufreq_init(struct cpufreq_policy *policy)
 {

drivers/cpufreq/tegra186-cpufreq.c static int tegra186_cpufreq_init(struct cpufreq_policy *policy) · line 83

Quoted 10 lines
drivers/cpufreq/tegra186-cpufreq.c +3 -0
 	struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
 	unsigned int cluster = data->cpus[policy->cpu].bpmp_cluster_id;
+	u32 cpu;
 
 	policy->freq_table = data->clusters[cluster].table;
 	policy->cpuinfo.transition_latency = 300 * 1000;
 	policy->driver_data = NULL;
 
+	/* set same policy for all cpus in a cluster */
+	for (cpu = 0; cpu < (sizeof(tegra186_cpus)/sizeof(struct tegra186_cpufreq_cpu)); cpu++) {

Can't you use ARRAY_SIZE here ?

Quoted 5 lines
drivers/cpufreq/tegra186-cpufreq.c +4 -0
+		if (data->cpus[cpu].bpmp_cluster_id == cluster)
+			cpumask_set_cpu(cpu, policy->cpus);
+	}
+
 	return 0;
Signature · 1 line
viresh
#6 lore raw
Quoted 20 lines · Viresh Kumar
Quoted 18 lines · Aaron Kling

This functionally brings tegra186 in line with tegra210 and tegra194, sharing a cpufreq policy between all cores in a cluster.

---
 drivers/cpufreq/tegra186-cpufreq.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/cpufreq/tegra186-cpufreq.c +1 -0
index c7761eb99f3cc..c832a1270e688 100644
@@ -73,11 +73,18 @@ static int tegra186_cpufreq_init(struct cpufreq_policy *policy)
 {
      struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
      unsigned int cluster = data->cpus[policy->cpu].bpmp_cluster_id;
+     u32 cpu;
 
Quoted 8 lines

drivers/cpufreq/tegra186-cpufreq.c static int tegra186_cpufreq_init(struct cpufreq_policy *policy) · line 83

Quoted 6 lines
drivers/cpufreq/tegra186-cpufreq.c +2 -0
      policy->freq_table = data->clusters[cluster].table;
      policy->cpuinfo.transition_latency = 300 * 1000;
      policy->driver_data = NULL;
 
+     /* set same policy for all cpus in a cluster */
+     for (cpu = 0; cpu < (sizeof(tegra186_cpus)/sizeof(struct tegra186_cpufreq_cpu)); cpu++) {

Can't you use ARRAY_SIZE here ?

I could, just wasn't aware of that macro. Is that enough to send a v2 over?

Quoted 9 lines

drivers/cpufreq/tegra186-cpufreq.c static int tegra186_cpufreq_init(struct cpufreq_policy *policy) · line 88

Quoted 6 lines
drivers/cpufreq/tegra186-cpufreq.c +4 -0
+             if (data->cpus[cpu].bpmp_cluster_id == cluster)
+                     cpumask_set_cpu(cpu, policy->cpus);
+     }
+
      return 0;

--
viresh

Sincerely,
Aaron

maintainer
#7 lore raw
Quoted 25 lines · Aaron Kling
Quoted 24 lines · Viresh Kumar
Quoted 22 lines · Aaron Kling

This functionally brings tegra186 in line with tegra210 and tegra194, sharing a cpufreq policy between all cores in a cluster.

---
 drivers/cpufreq/tegra186-cpufreq.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/cpufreq/tegra186-cpufreq.c +1 -0
index c7761eb99f3cc..c832a1270e688 100644
@@ -73,11 +73,18 @@ static int tegra186_cpufreq_init(struct cpufreq_policy *policy)
 {
      struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
      unsigned int cluster = data->cpus[policy->cpu].bpmp_cluster_id;
+     u32 cpu;
 
      policy->freq_table = data->clusters[cluster].table;
      policy->cpuinfo.transition_latency = 300 * 1000;
      policy->driver_data = NULL;
 
Quoted 6 lines
Quoted 4 lines

drivers/cpufreq/tegra186-cpufreq.c static int tegra186_cpufreq_init(struct cpufreq_policy *policy) · line 83

Quoted 2 lines
drivers/cpufreq/tegra186-cpufreq.c +2 -0
+     /* set same policy for all cpus in a cluster */
+     for (cpu = 0; cpu < (sizeof(tegra186_cpus)/sizeof(struct tegra186_cpufreq_cpu)); cpu++) {

Can't you use ARRAY_SIZE here ?

I could, just wasn't aware of that macro. Is that enough to send a v2 over?

Yes, please send that and include the tags you received.

Signature · 1 line
viresh