* [PATCH v3 0/2] cpufreq: tegra186: Fix initialization and scaling
@ 2025-08-29 2:48 Aaron Kling via B4 Relay
2025-08-29 2:48 ` [PATCH v3 1/2] cpufreq: tegra186: Set target frequency for all cpus in policy Aaron Kling via B4 Relay
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Aaron Kling via B4 Relay @ 2025-08-29 2:48 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter,
Aaron Kling, Sumit Gupta
Cc: Thierry Reding, linux-pm, linux-tegra, linux-kernel, Aaron Kling,
Mikko Perttunen
This series fixes an issue with shared policy per cluster not scaling
all cpus and with some cores being initialized by the subsystem.
Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
---
Changes in v3:
- Use more clearly named variables in patch 2
- In patch 2, fail probe if no cpu rates reported by bpmp
- Link to v2: https://lore.kernel.org/r/20250828-tegra186-cpufreq-fixes-v2-0-fcffe4de1e15@gmail.com
Changes in v2:
- Set max freq instead of base freq in patch 2
- Link to v1: https://lore.kernel.org/r/20250826-tegra186-cpufreq-fixes-v1-0-97f98d3e0adb@gmail.com
---
Aaron Kling (2):
cpufreq: tegra186: Set target frequency for all cpus in policy
cpufreq: tegra186: Initialize all cores to max frequencies
drivers/cpufreq/tegra186-cpufreq.c | 35 +++++++++++++++++++++++++++--------
1 file changed, 27 insertions(+), 8 deletions(-)
---
base-commit: 1b237f190eb3d36f52dffe07a40b5eb210280e00
change-id: 20250826-tegra186-cpufreq-fixes-7fbff81c68a2
Best regards,
--
Aaron Kling <webgeek1234@gmail.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH v3 1/2] cpufreq: tegra186: Set target frequency for all cpus in policy
2025-08-29 2:48 [PATCH v3 0/2] cpufreq: tegra186: Fix initialization and scaling Aaron Kling via B4 Relay
@ 2025-08-29 2:48 ` Aaron Kling via B4 Relay
2025-08-29 2:48 ` [PATCH v3 2/2] cpufreq: tegra186: Initialize all cores to max frequencies Aaron Kling via B4 Relay
2025-09-04 5:03 ` [PATCH v3 0/2] cpufreq: tegra186: Fix initialization and scaling Viresh Kumar
2 siblings, 0 replies; 6+ messages in thread
From: Aaron Kling via B4 Relay @ 2025-08-29 2:48 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter,
Aaron Kling, Sumit Gupta
Cc: Thierry Reding, linux-pm, linux-tegra, linux-kernel, Aaron Kling
From: Aaron Kling <webgeek1234@gmail.com>
The original commit set all cores in a cluster to a shared policy, but
did not update set_target to apply a frequency change to all cores for
the policy. This caused most cores to remain stuck at their boot
frequency.
Fixes: be4ae8c19492 ("cpufreq: tegra186: Share policy per cluster")
Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
---
drivers/cpufreq/tegra186-cpufreq.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/cpufreq/tegra186-cpufreq.c b/drivers/cpufreq/tegra186-cpufreq.c
index cbabb726c6645d2e5f1857a47e5643c8552d1933..6c394b429b6182faffabf222e5af501393dbbba9 100644
--- a/drivers/cpufreq/tegra186-cpufreq.c
+++ b/drivers/cpufreq/tegra186-cpufreq.c
@@ -93,10 +93,14 @@ static int tegra186_cpufreq_set_target(struct cpufreq_policy *policy,
{
struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
struct cpufreq_frequency_table *tbl = policy->freq_table + index;
- unsigned int edvd_offset = data->cpus[policy->cpu].edvd_offset;
+ unsigned int edvd_offset;
u32 edvd_val = tbl->driver_data;
+ u32 cpu;
- writel(edvd_val, data->regs + edvd_offset);
+ for_each_cpu(cpu, policy->cpus) {
+ edvd_offset = data->cpus[cpu].edvd_offset;
+ writel(edvd_val, data->regs + edvd_offset);
+ }
return 0;
}
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH v3 2/2] cpufreq: tegra186: Initialize all cores to max frequencies
2025-08-29 2:48 [PATCH v3 0/2] cpufreq: tegra186: Fix initialization and scaling Aaron Kling via B4 Relay
2025-08-29 2:48 ` [PATCH v3 1/2] cpufreq: tegra186: Set target frequency for all cpus in policy Aaron Kling via B4 Relay
@ 2025-08-29 2:48 ` Aaron Kling via B4 Relay
2025-08-29 5:39 ` Viresh Kumar
2025-09-04 5:03 ` [PATCH v3 0/2] cpufreq: tegra186: Fix initialization and scaling Viresh Kumar
2 siblings, 1 reply; 6+ messages in thread
From: Aaron Kling via B4 Relay @ 2025-08-29 2:48 UTC (permalink / raw)
To: Rafael J. Wysocki, Viresh Kumar, Thierry Reding, Jonathan Hunter,
Aaron Kling, Sumit Gupta
Cc: Thierry Reding, linux-pm, linux-tegra, linux-kernel, Aaron Kling,
Mikko Perttunen
From: Aaron Kling <webgeek1234@gmail.com>
During initialization, the EDVD_COREx_VOLT_FREQ registers for some cores
are still at reset values and not reflecting the actual frequency. This
causes get calls to fail. Set all cores to their respective max
frequency during probe to initialize the registers to working values.
Suggested-by: Mikko Perttunen <mperttunen@nvidia.com>
Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
---
drivers/cpufreq/tegra186-cpufreq.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/drivers/cpufreq/tegra186-cpufreq.c b/drivers/cpufreq/tegra186-cpufreq.c
index 6c394b429b6182faffabf222e5af501393dbbba9..bd94beebc4cc2fe6870e13ca55343cedb9729e99 100644
--- a/drivers/cpufreq/tegra186-cpufreq.c
+++ b/drivers/cpufreq/tegra186-cpufreq.c
@@ -138,13 +138,14 @@ static struct cpufreq_driver tegra186_cpufreq_driver = {
static struct cpufreq_frequency_table *init_vhint_table(
struct platform_device *pdev, struct tegra_bpmp *bpmp,
- struct tegra186_cpufreq_cluster *cluster, unsigned int cluster_id)
+ struct tegra186_cpufreq_cluster *cluster, unsigned int cluster_id,
+ int *num_rates)
{
struct cpufreq_frequency_table *table;
struct mrq_cpu_vhint_request req;
struct tegra_bpmp_message msg;
struct cpu_vhint_data *data;
- int err, i, j, num_rates = 0;
+ int err, i, j;
dma_addr_t phys;
void *virt;
@@ -174,6 +175,7 @@ static struct cpufreq_frequency_table *init_vhint_table(
goto free;
}
+ *num_rates = 0;
for (i = data->vfloor; i <= data->vceil; i++) {
u16 ndiv = data->ndiv[i];
@@ -184,10 +186,10 @@ static struct cpufreq_frequency_table *init_vhint_table(
if (i > 0 && ndiv == data->ndiv[i - 1])
continue;
- num_rates++;
+ (*num_rates)++;
}
- table = devm_kcalloc(&pdev->dev, num_rates + 1, sizeof(*table),
+ table = devm_kcalloc(&pdev->dev, *num_rates + 1, sizeof(*table),
GFP_KERNEL);
if (!table) {
table = ERR_PTR(-ENOMEM);
@@ -229,7 +231,9 @@ static int tegra186_cpufreq_probe(struct platform_device *pdev)
{
struct tegra186_cpufreq_data *data;
struct tegra_bpmp *bpmp;
- unsigned int i = 0, err;
+ unsigned int i = 0, err, edvd_offset;
+ int num_rates = 0;
+ u32 edvd_val, cpu;
data = devm_kzalloc(&pdev->dev,
struct_size(data, clusters, TEGRA186_NUM_CLUSTERS),
@@ -252,10 +256,21 @@ static int tegra186_cpufreq_probe(struct platform_device *pdev)
for (i = 0; i < TEGRA186_NUM_CLUSTERS; i++) {
struct tegra186_cpufreq_cluster *cluster = &data->clusters[i];
- cluster->table = init_vhint_table(pdev, bpmp, cluster, i);
+ cluster->table = init_vhint_table(pdev, bpmp, cluster, i, &num_rates);
if (IS_ERR(cluster->table)) {
err = PTR_ERR(cluster->table);
goto put_bpmp;
+ } else if (!num_rates) {
+ err = -EINVAL;
+ goto put_bpmp;
+ }
+
+ for (cpu = 0; cpu < ARRAY_SIZE(tegra186_cpus); cpu++) {
+ if (data->cpus[cpu].bpmp_cluster_id == i) {
+ edvd_val = cluster->table[num_rates - 1].driver_data;
+ edvd_offset = data->cpus[cpu].edvd_offset;
+ writel(edvd_val, data->regs + edvd_offset);
+ }
}
}
--
2.50.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v3 2/2] cpufreq: tegra186: Initialize all cores to max frequencies
2025-08-29 2:48 ` [PATCH v3 2/2] cpufreq: tegra186: Initialize all cores to max frequencies Aaron Kling via B4 Relay
@ 2025-08-29 5:39 ` Viresh Kumar
0 siblings, 0 replies; 6+ messages in thread
From: Viresh Kumar @ 2025-08-29 5:39 UTC (permalink / raw)
To: webgeek1234
Cc: Rafael J. Wysocki, Thierry Reding, Jonathan Hunter, Aaron Kling,
Sumit Gupta, Thierry Reding, linux-pm, linux-tegra, linux-kernel,
Mikko Perttunen
On 28-08-25, 21:48, Aaron Kling via B4 Relay wrote:
> From: Aaron Kling <webgeek1234@gmail.com>
>
> During initialization, the EDVD_COREx_VOLT_FREQ registers for some cores
> are still at reset values and not reflecting the actual frequency. This
> causes get calls to fail. Set all cores to their respective max
> frequency during probe to initialize the registers to working values.
>
> Suggested-by: Mikko Perttunen <mperttunen@nvidia.com>
> Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
> ---
> drivers/cpufreq/tegra186-cpufreq.c | 27 +++++++++++++++++++++------
> 1 file changed, 21 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/cpufreq/tegra186-cpufreq.c b/drivers/cpufreq/tegra186-cpufreq.c
> index 6c394b429b6182faffabf222e5af501393dbbba9..bd94beebc4cc2fe6870e13ca55343cedb9729e99 100644
> --- a/drivers/cpufreq/tegra186-cpufreq.c
> +++ b/drivers/cpufreq/tegra186-cpufreq.c
> @@ -138,13 +138,14 @@ static struct cpufreq_driver tegra186_cpufreq_driver = {
>
> static struct cpufreq_frequency_table *init_vhint_table(
> struct platform_device *pdev, struct tegra_bpmp *bpmp,
> - struct tegra186_cpufreq_cluster *cluster, unsigned int cluster_id)
> + struct tegra186_cpufreq_cluster *cluster, unsigned int cluster_id,
> + int *num_rates)
> {
> struct cpufreq_frequency_table *table;
> struct mrq_cpu_vhint_request req;
> struct tegra_bpmp_message msg;
> struct cpu_vhint_data *data;
> - int err, i, j, num_rates = 0;
> + int err, i, j;
> dma_addr_t phys;
> void *virt;
>
> @@ -174,6 +175,7 @@ static struct cpufreq_frequency_table *init_vhint_table(
> goto free;
> }
>
> + *num_rates = 0;
> for (i = data->vfloor; i <= data->vceil; i++) {
> u16 ndiv = data->ndiv[i];
>
> @@ -184,10 +186,10 @@ static struct cpufreq_frequency_table *init_vhint_table(
> if (i > 0 && ndiv == data->ndiv[i - 1])
> continue;
>
> - num_rates++;
> + (*num_rates)++;
> }
>
> - table = devm_kcalloc(&pdev->dev, num_rates + 1, sizeof(*table),
> + table = devm_kcalloc(&pdev->dev, *num_rates + 1, sizeof(*table),
> GFP_KERNEL);
> if (!table) {
> table = ERR_PTR(-ENOMEM);
> @@ -229,7 +231,9 @@ static int tegra186_cpufreq_probe(struct platform_device *pdev)
> {
> struct tegra186_cpufreq_data *data;
> struct tegra_bpmp *bpmp;
> - unsigned int i = 0, err;
> + unsigned int i = 0, err, edvd_offset;
> + int num_rates = 0;
You don't need to initialize this AFAICT.
> + u32 edvd_val, cpu;
>
> data = devm_kzalloc(&pdev->dev,
> struct_size(data, clusters, TEGRA186_NUM_CLUSTERS),
> @@ -252,10 +256,21 @@ static int tegra186_cpufreq_probe(struct platform_device *pdev)
> for (i = 0; i < TEGRA186_NUM_CLUSTERS; i++) {
> struct tegra186_cpufreq_cluster *cluster = &data->clusters[i];
>
> - cluster->table = init_vhint_table(pdev, bpmp, cluster, i);
> + cluster->table = init_vhint_table(pdev, bpmp, cluster, i, &num_rates);
> if (IS_ERR(cluster->table)) {
> err = PTR_ERR(cluster->table);
> goto put_bpmp;
> + } else if (!num_rates) {
> + err = -EINVAL;
> + goto put_bpmp;
> + }
> +
> + for (cpu = 0; cpu < ARRAY_SIZE(tegra186_cpus); cpu++) {
> + if (data->cpus[cpu].bpmp_cluster_id == i) {
> + edvd_val = cluster->table[num_rates - 1].driver_data;
> + edvd_offset = data->cpus[cpu].edvd_offset;
> + writel(edvd_val, data->regs + edvd_offset);
> + }
> }
> }
>
>
> --
> 2.50.1
>
--
viresh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] cpufreq: tegra186: Fix initialization and scaling
2025-08-29 2:48 [PATCH v3 0/2] cpufreq: tegra186: Fix initialization and scaling Aaron Kling via B4 Relay
2025-08-29 2:48 ` [PATCH v3 1/2] cpufreq: tegra186: Set target frequency for all cpus in policy Aaron Kling via B4 Relay
2025-08-29 2:48 ` [PATCH v3 2/2] cpufreq: tegra186: Initialize all cores to max frequencies Aaron Kling via B4 Relay
@ 2025-09-04 5:03 ` Viresh Kumar
2025-09-04 7:58 ` Mikko Perttunen
2 siblings, 1 reply; 6+ messages in thread
From: Viresh Kumar @ 2025-09-04 5:03 UTC (permalink / raw)
To: webgeek1234
Cc: Rafael J. Wysocki, Thierry Reding, Jonathan Hunter, Aaron Kling,
Sumit Gupta, Thierry Reding, linux-pm, linux-tegra, linux-kernel,
Mikko Perttunen
On 28-08-25, 21:48, Aaron Kling via B4 Relay wrote:
> This series fixes an issue with shared policy per cluster not scaling
> all cpus and with some cores being initialized by the subsystem.
>
> Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
> ---
> Changes in v3:
> - Use more clearly named variables in patch 2
> - In patch 2, fail probe if no cpu rates reported by bpmp
> - Link to v2: https://lore.kernel.org/r/20250828-tegra186-cpufreq-fixes-v2-0-fcffe4de1e15@gmail.com
Would be nice to get an Ack from one of the Tegra maintainers before I
apply this.
--
viresh
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v3 0/2] cpufreq: tegra186: Fix initialization and scaling
2025-09-04 5:03 ` [PATCH v3 0/2] cpufreq: tegra186: Fix initialization and scaling Viresh Kumar
@ 2025-09-04 7:58 ` Mikko Perttunen
0 siblings, 0 replies; 6+ messages in thread
From: Mikko Perttunen @ 2025-09-04 7:58 UTC (permalink / raw)
To: webgeek1234, Viresh Kumar
Cc: Rafael J. Wysocki, Thierry Reding, Jonathan Hunter, Aaron Kling,
Sumit Gupta, Thierry Reding, linux-pm, linux-tegra, linux-kernel
On Thursday, September 4, 2025 2:03 PM Viresh Kumar wrote:
> On 28-08-25, 21:48, Aaron Kling via B4 Relay wrote:
> > This series fixes an issue with shared policy per cluster not scaling
> > all cpus and with some cores being initialized by the subsystem.
> >
> > Signed-off-by: Aaron Kling <webgeek1234@gmail.com>
> > ---
> > Changes in v3:
> > - Use more clearly named variables in patch 2
> > - In patch 2, fail probe if no cpu rates reported by bpmp
> > - Link to v2: https://lore.kernel.org/r/20250828-tegra186-cpufreq-fixes-v2-0-fcffe4de1e15@gmail.com
>
> Would be nice to get an Ack from one of the Tegra maintainers before I
> apply this.
>
>
Not technically a maintainer for this area, but FWIW,
Reviewed-by: Mikko Perttunen <mperttunen@nvidia.com>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-09-04 7:58 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-29 2:48 [PATCH v3 0/2] cpufreq: tegra186: Fix initialization and scaling Aaron Kling via B4 Relay
2025-08-29 2:48 ` [PATCH v3 1/2] cpufreq: tegra186: Set target frequency for all cpus in policy Aaron Kling via B4 Relay
2025-08-29 2:48 ` [PATCH v3 2/2] cpufreq: tegra186: Initialize all cores to max frequencies Aaron Kling via B4 Relay
2025-08-29 5:39 ` Viresh Kumar
2025-09-04 5:03 ` [PATCH v3 0/2] cpufreq: tegra186: Fix initialization and scaling Viresh Kumar
2025-09-04 7:58 ` Mikko Perttunen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).