Commit Graph

181 Commits

Author SHA1 Message Date
Sultanxda 9bef265ccc PM / devfreq: Fix typo that caused an infinite loop
This is really, really bad.

Signed-off-by: Sultanxda <sultanxda@gmail.com>
2019-08-26 17:01:17 +02:00
Sultanxda b276aff15a PM / devfreq: Remove null termination in boost_devices
We're not passing boost_devices anywhere outside of this driver, so there's
no need for null termination.

Signed-off-by: Sultanxda <sultanxda@gmail.com>
2019-08-26 17:01:16 +02:00
Francisco Franco ecf919fc53 PM / devfreq: Boost cpubw on screen on events
Signed-off-by: Francisco Franco <franciscofranco.1990@gmail.com>
2019-08-26 17:01:16 +02:00
Sultanxda bf3a2d44e3 PM / devfreq: Reduce wake boost duration to 5000 ms 2019-08-26 17:01:15 +02:00
Sultanxda 3fe368a347 PM / devfreq: Add an interface to boost devices when the screen is woken
This adds a generic interface to boost a list of devfreq devices defined
at compile time. The specified devfreq devices (boost_devices) are boosted
to their respective max frequencies when the screen is turned on in order to
improve screen-wake performance. The default boost duration is 10 seconds.

Signed-off-by: Sultanxda <sultanxda@gmail.com>
2019-08-26 17:01:15 +02:00
Chanwoo Choi b220966ae7 PM / devfreq: Fix the bug of devfreq_add_device when governor is NULL
This patch fixes the bug of devfreq_add_device(). The devfreq device must
have the default governor. If find_devfreq_governor() returns error,
devfreq_add_device() fail to add the devfreq instance.

Fixes: 1b5c1be2c8 (PM / devfreq: map devfreq drivers to governor using name)
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-08-26 17:01:14 +02:00
Saravana Kannan a9bbbe2e8e PM / devfreq: Restart previous governor if new governor fails to start
If the new governor fails to start, switch back to old governor so that the
devfreq state is not left if some weird limbo.

Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:01:14 +02:00
Tobias Jakobi 0acc92f183 PM / devfreq: Skip status update on uninitialized previous_freq
In case devfreq->previous_freq is still uninitialized in
devfreq_update_status(), i.e. it has value '0', the lookups in
that function fail, eventually leading to some error message:
[    3.041292] devfreq bus_dmc: Couldn't update frequency transition information.

Just skip the statup update in this situation.

Signed-off-by: Tobias Jakobi <tjakobi@math.uni-bielefeld.de>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-08-26 17:01:13 +02:00
Axel Lin eb073bb65c PM / devfreq: Add proper locking around list_del()
Use devfreq_list_lock around list_del() to prevent list corruption.

Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-08-26 17:01:12 +02:00
Sultanxda 37254f5209 PM / devfreq: Add a governor white list
Many of the devfreq governors compiled in are unstable/incomplete, so we
don't want users switching to them. Compiling out the unused governors is
messy because many other drivers link to them, and there are not proper

Add a white list of the only governors intended for use to the governor
sysfs node in order to prevent users from enabling governors that unstable.

Signed-off-by: Sultanxda <sultanxda@gmail.com>
2019-08-26 17:01:12 +02:00
Hanumant Singh f840612efb PM/devfreq: Remove redundant put_device()
When unregistering devfreq device (devfreq_remove_device()),
there is an additional call to put_device,
after device_unregister().This causes data aborts in case
of access to a kobj in put_device(), that was already freed
by preceding device_unregister()

CRs-Fixed: 841819
Change-Id: I98bd9e4cc9ecfbc48a0bfe72fc47e362a6697741
Signed-off-by: Hanumant Singh <hanumant@codeaurora.org>
2019-08-26 17:01:11 +02:00
Chanwoo Choi 7ec6ce0009 PM / devfreq: Fix devfreq_remove_device() to improve the sequence of resource free
This patch modify devfreq_remove_device() to improve the sequence of resource
free. If executing existing devfreq_remove_device(), this function always
executes _remove_devfreq() twice. In result, second _remove_devfreq() always
return error value. So, This patch resolves complicated function sequence
as following:

