Commit Graph

173 Commits

Author SHA1 Message Date
David Dai a189a10a90 dev_freq: devfreq_spdm: add null terminator to prevent OOB access
Add null terminator to end of buffered copied from user to prevent
over reading.

Change-Id: I80cfcb087ea2c335fd65d8fcdaf372c7d34a533d
Signed-off-by: David Dai <daidavid1@codeaurora.org>
2019-07-27 21:50:47 +02:00
Danny Baumann 98049851b6 devfreq_devbw: Assign labels to devbw nodes.
Helps in using them from user space later.

Change-Id: Ic4c33e882d6535eded77a2a7c79c223ec3255924
2017-04-18 12:24:57 +02:00
LuK1337 fc9499e55a Import latest Samsung release
* Package version: T713XXU2BQCO

Change-Id: I293d9e7f2df458c512d59b7a06f8ca6add610c99
2017-04-18 03:43:52 +02:00
Dilip Kota 7c3426bea1 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>
2016-01-20 01:34:18 -08:00
Linux Build Service Account c6a4cfb8bb Merge "PM / devfreq: msmcci-hwmon: Add support for handling shared irq" 2015-08-18 07:42:32 -07:00
Linux Build Service Account 13f31213b5 Merge "PM / devfreq: bimc-bwmon: Fix counter clearing" 2015-08-16 16:19:44 -07:00
Hanumath Prasad 556900590c PM / devfreq: msmcci-hwmon: Add support for handling shared irq
Some targets have a single irq line which is shared among all
the cci hwmon counters. Enhance the driver to support shared interrupt
handling.

Change-Id: I5fdaecfaa14fa47e8f393fe51c538e5000e6ad5b
Signed-off-by: Arun KS <arunks@codeaurora.org>
Signed-off-by: Hanumath Prasad <hpprasad@codeaurora.org>
2015-08-13 12:38:12 +05:30
Saravana Kannan e3f781263e 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>
2015-08-12 23:52:11 -07:00
Hanumath Prasad 0c16de62bd 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>
2015-08-12 17:19:33 +05:30
Junjie Wu d2dd9e751b 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>
2015-08-03 15:47:30 +05:30
Arun KS 1af3fa893f PM / devfreq: msmcci-hwmon: Add provision for normal reg access
On some systems, scm calls for cci registers are not supported.
Use normal writel/readl in those cases. Add device tree flag to
distinguish them.

Change-Id: Icfb609d43f888856786c1881b2ee34ffd501e37a
Signed-off-by: Arun KS <arunks@codeaurora.org>
2015-08-03 15:46:21 +05:30
Junjie Wu a38a32aa42 PM / devfreq: Introduce MSM CCI HWmon device
CCI400 on MSM has additional PMU counters that can be used to monitor
cache requests. MSM CCI hardware monitor device configures these
registers to monitor cache and inform governor. It can also set an
IRQ when count exceeds a programmable limit.

Change-Id: I1d80f57749b91c3972e60e54c75226c4d49d2ec6
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2015-07-30 04:32:33 -07:00
Sunil Khatri 8334ba38f2 msm: kgsl: Update bandwidth vote using the right API
When a gpubw-dev node is not populated in a dtsi, pwrctrl_init
registers the bus votes through the msm_bus_scale_register_client.
Make sure we don't call the vbif governor APIs in such a case to
update the  bandwidth.

Change-Id: I2125c4093c259737c73db652b38cb5e30206d222
Signed-off-by: Suman Tatiraju <sumant@codeaurora.org>
Signed-off-by: Sunil Khatri <sunilkh@codeaurora.org>
2015-06-25 19:18:34 +05:30
Linux Build Service Account 15bef93a9e Merge "PM / devfreq: bimc-bwmon: set a floor_mbps for irq threshold" 2015-05-30 12:32:40 -07:00
Hanumath Prasad b93ecb428d 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>
2015-05-28 16:33:56 +05:30
Linux Build Service Account b9beca8d02 Merge "devfreq: devfreq_spdm: Scale parameters to and from TZ driver" 2015-05-27 00:29:19 -07:00
Dan Sneddon 271a080090 devfreq: spdm: Fix call to TZ spdm driver
The TZ SPDM driver mandates the number of arguments be constant for a
given command id.  This patch allows the spdm driver to communicate with
the TZ driver correctly.

