History

Merge tag 'cpufreq-arm-updates-7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm

Pull CPUFreq Arm updates for 7.3 from Viresh Kumar: "- Minor fixes / cleanups in cpufreq drivers (Dan Carpenter, Guru Das Srinagesh, Haoxiang Li, Karl Mehltretter, Sasha Finkelstein, and Pan Chuang). - Fix cpufreq table creation and bios_limits() callback in the Rust bindings (Priya Bala Govindasamy). - Add IPQ5210 support to qcom-nvmem driver (Varadarajan Narayanan)." * tag 'cpufreq-arm-updates-7.3' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: cpufreq: imx6q: fix out-of-bounds write when probed more than once cpufreq: imx6q: fix devres accumulation across driver rebind rust: cpufreq: Fix temporary write in Registration::bios_limit_callback rust: cpufreq: Add CPUFREQ_TABLE_END as last table entry in TableBuilder::to_table cpufreq: apple-soc: Calculate frequency as a 64-bit value cpufreq: spear: Fix an IS_ERR() vs NULL bug in spear1340_set_cpu_rate() cpufreq: brcmstb-avs: Remove redundant dev_err() rust: rcpufreq_dt: use vertical import style cpufreq: apple-soc: Fix OPP table cleanup cpufreq: qcom-nvmem: Add IPQ5210 support

Rafael J. Wysocki committed 3 months ago

Commit f4fa4b72 parents eb49643 8c3afcf8 files · +58 −41Browse files

Unified · Split

8 files
  1. drivers/cpufreq/apple-soc-cpufreq.c +15 −23
  2. drivers/cpufreq/brcmstb-avs-cpufreq.c +1 −4
  3. drivers/cpufreq/cpufreq-dt-platdev.c +1 −0
  4. drivers/cpufreq/imx6q-cpufreq.c +4 −2
  5. drivers/cpufreq/qcom-cpufreq-nvmem.c +8 −0
  6. drivers/cpufreq/rcpufreq_dt.rs +10 −3
  7. drivers/cpufreq/spear-cpufreq.c +2 −2
  8. rust/kernel/cpufreq.rs +17 −7
