Commit Graph

13 Commits

Author SHA1 Message Date
Saravana Kannan 30fedcc25a PM / devfreq: bw_hwmon: Fix race condition in polling interval update
When the polling interval is updated, the delayed workqueue is cancelled
and requeued with the new polling interval. However, the bw_hwmon IRQ can
come at the same time and try to stop and restart the delayed work (in the
IRQ thread). This can cause a race where the work might be queued twice or
canceled twice and cause a crash.

Fix this race condition by suspending and resuming the HW monitor when we
are updating the polling interval. This entirely avoids the race because
suspending the HW monitor also avoid the possibility of the IRQ coming
during the polling interval update.

CRs-Fixed: 954082
Change-Id: Ic7baf2a3da4ed8f8a9023617059e22fd81c3ba45
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:01:10 +02:00
Rohit Gupta 8a7061e34f 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>
2019-08-26 17:01:09 +02:00
Saravana Kannan 3318708f4d PM / devfreq: bw_hwmon: Fix handling of max_mbps
When doing over-voting due to an UP_WAKE event, the governor
pre-initialized the max_mbps value for the next decision window. This was
done to prevent a dropping the vote below the original measurement in case
a DOWN_WAKE event comes before the decision window is complete. This has
the undesirable side-effect of keeping the votes high for two decision
windows following an UP_WAKE event.

Also, DOWN_WAKE event is currently disabled for any decision windows that
didn't do over-voting because doing so had significant performance impacts.

However, with historic max tracking, pattern detection and hysteresis, and
mbps zones awareness that were added later on, the above concerns aren't
really valid anymore.  So, simply delete the pre-initialization of the
max_mbps so that one decision window isn't unnecessarily voting higher than
necessary. As part of the change, also fix down_cnt logic to allow it to
work for all decision windows if enabled.

Change-Id: I600e3783da617ed4efef5b05156016d88c301cea
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:01:08 +02:00
Rohit Gupta be345e7a29 PM / devfreq: bw_hwmon: Allow up_scale to be set to zero
Currently the lower limit for setting up_scale is 100. Change it
to 0 so that over-voting for spikes in measured bandwidth can be
disabled by setting up_scale to 0.

Change-Id: I1e5e3d51c625163b38074fb1eda26763455ea6c5
Signed-off-by: Rohit Gupta <rohgup@codeaurora.org>
2019-08-26 17:01:07 +02:00
Saravana Kannan 0e3e7f775a PM / devfreq: bw_hwmon: Remove debug logs from high frequency code path
Using debug logs for the short samples would result in excessive logging
and also have an impact on CPU power and performance. The tracepoint that's
already there is a much better alternative. So, delete the debug logs.

Change-Id: Idd1d634f510381d14637f3b84588a118572f3f16
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:01:07 +02:00
Saravana Kannan 9e0026159a PM / devfreq: bw_hwmon: Take at least one sample per decision window
Due to the way the short samples are triggered, when the traffic is very
low, we could have a decision window where no sample is taken. Fix this by
forcing a sample at the end of every decision window as long as that is the
first sample for that decision window or the sample window won't be smaller
than the sample_ms tunable.

Change-Id: Ia33b59fbff9ff4058c06e24208d1e037d6e9eda9
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:00:46 +02:00
Saravana Kannan 4fe9afbe30 PM / devfreq: bw_hwmon: Remove unused tunables and disable some by default
With the rewrite of the algorithm, some tunables are not used. Remove those
tunables. Other tunables don't make a lot of sense to be turned on by
default. Change their default state to be disabled.

Change-Id: I228d275a21765986a7117b335a669deebf590f29
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2019-08-26 17:00:31 +02:00
Saravana Kannan 1a9a4d11a2 PM / devfreq: bw_hwmon: Fix AB vote less than measurement when freq at max
When the decision window is terminated early by an IRQ and the frequency
voted by the governor is the max_freq allowed for that device, the AB vote
can be lower than the measured value. This really shouldn't affect power or
performance since the device frequency is already maxed out, but fix it
anyway so that the logs don't look suspicious.

Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Change-Id: I1788cbb1af026f1c54f9acc4806cb29cd6069e04
2019-08-26 17:00:31 +02:00
Saravana Kannan dd70ab5d7b 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>
2019-08-26 17:00:30 +02:00
Saravana Kannan 4c80046aa6 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>
2014-09-12 10:13:58 -06:00
Saravana Kannan 1b09e63bfd PM / devfreq: governor_bw_hwmon: Find the correct hwmon for a devfreq dev
The governor pointer match is only present to support legacy BW HW monitors
(Krait) to maintain the legacy governor name. The newer BW HW monitor
devices do the matching using device pointer or of_node. So, the governor
pointer should not be checked if the BW HW monitor devices provide device
or of_node pointers.

Change-Id: Ic48f53e39a9b176b7dec415489bd1657d0df02e2
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2014-07-23 18:42:46 -06:00
Saravana Kannan d8b46e28bb PM / devfreq: bw_hwmon: Move IRQ handling to device specific drivers
The bandwidth 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 bandwidth
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 bandwidth has exceeded the previously set limit
instead of waiting for the periodic update.

Change-Id: I8bfd85d0cb59a1fd0116000aac430680e483b422
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2014-06-24 15:15:38 -07:00
Saravana Kannan b53827a80c PM / devfreq: Refactor CPUBW HWmon governor to be more generic
The refactored governor will be called bw_hwmon since it's no longer
limited to monitoring the CPU BW in hardware.

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.

The refactor also fixes a very unlikely race condition that can happen when
starting/stopping the governor.

Change-Id: Ifeeeb256115f6ae3075f391d9b4b02666e06f737
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
2014-06-17 20:15:39 -07:00