]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm/i915: Add a wakeref getter for iff the wakeref is already active
authorChris Wilson <chris@chris-wilson.co.uk>
Wed, 26 Jun 2019 15:45:47 +0000 (16:45 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Wed, 26 Jun 2019 17:01:01 +0000 (18:01 +0100)
For use in the next patch, we want to acquire a wakeref without having
to wake the device up -- i.e. only acquire the engine wakeref if the
engine is already active.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190626154549.10066-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/gt/intel_engine_pm.h
drivers/gpu/drm/i915/intel_wakeref.h

index f3f5b031b4a1b127d72a6a97c115351f7264ede4..7d057cdcd919066439d95f8424a0e3a5189b2c24 100644 (file)
@@ -11,7 +11,6 @@
 #include "intel_wakeref.h"
 
 struct drm_i915_private;
-struct intel_engine_cs;
 
 void intel_engine_pm_get(struct intel_engine_cs *engine);
 void intel_engine_pm_put(struct intel_engine_cs *engine);
@@ -22,6 +21,12 @@ intel_engine_pm_is_awake(const struct intel_engine_cs *engine)
        return intel_wakeref_is_active(&engine->wakeref);
 }
 
+static inline bool
+intel_engine_pm_get_if_awake(struct intel_engine_cs *engine)
+{
+       return intel_wakeref_get_if_active(&engine->wakeref);
+}
+
 void intel_engine_park(struct intel_engine_cs *engine);
 
 void intel_engine_init__pm(struct intel_engine_cs *engine);
index f74272770a5c011704e5849a238f87bd82867393..1d6f5986e4e5a3522a2f4bdf5bf93a873620e9e6 100644 (file)
@@ -71,6 +71,21 @@ intel_wakeref_get(struct intel_runtime_pm *rpm,
        return 0;
 }
 
+/**
+ * intel_wakeref_get_if_in_use: Acquire the wakeref
+ * @wf: the wakeref
+ *
+ * Acquire a hold on the wakeref, but only if the wakeref is already
+ * active.
+ *
+ * Returns: true if the wakeref was acquired, false otherwise.
+ */
+static inline bool
+intel_wakeref_get_if_active(struct intel_wakeref *wf)
+{
+       return atomic_inc_not_zero(&wf->count);
+}
+
 /**
  * intel_wakeref_put: Release the wakeref
  * @i915: the drm_i915_private device