drivers/cpufreq/apple-soc-cpufreq.c+15−23
@@ -249,21 +249,19 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy) · 248 unmodified lines
249 return -ENODEV;249 return -ENODEV;
250 }250 }
251 251
252 ret = dev_pm_opp_of_add_table(cpu_dev);252 priv = kzalloc_obj(*priv);
253 if (ret < 0) {253 if (!priv)
254 dev_err(cpu_dev, "%s: failed to add OPP table: %d\n", __func__, ret);254 return -ENOMEM;
255 return ret;
256 }
257 255
258 ret = apple_soc_cpufreq_find_cluster(policy, &reg_base, &info);256 ret = apple_soc_cpufreq_find_cluster(policy, &reg_base, &info);
259 if (ret) {257 if (ret) {
260 dev_err(cpu_dev, "%s: failed to get cluster info: %d\n", __func__, ret);258 dev_err(cpu_dev, "%s: failed to get cluster info: %d\n", __func__, ret);
261 return ret;259 goto out_free_priv;
262 }260 }
263 261
264 ret = dev_pm_opp_set_sharing_cpus(cpu_dev, policy->cpus);262 ret = dev_pm_opp_of_cpumask_add_table(policy->cpus);
265 if (ret) {263 if (ret < 0) {
266 dev_err(cpu_dev, "%s: failed to mark OPPs as shared: %d\n", __func__, ret);264 dev_err(cpu_dev, "%s: failed to add OPP table: %d\n", __func__, ret);
267 goto out_iounmap;265 goto out_iounmap;
268 }266 }
269 267
@@ -271,24 +269,18 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy) · 1 unmodified line
271 if (ret <= 0) {269 if (ret <= 0) {
272 dev_dbg(cpu_dev, "OPP table is not ready, deferring probe\n");270 dev_dbg(cpu_dev, "OPP table is not ready, deferring probe\n");
273 ret = -EPROBE_DEFER;271 ret = -EPROBE_DEFER;
274 goto out_free_opp;272 goto out_free_table;
275 }
276
277 priv = kzalloc_obj(*priv);
278 if (!priv) {
279 ret = -ENOMEM;
280 goto out_free_opp;
281 }273 }
282 274
283 ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);275 ret = dev_pm_opp_init_cpufreq_table(cpu_dev, &freq_table);
284 if (ret) {276 if (ret) {
285 dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret);277 dev_err(cpu_dev, "failed to init cpufreq table: %d\n", ret);
286 goto out_free_priv;278 goto out_free_table;
287 }279 }
288 280
289 /* Get OPP levels (p-state indexes) and stash them in driver_data */281 /* Get OPP levels (p-state indexes) and stash them in driver_data */
290 for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {282 for (i = 0; freq_table[i].frequency != CPUFREQ_TABLE_END; i++) {
291 unsigned long rate = freq_table[i].frequency * 1000 + 999;283 unsigned long rate = freq_table[i].frequency * 1000UL + 999;
292 struct dev_pm_opp *opp = dev_pm_opp_find_freq_floor(cpu_dev, &rate);284 struct dev_pm_opp *opp = dev_pm_opp_find_freq_floor(cpu_dev, &rate);
293 285
294 if (IS_ERR(opp)) {286 if (IS_ERR(opp)) {
@@ -318,12 +310,12 @@ static int apple_soc_cpufreq_init(struct cpufreq_policy *policy) · 23 unmodified lines
318 310
319out_free_cpufreq_table:311out_free_cpufreq_table:
320 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);312 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
321out_free_priv:313out_free_table:
322 kfree(priv);314 dev_pm_opp_of_cpumask_remove_table(policy->cpus);
323out_free_opp:
324 dev_pm_opp_remove_all_dynamic(cpu_dev);
325out_iounmap:315out_iounmap:
326 iounmap(reg_base);316 iounmap(reg_base);
317out_free_priv:
318 kfree(priv);
327 return ret;319 return ret;
328}320}
329 321
@@ -332,7 +324,7 @@ static void apple_soc_cpufreq_exit(struct cpufreq_policy *policy) · 2 unmodified lines
332 struct apple_cpu_priv *priv = policy->driver_data;324 struct apple_cpu_priv *priv = policy->driver_data;
333 325
334 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);326 dev_pm_opp_free_cpufreq_table(priv->cpu_dev, &policy->freq_table);
335 dev_pm_opp_remove_all_dynamic(priv->cpu_dev);327 dev_pm_opp_of_cpumask_remove_table(policy->cpus);
336 iounmap(priv->reg_base);328 iounmap(priv->reg_base);
337 kfree(priv);329 kfree(priv);
338}330}
drivers/cpufreq/brcmstb-avs-cpufreq.c+1−4
@@ -584,11 +584,8 @@ static int brcm_avs_prepare_init(struct platform_device *pdev) · 583 unmodified lines
584 ret = devm_request_irq(dev, priv->host_irq, irq_handler,584 ret = devm_request_irq(dev, priv->host_irq, irq_handler,
585 IRQF_TRIGGER_RISING,585 IRQF_TRIGGER_RISING,
586 BRCM_AVS_HOST_INTR, priv);586 BRCM_AVS_HOST_INTR, priv);
587 if (ret && priv->host_irq >= 0) {587 if (ret && priv->host_irq >= 0)
588 dev_err(dev, "IRQ request failed: %s (%d) -- %d\n",
589 BRCM_AVS_HOST_INTR, priv->host_irq, ret);
590 goto unmap_intr_base;588 goto unmap_intr_base;
591 }
592 589
593 if (brcm_avs_is_firmware_loaded(priv))590 if (brcm_avs_is_firmware_loaded(priv))
594 return 0;591 return 0;
drivers/cpufreq/cpufreq-dt-platdev.c+1−0
@@ -200,6 +200,7 @@ static const struct of_device_id blocklist[] __initconst = { · 199 unmodified lines
200 { .compatible = "ti,am62l3", },200 { .compatible = "ti,am62l3", },
201 { .compatible = "ti,am62p5", },201 { .compatible = "ti,am62p5", },
202 202
203 { .compatible = "qcom,ipq5210", },
203 { .compatible = "qcom,ipq5332", },204 { .compatible = "qcom,ipq5332", },
204 { .compatible = "qcom,ipq5424", },205 { .compatible = "qcom,ipq5424", },
205 { .compatible = "qcom,ipq6018", },206 { .compatible = "qcom,ipq6018", },
drivers/cpufreq/imx6q-cpufreq.c+4−2
@@ -55,7 +55,6 @@ static unsigned int max_freq; · 54 unmodified lines
55static unsigned int transition_latency;55static unsigned int transition_latency;
56 56
57static u32 *imx6_soc_volt;57static u32 *imx6_soc_volt;
58static u32 soc_opp_count;
59 58
60static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)59static int imx6q_set_target(struct cpufreq_policy *policy, unsigned int index)
61{60{
@@ -330,6 +329,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) · 268 unmodified lines
330 const struct property *prop;329 const struct property *prop;
331 const __be32 *val;330 const __be32 *val;
332 u32 nr, i, j;331 u32 nr, i, j;
332 u32 soc_opp_count = 0;
333 333
334 cpu_dev = get_cpu_device(0);334 cpu_dev = get_cpu_device(0);
335 if (!cpu_dev) {335 if (!cpu_dev) {
@@ -400,7 +400,7 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) · 64 unmodified lines
400 }400 }
401 401
402 /* Make imx6_soc_volt array's size same as arm opp number */402 /* Make imx6_soc_volt array's size same as arm opp number */
403 imx6_soc_volt = devm_kcalloc(cpu_dev, num, sizeof(*imx6_soc_volt),403 imx6_soc_volt = devm_kcalloc(&pdev->dev, num, sizeof(*imx6_soc_volt),
404 GFP_KERNEL);404 GFP_KERNEL);
405 if (imx6_soc_volt == NULL) {405 if (imx6_soc_volt == NULL) {
406 ret = -ENOMEM;406 ret = -ENOMEM;
@@ -485,6 +485,7 @@ soc_opp_out: · 78 unmodified lines
485 return 0;485 return 0;
486 486
487free_freq_table:487free_freq_table:
488 imx6_soc_volt = NULL;
488 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);489 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
489out_free_opp:490out_free_opp:
490 dev_pm_opp_of_remove_table(cpu_dev);491 dev_pm_opp_of_remove_table(cpu_dev);
@@ -506,6 +507,7 @@ put_node: · 15 unmodified lines
506static void imx6q_cpufreq_remove(struct platform_device *pdev)507static void imx6q_cpufreq_remove(struct platform_device *pdev)
507{508{
508 cpufreq_unregister_driver(&imx6q_cpufreq_driver);509 cpufreq_unregister_driver(&imx6q_cpufreq_driver);
510 imx6_soc_volt = NULL;
509 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);511 dev_pm_opp_free_cpufreq_table(cpu_dev, &freq_table);
510 dev_pm_opp_of_remove_table(cpu_dev);512 dev_pm_opp_of_remove_table(cpu_dev);
511 regulator_put(arm_reg);513 regulator_put(arm_reg);
drivers/cpufreq/qcom-cpufreq-nvmem.c+8−0
@@ -200,6 +200,13 @@ static int qcom_cpufreq_kryo_name_version(struct device *cpu_dev, · 199 unmodified lines
200 case QCOM_ID_IPQ9574:200 case QCOM_ID_IPQ9574:
201 drv->versions = 1 << (unsigned int)(*speedbin);201 drv->versions = 1 << (unsigned int)(*speedbin);
202 break;202 break;
203 case QCOM_ID_IPQ5200:
204 case QCOM_ID_IPQ5210:
205 case QCOM_ID_QCF2200:
206 case QCOM_ID_QCF3200:
207 case QCOM_ID_QCF3210:
208 drv->versions = (*speedbin == 0xcd) ? BIT(1) : BIT(0);
209 break;
203 case QCOM_ID_IPQ5424:210 case QCOM_ID_IPQ5424:
204 case QCOM_ID_IPQ5404:211 case QCOM_ID_IPQ5404:
205 drv->versions = (*speedbin == 0x3b) ? BIT(1) : BIT(0);212 drv->versions = (*speedbin == 0x3b) ? BIT(1) : BIT(0);
@@ -618,6 +625,7 @@ static const struct of_device_id qcom_cpufreq_match_list[] __initconst __maybe_u · 412 unmodified lines
618 { .compatible = "qcom,msm8909", .data = &match_data_msm8909 },625 { .compatible = "qcom,msm8909", .data = &match_data_msm8909 },
619 { .compatible = "qcom,msm8996", .data = &match_data_kryo },626 { .compatible = "qcom,msm8996", .data = &match_data_kryo },
620 { .compatible = "qcom,qcs404", .data = &match_data_qcs404 },627 { .compatible = "qcom,qcs404", .data = &match_data_qcs404 },
628 { .compatible = "qcom,ipq5210", .data = &match_data_kryo },
621 { .compatible = "qcom,ipq5332", .data = &match_data_kryo },629 { .compatible = "qcom,ipq5332", .data = &match_data_kryo },
622 { .compatible = "qcom,ipq5424", .data = &match_data_kryo },630 { .compatible = "qcom,ipq5424", .data = &match_data_kryo },
623 { .compatible = "qcom,ipq6018", .data = &match_data_ipq6018 },631 { .compatible = "qcom,ipq6018", .data = &match_data_ipq6018 },
drivers/cpufreq/rcpufreq_dt.rs+10−3
@@ -4,12 +4,19 @@ · 3 unmodified lines
4 4
5use kernel::{5use kernel::{
6 clk::Clk,6 clk::Clk,
7 cpu, cpufreq,7 cpu,
8 cpufreq, //
8 cpumask::CpumaskVar,9 cpumask::CpumaskVar,
9 device::{Core, Device},10 device::{
11 Core,
12 Device, //
13 },
10 error::code::*,14 error::code::*,
11 macros::vtable,15 macros::vtable,
12 module_platform_driver, of, opp, platform,16 module_platform_driver,
17 of,
18 opp,
19 platform, //
13 prelude::*,20 prelude::*,
14 str::CString,21 str::CString,
15 sync::Arc,22 sync::Arc,
drivers/cpufreq/spear-cpufreq.c+2−2
@@ -79,9 +79,9 @@ static int spear1340_set_cpu_rate(struct clk *sys_pclk, unsigned long newfreq) · 78 unmodified lines
79 int ret = 0;79 int ret = 0;
80 80
81 sys_clk = clk_get_parent(spear_cpufreq.clk);81 sys_clk = clk_get_parent(spear_cpufreq.clk);
82 if (IS_ERR(sys_clk)) {82 if (!sys_clk) {
83 pr_err("failed to get cpu's parent (sys) clock\n");83 pr_err("failed to get cpu's parent (sys) clock\n");
84 return PTR_ERR(sys_clk);84 return -EINVAL;
85 }85 }
86 86
87 /* Set the rate of the source clock before changing the parent */87 /* Set the rate of the source clock before changing the parent */
rust/kernel/cpufreq.rs+17−7
@@ -361,23 +361,28 @@ impl TableBuilder { · 360 unmodified lines
361 }361 }
362 }362 }
363 363
364 /// Adds a new entry to the table.364 /// Adds a raw frequency-table entry.
365 pub fn add(&mut self, freq: Hertz, flags: u32, driver_data: u32) -> Result {365 fn push(&mut self, frequency: u32, flags: u32, driver_data: u32) -> Result {
366 // Adds the new entry at the end of the vector.366 // Adds the new entry at the end of the vector.
367 Ok(self.entries.push(367 Ok(self.entries.push(
368 bindings::cpufreq_frequency_table {368 bindings::cpufreq_frequency_table {
369 flags,369 flags,
370 driver_data,370 driver_data,
371 frequency: freq.as_khz() as u32,371 frequency,
372 },372 },
373 GFP_KERNEL,373 GFP_KERNEL,
374 )?)374 )?)
375 }375 }
376 376
377 /// Adds a new entry to the table.
378 pub fn add(&mut self, freq: Hertz, flags: u32, driver_data: u32) -> Result {
379 self.push(freq.as_khz() as u32, flags, driver_data)
380 }
381
377 /// Consumes the [`TableBuilder`] and returns [`TableBox`].382 /// Consumes the [`TableBuilder`] and returns [`TableBox`].
378 pub fn to_table(mut self) -> Result<TableBox> {383 pub fn to_table(mut self) -> Result<TableBox> {
379 // Add last entry to the table.384 // Add last entry to the table.
380 self.add(Hertz(c_ulong::MAX), 0, 0)?;385 self.push(bindings::CPUFREQ_TABLE_END as u32, 0, 0)?;
381 386
382 TableBox::new(self.entries)387 TableBox::new(self.entries)
383 }388 }
@@ -823,7 +828,9 @@ pub trait Driver { · 439 unmodified lines
823 }828 }
824 829
825 /// Driver's `bios_limit` callback.830 /// Driver's `bios_limit` callback.
826 fn bios_limit(_policy: &mut Policy, _limit: &mut u32) -> Result {831 ///
832 /// Returns HW/BIOS max frequency limitations for the CPU.
833 fn bios_limit(_policy: &mut Policy) -> Result<u32> {
827 build_error!(VTABLE_DEFAULT_ERROR)834 build_error!(VTABLE_DEFAULT_ERROR)
828 }835 }
829 836
@@ -1359,9 +1366,12 @@ impl<T: Driver> Registration<T> { · 529 unmodified lines
1359 1366
1360 from_result(|| {1367 from_result(|| {
1361 let mut policy = PolicyCpu::from_cpu(cpu_id)?;1368 let mut policy = PolicyCpu::from_cpu(cpu_id)?;
1362 1369 let val = T::bios_limit(&mut policy)?;
1363 // SAFETY: `limit` is guaranteed by the C code to be valid.1370 // SAFETY: `limit` is guaranteed by the C code to be valid.
1364 T::bios_limit(&mut policy, &mut (unsafe { *limit })).map(|()| 0)1371 unsafe {
1372 *limit = val;
1373 }
1374 Ok(0)
1365 })1375 })
1366 }1376 }
1367 1377

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t