]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/gpu/drm/i915/intel_ringbuffer.h
drm/i915: Avoid accessing request->timeline outside of its lifetime
[karo-tx-linux.git] / drivers / gpu / drm / i915 / intel_ringbuffer.h
index 9d228bee3511ed8347c5fb6ee7c7bd940b4ac0b3..642b54692d0d9697b3c8c8117dc96f84ac18a957 100644 (file)
@@ -207,7 +207,7 @@ struct intel_engine_cs {
                struct task_struct __rcu *irq_seqno_bh; /* bh for interrupts */
                bool irq_posted;
 
-               spinlock_t lock; /* protects the lists of requests */
+               spinlock_t lock; /* protects the lists of requests; irqsafe */
                struct rb_root waiters; /* sorted by retirement, priority */
                struct rb_root signals; /* sorted by retirement */
                struct intel_wait *first_wait; /* oldest waiter by retirement */
@@ -314,8 +314,6 @@ struct intel_engine_cs {
         *  ie. transpose of f(x, y)
         */
        struct {
-               u32     sync_seqno[I915_NUM_ENGINES-1];
-
                union {
 #define GEN6_SEMAPHORE_LAST    VECS_HW
 #define GEN6_NUM_SEMAPHORES    (GEN6_SEMAPHORE_LAST + 1)
@@ -385,27 +383,6 @@ intel_engine_flag(const struct intel_engine_cs *engine)
        return 1 << engine->id;
 }
 
-static inline u32
-intel_engine_sync_index(struct intel_engine_cs *engine,
-                       struct intel_engine_cs *other)
-{
-       int idx;
-
-       /*
-        * rcs -> 0 = vcs, 1 = bcs, 2 = vecs, 3 = vcs2;
-        * vcs -> 0 = bcs, 1 = vecs, 2 = vcs2, 3 = rcs;
-        * bcs -> 0 = vecs, 1 = vcs2. 2 = rcs, 3 = vcs;
-        * vecs -> 0 = vcs2, 1 = rcs, 2 = vcs, 3 = bcs;
-        * vcs2 -> 0 = rcs, 1 = vcs, 2 = bcs, 3 = vecs;
-        */
-
-       idx = (other->id - engine->id) - 1;
-       if (idx < 0)
-               idx += I915_NUM_ENGINES;
-
-       return idx;
-}
-
 static inline void
 intel_flush_status_page(struct intel_engine_cs *engine, int reg)
 {
@@ -519,6 +496,18 @@ static inline u32 intel_engine_get_seqno(struct intel_engine_cs *engine)
        return intel_read_status_page(engine, I915_GEM_HWS_INDEX);
 }
 
+static inline u32 intel_engine_last_submit(struct intel_engine_cs *engine)
+{
+       /* We are only peeking at the tail of the submit queue (and not the
+        * queue itself) in order to gain a hint as to the current active
+        * state of the engine. Callers are not expected to be taking
+        * engine->timeline->lock, nor are they expected to be concerned
+        * wtih serialising this hint with anything, so document it as
+        * a hint and nothing more.
+        */
+       return READ_ONCE(engine->timeline->last_submitted_seqno);
+}
+
 int init_workarounds_ring(struct intel_engine_cs *engine);
 
 void intel_engine_get_instdone(struct intel_engine_cs *engine,
@@ -592,9 +581,4 @@ void intel_engine_fini_breadcrumbs(struct intel_engine_cs *engine);
 unsigned int intel_kick_waiters(struct drm_i915_private *i915);
 unsigned int intel_kick_signalers(struct drm_i915_private *i915);
 
-static inline bool intel_engine_is_active(struct intel_engine_cs *engine)
-{
-       return i915_gem_active_isset(&engine->timeline->last_request);
-}
-
 #endif /* _INTEL_RINGBUFFER_H_ */