[Flow sequence before modification]
devfreq_remove_device()
   _remove_devfreq(devfreq, false)
      kfree(devfreq);  /* Free devfreq */
      if (!skip ...) { /* skip is false */
         device_unregister(&devfreq->dev)
         put_device(&devfreq->dev);
            ...
            dev->release()
               devfreq_dev_release()
                  _remove_devfreq(devfreq, true) <- Recall to free devfreq
                  /*
		   * Always return error without freeing resource because
		   * already _remove_devfreq() frees the memory of devfreq.
		   */
   }

[Flow sequence after modification]
devfreq_remove_device
   device_unregister(&devfreq->dev)
   put_device(&devfreq->dev);
      ..
      dev->release()
         devfreq_dev_release()
            _remove_devfreq()
               kfree(devfreq); /* Free devfreq */

Change-Id: I8ce4801795539d281ff0ff0c7c73e7f98ba6fe7d
Signed-off-by: Chanwoo Choi <cw00.choi@samsung.com>
[Merge conflict resolved by MyungJoo]
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
Git-commit: 585fc83ece43be63d5775e536f855db33dd752cf
Git-repo: git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2019-08-26 17:01:11 +02:00
Geliang Tang 9c3fe3baa1 PM / devfreq: fix double kfree
When device_register() fails, kfree(devfreq) is called already in
devfreq_dev_release(), hence there is no need to call kfree(devfreq)
in err_dev again.

Signed-off-by: Geliang Tang <geliangtang@163.com>
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-26 17:01:10 +02:00
Saravana Kannan 30fedcc25a PM / devfreq: bw_hwmon: Fix race condition in polling interval update
When the polling interval is updated, the delayed workqueue is cancelled
and requeued with the new polling interval. However, the bw_hwmon IRQ can
come at the same time and try to stop and restart the delayed work (in the
IRQ thread). This can cause a race where the work might be queued twice or
canceled twice and cause a crash.

Fix this race condition by suspending and resuming the HW monitor when we
are updating the polling interval. This entirely avoids the race because
suspending the HW monitor also avoid the possibility of the IRQ coming
during the polling interval update.

CRs-Fixed: 954082
Change-Id: Ic7baf2a3da4ed8f8a9023617059e22fd81c3ba45
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:01:10 +02:00
Rajagopal Venkat b6a737e00f PM / devfreq: account suspend/resume for stats
devfreq stats is not taking device suspend and resume into
account. Fix it.

Signed-off-by: Rajagopal Venkat <rajagopal.venkat@linaro.org>
Acked-by: MyungJoo Ham <myungjoo.ham@samsung.com>
2019-08-26 17:01:09 +02:00
Rohit Gupta 8a7061e34f PM / devfreq: bw_hwmon: Expose a throttle adjust tunable
Newer versions of bimc-bwmon counters have the capability to fake
higher byte count than what's actually transferred between a bus
master and DDR if the bus master is being throttled by QoS hardware
logic. Add support to set the throttle adjust field that comes with
this newer version of bimc-bwmon.

Change-Id: I33376c825fb11ab2e378f828b1d2ae46dd582836
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
2019-08-26 17:01:09 +02:00
Hanumath Prasad 42fe2b6620 devfreq: devfreq_simple_dev: call clk_round_rate in dev_target
clk_set_rate is failing for some of the frequencies due to higher
precision introduced in clock driver. Hence call the clk_round_rate
again in dev_target to make sure we send the correct frequency to
clk_set_rate.

Change-Id: I3e40690bf794d99debbcecdcaf05aaac3363caa8
Signed-off-by: Hanumath Prasad <hpprasad@codeaurora.org>
2019-08-26 17:01:08 +02:00
Saravana Kannan 3318708f4d PM / devfreq: bw_hwmon: Fix handling of max_mbps
When doing over-voting due to an UP_WAKE event, the governor
pre-initialized the max_mbps value for the next decision window. This was
done to prevent a dropping the vote below the original measurement in case
a DOWN_WAKE event comes before the decision window is complete. This has
the undesirable side-effect of keeping the votes high for two decision
windows following an UP_WAKE event.

Also, DOWN_WAKE event is currently disabled for any decision windows that
didn't do over-voting because doing so had significant performance impacts.

However, with historic max tracking, pattern detection and hysteresis, and
mbps zones awareness that were added later on, the above concerns aren't
really valid anymore.  So, simply delete the pre-initialization of the
max_mbps so that one decision window isn't unnecessarily voting higher than
necessary. As part of the change, also fix down_cnt logic to allow it to
work for all decision windows if enabled.

