Commit graph

875,567 commits

Author SHA1 Message Date
Rama Aparna Mallavarapu
db4f4a0933 PM/devfreq: Do not switch governors from sysfs when device is suspended
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. Utilize suspend_count 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>
[avajid@codeaurora.org: updated to utilize suspend_count from upstream, resolved minor merge conflicts and updated commit text]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:32 -08:00
Rama Aparna Mallavarapu
96784c4520 PM / devfreq: Fix race condition between suspend/resume and governor_store
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.

Change-Id: Ifa0e93915a920cec3e0429966328a1128d61098b
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
[avajid@codeaurora.org: updated to merge better with upstream changes and removed renaming since done in previous commit]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:31 -08:00
Jonathan Avila
9693b4d620 PM / devfreq: Introduce an event lock
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>
[avajid@codeaurora.org: renamed to event lock and only used when CONFIG_QCOM_DEVFREQ_ICC is enabled]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:30 -08:00
Jonathan Avila
52ab3535b2 Revert "PM / devfreq: Modify the device name as devfreq(X) for sysfs"
This reverts commit 4585fbcb53. The change
to be reverted would add probe order-dependent numbers to the end of each
devfreq device, making our post boot script (among others) incredibly
brittle.

Change-Id: I8fdb679ae651d9f425ffd60e2141613ae20bb029
Signed-off-by: Jonathan Avila <avilaj@codeaurora.org>
[avajid@codeaurora.org: resolved trival merge conflicts]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:30 -08:00
Amir Vajid
1bb4b043b3 PM / devfreq: qoslat: Update voting level definitions
Having OPP levels of 0 and 1 causes a minor error in OPP
debugfs since an OPP level of 0 causes the OPP index to be
used instead (1 in this case) which later clashes with an
actual OPP of 1. Update the qoslat OPP levels to avoid this.

Change-Id: I23c0e736c9f1bfe77a99af44ced180d488a52eeb
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:29 -08:00
Rama Aparna Mallavarapu
6b1a168b7e devfreq: Allow bw_hwmon resume with zero resume freq
Currently bw_hwmon governor does not allow the device
to be resume 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>
[avajid@codeaurora.org: removed suspended check in devfreq framework]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:28 -08:00
Rama Aparna Mallavarapu
6f5e9162ed devfreq: bwmon: Increase the IOPercentage limits to 400
The IO percentage limits the values to 100, increase it
since some devices might need a higher value.

