Skip to content

Commit fa06c48

Browse files
committed
Merge tag 'cpufreq-arm-updates-6.18-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm
Merge CPUFreq fixes for 6.18 from Viresh Kumar: "- Update frequency for all tegra CPUs (Aaron Kling). - Fix device leak in mediatek driver (Johan Hovold). - Rust cpufreq helper cleanup (Thorsten Blum)." * tag 'cpufreq-arm-updates-6.18-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: cpufreq: tegra186: Initialize all cores to max frequencies cpufreq: tegra186: Set target frequency for all cpus in policy rust: cpufreq: streamline find_supply_names cpufreq: mediatek: fix device leak on probe failure
2 parents 950c645 + ba60189 commit fa06c48

3 files changed

Lines changed: 41 additions & 18 deletions

File tree

drivers/cpufreq/mediatek-cpufreq.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,11 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
403403
}
404404

405405
info->cpu_clk = clk_get(cpu_dev, "cpu");
406-
if (IS_ERR(info->cpu_clk))
407-
return dev_err_probe(cpu_dev, PTR_ERR(info->cpu_clk),
408-
"cpu%d: failed to get cpu clk\n", cpu);
406+
if (IS_ERR(info->cpu_clk)) {
407+
ret = PTR_ERR(info->cpu_clk);
408+
dev_err_probe(cpu_dev, ret, "cpu%d: failed to get cpu clk\n", cpu);
409+
goto out_put_cci_dev;
410+
}
409411

410412
info->inter_clk = clk_get(cpu_dev, "intermediate");
411413
if (IS_ERR(info->inter_clk)) {
@@ -551,6 +553,10 @@ static int mtk_cpu_dvfs_info_init(struct mtk_cpu_dvfs_info *info, int cpu)
551553
out_free_mux_clock:
552554
clk_put(info->cpu_clk);
553555

556+
out_put_cci_dev:
557+
if (info->soc_data->ccifreq_supported)
558+
put_device(info->cci_dev);
559+
554560
return ret;
555561
}
556562

@@ -568,6 +574,8 @@ static void mtk_cpu_dvfs_info_release(struct mtk_cpu_dvfs_info *info)
568574
clk_put(info->inter_clk);
569575
dev_pm_opp_of_cpumask_remove_table(&info->cpus);
570576
dev_pm_opp_unregister_notifier(info->cpu_dev, &info->opp_nb);
577+
if (info->soc_data->ccifreq_supported)
578+
put_device(info->cci_dev);
571579
}
572580

573581
static int mtk_cpufreq_init(struct cpufreq_policy *policy)

