msm: cpubw-krait: Vote for Krait-DDR bandwidth by monitoring transactions.

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 uses that measured bandwidth to vote for Krait-DDR BW
requirements.

The driver provides various other 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 MHz. 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).

- enable: A boolean flag to control if the driver is enabled or disabled.
  Disabling the driver leave the bandwidth vote at the last voted value.

Change-Id: I021ae64c71451e272a13be2841bfda4d121d318d
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Amir Vajid <avajid@codeaurora.org>
2 files changed