Commit graph

158 commits

Author SHA1 Message Date
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
Subhash Jadavani f88dd9deab PM / devfreq: fix scaling down logic for simple clock scaling
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>
2014-11-05 16:21:09 -08:00
Dan Sneddon 1fb6f163d9 devfreq: spdm: Fix bad pointer access
If the spdm governor fails to connect to the hypervisor correctly
the device it is supposed to be governing will be freed but still
stored in the local list.  This patch removes the device from the
list to prevent accessing an invalid pointer if the hypervisor returns
an error.

Change-Id: I536c198b5a25adbd3044ffd37d9951c197b1dfd9
Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org>
2014-10-30 08:48:41 -06:00
Linux Build Service Account 80fb509d6f Merge "devfreq: devfreq_spdm: Fix enable/disable calls" 2014-10-14 18:32:10 -07:00
Dan Sneddon 4ab21296c6 devfreq: devfreq_spdm: Fix enable/disable calls
The enable and disable calls in the spdm governor are missing
the hypervisor call.  This patch adds the hvc call.

Change-Id: Ic8f4feeb9bc0b7066b6620553725aa636c017c03
Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org>
2014-10-13 11:51:46 -06:00
Dan Sneddon bd2e98933c devfreq: devfreq spdm: Add debugfs support
Add debugfs support for the devfreq spdm driver.
The parameters used for determing the SPDM port
threshold value can be updated via debugfs and sent
to the hypervisor to support fine tuning SPDM
performance.

Change-Id: I6f85deacd7d463d90f512f5de18b7e2140c9f492
Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org>
2014-10-13 08:04:27 -06:00
Linux Build Service Account 2eb9a6a57d Merge "devfreq_devbw: Add support for voting for AB based on IB" 2014-10-12 08:39:43 -07:00
Taniya Das 4238222f12 devfreq_devbw: Add support for voting for AB based on IB
Some generic devfreq governors might not provide AB values since that's a
devbw device specific attribute. In such cases, we might want to make an
average bandwidth (AB) vote that's a percentage of the IB vote to make
sure device BW requirement are not grossly misrepresented. This patch adds
support for that.

Change-Id: I76fbb8d688742058980f0d7568f2e7140023917e
Signed-off-by: Taniya Das <tdas@codeaurora.org>
2014-10-12 05:04:14 +05:30
Linux Build Service Account 8604f18e7e Merge "devfreq: devfreq_spdm: Introduce devfreq_spdm driver." 2014-10-11 14:53:32 -07:00
Saravana Kannan a79b27a5af PM / devfreq: Add timeout feature for cpufreq governor
Some devfreq devices might need their frequency to be set only for a short
time after the CPU frequency changes.

For such devices, add a "timeout" tunable that determines for how many
milliseconds the governor sets the device frequency based on the CPU
frequency. After "timeout" milliseconds from the CPU frequency change, the
governor will set the device frequency back to its minimum value.

Change-Id: I17fc972c0b03fab781864ce735013710c2df4647
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2014-10-10 13:05:41 -07:00
Saravana Kannan c661a07e09 PM / devfreq: bimc-bwmon: Add support for version 2
The version 2 of the BIMC BWMON HW doesn't reset the counter to 0 when it
hits the threshold. It also has support for an overflow status register.

Change-Id: I9f18d2153a2e5e762ec9950f26e0e7601468a80a
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2014-10-10 11:33:27 -07:00
Dan Sneddon 56feb971e8 devfreq: devfreq_spdm: Introduce devfreq_spdm driver.
The devfreq_spdm driver implements support for bandwidth voting
based on input from the SPDM device on MSM SoC's.  The SPDM
governor registers for the SPDM interrupt and then calls
the hypervisor to determine the correct bandwidth to vote for.
The devfreq framework poll timer is used to perdiocially
ask the hypervisor for the new bandwidth to request from
the MSM bus scaling code.

Change-Id: I851457e40d49b5929f01c510249d3e6bb4ff2f1d
Signed-off-by: Dan Sneddon <dsneddon@codeaurora.org>
2014-10-09 12:25:35 -06:00
Kumar Gala 25addda607 msm: kgsl: fix build issue with devfreq_trace.h
When building the kernel in tree we get:

In file included from drivers/devfreq/devfreq_trace.h:43:0,
                 from drivers/devfreq/devfreq_trace.c:20:
include/trace/define_trace.h:79:43: fatal error: ./devfreq_trace.h:
No such file or directory
 #include TRACE_INCLUDE(TRACE_INCLUDE_FILE)

The recommend solution is to add the include path to CFLAGS for the file.

Change-Id: I0389abcdcec29b35fa4da997b4ee3fd71c8a6c04
Signed-off-by: Kumar Gala <galak@codeaurora.org>
2014-09-30 15:23:23 -07:00
Saravana Kannan 26656e2447 PM / devfreq: Improve debug logs
- Add more debug logs
- Change the format out the count logs to use hex instead of decimal to be
  consistent with the rest of the logs
- Fix the type of the count variable from signed to unsigned to do the
  above

Change-Id: I02a2968a3f10ce20ca00618e7aeeac9b9cd52bd3
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2014-09-24 13:01:19 -07:00
Saravana Kannan e83b06b08b PM / devfreq: Fix IRQ clearing in bimc-bwmon
The clearing of the BIMC BWMON IRQ needs clearing bits in two separate
registers. One is a global register and the other is a port specific
register.

The bit in the port specific register needs to be cleared first before
clearing the bit in the global register. Otherwise, the bit in the global
register gets set again before the port specific bit is cleared. Since
these register are in different address regions, we also need memory
barriers around writes to the global register.

Also, clear the counter value before clearing the interrupt status just to
be safe.

Change-Id: Iee8d2caf9bf7d639c65ed19c979036bd5e203bfd
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2014-09-22 16:18:41 -07:00
Saravana Kannan 67616a640e PM / devfreq: bimc-bwmon: Reduce margin for HW workaround
The HW workaround margin being too high reduces the effectiveness of the
interrupt. Try using a margin only when the measured bandwidth is too small
and risks the counter wrapping around multiple times before it's read.

Change-Id: Ic1e88ad360b2348dfb9ad314c42c1b0218010c1d
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2014-09-22 16:18:40 -07:00