summaryrefslogtreecommitdiffstats
path: root/drivers/opp
Commit message (Collapse)AuthorAgeFilesLines
* OPP: No need to defer probe from _opp_attach_genpd()Viresh Kumar2023-10-171-8/+0
| | | | | | | | | | When the new interface for attaching genpd's via the OPP core was added, it was possible for required_opp_count to be zero, but not anymore. Remove the unused check. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
* OPP: Remove genpd_virt_dev_lockViresh Kumar2023-10-172-35/+6
| | | | | | | | | | | | | | | All the config operations for OPP tables share common code paths now and none of the other ones have such protection in place. Either all should have it or none. The understanding here is that user won't clear the OPP configs while still using them and so such a case won't happen. We can always come back and use a wider lock for all resource types if required. Also fix the error on failing to allocate memory. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
* OPP: Reorder code in _opp_set_required_opps_genpd()Viresh Kumar2023-10-171-14/+18
| | | | | | | Reorder code in _opp_set_required_opps_genpd() to reduce duplicate code. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
* OPP: Add _link_required_opps() to avoid code duplicationViresh Kumar2023-10-161-33/+29
| | | | | | | | Factor out _link_required_opps() to remove duplicate code. No functional change. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
* OPP: Fix formatting of if/else blockViresh Kumar2023-10-161-2/+2
| | | | | | | Add {} to both if else blocks or none. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
* OPP: Fix -Wunsequenced in _of_add_opp_table_v1()Nathan Chancellor2023-10-061-2/+4
| | | | | | | | | | | | | | | | | | | | Clang warns (or errors with CONFIG_WERROR=y): drivers/opp/of.c:1081:28: error: multiple unsequenced modifications to 'val' [-Werror,-Wunsequenced] 1081 | .freq = be32_to_cpup(val++) * 1000, | ^ 1082 | .u_volt = be32_to_cpup(val++), | ~~ 1 error generated. There is no sequence point in a designated initializer. Move back to separate variables for the creation of the values, so that there are sequence points between each evaluation and increment of val. Fixes: 75bbc92c09d8 ("OPP: Add dev_pm_opp_add_dynamic() to allow more flexibility") Signed-off-by: Nathan Chancellor <nathan@kernel.org> Reviewed-by: Nick Desaulniers <ndesaulniers@google.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: debugfs: Fix warning with W=1 buildsViresh Kumar2023-10-061-1/+1
| | | | | | | | | | | | | | | | | | We currently get the following warning: debugfs.c: In function ‘opp_debug_create_one’: debugfs.c:63:42: warning: ‘%.1d’ directive output may be truncated writing between 1 and 10 bytes into a region of size 2 [-Wformat-truncation=] snprintf(name, sizeof(name), "icc-path-%.1d", i); ^~~~ debugfs.c:63:32: note: directive argument in the range [0, 2147483647] snprintf(name, sizeof(name), "icc-path-%.1d", i); ^~~~~~~~~~~~~~~ debugfs.c:63:3: note: ‘snprintf’ output between 11 and 20 bytes into a destination of size 11 snprintf(name, sizeof(name), "icc-path-%.1d", i); Fix it by increasing size of the `name` array. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Remove doc style comments for internal routinesViresh Kumar2023-10-061-72/+7
| | | | | | | | | | | | | | | | | | | | | | | | These were previously exposed outside of the OPP core and needed doc style commenting. They aren't public now and don't need the same. This fixes warnings generated for builds with `W=1`: core.c:2105: warning: Function parameter or member 'opp_table' not described in '_opp_set_supported_hw' core.c:2105: warning: Excess function parameter 'dev' description in '_opp_set_supported_hw' core.c:2148: warning: Function parameter or member 'opp_table' not described in '_opp_set_prop_name' core.c:2148: warning: Excess function parameter 'dev' description in '_opp_set_prop_name' core.c:2189: warning: Function parameter or member 'opp_table' not described in '_opp_set_regulators' core.c:2189: warning: Excess function parameter 'count' description in '_opp_set_regulators' core.c:2293: warning: Function parameter or member 'opp_table' not described in '_opp_set_clknames' core.c:2293: warning: Function parameter or member 'config_clks' not described in '_opp_set_clknames' core.c:2391: warning: Function parameter or member 'opp_table' not described in '_opp_set_config_regulators_helper' core.c:2455: warning: Function parameter or member 'opp_table' not described in '_opp_attach_genpd' core.c:2682: warning: Function parameter or member 'token' not described in 'dev_pm_opp_clear_config' core.c:2682: warning: Excess function parameter 'opp_table' description in 'dev_pm_opp_clear_config' Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202309091558.x3JJrxFI-lkp@intel.com/ Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Add dev_pm_opp_find_level_floor()Krishna chaitanya chundru2023-10-061-0/+25
| | | | | | | | | Add dev_pm_opp_find_level_floor(), as is done for frequency and bandwidth. Signed-off-by: Krishna chaitanya chundru <quic_krichai@quicinc.com> [ Viresh: Updated commit log and rearranged code ] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Extend support for the opp-level beyond required-oppsUlf Hansson2023-10-061-0/+35
| | | | | | | | | | | | | | | | At this point the level (performance state) for an OPP is currently limited to be requested for a device that is attached to a PM domain. Moreover, the device needs to have the so called required-opps assigned to it, which are based upon OPP tables being described in DT. To extend the support beyond required-opps and DT, let's enable the level to be set for all OPPs. More precisely, if the requested OPP has a valid level let's try to request it through the device's optional PM domain, via calling dev_pm_domain_set_performance_state(). Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> [ Viresh: Handle NULL opp in _set_opp_level() ] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Switch to use dev_pm_domain_set_performance_state()Ulf Hansson2023-10-061-1/+1
| | | | | | | | | | | To support performance scaling for any kinds of PM domains, let's move away from using the genpd specific API, dev_pm_genpd_set_performance_state(), to the common dev_pm_domain_set_performance_state(). No intended functional impact at this point. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Extend dev_pm_opp_data with a levelUlf Hansson2023-10-061-0/+1
| | | | | | | | | Let's extend the dev_pm_opp_data with a level variable, to allow users to specify a corresponding level (performance state) for a dynamically added OPP. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Add dev_pm_opp_add_dynamic() to allow more flexibilityUlf Hansson2023-10-063-17/+17
| | | | | | | | | | The dev_pm_opp_add() API is limited to add dynamic OPPs with a frequency and a voltage level. To enable more flexibility, let's add a new API, dev_pm_opp_add_dynamic() that's takes a struct dev_pm_opp_data* instead of a list of in-parameters. Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Fix argument name in doc commentViresh Kumar2023-08-181-2/+2
| | | | | | | | | The name of the argument is "opp_table" and not "table", fix the comment. Reported-by: kernel test robot <lkp@intel.com> Closes: https://lore.kernel.org/oe-kbuild-all/202308172310.FzcidE4c-lkp@intel.com/ Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Fix passing 0 to PTR_ERR in _opp_attach_genpd()Manivannan Sadhasivam2023-07-241-1/+1
| | | | | | | | | | | | | | If dev_pm_domain_attach_by_name() returns NULL, then 0 will be passed to PTR_ERR() as reported by the smatch warning below: drivers/opp/core.c:2456 _opp_attach_genpd() warn: passing zero to 'PTR_ERR' Fix it by checking for the non-NULL virt_dev pointer before passing it to PTR_ERR. Otherwise return -ENODEV. Fixes: 4ea9496cbc95 ("opp: Fix error check in dev_pm_opp_attach_genpd()") Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Fix potential null ptr dereference in dev_pm_opp_get_required_pstate()Manivannan Sadhasivam2023-07-241-5/+3
| | | | | | | | | | | | | | | "opp" pointer is dereferenced before the IS_ERR_OR_NULL() check. Fix it by removing the dereference to cache opp_table and dereference it directly where opp_table is used. This fixes the following smatch warning: drivers/opp/core.c:232 dev_pm_opp_get_required_pstate() warn: variable dereferenced before IS_ERR check 'opp' (see line 230) Fixes: 84cb7ff35fcf ("OPP: pstate is only valid for genpd OPP tables") Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Reuse dev_pm_opp_get_freq_indexed()Viresh Kumar2023-07-241-21/+0
| | | | | | | Reuse dev_pm_opp_get_freq_indexed() from dev_pm_opp_get_freq(). Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
* OPP: Update _read_freq() to return the correct frequencyViresh Kumar2023-07-241-1/+1
| | | | | | | | Now that we support finding indexed frequencies, lets update _read_freq() to return the right one. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
* OPP: Add dev_pm_opp_find_freq_exact_indexed()Viresh Kumar2023-07-241-0/+28
| | | | | | | The indexed version of the API is added for other floor and ceil, add the same for exact as well for completeness. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Introduce dev_pm_opp_get_freq_indexed() APIManivannan Sadhasivam2023-07-241-0/+20
| | | | | | | | | | | In the case of devices with multiple clocks, drivers need to specify the frequency index for the OPP framework to get the specific frequency within the required OPP. So let's introduce the dev_pm_opp_get_freq_indexed() API accepting the frequency index as an argument. Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> [ Viresh: Fixed potential access to NULL opp pointer ] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Introduce dev_pm_opp_find_freq_{ceil/floor}_indexed() APIsManivannan Sadhasivam2023-07-211-0/+56
| | | | | | | | | | | | | | In the case of devices with multiple clocks, drivers need to specify the clock index for the OPP framework to find the OPP corresponding to the floor/ceil of the supplied frequency. So let's introduce the two new APIs accepting the clock index as an argument. These APIs use the exising _find_key_ceil() helper by supplying the clock index to it. Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> [ Viresh: Rearranged definitions in pm_opp.h ] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Properly propagate error along when failing to get icc_pathAndrew Halaney2023-06-271-1/+1
| | | | | | | | | | | | | | | | | fa155f4f8348 ("OPP: Use dev_err_probe() when failing to get icc_path") failed to actually use the error it was trying to log: smatch warnings: drivers/opp/of.c:516 dev_pm_opp_of_find_icc_paths() warn: passing zero to 'dev_err_probe' Make sure to use the right error and pass it along. Fixes: fa155f4f8348 ("OPP: Use dev_err_probe() when failing to get icc_path") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Closes: https://lore.kernel.org/r/202306262008.guNLgjt6-lkp@intel.com/ Signed-off-by: Andrew Halaney <ahalaney@redhat.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Use dev_err_probe() when failing to get icc_pathAndrew Halaney2023-06-261-5/+1
| | | | | | | | | | | This, in tandem with dynamic debug, can print useful information about -EPROBE_DEFFER like below, and keeps similar behavior for other errors: [ 16.561072] cpu cpu0: error -EPROBE_DEFER: dev_pm_opp_of_find_icc_paths: Unable to get path0 [ 16.575777] platform 18591000.cpufreq: deferred probe pending Signed-off-by: Andrew Halaney <ahalaney@redhat.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Simplify the over-designed pstate <-> level danceViresh Kumar2023-06-194-13/+5
| | | | | | | | | | | | | | | | | | | | | While adding support for "performance states" in the OPP and genpd core, it was decided to set the `pstate` field via genpd's pm_genpd_opp_to_performance_state() helper, to allow platforms to set `pstate` even if they don't have a corresponding `level` field in the DT OPP tables (More details are present in commit 6e41766a6a50 ("PM / Domain: Implement of_genpd_opp_to_performance_state()")). Revisiting that five years later clearly suggests that it was over-designed as all current users are eventually using the `level` value only. The previous commit already added necessary checks to make sure pstate is only used for genpd tables. Lets now simplify this a little, and use `level` directly and remove `pstate` field altogether. Suggested-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
* OPP: pstate is only valid for genpd OPP tablesViresh Kumar2023-06-193-3/+25
| | | | | | | | | | | | | It is not very clear right now that the `pstate` field is only valid for genpd OPP tables and not consumer tables. And there is no checking for the same at various places. Add checks in place to verify that and make it clear to the reader. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org> Reviewed-by: Bjorn Andersson <quic_bjorande@quicinc.com> Tested-by: Bjorn Andersson <quic_bjorande@quicinc.com>
* OPP: don't drop performance constraint on OPP table removalViresh Kumar2023-06-143-19/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This code was added (long back) by commit 009acd196fc8 ("PM / OPP: Support updating performance state of device's power domain") and at that time the `opp->pstate` field was used to store the performance state required by a device's OPP. Over time that changed and the `->pstate` field is now used only for genpd devices and consumer devices access that via the required-opps instead. Because of all these changes, _opp_table_kref_release() now drops the constraint only when the genpd's OPP table gets freed and not the device's. Which is definitely not what we wanted. And dropping the constraint doesn't have much meaning as the genpd itself is going away. Moreover, if we want to drop constraints here, then just dropping the performance constraint alone isn't sufficient as there are other resource constraints like clk, regulator, etc. too, which must be handled. Probably the right thing to do here is to leave this decision to the consumers, which can call `dev_pm_opp_set_rate(dev, 0)` or similar APIs to drop all constraints properly. Which many of the consumers already do. Remove the special code, which is broken anyway. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
* OPP: Protect `lazy_opp_tables` list with `opp_table_lock`Viresh Kumar2023-06-141-2/+12
| | | | | | | | | The `opp_table_lock` lock is already used to protect the list elsewhere, use it while adding or removing entries from it. Reported-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Tested-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com>
* OPP: Staticize `lazy_opp_tables` in of.cViresh Kumar2023-06-083-4/+4
| | | | | | | `lazy_opp_tables` is only used in of.c, move it there and mark it `static`. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* opp: Fix use-after-free in lazy_opp_tables after probe deferralStephan Gerhold2023-05-311-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When dev_pm_opp_of_find_icc_paths() in _allocate_opp_table() returns -EPROBE_DEFER, the opp_table is freed again, to wait until all the interconnect paths are available. However, if the OPP table is using required-opps then it may already have been added to the global lazy_opp_tables list. The error path does not remove the opp_table from the list again. This can cause crashes later when the provider of the required-opps is added, since we will iterate over OPP tables that have already been freed. E.g.: Unable to handle kernel NULL pointer dereference when read CPU: 0 PID: 7 Comm: kworker/0:0 Not tainted 6.4.0-rc3 PC is at _of_add_opp_table_v2 (include/linux/of.h:949 drivers/opp/of.c:98 drivers/opp/of.c:344 drivers/opp/of.c:404 drivers/opp/of.c:1032) -> lazy_link_required_opp_table() Fix this by calling _of_clear_opp_table() to remove the opp_table from the list and clear other allocated resources. While at it, also add the missing mutex_destroy() calls in the error path. Cc: stable@vger.kernel.org Suggested-by: Viresh Kumar <viresh.kumar@linaro.org> Fixes: 7eba0c7641b0 ("opp: Allow lazy-linking of required-opps") Signed-off-by: Stephan Gerhold <stephan.gerhold@kernkonzept.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: rate-limit debug messages when no change in OPP is requiredAdrián Larumbe2023-05-221-1/+1
| | | | | | | | | Otherwise, when enabling a debug build and dynamic debug in the kernel, it quickly floods the kernel ring buffer and makes debugging of other subsystems almost impossible, unless manually disabled. Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* Merge tag 'devicetree-for-6.4-2' of ↵Linus Torvalds2023-04-271-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux Pull more devicetree updates from Rob Herring: - First part of DT header detangling dropping cpu.h from of_device.h and replacing some includes with forward declarations. A handful of drivers needed some adjustment to their includes as a result. - Refactor of_device.h to be used by bus drivers rather than various device drivers. This moves non-bus related functions out of of_device.h. The end goal is for of_platform.h and of_device.h to stop including each other. - Refactor open coded parsing of "ranges" in some bus drivers to use DT address parsing functions - Add some new address parsing functions of_property_read_reg(), of_range_count(), and of_range_to_resource() in preparation to convert more open coded parsing of DT addresses to use them. - Treewide clean-ups to use of_property_read_bool() and of_property_present() as appropriate. The ones here are the ones that didn't get picked up elsewhere. * tag 'devicetree-for-6.4-2' of git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux: (34 commits) bus: tegra-gmi: Replace of_platform.h with explicit includes hte: Use of_property_present() for testing DT property presence w1: w1-gpio: Use of_property_read_bool() for boolean properties virt: fsl: Use of_property_present() for testing DT property presence soc: fsl: Use of_property_present() for testing DT property presence sbus: display7seg: Use of_property_read_bool() for boolean properties sparc: Use of_property_read_bool() for boolean properties sparc: Use of_property_present() for testing DT property presence bus: mvebu-mbus: Remove open coded "ranges" parsing of/address: Add of_property_read_reg() helper of/address: Add of_range_count() helper of/address: Add support for 3 address cell bus of/address: Add of_range_to_resource() helper of: unittest: Add bus address range parsing tests of: Drop cpu.h include from of_device.h OPP: Adjust includes to remove of_device.h irqchip: loongson-eiointc: Add explicit include for cpuhotplug.h cpuidle: Adjust includes to remove of_device.h cpufreq: sun50i: Add explicit include for cpu.h cpufreq: Adjust includes to remove of_device.h ...
| * OPP: Adjust includes to remove of_device.hRob Herring2023-04-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | Now that of_cpu_device_node_get() is defined in of.h, of_device.h is just implicitly including other includes, and is no longer needed. Adjust the include files with what was implicitly included by of_device.h (cpu.h and of.h) and drop including of_device.h. Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Link: https://lore.kernel.org/r/20230329-dt-cpu-header-cleanups-v1-18-581e2605fe47@kernel.org Signed-off-by: Rob Herring <robh@kernel.org>
* | OPP: Move required opps configuration to specialized callbackViresh Kumar2023-04-033-27/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The required-opps configuration is closely tied to genpd and performance states at the moment and it is not very obvious that required-opps can live without genpds. Though we don't support configuring required-opps for non-genpd cases currently. This commit aims at separating these parts, where configuring genpds would be a special case of configuring the required-opps. Add a specialized callback, set_required_opps(), to the opp table and set it to different callbacks accordingly. This shouldn't result in any functional changes for now. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
* | OPP: Handle all genpd cases together in _set_required_opps()Viresh Kumar2023-04-031-7/+2
| | | | | | | | | | | | | | | | There is no real need of keeping separate code for single genpd case, it can be made to work with a simple change. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Ulf Hansson <ulf.hansson@linaro.org>
* | opp: Use of_property_present() for testing DT property presenceRob Herring2023-03-131-2/+2
|/ | | | | | | | | | | | It is preferred to use typed property access functions (i.e. of_property_read_<type> functions) rather than low-level of_get_property/of_find_property functions for reading properties. As part of this, convert of_get_property/of_find_property calls to the recently added of_property_present() helper when we just want to test for presence of a property and nothing more. Signed-off-by: Rob Herring <robh@kernel.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: fix error checking in opp_migrate_dentry()Qi Zheng2023-02-081-1/+1
| | | | | | | | | | | Since commit ff9fb72bc077 ("debugfs: return error values, not NULL") changed return value of debugfs_rename() in error cases from %NULL to %ERR_PTR(-ERROR), we should also check error values instead of NULL. Fixes: ff9fb72bc077 ("debugfs: return error values, not NULL") Signed-off-by: Qi Zheng <zhengqi.arch@bytedance.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* drivers/opp: Remove "select SRCU"Paul E. McKenney2023-01-051-1/+0
| | | | | | | | | | | | | Now that the SRCU Kconfig option is unconditionally selected, there is no longer any point in selecting it. Therefore, remove the "select SRCU" Kconfig statements. Signed-off-by: Paul E. McKenney <paulmck@kernel.org> Cc: Viresh Kumar <vireshk@kernel.org> Cc: Nishanth Menon <nm@ti.com> Cc: Stephen Boyd <sboyd@kernel.org> Cc: <linux-pm@vger.kernel.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: decouple dt properties in opp_parse_supplies()James Calligeros2022-11-041-11/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The opp-microwatt property was added with the intention of providing platforms a way to specify a precise value for the power consumption of a device at a given OPP to enable better energy-aware scheduling decisions by informing the kernel of the total static and dynamic power of a device at a given OPP, removing the reliance on the EM subsystem's often flawed estimations. This property is parsed by opp_parse_supplies(), which creates a hard dependency on the opp-microvolt property. Some platforms, such as Apple Silicon, do not describe their device's voltage regulators in the DT as they cannot be controlled by the kernel and/or rely on opaque firmware algorithms to control their voltage and current characteristics at runtime. We can, however, experimentally determine the power consumption of a given device at a given OPP, taking advantage of opp-microwatt to provide EAS on such devices as was initially intended. Allow platforms to specify and consume any subset of opp-microvolt, opp-microamp, or opp-microwatt without a hard dependency on opp-microvolt to enable this functionality on such platforms. Tested-by: James Calligeros <jcalligeros99@gmail.com> Signed-off-by: James Calligeros <jcalligeros99@gmail.com> Co-developed-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Simplify opp_parse_supplies() by restructuring itViresh Kumar2022-11-041-135/+81
| | | | | | | | | | | | | opp_parse_supplies() has grown into too big of a routine (~190 lines) and it is not straight-forward to understand it anymore. Break it into smaller routines and reduce code redundancy a bit by using the same code to parse properties. This shouldn't result in any logical changes. Tested-by: James Calligeros <jcalligeros99@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Parse named opp-microwatt property tooViresh Kumar2022-11-041-3/+13
| | | | | | | We missed parsing the named opp-microwatt-<name> property, fix that. Tested-by: James Calligeros <jcalligeros99@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* OPP: Fix an un-initialized variable usageChristophe JAILLET2022-08-161-1/+1
| | | | | | | | | | | smatch complains that 'ret' may be returned un-initialized. Explicitly return 0 if we reach the end of the function (should 'opp_table->clk_count' be 0). Fixes: 8174a3a613af ("OPP: Provide a simple implementation to configure multiple clocks") Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
* Merge tag 'opp-updates-5.20-rc1' of ↵Rafael J. Wysocki2022-08-036-922/+971
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm Pull operating performance points (OPP) updates for 5.20-rc1 from Viresh Kumar: "- Make dev_pm_opp_set_regulators() accept NULL terminated list (Viresh Kumar). - Add dev_pm_opp_set_config() and friends and migrate other users/helpers to using them (Viresh Kumar). - Add support for multiple clocks for a device (Viresh Kumar and Krzysztof Kozlowski). - Configure resources before adding OPP table for Venus (Stanimir Varbanov). - Keep reference count up for opp->np and opp_table->np while they are still in use (Liang He). - Minor cleanups (Viresh Kumar and Yang Li)." * tag 'opp-updates-5.20-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/vireshk/pm: (43 commits) venus: pm_helpers: Fix warning in OPP during probe OPP: Don't drop opp->np reference while it is still in use OPP: Don't drop opp_table->np reference while it is still in use OPP: Remove dev{m}_pm_opp_of_add_table_noclk() PM / devfreq: tegra30: Register config_clks helper OPP: Allow config_clks helper for single clk case OPP: Provide a simple implementation to configure multiple clocks OPP: Assert clk_count == 1 for single clk helpers OPP: Add key specific assert() method to key finding helpers OPP: Compare bandwidths for all paths in _opp_compare_key() OPP: Allow multiple clocks for a device dt-bindings: opp: accept array of frequencies OPP: Make dev_pm_opp_set_opp() independent of frequency OPP: Reuse _opp_compare_key() in _opp_add_static_v2() OPP: Remove rate_not_available parameter to _opp_add() OPP: Use consistent names for OPP table instances OPP: Use generic key finding helpers for bandwidth key OPP: Use generic key finding helpers for level key OPP: Add generic key finding helpers and use them for freq APIs OPP: Remove dev_pm_opp_find_freq_ceil_by_volt() ...
| * OPP: Don't drop opp->np reference while it is still in useLiang He2022-07-193-8/+12
| | | | | | | | | | | | | | | | | | | | | | The struct dev_pm_opp contains a reference of the DT node, opp->np, throughout its lifetime. We should increase the refcount for the same from _opp_add_static_v2(), and drop it while removing the OPP finally. Signed-off-by: Liang He <windhl@126.com> [ Viresh: Updated subject / commit log, create _of_clear_opp() and drop reference from it] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
| * OPP: Don't drop opp_table->np reference while it is still in useLiang He2022-07-191-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | The OPP table contains a reference of the DT node, opp_table->np, throughout its lifetime. We shouldn't drop the refcount for the same from _of_init_opp_table(), but do that while removing the OPP table finally. Signed-off-by: Liang He <windhl@126.com> [ Viresh: Updated subject / commit log and drop reference from _of_clear_opp_table() ] Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
| * OPP: Remove dev{m}_pm_opp_of_add_table_noclk()Viresh Kumar2022-07-121-40/+8
| | | | | | | | | | | | | | Remove the now unused variants and the now unnecessary "getclk" parameter from few routines. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
| * OPP: Allow config_clks helper for single clk caseViresh Kumar2022-07-121-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There is a corner case with Tegra30, where we want to skip clk configuration via dev_pm_opp_set_opp(), but still want the OPP core to read the "opp-hz" property so we can find the right OPP via freq finding helpers. This is the easiest of the ways to make it work, without any special hacks in the OPP core. Allow config_clks to be passed for single clk case. Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
| * OPP: Provide a simple implementation to configure multiple clocksViresh Kumar2022-07-121-0/+34
| | | | | | | | | | | | | | | | This provides a simple implementation to configure multiple clocks for a device. Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
| * OPP: Assert clk_count == 1 for single clk helpersViresh Kumar2022-07-121-6/+39
| | | | | | | | | | | | | | | | Many helpers can be safely called only for devices that have a single clk associated with them. Assert the same for those routines. Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
| * OPP: Add key specific assert() method to key finding helpersViresh Kumar2022-07-121-19/+33
| | | | | | | | | | | | | | | | | | The helpers for the clock key, at least, would need to assert that the helpers are called only for single clock case. Prepare for that by adding an argument to the key finding helpers. Tested-by: Dmitry Osipenko <dmitry.osipenko@collabora.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
| * OPP: Compare bandwidths for all paths in _opp_compare_key()Viresh Kumar2022-07-121-3/+17
| | | | | | | | | | | | | | Replicate the same behavior as "rates" here and compare all values instead of relying on the first entry alone. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>