Change-Id: I600e3783da617ed4efef5b05156016d88c301cea
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:01:08 +02:00
Rohit Gupta be345e7a29 PM / devfreq: bw_hwmon: Allow up_scale to be set to zero
Currently the lower limit for setting up_scale is 100. Change it
to 0 so that over-voting for spikes in measured bandwidth can be
disabled by setting up_scale to 0.

Change-Id: I1e5e3d51c625163b38074fb1eda26763455ea6c5
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
2019-08-26 17:01:07 +02:00
Saravana Kannan 0e3e7f775a PM / devfreq: bw_hwmon: Remove debug logs from high frequency code path
Using debug logs for the short samples would result in excessive logging
and also have an impact on CPU power and performance. The tracepoint that's
already there is a much better alternative. So, delete the debug logs.

Change-Id: Idd1d634f510381d14637f3b84588a118572f3f16
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:01:07 +02:00
Saravana Kannan ecf75cf35e PM / devfreq: bimc-bwmon: Fix IRQ registration in resume path
The IRQ registration on the resume path was not updated properly when the
high sampling rate algorithm was implemented. Update it so that the IRQ
registration is done correctly.

Change-Id: I17a016dd9c0b50c7b415beda21368cb4586d203c
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:01:06 +02:00
Hanumath Prasad 135637be54 PM / devfreq: bimc-bwmon: Update irq handling in suspend/resume
Change the sequence of registering and freeing the interrupt
handler in suspend/resume. Freeirq needs a guarantee that the
IRQ can't come anymore before we call it. So, we disable the IRQ
before calling freeirq.And register the handler before enabling
the irq to avoid the interrupt getting unhandled.

Change-Id: I3945202d049e16f64a16e456f914f7602b763c89
Signed-off-by: Hanumath Prasad <hpprasad@codeaurora.org>
2019-08-26 17:01:05 +02:00
Saravana Kannan 9e0026159a PM / devfreq: bw_hwmon: Take at least one sample per decision window
Due to the way the short samples are triggered, when the traffic is very
low, we could have a decision window where no sample is taken. Fix this by
forcing a sample at the end of every decision window as long as that is the
first sample for that decision window or the sample window won't be smaller
than the sample_ms tunable.

Change-Id: Ia33b59fbff9ff4058c06e24208d1e037d6e9eda9
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:00:46 +02:00
Saravana Kannan 4fe9afbe30 PM / devfreq: bw_hwmon: Remove unused tunables and disable some by default
With the rewrite of the algorithm, some tunables are not used. Remove those
tunables. Other tunables don't make a lot of sense to be turned on by
default. Change their default state to be disabled.

Change-Id: I228d275a21765986a7117b335a669deebf590f29
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:00:31 +02:00
Saravana Kannan 1a9a4d11a2 PM / devfreq: bw_hwmon: Fix AB vote less than measurement when freq at max
When the decision window is terminated early by an IRQ and the frequency
voted by the governor is the max_freq allowed for that device, the AB vote
can be lower than the measured value. This really shouldn't affect power or
performance since the device frequency is already maxed out, but fix it
anyway so that the logs don't look suspicious.

Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Change-Id: I1788cbb1af026f1c54f9acc4806cb29cd6069e04
2019-08-26 17:00:31 +02:00
Junjie Wu 0351256a2e devfreq: devfreq_simple_dev: Add support for preparing device clock
For certain implementation, device clock needs to be prepared before
rate voting taking effect. Add support for preparing device clock
during initialization.

Change-Id: Ib22e83952187118342ff2546d4c79d3970a288f9
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2019-08-26 17:00:30 +02:00
Saravana Kannan dd70ab5d7b PM / devfreq: bw_hwmon: Update to low latency, high sampling rate algorithm
The existing bw_hwmon governor samples the bandwidth every polling_interval
milliseconds and makes decisions. Polling interval of 50ms or even 10ms
gives a very low resolution picture of the DDR/bus traffic. Due to the
lower resolution picture, the existing governor algorithm has to be biased
aggressively towards performance to avoid any performance degradation
compared to using a static mapping between bus master (CPU, GPU, etc)
frequency to DDR/bus BW votes.

While the existing governor uses IRQ to get early notification of traffic
increase, even a 4x early notification for a 50ms polling interval still
takes 12.5ms. This kind of reaction time is still too slow for some bus
masters like CPU.

