5 Commits

Author SHA1 Message Date
Saravana Kannan
039d0f4e11 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>
Signed-off-by: David Keitel <dkeitel@codeaurora.org>
2018-01-04 17:40:46 -08:00
Rohit Gupta
e5e8aa6c73 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>
2018-01-04 17:40:39 -08:00
Saravana Kannan
9ccdea15bf 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>
[Update suspend/resume irq handling]
Signed-off-by: Hanumath Prasad <hpprasad@codeaurora.org>
[Fix parsing of mbps_zones]
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
[Fix event-based race condition]
Signed-off-by: Jonathan Avila <avilaj@codeaurora.org>
2018-01-04 17:40:37 -08:00
Saravana Kannan
3086106985 PM / devfreq: governor_bw_hwmon: Add suspend/resume support
Some devfreq devices using this governor might need suspend/resume support.
When suspended, those devices won't need any bandwidth votes and there is
no point in monitoring their bandwidth either.

Therefore, upon suspend, vote for zero bandwidth and stop the HW monitor.
Upon resume, vote for the previous bandwidth and start the HW monitor.

Change-Id: I318449995d714959f0ebfe91961bc23fa8edbd04
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2018-01-04 17:40:15 -08:00
Saravana Kannan
2096d8581e devfreq: Add CPUBW HW monitor governor
The CPUBW HW monitor devfreq governor uses the Krait L2 PM counters to
determine the bandwidth needed by the Krait CPU subsystem. This governor
can be used in conjunction with the CPUBW devfreq device to dynamically
scale the DDR frequency based on the demand/actual usage from the Krait CPU
subsystem. Since this governor uses the Krait L2 PM counters it can
conflict with certain profiling tools.

The Krait L2 performance monitor counters have the capability to count the
no. of read/write transactions going out the master ports. They also have
the capability to raise interrupts when they overflow. This driver uses
those counters to determine the true usage of DDR from the Krait processor
subsystem and then recommends CPU DDR BW votes based on the measured values
and the following tunable parameters.

The driver provides various tunables that allow it to be tuned more in
favor of power or performance:

- io_percent: The percentage of the CPU time that can be spent waiting on
  memory I/O. Lower value is better performance and worse power.

- sample_ms: The sampling period in milliseconds. This only affects the
  sampling period when DDR use is ramping down or is increasing very slowly
  (See tolerance_percent).

- tolerance_percent: The minimum increase in DDR use, compared to previous
  sample, that will trigger an IRQ to immediately bump up the bandwidth
  vote. It's expressed as a percentage of the previous sampled DDR use.

- decay_rate: The parameter controls the rate at which the history is
  forgotten when ramping down. This is expressed as a percentage of history
  to be forgotten.  So 100% means ignore history, 0% mean never forget the
  historical max. The default 90% means forget 90% of history each time.

- guard_band_mbps: This is a margin that's added to the measured BW (and
  hence also the Bus BW votes) that's present to account for the time it
  takes to ramp up the DDR BW while the CPU continues to use the DDR.

- bw_step: All BW votes are rounded up to multiples of bw_step. The default
  value is 200 MB/s that turns out to ~25 or 12.5 MHz based on the SoC. A
  smaller value would mean more frequent bus BW changes. A higher value
  would mean less frequent BW vote updates, but also means at times an
  unnecessarily higher BW vote (due to the rounding up).

Change-Id: I88629a3e545cdca7160af8f8ca616ecc949d9947
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2018-01-04 17:36:33 -08:00