drm/i915/pmu: Inspect runtime PM state more carefully while estimating RC6
authorTvrtko Ursulin <tvrtko.ursulin@intel.com>
Tue, 10 Apr 2018 11:27:04 +0000 (12:27 +0100)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Wed, 11 Apr 2018 09:01:00 +0000 (10:01 +0100)
commit2924bdee21edd6785a4df1b4d17fd3cb265fddd9
tree235435196e73ef7d97e847269e2d3517d3c8d2c0
parent2184b3d69b961b5beb2781acf200b5b93643e32a
drm/i915/pmu: Inspect runtime PM state more carefully while estimating RC6

While thinking about sporadic failures of perf_pmu/rc6-runtime-pm* tests
on some CI machines I have concluded that: a) the PMU readout of RC6 can
race against runtime PM transitions, and b) there are other reasons than
being runtime suspended which can cause intel_runtime_pm_get_if_in_use to
fail.

Therefore when estimating RC6 the code needs to assert we are indeed in
suspended state, and if not, the best we can do is return the last known
RC6 value.

Without this check we can calculate the estimated value based on un-
initialized or inappropriate internal state, which can result in over-
estimation, or in any case incorrect value being returned.

v2:
 * Re-arrange the code a bit to avoid second unlock and return branch.
   (Chris Wilson)

v3:
 * Insert some strategic blank lines and improve commit msg.
   (Chris Wilson)

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Fixes: 1fe699e30113 ("drm/i915/pmu: Fix sleep under atomic in RC6 readout")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105010
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Imre Deak <imre.deak@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Link: https://patchwork.freedesktop.org/patch/msgid/20180410112704.24462-1-tvrtko.ursulin@linux.intel.com
drivers/gpu/drm/i915/i915_pmu.c