To take care of these limitations, rewrite the governor algorithm to take
multiple short samples of BW within a decision window (polling interval)
and use that higher resolution picture to make much better and faster
decisions. Doing so allows the governor to have the following features:
- Very low reaction time
- Over voting to stay ahead of increasing traffic
- Historic peak tracking to limit over voting
- Being power aware when doing over voting
- Pattern detection and intelligent hysteresis
- Detection low traffic modes and being less aggressive about BW votes

Change-Id: I69886b7fbeea0b64d10b5a1fb23fcb5f3918f0ce
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:00:30 +02:00
Saravana Kannan cd300b93e2 PM / devfreq: bimc-bwmon: Fix typo
Accidentally used a , instead of a ; to end statements. This change fixes
that. Should not have any functional impact.

Change-Id: I36ea6c49a8a8973f1856cac6709f01432e6d60c7
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:00:29 +02:00
Saravana Kannan 8c66a8cac5 PM / devfreq: bimc-bwmon: Optimize some debug messages
A device register is read and printed using pr_debug. Register reads can be
slow. So, refactor the code such that the register read is also compiled
out if the pr_debug is compiled out.

Change-Id: I4de5ab1f2133e19d6ce0b3cb4547b815526c7abd
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:00:29 +02:00
Saravana Kannan 99b8cee343 PM / devfreq: bimc-bwmon: Fix counter clearing
The counter needs to be cleared and acknowledged before clearing the IRQ
bits. Otherwise, the HW could set the IRQ bit again if the old counter
value was higher than the threshold. So, add a memory barrier after
clearing the counter.

Change-Id: I35f9f7905b05b8a185eb94d04d9c0a8ccfc2db51
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:00:28 +02:00
Junjie Wu fe1002ea3e PM / devfreq: governor_cache_hwmon: Fix race in monitor start/stop
Some cache_hwmon devices can have interrupts firing at any time. The
interrupt handler would stop devfreq monitor, update its vote and
restart the monitor again. This introduces a race if
devfreq_supend/resume() or devfreq_interval_update() is called at
the same time. Since devfreq_monitor_start() re-initializes the work,
it could cause corruption while the work is being used elsewhere.

Protect governor monitor start/stops with a new lock.

Change-Id: I143aaaea86494b4c617df46e2c521a19b43861d5
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2019-08-26 17:00:28 +02:00
Hanumath Prasad b0d7f48be9 PM / devfreq: bimc-bwmon: set a floor_mbps for irq threshold
Interrupt storm happens when bwmon is enabled for GPU. This is mainly
due to constant low traffic observed with GPU while doing memory
read/write. So as the data rates read from counters are low and so the
threshold set for triggering the interrupt also set as low, which in
turn causes huge number of interrupts. Avoid this by setting a minimum
floor for the irq threshold.

Change-Id: I190fad5108bc24afcb67bec5809485380ee3662e
Signed-off-by: Hanumath Prasad <hpprasad@codeaurora.org>
2019-08-26 17:00:27 +02:00
Dilip Kota 220bfbef2d devfreq_spdm: Handle spurious interrupts during bootup
Terminate the interrupts triggered before the intitalisation
itself.

Change-Id: I7c005134ecbdae38b58e4312f9e294f5b59c2510
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
2019-08-26 17:00:27 +02:00
Arun KS d2ac845743 PM / devfreq: bimc-bwmon: Use free_irq during governor suspend/stop
Use free_irq to free the interrupt handler for a shared interrupt.

Enable_irqs are not refcounted, whereas disable_irqs are. Depth variable
in irq_desc is actually disable-depth, for nested irq_disable() calls.
It can have value from 0 to N. 0 is when interrupt is enabled and N shows
the irq_disable depth.

Lets say, if  disable_irq is called 4 times, driver need to call
enable_irq 4 times to actually enable the interrupt back. But if
enable_irq is called 4 times, only one disable_irq needed to actually
disable the interrupt.

Use request/free_irq instead of disable/enable_irq.

Change-Id: Ie7fe866b403da9bf363f741b1693361b8e2f6a3d
Signed-off-by: Arun KS <arunks@codeaurora.org>
2019-08-26 17:00:13 +02:00
Dan Sneddon 59387b83e6 devfreq: devfreq_spdm: Enhance debugfs entries
Add ability to read filter properties from debugfs and add ability to
enable and disable spdm processing.

