Your ROOT_URL in app.ini is https://gitea.jennalody.de/ but you are visiting https://gitea.jenslody.de/jenna/kernel_samsung_sm7125/commits/commit/29e99761ebe6e28c78f4e87a3944372d1874dc10/drivers/devfreq
You should set ROOT_URL correctly, otherwise the web may not work correctly.
commit 66d0e797bf095d407479c89952d42b1d96ef0a7f upstream.
This reverts commit 4585fbcb53.
The name changing as devfreq(X) breaks some user space applications,
such as Android HAL from Unisoc and Hikey [1].
The device name will be changed unexpectly after every boot depending
on module init sequence. It will make trouble to setup some system
configuration like selinux for Android.
So we'd like to revert it back to old naming rule before any better
way being found.
[1] https://lkml.org/lkml/2018/5/8/1042
Cc: John Stultz <john.stultz@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: stable@vger.kernel.org
Signed-off-by: Orson Zhai <orson.unisoc@gmail.com>
Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Upstream commit eff5d31f7407fa9d31fb840106f1593399457298 ]
To build test, add COMPILE_TEST depedency to both ARM_RK3399_DMC_DEVFREQ
and DEVFREQ_EVENT_ROCKCHIP_DFI configuration. And ARM_RK3399_DMC_DEVFREQ
used the SMCCC interface so that add HAVE_ARM_SMCCC dependency to prevent
the build break.
Reported-by: kbuild test robot <lkp@intel.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
commit 2fee1a7cc6b1ce6634bb0f025be2c94a58dfa34d upstream.
The commit 4585fbcb53 ("PM / devfreq: Modify the device name as devfreq(X) for
sysfs") changed the node name to devfreq(x). After this commit, it is not
possible to get the device name through /sys/class/devfreq/devfreq(X)/*.
Add new name attribute in order to get device name.
Cc: stable@vger.kernel.org
Fixes: 4585fbcb53 ("PM / devfreq: Modify the device name as devfreq(X) for sysfs")
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
commit d68adc8f85cd757bd33c8d7b2660ad6f16f7f3dc upstream.
The governor is initialized after sysfs attributes become visible so in
theory the governor field can be NULL here.
Fixes: bcf23c79c4 ("PM / devfreq: Fix available_governor sysfs")
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Upstream commit 42a6b25e67df6ee6675e8d1eaf18065bd73328ba ]
Right now devfreq_dev_release will print a warning and abort the rest of
the cleanup if the devfreq instance is not part of the global
devfreq_list. But this is a valid scenario, for example it can happen if
the governor can't be found or on any other init error that happens
after device_register.
Initialize devfreq->node to an empty list head in devfreq_add_device so
that list_del becomes a safe noop inside devfreq_dev_release and we can
continue the rest of the cleanup.
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
commit 2abb0d5268ae7b5ddf82099b1f8d5aa8414637d4 upstream.
There is no locking in this sysfs show function so stats printing can
race with a devfreq_update_status called as part of freq switching or
with initialization.
Also add an assert in devfreq_update_status to make it clear that lock
must be held by caller.
Fixes: 39688ce6fa ("PM / devfreq: account suspend/resume for stats")
Cc: stable@vger.kernel.org
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Reviewed-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Adds ASYNC probe for bimc-bwmon driver specific to AUTO.
Change-Id: I302aeec9edb81640eb1b4b51f571144710939540
Signed-off-by: ankusa <ankusa@codeaurora.org>
This fixes below compilation error for 32bit kernel build.
Comparison of distinct pointer types - 'unsigned long' with
'unsigned long long'. Change is to use uint64_t to fix this.
Change-Id: I5c76433854eff81c850fb44381e418f2bdc1a8c7
Signed-off-by: Lijuan Gao <lijuang@codeaurora.org>
This fixes below compilation error for 32bit kernel
build. Compiler reference __aeabi_uldivmod if there
is a 64bit divide or module. Change is to use do_div
to fix this.
governor_msm_adreno_tz.c: undefined reference to `__aeabi_uldivmod'.
Change-Id: I4de7ada2274698d20d304d8ffe1a92d3bcb7653d
Signed-off-by: Deepak Kumar <dkumar@codeaurora.org>
Update the condition to check valid hwmon before accessing it because
during parallel usecase of resume call and scaling_max_freq store call
it triggers a call to governor to get frequency and governor tries to
access bw_hwmon node from devfreq pointer and it will be NULL if the
governor has failed to start.
Change-Id: I6ee7b784c3cf5e62d5f3f5b48e75ed44483d1a50
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
Current SW limit is not matching the HW limit, update
limit to align with the available HW limit.
Change-Id: I6e221136142785a98e3cd378915b2139904f1551
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
In some usecases AB votes may not be needed but governor
cannot suppress the AB measured on HW.
Provide use_ab tunable for userspace to drop AB vote.
Change-Id: Ib7734e06fa00f86eb536b63526c16212012b614d
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
The sample_ms should never be larger than the devfreq polling
interval. If userspace tries to configure this invalid
configuration, return an error.
Devfreq polling interval should be always greater then the
sample_ms add check in the governor interval event to update
the polling interval accordingly.
Change-Id: I2d07c95668a7fc8e3b2f16e49448ad2e3da8785c
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
Current acc_relative_busy calculation is causing integer overflow
in 32 bit system. "stats->busy_time * stats->current_frequency"
results in a value which is beyond the 32 bit range.
Typecasting the value to u64 to avoid overflow.
Change-Id: Id97da02bef608787ceb7c9751bbfc203af56deb1
Signed-off-by: Harshitha Sai Neelati <hsaine@codeaurora.org>
commit 62bacb06b9f08965c4ef10e17875450490c948c0 upstream.
The kHz to Hz is incorrectly converted in a few places in the code,
this results in a wrong frequency being calculated because devfreq core
uses OPP frequencies that are given in Hz to clamp the rate, while
tegra-devfreq gives to the core value in kHz and then it also expects to
receive value in kHz from the core. In a result memory freq is always set
to a value which is close to ULONG_MAX because of the bug. Hence the EMC
frequency is always capped to the maximum and the driver doesn't do
anything useful. This patch was tested on Tegra30 and Tegra124 SoC's, EMC
frequency scaling works properly now.
Cc: <stable@vger.kernel.org> # 4.14+
Tested-by: Steev Klimaszewski <steev@kali.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
[ Upstream commit 2c2b20e0da89c76759ee28c6824413ab2fa3bfc6 ]
Regulators should be enabled before clocks to avoid h/w hang. This
require change in exynos_bus_probe() to move exynos_bus_parse_of()
after exynos_bus_parent_parse_of() and change in error handling.
Similar change is needed in exynos_bus_exit() where clock should be
disabled before regulators.
Signed-off-by: Kamil Konieczny <k.konieczny@partner.samsung.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
[ Upstream commit 0ef7c7cce43f6ecc2b96d447e69b2900a9655f7c ]
The devfreq passive governor registers and unregisters devfreq
transition notifiers on DEVFREQ_GOV_START/GOV_STOP using devm wrappers.
If devfreq itself is registered with devm then a warning is triggered on
rmmod from devm_devfreq_unregister_notifier. Call stack looks like this:
devm_devfreq_unregister_notifier+0x30/0x40
devfreq_passive_event_handler+0x4c/0x88
devfreq_remove_device.part.8+0x6c/0x9c
devm_devfreq_dev_release+0x18/0x20
release_nodes+0x1b0/0x220
devres_release_all+0x78/0x84
device_release_driver_internal+0x100/0x1c0
driver_detach+0x4c/0x90
bus_remove_driver+0x7c/0xd0
driver_unregister+0x2c/0x58
platform_driver_unregister+0x10/0x18
imx_devfreq_platdrv_exit+0x14/0xd40 [imx_devfreq]
This happens because devres_release_all will first remove all the nodes
into a separate todo list so the nested devres_release from
devm_devfreq_unregister_notifier won't find anything.
Fix the warning by calling the non-devm APIS for frequency notification.
Using devm wrappers is not actually useful for a governor anyway: it
relies on the devfreq core to correctly match the GOV_START/GOV_STOP
notifications.
Fixes: 996133119f ("PM / devfreq: Add new passive governor")
Signed-off-by: Leonard Crestez <leonard.crestez@nxp.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Some BWMON devices require clocks to be enabled. Some of these
clocks are dependent on the bus to be active before we enable
the clocks. Add code to vote for the bus bandwidth before enabling
the BWMON clocks.
Change-Id: Ic31f4f45ed59ba3fb5bcad007132fab30b1bd0b5
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
Currently bw_hwmon governor does not allow the device
to be resumed if the resume_freq is set to zero. But there
can be devices that vote for zero frequency when there is
no bandwidth on the device. This does not mean that the device
should not be resume from suspend. Remove the check with prevents
resume, instead add a check in the devfreq framework to check if
device is suspended or not before calling the governor resume.
Change-Id: Ib82a6a36308aee52e8bb989fddca92265de6c4a4
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
During SUSPEND event, check the pointer for governor
private data is not NULL before updating bus parameters
to zero.
Change-Id: I1a37173e8ae7ad4bcd5f8497c5956302e647c862
Signed-off-by: Archana Sriram <apsrir@codeaurora.org>
The BWMON governor start is returning success on GOV_START event
without checking for the return value of start_monitor.
The return value of start_monitor is not being returned to
ret variable. This would cause the governor to start successfully
even when the monitor failed to start causing a NULL pointer
derefence when accessing the device attributes. Fix it by checking
the return value of start_monitor.
Change-Id: I8c1f6933d44ae4533c6b81ccda8a5c4c0da3779c
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
Some BWMON devices requires clocks to be enabled, hence
add necessary support in the bwmon driver to enable the
required clocks if any.
Change-Id: Ie06731f764ff24d602ae2a86dea4f39ce75df800
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
Currently only BWMON5 devices increment the count for non-zero
bandwidth while BWMON4 devices increment the count all the time.
This results in a non-zero bandwidth report even when the count
is zero for BWMON4 devices leading to unnecessarily higher
bandwidth votes. Apply checks similar to BWMON5 devices for BWMON4
monitors as well.
Change-Id: I0a2d1c0ed979973966668391a32f63bf2711f981
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
Re-initialize adreno freq table to TZ when resuming from
hibernation, since TZ is not aware of hibernation.
Change-Id: Ia01be44521b9f79c5595510e9a777102ce223e25
Signed-off-by: Thomas (Wonyoung) Yun <wyun@codeaurora.org>
Check return value for success of operating point property
from the dt node.
Change-Id: I7c6c8efc2cf1241c6389a868788683b89aac77d4
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
Trinket target support LPDDR3 and LPDDR4 HW supporting different
frequency levels, update devfreq drivers to detect the DDR type
and add frequency tables accordingly.
Change-Id: I5286466274a3e96739b1feecdaccc9bea773d2b8
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
Remove partner (bus) devfreq management from the adreno governor.
Partner devfreq can be managed directly from the device driver.
Change-Id: I745361c2b585e0dd91f208e09ec3001d7ecba717
Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
Currently update_devfreq() is only visible to devfreq governors outside
of devfreq.c. Make it public to allow drivers that adjust devfreq policies
to cause a re-evaluation of the frequency after a policy change.
Change-Id: I629c39eaa441a4d1cb675f73f0efb679e7a9e702
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
Reviewed-by: Brian Norris <briannorris@chromium.org>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Git-commit: b596d895fa2957e136a6b398b97b06bd42b51291
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Akhil P Oommen <akhilpo@codeaurora.org>
If there is a failure in starting hw monitor required for
memlat governor, return the error code to devfreq framework
so that the framework will make sure the governor is
switched back to previous governor.
Change-Id: I76705725fc8b94d5341b1b8af7c1bd2b79e7642a
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
Some devices freq_table is NULL, when show available_frequencies,
shouldn't access freq_table if max_state is 0.
Change-Id: I58ffaa23c1d27c0fe147c6d4f755244c3f69fbc0
Signed-off-by: Qiwei Liu <qiweil@codeaurora.org>
In bytes_to_mbps function, the parameter is all unsigned,
so change the decleration of the function to include unsigned long
long to avoid compilation errors in 32 bit environment.
Also changed the return value as unsigned long to avoid
any data loss possible in 64 bit environment.
Change-Id: I90aebfe32e86ebc17c414d6f3c0c3cbd6dddb0bd
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
There is a possibility to switch the governors from sysfs even when the
device is in suspended state. This can cause a NOC error at times when
trying to access the device's monitor registers in a suspended state. This
change fixes this issue. Introduce a variable dev_suspended to know if
the device is in suspended state or not. Check if the device is suspended
before switching the governor from sysfs.
Change-Id: I15055aa51daa35272be4667e5bafb8ccd7933098
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
There is a race condition when the event governor_store is being executed
from sysfs and the device issues a suspend. The devfreq data structures
would become stale when the suspend tries to access them in the middle
of the governor_store operation. Fix this issue by taking a lock around
suspend and resume operations so that these operations are not concurrent
with the other events from sysfs.
Also rename the sysfs_lock as event_lock since the same lock is used
for non sysfs operations like suspend and resume as well.
Change-Id: Ifa0e93915a920cec3e0429966328a1128d61098b
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
Update GPU Bus DCVS to weight high stall cycles (as a percentage
of total bus usage) heavier in order to vote up the bus when the
GPU is stalling a lot waiting for data.
Change-Id: I8a331a48a1ab737c51f1001ea1991f09af9ef900
Signed-off-by: Kyle Piefer <kpiefer@codeaurora.org>
Remove using the waiting bandwidth cycles for deciding
when to change bandwidth levels.
Change-Id: I65341c5c115684f19b5a3b2522d362e80315f2c9
Signed-off-by: Carter Cooper <ccooper@codeaurora.org>
Signed-off-by: Kyle Piefer <kpiefer@codeaurora.org>
Some instances of memlat governor need to use a higher value for ratio_ceil
to get a better power/performance balance. So increase the max limit from
10000 to 20000.
Change-Id: I0c8900e574c91c4c02bbb49416da6df764aab030
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
When "simple_scaling" flag is enabled for on demand governor then clocks
should be scaled up when the load is more than up threshold and should
be scaled down when load is less than the up threshold minus down
differential threshold. But currently governor is only scaling down
when load is less than the down differential threshold which is definitely
not intentional. This change fixes the above bug.
Change-Id: If2a234155c12989dc0df397cd84eef4a759ecdfc
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
[junjiew@codeaurora.org: resolved trivial conflicts]
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Currently, the bw_hwmon governor handles DEVFREQ_GOV_STOP and
DEVFREQ_GOV_SUSPEND events by calling devfreq_monitor_stop
and devfreq_monitor_suspend respectively, prior to disabling
the bw_hwmon irq. Doing so allows for the following race condition:
T0: bw_hwmon irq thread:
/* df->governor == bw_hwmon
* changing to
* powersave governor
*/
governor_store()
/* Calls bw_hwmon governor event
* handler with DEVFREQ_GOV_STOP
* event
*/
df->governor->event_handler()
gov_stop()
stop_monitor()
update_bw_hwmon()
devfreq_monitor_stop()
/* Cancels timer for future calls
* to devfreq_monitor
*/
devfreq_monitor_stop()
/* Calls free_irq(), which waits
* for the bw_hwmon IRQ thread
* to finish.
*/
hw->stop_hwmon()
--finishes update_devfreq()--
/* Incorrectly starts
* devfreq_monitoring
*/
devfreq_monitor_start()
--thread finishes execution--
--finishes DEVFREQ_GOV_STOP
handling--
--switches governor to powersave--
/* devfreq monitor for this
* instance. This will call
* queue_delayed_work()
* which internally queues
* the timer for this devfreq
* structure.
*/
devfreq_monitor()
/* df->governor == powersave
* changing to bw_hwmon
*/
governor_store()
/* powersave: DEVFREQ_GOV_STOP
*/
df->governor->event_handler()
/* bw_hwmon: DEVFREQ_GOV_START
*/
df->governor->event_handler()
gov_start()
/* Will incorrectly adjust
* the fields within the
* timer and corrupt the
* timer data structure
*/
devfreq_monitor_start()
Since this corrupts the timer data structures, when the timer
gets expired, it will be expired twice. Fix this race condition
by introducing new lock to synchronize the access to the
mon_started variable, so that the irq thread does not restart
the devfreq monitor after it has been stopped.
Change-Id: I2dced21d5343afd6ec2e13876e26aeb5c83a4d12
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
For simple-dev and devbw platform driver does not
support the manual bind / unbind feature through sysfs,
when the governor is registered and started.
Suppress the bind / unbind calls using driver attribute.
Change-Id: Ide843476bdc3870c48f6557097ee549e7a794a22
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
For arm-memlat and bimc-hwmon platform driver does not
support the manual bind / unbind feature through sysfs,
when the governor is registered and started.
Suppress the bind / unbind calls using driver attribute.
Change-Id: I8287012e1e6931d80953382f3d625223315cec85
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
Update freq variable from unsigned long to uint64_t of
compute_freq function to be in compliance with 32 bit
environment.
Change-Id: Ia9183b0e593daf3780135a8e1ae8ddb36db16f86
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
Add suspend/resume support for the mem_latency governor. Uses hwmon driver-
defined suspend/resume calls in addition to monitor start/stop calls within
the devfreq framework.
Change-Id: I900b322a05cd0312f082d70640e21851879cb18c
Signed-off-by: Jonathan Avila <avilaj@codeaurora.org>
OPP framework exposes a set of functions that could be used to fetch
the list of supported bandwidth values from DT and to query the list
for an appropriate value while honoring requests from
governors/clients.
Use OPP table APIs and get rid of frequency table logic to make the
code more concise and upstream friendly.
Change-Id: I120ae7230bdbfaaa9523263c65a8b84470583071
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
[ Upstream commit 63f1e05f7fe9ca509c60154d6a833abf96eecdc9 ]
df->governor is being dereferenced before it is null checked,
hence there is a potential null pointer dereference.
Notice that df->governor is being null checked at line 1004:
if (df->governor) {, which implies it might be null.
Fix this by null checking df->governor before dereferencing it.
Addresses-Coverity-ID: 1401988 ("Dereference before null check")
Fixes: bcf23c79c4 ("PM / devfreq: Fix available_governor sysfs")
Signed-off-by: Gustavo A. R. Silva <garsilva@embeddedor.com>
Reviewed-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Currently, concurrent writes to sysfs entries leave the possibility for
race conditions within the devfreq framework. For example, concurrently
executing max_freq_store and governor_store can result in attempting to
perform an update_devfreq() before the new governor's start handler can be
executed.
A more concrete case is a race between polling_interval_store and
governor_store. Because no lock is used after calling into the event
handler of the old governor and there's nothing preventing work from being
queued after the monitor is stopped, it's possible to accidentally cause
delayed work to be queued on the governor being switched to. This can be
seen if you create two threads, one which changes a device's governor
between simple_ondemand and performance, and one which changes its polling
interval between 45 and 50.
All of these races can be addressed with the introduction of a lock that
prevents sysfs operations from interleaving in this fashion.
Change-Id: Ia6887dcb2d69dc2576837a6c09fed55a28943abc
Signed-off-by: Jonathan Avila <avilaj@codeaurora.org>
Calling dev_pm_opp_put without the associated get leads to potential memory
corruption of other variables on the stack.
Change-Id: I7b4220651786a9b996a9ceb0336c8c4a884df513
Signed-off-by: Kyle Yan <kyan@codeaurora.org>