Change-Id: Id3cfd2490039c4abde6d5381859d8facf545e85e
Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org>
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
2015-05-23 04:58:27 -07:00
Dilip Kota d4c3883ced devfreq: devfreq_spdm: Scale parameters to and from TZ driver
Send all the frequency performance levels in KHz units to TZ driver and
convert all the bandwidth recommendations to Bytes/s from Kbytes/s to
accomodate change in the syscall interface calls to TZ SPDM driver.

Change-Id: I209ea0583fdd43f78f51793d7818ea5afd5959c7
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
Signed-off-by: Girish Mahadevan <girishm@codeaurora.org>
2015-05-22 14:30:16 +05:30
Mihir Patel 72c4388425 msm: kgsl: Dynamic AB voting based on actual bus transactions
Right now AB vote is calulated as a percentage of total possible BW
which causes higher AB vote than actual GPU bus transactions in some
use cases. We can calculate actual GPU bus BW if we know bus_width
for the target. This change will derive AB vote based on bus_width
defined in dtsi and VBIF counters.

Define bus_width in number of bytes in target gpu dtsi file to use
this new AB vote calculation.

Change-Id: I75d19c18649d9a87d20e3dbf7b623b772265fb5b
Signed-off-by: Mihir Patel <mihirp@codeaurora.org>
2015-05-12 14:58:23 +05:30
Linux Build Service Account 32a5d0d3fc Merge "PM / devfreq: Fix devfreq_remove_device() to improve the sequence of resource free" 2015-04-20 14:23:01 -07:00
Linux Build Service Account 7078845a6e Merge "PM / devfreq: bimc-bwmon: Use free_irq during governor suspend/stop" 2015-04-15 08:37:39 -07:00
Junjie Wu f28723bccc PM / devfreq: governor_cpufreq: Rewrite locking to avoid deadlocks
A devfreq governor store in parallel with a cpu freq update can cause
deadlock as shown below.

Assume current devfreq governor is cpufreq, and user tries to change
to some other governor.

Write to sysfs store_governor   | cpufreq driver updating cpu freq
------------------------------- | -----------------------------------
echo bw_hwmon > governor        |
                                | takes rcu_read_lock and calls all
                                | cpufreq transition callbacks for
                                | PRECHANGE or POSTCHANGE
                                |
GOV_STOP on governor_cpufreq.   |
unregister_cpufreq() accquires  |
state_lock mutex.               |
                                | try to accquire same state_lock in
                                | cpufreq_trans_notifier(). Blocked.
unregister from cpufreq         |
transition notifier and wait for|
all rcu_readers to finish.      |
                            Deadlock

A similar deadlock can happen with governor change and policy notifier
callbacks.

The state_lock currently protects multiple unrelated critical
sections: registering/unregistering of cpufreq notifiers, read/writing
the device list, and tracking the cpu states and updating device
frequencies. There is no need for register/unregister of the cpufreq
notifiers to be mutually excluded against the other critical sections
using the same lock.

Split state_lock into two locks to protect the register/unregister of
cpufreq notifiers from the rest of the critical sections.

Change-Id: Id06d326748a5cb0c84c4787da5d0910f44eb5c3c
Signed-off-by: Pan Fang <fangpan@codeaurora.org>
Signed-off-by: Arun KS <arunks@codeaurora.org>
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
Suggested-by: Saravana Kannan <skannan@codeaurora.org>
2015-04-14 18:35:16 -07:00
Arun KS 2f21b2ef0d 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>
2015-04-15 02:24:49 +05:30
Chanwoo Choi 7f3db4ca43 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>
2015-04-09 11:48:29 -07:00
Linux Build Service Account 9a54c39ff8 Merge "devfreq: devfreq_spdm: Enhance debugfs entries" 2015-03-18 00:24:10 -07:00
Dan Sneddon f6da3c9f48 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-03-16 09:20:37 -06:00
Linux Build Service Account bceb912247 Merge "msm: kgsl: Power Optimizer Push-Pop" 2015-03-14 00:59:23 -07:00
Lucille Sylvester 2ed46fc9f3 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-09 12:05:57 -07:00
Alok Chauhan b7e6f11930 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 14:26:00 -08:00
Dan Sneddon 76c37cd7e9 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-24 11:33:40 -07: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
Lucille Sylvester 86ff3d538c msm: kgsl: Bump the GPU frequency for long blocks of processing
If there are several frames of full GPU utilization immediately
bump the frequency to turbo rather than waiting for the DCVS
algorithm to run.