Change-Id: I7f19017b426832d9a1a11bd02195a4d15634c041
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
[avajid@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:28 -08:00
Rama Aparna Mallavarapu
b6d80a179b qcom-llcc-pmu: Update the LLCC PMU configurations for kona
Kona has new LLCC PMU version. This brought in changes in the
monitor enable, disable and configuration registers and hence
made code changes accordingly to read cache misses for multiple
CPUs.

Change-Id: I4d25487966a31f12143e2f99264a25d8c38f0188
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
[avajid@codeaurora.org: updated version enum, fixed disable/clear masks and made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:27 -08:00
Jonathan Avila
e43263bdea perf: Introduce a LLCC PMU
Some chips have hardware that can count misses for LLCC at a per-CPU level.
This PMU serves as an intermediary that allows us to retrieve these values
for use in other drivers.

Change-Id: I1dc3090a64ec7d5b12a36b0395c42930128287fe
Signed-off-by: Jonathan Avila <avilaj@codeaurora.org>
[avajid@codeaurora.org: removed BEAC registers, unused variables and made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:26 -08:00
Amir Vajid
71876da229 PM / devfreq: Add support for memory latency QoS voting
Add a devfreq device that has the ability to vote for a
QoS level to ensure better memory latency.

Change-Id: I33094b45ec250a58f244ecb1b7b8476df8791425
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:26 -08:00
Amir Vajid
3c55215ea5 PM / devfreq: memlat: optimize freq and stall_pct calculations
Currently, we calculate freq and stall_pct multiple times for
the same shared PMU counters. Calculate these once per cpu_grp
to prevent repeating the same calculation multiple times later.

Change-Id: I3b594e01ca50a583f45174e69a24f0b0eca32dde
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:25 -08:00
Jonathan Avila
74b58a68aa PM / devfreq: memlat: Aggregate memlat mons under a controller
Currently, each individual arm-memlat-mon instance separately reads from
a few shared PMUs, which leads to unnecessary IPI overhead. Tweak the
arm-memlat-mon design to allow multiple monitors to share certain event
counts, lowering overhead.

Change-Id: Ic3358afd1853efd84a4c3d5f3d66c3a86df6e5e7
Signed-off-by: Jonathan Avila <avilaj@codeaurora.org>
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
[avajid@codeaurora.org: squashed minor fixes and made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:51:17 -08:00
Rama Aparna Mallavarapu
c727848bb4 devfreq: detect ddr type and add frequency table accordingly
Some targets support different DDR types. Detect the DDR type
and populate the frequency table accordingly. OPP framework
supports opp-supported-hw bit map which allows the selected
frequencies to be added to the opp table based on the hardware
version check. Implement the same in the bandwidth monitor device
so that the right frequencies would be added to the opp table.
This patch also adds checks for the latency based device to detect
the DDR type at runtime and add the corresponding frequency map.

Change-Id: Ice5a0b14da67b3f2f07e98bc7349220da7d4efdb
Signed-off-by: Santosh Mardi <gsantosh@codeaurora.org>
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
[avajid@codeaurora.org: resolved minor conflicts and made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:50:43 -08:00
Santosh Mardi
b04e29f991 PM / devfreq: bw_hwmon: use unsigned parameter for bytes_to_mbps
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>
2019-12-06 08:50:42 -08:00
Rama Aparna Mallavarapu
4b5e726869 devfreq: bimc_bwmon: Add support to enable BWMON clks
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>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:50:42 -08:00
Santosh Mardi
5310a38087 devfreq: return error code when governor start fails
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>
[avajid@codeaurora.org: minor change to check ret < 0]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:50:41 -08:00
Rama Aparna Mallavarapu
2526ddbdbe devfreq: bw_mon: check for the return value of start_monitor
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>
[avajid@codeaurora.org: minor change to check ret < 0]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:50:40 -08:00
Rama Aparna Mallavarapu
9170b2bc7b devfreq: Do not round up bandwidth on BWMON4 devices
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>
2019-12-06 08:50:40 -08:00
Rama Aparna Mallavarapu
3f6460328d PM / devfreq: bw_hwmon: Fix a race condition in hwmon stop
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>
[avajid@codeaurora.org: made minor styling change]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:50:39 -08:00
Santosh Mardi
c5899ccfd3 devfreq: suppress platform driver bind / unbind feature
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>
[avajid@codeaurora.org: resolved minor merge conflict]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:50:38 -08:00
Santosh Mardi
5f7ae5c5e5 devfreq: suppress platform driver bind / unbind feature
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>
2019-12-06 08:50:38 -08:00
Santosh Mardi
fd91ce15bd devfreq: update freq variable in compute_freq function
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>
2019-12-06 08:50:37 -08:00
Jonathan Avila
10e4379923 devfreq: memlat: Add suspend/resume for mem_latency
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>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:50:37 -08:00
Rohit Gupta
f53c359b50 PM / devfreq: icc: Switch to OPP APIs
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>
[avajid@codeaurora.org: renamed devbw to icc and resolved minor merge conflicts]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:50:36 -08:00
Rohit Gupta
532b26b84a PM / devfreq: bw_hwmon: Reset clear bits for some hardware versions
Certain versions of the hardware modules have monitor/interrupt clear
registers that are not self-clearing after being written to.
Explicitly clear those register bits after writing to them.

Change-Id: I0e6252be11d8503bcd4719480f503650e46a23ae
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
2019-12-06 08:50:35 -08:00
Jonathan Avila
1aace2908a PM / devfreq: memlat: Add support for compute-bound logic
Currently, an entirely separate governor is used to handle compute-bound
cases.  Roll this functionality into the existing memlat governor and
allow devices to choose which logic to target by specifying different
drivers in the 'compatible' field.

Change-Id: I8dc41bf0474309c3564dec8e6c813511b8a7fc02
Signed-off-by: Jonathan Avila <avilaj@codeaurora.org>
[avajid@codeaurora.org: renamed compatible and resolved trivial merge conflicts]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-06 08:49:52 -08:00
Saravana Kannan
93c29d1397 PM / devfreq: memlat: Look for min stall% in addition to ratio criteria
Some workloads doing memory access might appear memory latency bound even
though they might not actually be memory latency bound.

This error can happen when the core that's running the workload is very
parallelized or can do out of order executions, etc so not all memory
accesses would actually stall the core.

This can also happen when the the memory access monitoring capabilities
aren't ideal and end up counting more kinds of memory accesses than what
would be ideal. In this case, the IPM ratio can be lower than what it would
be if we had ideal monitoring capabilities.

To account for these errors, if the core has a stall cycle counting
capabilities, check for a minimum stall% before the workload is considered
memory latency bound. This would help reduce the inaccuracies, but is not a
replacement for IPM ratio scheme because the stall% method doesn't allow us
to detect which level of memory the workload is latency bound on, but the
IPM ratio does (based on which memory accesses we use for calculating the
ratio).

Change-Id: I4363d7848584e5562f6683b5ad6b0f99017ec71b
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
[avajid@codeaurora.org: resolved minor merge conflicts and made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:22:01 -08:00
Rohit Gupta
6b881f24a9 devfreq: simple-dev: Make the freq-table property optional
The call to devfreq_add_device() tries to initialize frequency tables
for simple-dev. This can be a more efficient way of setting up
frequency tables in case there are multiple tables for a single device
depending on hardware version.
Make 'freq-tbl-khz' property an optional one so that probe doesn't
fail in its absence and devfreq_add_device() also gets a chance to
set up the freq table for simple-dev.

Change-Id: I96b5c2d4aef2085512d94dc6792f5ba2711de64b
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:22:01 -08:00
Stephen Boyd
b89dc2a891 PM / devfreq: bw_hwmon: Add support for specifying count factor
Not all bandwidth monitors count in units of 1MB. Add a DT
property that indicates the number of bytes the monitor counts in
so we can properly scale the count we read from the hardware to
reflect the traffic. By default, we will assume 1MB units if the
property doesn't exist.

Change-Id: I1b581b2fffda04ba151df6e87221628368ff5b17
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:22:00 -08:00
Stephen Boyd
d6ee9c7aa6 PM / devfreq: bw_hwmon: Add support for configuring byte MID match
Add support to configure the byte MID match value from DT.

Change-Id: I5848aef98f15c6de9fe0fae0a1188a17810a5ef5
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:59 -08:00
Stephen Boyd
0dd9e33079 PM / devfreq: bw_hwmon: Add support for BWMON5 monitors
Add support for the fifth type of bandwidth monitor. This monitor
is similar to the other types of monitors, but the register
offset is slightly different, and it doesn't have a global
interrupt base.

Change-Id: Ib05602832b6d4712b783ebaaa5aae9e60c00e30b
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:59 -08:00
Stephen Boyd
77d4c0bb9c PM / devfreq: bw_hwmon: Split out sw and hw paths
Let's split out the sw and hw counter configuration code paths
indicated by has_hw_sampling() into inline functions for the two
different types of monitors. This allows us to add different
types of monitors in the future with minimal changes.

Change-Id: I5cf6a1fe4d84ee0958fe68601cb1e76836d10256
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
[avajid@codeaurora.org: minor change to check ret < 0]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:58 -08:00
Stephen Boyd
e1b5bffc44 PM / devfreq: bw_hwmon: Reflow some code
Fix up style in this driver probe routine to use newer mechanisms
like of_device_get_match_data() and to not use things like
addresses of functions to assign function pointers. This makes
the code more readable.

Change-Id: Ib07edc0051fe9319e9a40cda7ba79646ce59b7e4
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
[avajid@codeaurora.org: resolved trivial merge conflict]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:58 -08:00
Stephen Boyd
9ff1db3cc7 PM / devfreq: bw_hwmon: irq can be negative
platform_get_irq() can return a negative number, but we assign it
to an unsigned integer, which can never be negative. Change the
type to int here so that we can detect irq errors.

Change-Id: I997063abfe5c9966f99014a099619e6bfe7aafe7
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:57 -08:00
Rohit Gupta
f30d9fbf4c PM / devfreq: bimc-bwmon: Add support for version 4
The version 4 of the BIMC BWMON hardware now has provisions for
counting bytes transferred at a high sampling rate.

Modify the existing driver and governor algorithm to
take advantage of that.

Change-Id: I5080297aef7e310d5c1a19098c177ddecb729c25
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:56 -08:00
Saravana Kannan
7236ae6387 PM / devfreq: bw_hwmon: Add HW offload support to governor
Some HW monitors can do a better job of the sampling and the threshold
checking than the SW implementation in the governor.  Update the governor's
API to add support for them.

Change-Id: Id4b5593a5ed3290684ba43ebebe2466ba0b730b6
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:56 -08:00
Rohit Gupta
a4e0d26f52 PM / devfreq: Introduce a memory-latency governor
Use performance counters to detect the memory latency sensitivity
of CPU workloads and vote for higher DDR frequency if required.

Change-Id: Ie77a3523bc5713fc0315bd0abc3913f485a96e0e
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
[avajid@codeaurora.org: updated attr definitions, removed exclude_idle flag and made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:55 -08:00
Rohit Gupta
4fe3e2f242 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>
[aparnam@codeaurora.org: Renamed throttle_adj functions]
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
[avajid@codeaurora.org: resolved minor merge conflicts made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:55 -08:00
Junjie Wu
f4c2ac968a 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>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:54 -08:00
Saravana Kannan
5121f0a5c3 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>
[aparnam@codeaurora.org: Replaced snprintf with scnprintf]
Signed-off-by: Rama Aparna Mallavarapu <aparnam@codeaurora.org>
[avajid@codeaurora.org: updated attr definitions, made to_mbps_zone() static and made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:54 -08:00
Junjie Wu
a3b03ca553 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-12-05 21:21:53 -08:00
Hanumath Prasad
b0dfbcd1e9 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-12-05 21:21:52 -08:00
Junjie Wu
7123adfcc0 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>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:52 -08:00
Junjie Wu
939d572b12 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>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:51 -08:00
Junjie Wu
b29a2f00d3 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>
[avajid@codeaurora.org: resolved minor conflict and  made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:51 -08:00
Saravana Kannan
f482e49077 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>
[avajid@codeaurora.org: made minor styling changes]
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2019-12-05 21:21:50 -08:00
qctecmdr
609f038c7d Merge "uio: msm_sharedmem: Fix format specifier to print resource_size_t" 2019-12-05 19:35:43 -08:00
qctecmdr
d4d0ed4fbc Merge "msm: kgsl: Make secure memory depend on QCOM_SECURE_BUFFER" 2019-12-05 19:00:04 -08:00
qctecmdr
9753b2fda8 Merge "usb: dwc3-msm: Add soft dependency on phy drivers" 2019-12-05 19:00:03 -08:00
qctecmdr
666a2266c1 Merge "msm:ipa: changing err prints to dbg prints" 2019-12-05 19:00:03 -08:00