Commit Graph

11 Commits

Author SHA1 Message Date
Yangtao Li b68ea4c2fb cpufreq: mediatek-hw: Convert to platform remove callback returning void
The .remove() callback for a platform driver returns an int which makes
many driver authors wrongly assume it's possible to do error handling by
returning an error code. However the value returned is (mostly) ignored
and this typically results in resource leaks. To improve here there is a
quest to make the remove callback return void. In the first step of this
quest all drivers are converted to .remove_new() which already returns
void.

Trivially convert this driver from always returning zero in the remove
callback to the void returning variant.

Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Yangtao Li <frank.li@vivo.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-07-20 16:02:12 +05:30
Rob Herring a70eb93a24 cpufreq: Explicitly include correct DT includes
The DT of_device.h and of_platform.h date back to the separate
of_platform_bus_type before it as merged into the regular platform bus.
As part of that merge prepping Arm DT support 13 years ago, they
"temporarily" include each other. They also include platform_device.h
and of.h. As a result, there's a pretty much random mix of those include
files used throughout the tree. In order to detangle these headers and
replace the implicit includes with struct declarations, users need to
explicitly include the correct includes.

Signed-off-by: Rob Herring <robh@kernel.org>
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-07-20 16:01:57 +05:30
Rafael J. Wysocki f0f8e9e730 Cpufreq arm updates for 6.3
- Enable thermal cooling for Tegra194 (Yi-Wei Wang).
 
 - Register module device table and add missing compatibles for
   cpufreq-qcom-hw (Nícolas F. R. A. Prado, Abel Vesa and Luca Weiss).
 
 - Various dt binding updates for qcom-cpufreq-nvmem and opp-v2-kryo-cpu
   (Christian Marangi).
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEx73Crsp7f6M6scA70rkcPK6BEhwFAmPrHSwACgkQ0rkcPK6B
 Ehww0Q//e2vfx0K3lc7F7rJGpSxWJeXoxgM+POh8aKHQw+ivni2YV08QSZMFlWkB
 X9QI02vcuKgTMw8Xj07+QMh/KTr4GCm3Ii+2EGK3sZaktLsQLmeNyXJ/QxG5shfi
 7BfRSF5zzkcQXDn622WzW/qC08IbSiPAHjlDxjowPapZcuGopsyzYXNB0fQxn647
 R9fWYKR5TtnHyqpIDMOjr1EKi88Cinqjk75okQHRDxJ7khsOMesfKNasdeCzW7D8
 +gmbTrAU/tkiNDw10uufbi0TUhdK+beHBFRE/qAXztpKgOIzUPa2iH+BsdCWbazg
 KGC3afZR6Zz/cqa5WtahRHtDYUdrMJnYXzH9XOggTqWv39CSjhx5V7yGhC/7nPw6
 2y4kp01vemJXHJLOs+0MiP4jfb3ZAUeXMEKtc3fq6y56zfo3T0hlA3eCXdTQy3kX
 lZoGhgoslxHUsmNwfM6Hejn45Gl4GXln5z8IvpAK+YDn6wFnRf+WIOqVVrsOvXnj
 PGr01OvDxVb7jWVAri/afZyX9h1cZ7Aj+cybB4KY+39LdqGqAhFgfF6pJqv6I+G7
 yQcgSLl4rMYAD9l3DakuTvutnaU73QdwjN1hPMm3sBueX7d4zrLKmtGPbJ0recQa
 dWWbDRC/cR6Sz79T3yrfGoy7VeJOvuH35BVKyNq0uM/kh8mwxoA=
 =dCgg
 -----END PGP SIGNATURE-----

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

Pull cpufreq ARM updates for 6.3 from Viresh Kumar:

"- Enable thermal cooling for Tegra194 (Yi-Wei Wang).

 - Register module device table and add missing compatibles for
   cpufreq-qcom-hw (Nícolas F. R. A. Prado, Abel Vesa and Luca Weiss).

 - Various dt binding updates for qcom-cpufreq-nvmem and opp-v2-kryo-cpu
   (Christian Marangi)."

* tag 'cpufreq-arm-updates-6.3' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm:
  dt-bindings: opp: opp-v2-kryo-cpu: enlarge opp-supported-hw maximum
  dt-bindings: cpufreq: qcom-cpufreq-nvmem: make cpr bindings optional
  dt-bindings: cpufreq: qcom-cpufreq-nvmem: specify supported opp tables
  dt-bindings: cpufreq: cpufreq-qcom-hw: Add SM8550 compatible
  dt-bindings: cpufreq: cpufreq-qcom-hw: Add missing compatibles
  cpufreq: mediatek-hw: Register to module device table
  cpufreq: tegra194: Enable CPUFREQ thermal cooling
2023-02-14 15:25:07 +01:00
Uwe Kleine-König dd329e1e21 cpufreq: Make cpufreq_unregister_driver() return void
All but a few drivers ignore the return value of
cpufreq_unregister_driver(). Those few that don't only call it after
cpufreq_register_driver() succeeded, in which case the call doesn't
fail.

