Terminate the interrupts triggered before the intitalisation
itself.
Change-Id: I7c005134ecbdae38b58e4312f9e294f5b59c2510
Signed-off-by: Dilip Kota <dkota@codeaurora.org>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Print out all three levels of requests for debugging.
Change-Id: I1e0d12c46386c1aed6b0bfe878449d070fd1adcc
Signed-off-by: Junjie Wu <junjiew@codeaurora.org>
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>
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>
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>
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>
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>