Change-Id: I1b94c5c44180df2a39097657ecc6606562736d1a
Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org>
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
2015-06-09 16:40:51 -07:00
Lucille Sylvester e6bbd976b8 msm: kgsl: Power Optimizer Push-Pop
A new feature for GPU power saving.  Using the output of normal
GPU DCVS delicately try pushing to a slightly lower than recommended
power level.  Pop up immediately if the lower level is non-sustainable.
Use statistic shaping to the point of DDR increase to help maintain
the lower GPU frequency.

Change-Id: I38c187aaf52114664ccea27b2cc3637cd0fd366f
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
2015-03-16 10:46:56 -07:00
Alok Chauhan e3d1a06a36 devfreq: devfreq_spdm: Correct Memory usages check in error cases
Correct some of memory free usages check to avoid corruption
later point of time.

Change-Id: Iaeff7bf413157ff324d1678f630de54c22d792a0
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
2015-03-06 23:24:14 -08:00
Dan Sneddon c81d6dbe8c devfreq: spdm: Fix debugfs file permissions
The files in the debugfs directory for spdm were
set incorrectly using hex instead of octal numbers.
This patch correctly uses octal codes and removes the
execute bit.

CRs-Fixed: 799304
Change-Id: I3bab83073d1ee1f426c402a05556c9ae97ca089d
Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org>
2015-02-25 06:54:27 -08:00
Dan Sneddon d91d94c8d6 devfreq: devfreq_spdm: Support scm and hvc
Currently SPDM driver uses hvc calls to support
the dcvs algorithm logic. On some targets this
dcvs algorithm support is present in TZ and which
is accessed via separate calls. Add SCM call to
support TZ based dcvs algorithm.

Change-Id: I197f0f13b4107047151e10e19e4849008607f3e8
Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org>
Signed-off-by: Alok Chauhan <alokc@codeaurora.org>
2015-02-06 09:17:34 +05:30
Linux Build Service Account 068491aeaa Merge "devfreq: devfreq_spdm: Add IPC logging for hypervisor calls" 2015-01-27 06:52:52 -08:00
Girish Mahadevan f49a6d7f28 devfreq: devfreq_spdm: Add IPC logging for hypervisor calls
Use IPC logging to log calls made to hypervisor for the SPDM driver.
The continuous logging is useful when debugging stability issues and also
to profile code execution.

Change-Id: Ib32fcc998319f4477dc8c1df383ed89b4a9e9214
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
2015-01-23 14:11:42 -07:00
Junjie Wu 0a9c8a3145 PM / devfreq: Fix error handling in governor_cpufreq
put_online_cpus() is not called if an error occurs during cpufreq
notification registration. Fix the error path by calling it properly.

Change-Id: Ia2e6b2debb2db4b39f8fcfcd1ee873538b44d405
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2015-01-15 11:38:08 -08:00
Linux Build Service Account 845c96e6f7 Merge "PM / devfreq: cache_hwmon: Also print low mrps for debugging" 2014-12-16 12:06:47 -08:00
Linux Build Service Account f605f30e10 Merge "PM / devfreq: cache_hwmon: Use array for reporting monitor stats" 2014-12-16 12:06:46 -08:00
Linux Build Service Account d6e3e534ae Merge "PM / devfreq: cache_hwmon: Move IRQ handling to device drivers" 2014-12-16 12:06:45 -08:00
Linux Build Service Account 839d832eec Merge "PM / devfreq: Refactor Cache HWmon governor to be more generic" 2014-12-15 16:17:41 -08:00
Junjie Wu f0ad99f92f PM / devfreq: Fix NULL pointer dereference if freq_table is empty
If max_state is 0, freq_table will be empty. Change do-while loop to
while loop to avoid dereferencing freq_table.

Change-Id: I4a24e9b8cab8073db429c74e627b7fb50076ea93
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2014-12-10 17:01:13 -08:00
Linux Build Service Account dca34e2b69 Merge "msm: kgsl: Bump the GPU frequency for long blocks of processing" 2014-12-03 01:34:19 -08:00
Linux Build Service Account 5c7ba6daab Merge "msm: kgsl: Add a dynamic AB bandwidth vote" 2014-12-02 17:39:56 -08:00
Linux Build Service Account 860aa3c72f Merge "msm: kgsl: Add a path for dynamic AB bus votes" 2014-12-02 17:39:54 -08:00