Make the function return no value and add a WARN_ON for the case that
the function is called in an invalid situation (i.e. without a previous
successful call to cpufreq_register_driver()).

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Acked-by: Florian Fainelli <f.fainelli@gmail.com> # brcmstb-avs-cpufreq.c
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2023-02-09 20:19:18 +01:00
Nícolas F. R. A. Prado 09608d62ae cpufreq: mediatek-hw: Register to module device table
Register the compatibles for this module on the module device table so
it can be automatically loaded when a matching device is found on the
system.

Signed-off-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2023-02-06 09:31:38 +05:30
Hector Martin d182dc6de9 cpufreq: Generalize of_perf_domain_get_sharing_cpumask phandle format
of_perf_domain_get_sharing_cpumask currently assumes a 1-argument
phandle format, and directly returns the argument. Generalize this to
return the full of_phandle_args, so it can be used by drivers which use
other phandle styles (e.g. separate nodes). This also requires changing
the CPU sharing match to compare the full args structure.

Also, make sure to of_node_put(args.np) (the original code was leaking a
reference).

Signed-off-by: Hector Martin <marcan@marcan.st>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2022-11-02 10:30:31 +05:30
Lukasz Luba ae6ccaa650 PM: EM: convert power field to micro-Watts precision and align drivers
The milli-Watts precision causes rounding errors while calculating
efficiency cost for each OPP. This is especially visible in the 'simple'
Energy Model (EM), where the power for each OPP is provided from OPP
framework. This can cause some OPPs to be marked inefficient, while
using micro-Watts precision that might not happen.

Update all EM users which access 'power' field and assume the value is
in milli-Watts.

Solve also an issue with potential overflow in calculation of energy
estimation on 32bit machine. It's needed now since the power value
(thus the 'cost' as well) are higher.

Example calculation which shows the rounding error and impact:

power = 'dyn-power-coeff' * volt_mV * volt_mV * freq_MHz

power_a_uW = (100 * 600mW * 600mW * 500MHz) / 10^6 = 18000
power_a_mW = (100 * 600mW * 600mW * 500MHz) / 10^9 = 18

power_b_uW = (100 * 605mW * 605mW * 600MHz) / 10^6 = 21961
power_b_mW = (100 * 605mW * 605mW * 600MHz) / 10^9 = 21

max_freq = 2000MHz

cost_a_mW = 18 * 2000MHz/500MHz = 72
cost_a_uW = 18000 * 2000MHz/500MHz = 72000

cost_b_mW = 21 * 2000MHz/600MHz = 70 // <- artificially better
cost_b_uW = 21961 * 2000MHz/600MHz = 73203

The 'cost_b_mW' (which is based on old milli-Watts) is misleadingly
better that the 'cost_b_uW' (this patch uses micro-Watts) and such
would have impact on the 'inefficient OPPs' information in the Cpufreq
framework. This patch set removes the rounding issue.

Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-07-15 19:17:30 +02:00
Lukasz Luba 75a3a99a5a PM: EM: Change the order of arguments in the .active_power() callback
The .active_power() callback passes the device pointer when it's called.
Aligned with a convetion present in other subsystems and pass the 'dev'
as a first argument. It looks more cleaner.

Adjust all affected drivers which implement that API callback.

Suggested-by: Ionela Voinescu <ionela.voinescu@arm.com>
Signed-off-by: Lukasz Luba <lukasz.luba@arm.com>
Reviewed-by: Ionela Voinescu <ionela.voinescu@arm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2022-04-13 16:26:17 +02:00
Hector.Yuan d776790a55 cpufreq: mediatek-hw: Fix double devm_remap in hotplug case
When hotpluging policy cpu, cpu policy init will be called multiple times.
Unplug CPU7 -> CPU6 -> CPU5 -> CPU4, then plug CPU4 again.
In this case, devm_remap will double remap and resource allocate fail.
So replace devm_remap to ioremap and release resources in cpu policy exit.

Signed-off-by: Hector.Yuan <hector.yuan@mediatek.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-12-27 09:44:53 +05:30
Vincent Donnefort 6215a5de9e cpufreq: mediatek-hw: Fix cpufreq_table_find_index_dl() call
The new cpufreq table flag RELATION_E introduced a new "efficient"
parameter for the cpufreq_table_find*() functions.

Fixes: 1f39fa0dcc (cpufreq: Introducing CPUFREQ_RELATION_E)
Signed-off-by: Vincent Donnefort <vincent.donnefort@arm.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-10-07 19:21:54 +02:00
Hector.Yuan 4855e26bcf cpufreq: mediatek-hw: Add support for CPUFREQ HW
Introduce cpufreq HW driver which can support
CPU frequency adjust in MT6779 platform.

Signed-off-by: Hector.Yuan <hector.yuan@mediatek.com>
[ Viresh: Massaged the patch and cleaned some stuff. ]
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
2021-09-06 15:15:19 +05:30