aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2015-11-02PM / OPP: Drop unlikely before IS_ERR(_OR_NULL)Viresh Kumar
IS_ERR(_OR_NULL) already contain an 'unlikely' compiler flag and there is no need to do that again from its callers. Drop it. Acked-by: Pavel Machek <pavel@ucw.cz> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 50a3cb04a5f9cd5323a76db9ee409a7f3004259a) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-11-02PM / OPP: Fix static checker warning (broken 64bit big endian systems)Viresh Kumar
Dan Carpenter reported (generated with static checker): drivers/base/power/opp.c:949 _opp_add_static_v2() warn: passing casted pointer '&new_opp->clock_latency_ns' to 'of_property_read_u32()' 64 vs 32. This code will break on 64 bit, big endian machines. Fix this by reading the value in a u32 type variable first and then assigning it to the unsigned long variable. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Suggested-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 68fa9f0ab1b61cfc7deee699da8b5b5cb12f7a58) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-11-02PM / OPP: Free resources and properly return error on failureViresh Kumar
_of_init_opp_table_v2() isn't freeing up resources on some errors and the error values returned are also not correct always. This fixes following problems: - Return -ENOENT, if no entries are found in the table. - Use IS_ERR() to properly check return value of _find_device_opp(). - Return error value with PTR_ERR() in above case. - Free table if _find_device_opp() fails. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 1f821ed7afaa7ed689322ee2369f270e374a6350) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-11-02cpufreq-dt: make scaling_boost_freqs sysfs attr available when boost is enabledBartlomiej Zolnierkiewicz
Make scaling_boost_freqs sysfs attribute is available when cpufreq-dt driver is used and boost support is enabled. Suggested-by: Viresh Kumar <viresh.kumar@linaro.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 21c36d35711d24a7689b7fb9606ce78f3b4c3d3b) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-11-02cpufreq: dt: Add support for turbo/boost modeViresh Kumar
With opp-v2 DT bindings, few OPPs can be used only for the boost mode. But using such OPPs require the boost mode to be supported by cpufreq driver. We will parse DT bindings only during ->init() and so can enable boost support only after registering cpufreq driver. This enables boost support as soon as any policy has boost/turbo OPPs for its CPUs. We don't need to disable boost support as that is done by the core, when the driver is unregistered. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit d15fa86276e8515443251c0d18930e392bc5afc5) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-11-02cpufreq: dt: Add support for operating-points-v2 bindingsViresh Kumar
Support for parsing operating-points-v2 bindings is in place now, lets modify cpufreq-dt driver to use them. For backward compatibility we will continue to support earlier bindings. Special handling for that is required, to make sure OPPs are initialized for all the CPUs. Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 2e02d8723edf6599988852a8ade8f83b2f766cb8) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-11-02cpufreq: Allow drivers to enable boost support after registering driverViresh Kumar
In some cases it wouldn't be known at time of driver registration, if the driver needs to support boost frequencies. For example, while getting boost information from DT with opp-v2 bindings, we need to parse the bindings for all the CPUs to know if turbo/boost OPPs are supported or not. One way out to do that efficiently is to delay supporting boost mode (i.e. creating /sys/devices/system/cpu/cpufreq/boost file), until the time OPP bindings are parsed. At that point, the driver can enable boost support. This can be done at ->init(), where the frequency table is created. To do that, the driver requires few APIs from cpufreq core that let him do this. This patch provides these APIs. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 44139ed4943ee8ec186eea3e9072ca16d2b48133) Signed-off-by: Alex Shi <alex.shi@linaro.org> Conflicts solution: drivers/cpufreq/cpufreq.c /* skip mismatched spaces */
2015-10-28PM / OPP: add dev_pm_opp_is_turbo() helperBartlomiej Zolnierkiewicz
Add dev_pm_opp_is_turbo() helper to verify if an opp is to be used only for turbo mode or not. Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 19445b25e350ebebaa304bb2135619f643302947) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Add helpers for initializing CPU OPPsViresh Kumar
With "operating-points-v2" its possible to tell which devices share OPPs. We already have infrastructure to decode that information. This patch adds following APIs: - of_get_cpus_sharing_opps: Returns cpumask of CPUs sharing OPPs (only valid with v2 bindings). - of_cpumask_init_opp_table: Initializes OPPs for all CPUs present in cpumask. - of_cpumask_free_opp_table: Frees OPPs for all CPUs present in cpumask. - set_cpus_sharing_opps: Sets which CPUs share OPPs (only valid with old OPP bindings, as this information isn't present in DT). Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 8d4d4e98acd68c31435ebb7beea591dbf60b9eb2) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Add support for opp-suspendViresh Kumar
With "operating-points-v2" bindings, it's possible to specify the OPP to which the device must be switched, before suspending. This patch adds support for getting that information. Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit ad656a6a8b1c8b4b2e723646e0402867f2f45395) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Add OPP sharing information to OPP libraryViresh Kumar
An opp can be shared by multiple devices, for example its very common for CPUs to share the OPPs, i.e. when they share clock/voltage rails. This patch adds support of shared OPPs to the OPP library. Instead of a single device, dev_opp will now contain a list of devices that use it. It also senses if the device (we are trying to initialize OPPs for) shares OPPs with a device added earlier and in that case we update the list of devices managed by OPPs instead of duplicating OPPs again. The same infrastructure will be used for the old OPP bindings, with later patches. Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 064416586190cb058d4c76a4e26b1996f434b6ca) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Add clock-latency-ns supportViresh Kumar
With "operating-points-v2" bindings, clock-latency is defined per OPP. Users of this value expect a single value which defines the latency to switch to any clock rate. Find maximum clock-latency-ns from the OPP table to service requests from such users. Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 3ca9bb33c627f22640cfca97fdf88eec0a120dfd) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Add support to parse "operating-points-v2" bindingsViresh Kumar
This adds support in OPP library to parse and create list of OPPs from operating-points-v2 bindings. It takes care of most of the properties of new bindings (except shared-opp, which will be handled separately). For backward compatibility, we keep supporting earlier bindings. We try to search for the new bindings first, in case they aren't present we look for the old deprecated ones. There are few things marked as TODO: - Support for multiple OPP tables - Support for multiple regulators They should be fixed separately. Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 274659029c9de5b11678d3a52a45e3dbc9177a48) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Break _opp_add_dynamic() into smaller functionsViresh Kumar
Later commits would add support for new OPP bindings and this would be required then. So, lets do it in a separate patch to make it easily reviewable. Another change worth noticing is INIT_LIST_HEAD(&opp->node). We weren't doing it earlier as we never tried to delete a list node before it is added to list. But this wouldn't be the case anymore. We might try to delete a node (just to reuse the same code paths), without it being getting added to the list. Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 23dacf6d2e993551ef3ae0629baf6f473930513c) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Allocate dev_opp from _add_device_opp()Viresh Kumar
There is no need to complicate _opp_add_dynamic() with allocation of dev_opp as well. Allocate it from _add_device_opp() instead. Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit aa5f2f854f03e6dc3dec8874bbcff1452b4bc09e) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Create _remove_device_opp() for freeing dev_oppViresh Kumar
This will be used from multiple places later. Lets create a separate routine for that. Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 3bac42caec612a1b82db7944570353cddca6a013) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Relocate few routinesViresh Kumar
In order to prepare for the later commits, this relocates few routines towards the top as they will be used earlier in the code. Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 737002b5de3d15b3012feea17f782a628b24699b) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Create a directory for opp bindingsViresh Kumar
More platform specific extended opp bindings will follow and it would be easy to manage them with a directory for opp. Lets create that and move the existing opp bindings into it. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 3566c5b277a41e912d15cd583c4604c95bb6b3f8) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq: Update boost flag while initializing freq table from OPPsBartlomiej Zolnierkiewicz
cpufreq table entries for OPPs with turbo modes enabled, should be marked with CPUFREQ_BOOST_FREQ flag. This ensures that these states are only used while operating in boost or turbo mode. Signed-off-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Stephen Boyd <sboyd@codeaurora.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 79eea44a5d7b9170d12d75c701d8c0e2d8d83c06) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq: dt: allow driver to boot automaticallyFelipe Balbi
by adding the missing MODULE_ALIAS(), cpufreq-dt can be autoloaded by udev/systemd. Signed-off-by: Felipe Balbi <balbi@ti.com> Acked-by: Nishanth Menon <nm@ti.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 07949bf9c63c9a80027fe8452d5fe8b9ba9b3c23) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP / clk: Remove unnecessary OOM messageQuentin Lambert
This patch reduces the kernel size by removing error messages that duplicate the normal OOM message. A simplified version of the semantic patch that finds this problem is as follows: (http://coccinelle.lip6.fr) @@ identifier f,print,l; expression e; constant char[] c; @@ e = \(kzalloc\|kmalloc\|devm_kzalloc\|devm_kmalloc\)(...); if (e == NULL) { <+... - print(...,c,...); ... when any ( goto l; | return ...; ) ...+> } Signed-off-by: Quentin Lambert <lambert.quentin@gmail.com> Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 59d84ca8c46a93ad62f9129458e897e7fe5075de) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq-dt: Drop unnecessary check before cpufreq_cooling_unregister() ↵Markus Elfring
invocation The cpufreq_cooling_unregister() function tests whether its argument is NULL and then returns immediately. Thus the test around the call is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> [ rjw: Subject ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 17ad13ba842bd5c197e20c17e107788aa0498ba9) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Assert RCU lock in exported functionsKrzysztof Kozlowski
Add lockdep asserts for holding the RCU lock when calling dev_pm_opp_get_freq() and dev_pm_opp_get_voltage() to aid in detecting RCU misuses. These are called often after dev_pm_opp_find_freq_ceil/exact() which already asserts for RCU lock. However one could make an error by releasing lock too early - just after dev_pm_opp_find_freq_ceil(). Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 04bf1c7f76b05be8134a833ec023f1c96f81b8a1) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Update kernel documentationNishanth Menon
kernel doc has gotten bit-rotted over time. Re-sync with Locking and Return information. document all functions properly and ensure that ./scripts/kernel-doc -v ./drivers/base/power/opp.c >/dev/null returns no errors Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 984f16c8490cba715444124a453ed4a2ac7a5a54) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Ensure consistent naming of static functionsNishanth Menon
All exported functions use dev_pm_* prefix and all static functions are now standardized with _ prefix. This is better than having to deal with multiple function naming styles within the same file. Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 327854c871178af58461b34f116a0300fbb3a74f) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: export dev_pm_opp_get_notifierNishanth Menon
Allows user drivers such as devfreq to be modules. Signed-off-by: Nishanth Menon <nm@ti.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 4679ec3727a0eb4d57e23dffa8e19ce911362c9f) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq-dt: defer probing if OPP table is not readyDmitry Torokhov
cpufreq-dt driver supports mode when OPP table is provided by platform code and not device tree. However on certain platforms code that fills OPP table may run after cpufreq driver tries to initialize, so let's report -EPROBE_DEFER if we do not find any entires in OPP table for the CPU. Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 62a041a4f58f32989460e37cb4f9aed5183f357f) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: take RCU lock in dev_pm_opp_get_opp_countDmitry Torokhov
A lot of callers are missing the fact that dev_pm_opp_get_opp_count needs to be called under RCU lock. Given that RCU locks can safely be nested, instead of providing *_locked() API, let's take RCU lock inside dev_pm_opp_get_opp_count() and leave callers as is. Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit b4718c02f49ab5e1452353f0fae78beabe81467c) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: fix warning in of_free_opp_table()Dmitry Torokhov
Not having OPP defined for a device is not a crime, we should not splat warning in this case. Also, it seems that we are ready to accept invalid dev (find_device_opp will return ERR_PTR(-EINVAL) then) so let's not crash in dev_name() in such case. Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 0fe30da2cb43782ee62d30c00a273d6934e5370e) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: add some lockdep annotationsDmitry Torokhov
Certain OPP APIs need to be called under RCU lock; let's add a few rcu_lockdep_assert() calls to warn about potential misuse. Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit b02ded246d011d0eb22efc178ee711b636214083) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: do error handling at the bottom of dev_pm_opp_add_dynamic()Viresh Kumar
This makes it less error prone and moves common resource deallocation at a single place. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 6ce4184d0308888dd6ac2b6ab5f8ec0b2006092e) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: handle allocation of device_opp in a separate routineViresh Kumar
Get the 'device_opp' allocation code into a separate routine to keep only the necessary part in dev_pm_opp_add_dynamic(). Also do s/sizeof(struct device_opp)/sizeof(*dev_opp) and remove the print message on kzalloc() failure as checkpatch warns for that. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 07cce74a7b259cb90029530e9549bf1d9a1b1c34) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: reuse find_device_opp() instead of duplicating codeViresh Kumar
Reuse find_device_opp() in opp_set_availability() instead of duplicating code. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 29df0ee1b14ab5cdc83c225258f42600825f45b2) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: Staticize __dev_pm_opp_remove()Viresh Kumar
Its a local routine and need not be accessible outside of opp.c. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 86453b473b1f68c238a6901b26158b4ca3b369bc) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: replace kfree with kfree_rcu while freeing 'struct device_opp'Viresh Kumar
Somehow one of the instance of freeing resources failed to use kfree_rcu() and used kfree() instead. This might cause problems as the node might be referenced by readers under rcu locks and we must wait for the rcu grace period as well. While we are at it, also update comment over 'struct device_opp' to mention why we are waiting for both rcu and srcu grace periods. Fixes: 129eec55df6a (PM / OPP Introduce APIs to remove OPPs) Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 1c6a662f898ecd1615d25fecb8098ea646720a7a) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: remove double calls to find_device_opp()Viresh Kumar
By mistake we called find_device_opp() twice in of_free_opp_table(), fix it. Generated diff doesn't show the problem well and so here is the code snippet: void of_free_opp_table(struct device *dev) { struct device_opp *dev_opp = find_device_opp(dev); struct dev_pm_opp *opp, *tmp; /* Check for existing list for 'dev' */ dev_opp = find_device_opp(dev); ... } Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 2a6127d037de96e8add0b09e0200b331a4db54be) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP: set new_opp->dev_opp to a valid dev_oppViresh Kumar
We find/allocate dev_opp after using its value to fill new_opp->dev_opp right now. Move this to a later point where dev_opp is valid. Fixes: a7470db6fec4 (PM / OPP don't match for existing OPPs when list is empty) Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 7284a00f17290114d304528fc49aeee5c2b9b433) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq-dt: free OPP table created during ->init()Viresh Kumar
OPP layer now supports freeing of OPPs and we should free them once they aren't useful anymore. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Tested-by: Stefan Wahren <stefan.wahren@i2se.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 2f0f609f2e3b874e8acf895459939903e6574d9c) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP replace kfree_rcu() with call_srcu() in opp_set_availability()Viresh Kumar
This existed before we introduced call_srcu() in opp layer to synchronize with srcu_notifier_call_chain() while removing OPPs. And is a potential bug which wasn't noticed earlier. Let fix it as well by using the right API to free OPP. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit b4037aaa584bd914bbf578f5ceb2d9884fa7ddb6) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP Introduce APIs to remove OPPsViresh Kumar
OPPs are created statically (from DT) or dynamically. Currently we don't free OPPs that are created statically, when the module unloads. And so if the module is inserted back again, we get warning for duplicate OPPs as the same were already present. Also, there might be a need to remove dynamic OPPs in future and so API for that is also added. This patch adds helper APIs to remove/free existing static and dynamic OPPs. Because the OPPs are used both under RCU and SRCU, we have to wait for grace period of both. And so are using kfree_rcu() from within call_srcu(). Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 129eec55df6ab1b5ecdd89fd7db7a2cd103200b5) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP rename 'head' as 'rcu_head' or 'srcu_head' based on its typeViresh Kumar
Both 'struct dev_pm_opp' and 'struct device_opp' have member with name 'head' but with different types. This leads to confusion while reading the code. Name them 'rcu_head' and 'srcu_head'. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit cd1a068a52ee6a3331a62fe53e87d6ca6cfd68a5) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP mark OPPs as 'static' or 'dynamic'Viresh Kumar
Static OPPs are the ones created from Device Tree entries and dynamic are the ones created at runtime by calling dev_pm_opp_add(). There is a need to distinguish them as we need to free static OPPs from cpufreq drivers when they are removed. So, add another field 'dynamic' in 'struct dev_pm_opp' to keep this information. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 38393409da345cd48d94a0e74c7bbc3402742882) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28PM / OPP don't match for existing OPPs when list is emptyViresh Kumar
OPP list is guaranteed to be empty when 'dev_opp' is created. And so we don't need to run the comparison loop with existing OPPs. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit a7470db6fec481b14afea117846fce383671ba59) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq-dt: register cooling device from ->ready() callbackViresh Kumar
Currently we are calling of_cpufreq_cooling_register() from ->init() callback. At this point of time cpufreq driver's policy isn't completely ready to be used as few of its fields/structure/pointers aren't yet initialized. Because of_cpufreq_cooling_register() tries to access policy with help of cpufreq_cpu_get() and then tries to get freq-table as well, these calls fail. To fix this, register the cooling device after the policy is ready to be used. And the right callback for it is the newly added ->ready() one. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Eduardo Valentin <edubezval@gmail.com> Tested-by: Eduardo Valentin <edubezval@gmail.com> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 9a004428d77f1571c883b993d77ec64767b1959a) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq: Introduce ->ready() callback for cpufreq driversViresh Kumar
Currently there is no callback for cpufreq drivers which is called once the policy is ready to be used. There are some requirements where such a callback is required. One of them is registering a cooling device with the help of of_cpufreq_cooling_register(). This routine tries to get 'struct cpufreq_policy' for CPUs which isn't yet initialed at the time ->init() is called and so we face issues while registering the cooling device. Because we can't register cooling device from ->init(), we need a callback that is called after the policy is ready to be used and hence we introduce ->ready() callback. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Eduardo Valentin <edubezval@gmail.com> Tested-by: Eduardo Valentin <edubezval@gmail.com> Reviewed-by: Lukasz Majewski <l.majewski@samsung.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 7c45cf31b3ab9be270a7bf6af2926631dc566436) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq-dt: pass 'policy->related_cpus' to of_cpufreq_cooling_register()Viresh Kumar
The second parameter of of_cpufreq_cooling_register() should be the CPUs to which the frequency constraint will apply. As the cpufreq-dt driver now supports platforms with multiple 'struct cpufreq_policy' instances (i.e. > 1 clock domains for CPUs), passing 'cpu_present_mask' isn't correct anymore. As every policy will have a set of CPUs and that may not be equal to 'cpu_present_mask' always. So, pass only mask of CPUs which are controlled by current policy. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Eduardo Valentin <edubezval@gmail.com> Tested-by: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit d3a10c14755a5929eaf43cea760bc307ee7e96bc) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq: Fix formatting issues in 'struct cpufreq_driver'Viresh Kumar
Adding any new callback to 'struct cpufreq_driver' gives following checkpatch warning: WARNING: Unnecessary space before function pointer arguments + void (*ready) (struct cpufreq_policy *policy); This is because we have been using a tab spacing between function pointer name and its arguments and the new one tried to follow that. Though we normally don't try to fix every checkpatch warning, specially around formatting issues as that creates unnecessary noise over lists. But I thought we better fix this so that new additions don't generate these warnings plus it looks far better/symmetric now. So, remove these tab spacing issues in 'struct cpufreq_driver' only + fix alignment of all members. Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org> Reviewed-by: Eduardo Valentin <edubezval@gmail.com> Tested-by: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 90452e61137a3e88aa705d3efcb3874f3ce8d390) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq: cpufreq-dt: Move newline to end of error messageGeert Uytterhoeven
Currently the error message is needlessly splitted across two lines. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz> (cherry picked from commit edd52b1c39ea3ddb1c814d1d5cd9cc4843a04c01) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq: cpufreq-dt: Handle regulator_get_voltage() failureStefan Wahren
In error cases regulator_get_voltage() returns a negative value. So take care of it. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 8197bb1bffbee6a7678d20b4c1e77940cdaa8640) Signed-off-by: Alex Shi <alex.shi@linaro.org>
2015-10-28cpufreq: cpufreq-dt: Improve debug about matching OPPStefan Wahren
During test of new DT OPPs it's very helpful to print the matching OPP in case of frequency change. So it will be easier to find frequency rounding issues in the dts file. Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> (cherry picked from commit 0a1e879d353f6f6e661d14c6a0e42dd19efbc504) Signed-off-by: Alex Shi <alex.shi@linaro.org>