Change-Id: I1215225f8903a8656e8ad92c6c82567b86665933
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
2014-12-02 16:56:09 -07:00
Lucille Sylvester dd2286bf25 msm: kgsl: Add a dynamic AB bandwidth vote
The vbif_bw governor should vote for AB tracking a
bus usage counter.  Vote for the previous bus usage
in the next itteration.

Change-Id: I613187646a261aed733ea5f1c0e413deac3a437c
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
2014-12-01 10:52:10 -07:00
Lucille Sylvester 4fa91be7e4 msm: kgsl: Add a path for dynamic AB bus votes
Modify the power control code and vbif_bw governor
to allow dynamic AB votes to be set with each GPU
IB vote.  As a placeholder set a static AB vote of
one fourth the IB vote.

Change-Id: I3edb430f9a4545f008ec81b75ddff3c717e91e39
Signed-off-by: Lucille Sylvester <lsylvest@codeaurora.org>
2014-12-01 10:46:39 -07:00
Junjie Wu d3c2789b2a PM / devfreq: cache_hwmon: Also print low mrps for debugging
Print out all three levels of requests for debugging.

Change-Id: I1e0d12c46386c1aed6b0bfe878449d070fd1adcc
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2014-11-22 14:29:27 -08:00
Junjie Wu b3f022f89f PM / devfreq: cache_hwmon: Use array for reporting monitor stats
Using an array to report monitor stats instead of hard coded variable
names would allow for cleaner implementations of some cache hwmon
device drivers.

Change-Id: I787bdc12f10a0c8ff3c4195ce229a2987acdfce7
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2014-11-22 14:29:27 -08:00
Junjie Wu fbe31fda38 PM / devfreq: cache_hwmon: Move IRQ handling to device drivers
The cache monitoring devices might have more than one IRQ to handle
or might have notifications from other drivers instead of using actual
IRQs. So, refactor the governor to move the IRQ handling to the cache
monitoring device specific drivers and just provide an API that can be
used to request a re-evaluation.

The device specific driver can call this API to request an immediate
re-evaluation whenever the cache request has exceeded the previously
set limit instead of waiting for the periodic update.

Change-Id: Ib2e9f53f95749d659f440739a1b074b5a0d94fd8
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2014-11-22 14:29:26 -08:00
Junjie Wu e770e6b214 PM / devfreq: Refactor Cache HWmon governor to be more generic
The refactor allows the governor to support multiple devfreq devices.
This is done by having different HW monitor instances register their
capability to monitor different devfreq devices and then picking the
right HW monitor based on which devfreq device is using this governor.

Change-Id: I72c0542ce97f3965e422df521e0ce86cad218d93
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
2014-11-22 14:29:26 -08:00
Vikram Mulukutla b55a0de88e PM / devfreq: Workaround cpufreq REMOVE_POLICY versus hotplug lock race
It is not possible to ensure the synchronization of REMOVE_POLICY
notifications with CPU hotplug lock; {get,put}_online_cpus ensures
that hotplug cannot happen, but it is still possible to receive
REMOVE_POLICY notifications asynchronously while checking for online
CPUs within a {get,put}_online_cpus critical section.

Account for this by detecting that we haven't yet setup a local state
when the REMOVE_POLICY notification comes in.

Change-Id: I3cb750f3984ebe078154734444660675e8d8b5bc
Signed-off-by: Vikram Mulukutla <markivx@codeaurora.org>
2014-11-06 11:17:20 -08:00