drivers/cpufreq/rcpufreq_dt.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,11 @@ fn find_supply_name_exact(dev: &Device, name: &str) -> Option<CString> {
2828
/// Finds supply name for the CPU from DT.
2929
fn find_supply_names(dev: &Device, cpu: cpu::CpuId) -> Option<KVec<CString>> {
3030
// Try "cpu0" for older DTs, fallback to "cpu".
31-
let name = (cpu.as_u32() == 0)
31+
(cpu.as_u32() == 0)
3232
.then(|| find_supply_name_exact(dev, "cpu0"))
3333
.flatten()
34-
.or_else(|| find_supply_name_exact(dev, "cpu"))?;
35-
36-
let mut list = KVec::with_capacity(1, GFP_KERNEL).ok()?;
37-
list.push(name, GFP_KERNEL).ok()?;
38-
39-
Some(list)
34+
.or_else(|| find_supply_name_exact(dev, "cpu"))
35+
.and_then(|name| kernel::kvec![name].ok())
4036
}
4137

4238
/// Represents the cpufreq dt device.

drivers/cpufreq/tegra186-cpufreq.c

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,14 @@ static int tegra186_cpufreq_set_target(struct cpufreq_policy *policy,
9393
{
9494
struct tegra186_cpufreq_data *data = cpufreq_get_driver_data();
9595
struct cpufreq_frequency_table *tbl = policy->freq_table + index;
96-
unsigned int edvd_offset = data->cpus[policy->cpu].edvd_offset;
96+
unsigned int edvd_offset;
9797
u32 edvd_val = tbl->driver_data;
98+
u32 cpu;
9899

99-
writel(edvd_val, data->regs + edvd_offset);
100+
for_each_cpu(cpu, policy->cpus) {
101+
edvd_offset = data->cpus[cpu].edvd_offset;
102+
writel(edvd_val, data->regs + edvd_offset);
103+
}
100104

101105
return 0;
102106
}
@@ -132,13 +136,14 @@ static struct cpufreq_driver tegra186_cpufreq_driver = {
132136

133137
static struct cpufreq_frequency_table *init_vhint_table(
134138
struct platform_device *pdev, struct tegra_bpmp *bpmp,
135-
struct tegra186_cpufreq_cluster *cluster, unsigned int cluster_id)
139+
struct tegra186_cpufreq_cluster *cluster, unsigned int cluster_id,
140+
int *num_rates)
136141
{
137142
struct cpufreq_frequency_table *table;
138143
struct mrq_cpu_vhint_request req;
139144
struct tegra_bpmp_message msg;
140145
struct cpu_vhint_data *data;
141-
int err, i, j, num_rates = 0;
146+
int err, i, j;
142147
dma_addr_t phys;
143148
void *virt;
144149

@@ -168,6 +173,7 @@ static struct cpufreq_frequency_table *init_vhint_table(
168173
goto free;
169174
}
170175

176+
*num_rates = 0;
171177
for (i = data->vfloor; i <= data->vceil; i++) {
172178
u16 ndiv = data->ndiv[i];
173179

@@ -178,10 +184,10 @@ static struct cpufreq_frequency_table *init_vhint_table(
178184
if (i > 0 && ndiv == data->ndiv[i - 1])
179185
continue;
180186

181-
num_rates++;
187+
(*num_rates)++;
182188
}
183189

184-
table = devm_kcalloc(&pdev->dev, num_rates + 1, sizeof(*table),
190+
table = devm_kcalloc(&pdev->dev, *num_rates + 1, sizeof(*table),
185191
GFP_KERNEL);
186192
if (!table) {
187193
table = ERR_PTR(-ENOMEM);
@@ -223,7 +229,9 @@ static int tegra186_cpufreq_probe(struct platform_device *pdev)
223229
{
224230
struct tegra186_cpufreq_data *data;
225231
struct tegra_bpmp *bpmp;
226-
unsigned int i = 0, err;
232+
unsigned int i = 0, err, edvd_offset;
233+
int num_rates = 0;
234+
u32 edvd_val, cpu;
227235

228236
data = devm_kzalloc(&pdev->dev,
229237
struct_size(data, clusters, TEGRA186_NUM_CLUSTERS),
@@ -246,10 +254,21 @@ static int tegra186_cpufreq_probe(struct platform_device *pdev)
246254
for (i = 0; i < TEGRA186_NUM_CLUSTERS; i++) {
247255
struct tegra186_cpufreq_cluster *cluster = &data->clusters[i];
248256

249-
cluster->table = init_vhint_table(pdev, bpmp, cluster, i);
257+
cluster->table = init_vhint_table(pdev, bpmp, cluster, i, &num_rates);
250258
if (IS_ERR(cluster->table)) {
251259
err = PTR_ERR(cluster->table);
252260
goto put_bpmp;
261+
} else if (!num_rates) {
262+
err = -EINVAL;
263+
goto put_bpmp;
264+
}
265+
266+
for (cpu = 0; cpu < ARRAY_SIZE(tegra186_cpus); cpu++) {
267+
if (data->cpus[cpu].bpmp_cluster_id == i) {
268+
edvd_val = cluster->table[num_rates - 1].driver_data;
269+
edvd_offset = data->cpus[cpu].edvd_offset;
270+
writel(edvd_val, data->regs + edvd_offset);
271+
}
253272
}
254273
}
255274

0 commit comments

Comments
 (0)