drm/i915/pmu: Fix building without CONFIG_PM
authorChris Wilson <chris@chris-wilson.co.uk>
Tue, 13 Feb 2018 09:57:47 +0000 (09:57 +0000)
committerRodrigo Vivi <rodrigo.vivi@intel.com>
Wed, 14 Feb 2018 00:56:06 +0000 (16:56 -0800)
As we peek inside struct device to query members guarded by CONFIG_PM,
so must be the code.

Reported-by: kbuild test robot <fengguang.wu@intel.com>
Fixes: 1fe699e30113 ("drm/i915/pmu: Fix sleep under atomic in RC6 readout")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180207160428.17015-1-chris@chris-wilson.co.uk
(cherry picked from commit 05273c950a3c93c5f96be8807eaf24f2cc9f1c1e)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180213095747.2424-4-tvrtko.ursulin@linux.intel.com
drivers/gpu/drm/i915/i915_pmu.c

index e13859aaa2a3120b30f7a5331353fccdd0fbee47..0e9b98c32b62b0225633a24d3fa41396f9ab70d8 100644 (file)
@@ -409,22 +409,32 @@ static int i915_pmu_event_init(struct perf_event *event)
        return 0;
 }
 
-static u64 get_rc6(struct drm_i915_private *i915, bool locked)
+static u64 __get_rc6(struct drm_i915_private *i915)
 {
-       unsigned long flags;
        u64 val;
 
-       if (intel_runtime_pm_get_if_in_use(i915)) {
-               val = intel_rc6_residency_ns(i915, IS_VALLEYVIEW(i915) ?
-                                                  VLV_GT_RENDER_RC6 :
-                                                  GEN6_GT_GFX_RC6);
+       val = intel_rc6_residency_ns(i915,
+                                    IS_VALLEYVIEW(i915) ?
+                                    VLV_GT_RENDER_RC6 :
+                                    GEN6_GT_GFX_RC6);
 
-               if (HAS_RC6p(i915))
-                       val += intel_rc6_residency_ns(i915, GEN6_GT_GFX_RC6p);
+       if (HAS_RC6p(i915))
+               val += intel_rc6_residency_ns(i915, GEN6_GT_GFX_RC6p);
+
+       if (HAS_RC6pp(i915))
+               val += intel_rc6_residency_ns(i915, GEN6_GT_GFX_RC6pp);
+
+       return val;
+}
 
-               if (HAS_RC6pp(i915))
-                       val += intel_rc6_residency_ns(i915, GEN6_GT_GFX_RC6pp);
+static u64 get_rc6(struct drm_i915_private *i915, bool locked)
+{
+#if IS_ENABLED(CONFIG_PM)
+       unsigned long flags;
+       u64 val;
 
+       if (intel_runtime_pm_get_if_in_use(i915)) {
+               val = __get_rc6(i915);
                intel_runtime_pm_put(i915);
 
                /*
@@ -481,6 +491,9 @@ static u64 get_rc6(struct drm_i915_private *i915, bool locked)
        }
 
        return val;
+#else
+       return __get_rc6(i915);
+#endif
 }
 
 static u64 __i915_pmu_event_read(struct perf_event *event, bool locked)