Merge drm-next into drm-intel-next-queued
[sfrench/cifs-2.6.git] / drivers / gpu / drm / i915 / intel_ringbuffer.h
index c5ff203e42d6a8627d3c6bb18c589a103311d0c3..bbacf4d0f4cb56a6a1c74cf57e22098b4ad49f6d 100644 (file)
@@ -3,10 +3,12 @@
 #define _INTEL_RINGBUFFER_H_
 
 #include <linux/hashtable.h>
+
 #include "i915_gem_batch_pool.h"
-#include "i915_gem_request.h"
 #include "i915_gem_timeline.h"
+
 #include "i915_pmu.h"
+#include "i915_request.h"
 #include "i915_selftest.h"
 
 struct drm_printer;
@@ -115,7 +117,7 @@ struct intel_engine_hangcheck {
        unsigned long action_timestamp;
        int deadlock;
        struct intel_instdone instdone;
-       struct drm_i915_gem_request *active_request;
+       struct i915_request *active_request;
        bool stalled;
 };
 
@@ -156,7 +158,7 @@ struct i915_ctx_workarounds {
        struct i915_vma *vma;
 };
 
-struct drm_i915_gem_request;
+struct i915_request;
 
 /*
  * Engine IDs definitions.
@@ -218,7 +220,7 @@ struct intel_engine_execlists {
                /**
                 * @request_count: combined request and submission count
                 */
-               struct drm_i915_gem_request *request_count;
+               struct i915_request *request_count;
 #define EXECLIST_COUNT_BITS 2
 #define port_request(p) ptr_mask_bits((p)->request_count, EXECLIST_COUNT_BITS)
 #define port_count(p) ptr_unmask_bits((p)->request_count, EXECLIST_COUNT_BITS)
@@ -255,6 +257,16 @@ struct intel_engine_execlists {
         */
        unsigned int port_mask;
 
+       /**
+        * @queue_priority: Highest pending priority.
+        *
+        * When we add requests into the queue, or adjust the priority of
+        * executing requests, we compute the maximum priority of those
+        * pending requests. We can then use this value to determine if
+        * we need to preempt the executing requests to service the queue.
+        */
+       int queue_priority;
+
        /**
         * @queue: queue of requests, in priority lists
         */
@@ -279,6 +291,11 @@ struct intel_engine_execlists {
         * @csb_use_mmio: access csb through mmio, instead of hwsp
         */
        bool csb_use_mmio;
+
+       /**
+        * @preempt_complete_status: expected CSB upon completing preemption
+        */
+       u32 preempt_complete_status;
 };
 
 #define INTEL_ENGINE_CS_MAX_NAME 8
@@ -334,7 +351,7 @@ struct intel_engine_cs {
                struct rb_root waiters; /* sorted by retirement, priority */
                struct rb_root signals; /* sorted by retirement */
                struct task_struct *signaler; /* used for fence signalling */
-               struct drm_i915_gem_request __rcu *first_signal;
+               struct i915_request __rcu *first_signal;
                struct timer_list fake_irq; /* used after a missed interrupt */
                struct timer_list hangcheck; /* detect missed interrupts */
 
@@ -366,20 +383,6 @@ struct intel_engine_cs {
                 */
 #define I915_ENGINE_SAMPLE_MAX (I915_SAMPLE_SEMA + 1)
                struct i915_pmu_sample sample[I915_ENGINE_SAMPLE_MAX];
-               /**
-                * @busy_stats: Has enablement of engine stats tracking been
-                *              requested.
-                */
-               bool busy_stats;
-               /**
-                * @disable_busy_stats: Work item for busy stats disabling.
-                *
-                * Same as with @enable_busy_stats action, with the difference
-                * that we delay it in case there are rapid enable-disable
-                * actions, which can happen during tool startup (like perf
-                * stat).
-                */
-               struct delayed_work disable_busy_stats;
        } pmu;
 
        /*
@@ -400,7 +403,7 @@ struct intel_engine_cs {
 
        int             (*init_hw)(struct intel_engine_cs *engine);
        void            (*reset_hw)(struct intel_engine_cs *engine,
-                                   struct drm_i915_gem_request *req);
+                                   struct i915_request *rq);
 
        void            (*park)(struct intel_engine_cs *engine);
        void            (*unpark)(struct intel_engine_cs *engine);
@@ -411,22 +414,20 @@ struct intel_engine_cs {
                                          struct i915_gem_context *ctx);
        void            (*context_unpin)(struct intel_engine_cs *engine,
                                         struct i915_gem_context *ctx);
-       int             (*request_alloc)(struct drm_i915_gem_request *req);
-       int             (*init_context)(struct drm_i915_gem_request *req);
+       int             (*request_alloc)(struct i915_request *rq);
+       int             (*init_context)(struct i915_request *rq);
 
-       int             (*emit_flush)(struct drm_i915_gem_request *request,
-                                     u32 mode);
+       int             (*emit_flush)(struct i915_request *request, u32 mode);
 #define EMIT_INVALIDATE        BIT(0)
 #define EMIT_FLUSH     BIT(1)
 #define EMIT_BARRIER   (EMIT_INVALIDATE | EMIT_FLUSH)
-       int             (*emit_bb_start)(struct drm_i915_gem_request *req,
+       int             (*emit_bb_start)(struct i915_request *rq,
                                         u64 offset, u32 length,
                                         unsigned int dispatch_flags);
 #define I915_DISPATCH_SECURE BIT(0)
 #define I915_DISPATCH_PINNED BIT(1)
 #define I915_DISPATCH_RS     BIT(2)
-       void            (*emit_breadcrumb)(struct drm_i915_gem_request *req,
-                                          u32 *cs);
+       void            (*emit_breadcrumb)(struct i915_request *rq, u32 *cs);
        int             emit_breadcrumb_sz;
 
        /* Pass the request to the hardware queue (e.g. directly into
@@ -435,7 +436,7 @@ struct intel_engine_cs {
         * This is called from an atomic context with irqs disabled; must
         * be irq safe.
         */
-       void            (*submit_request)(struct drm_i915_gem_request *req);
+       void            (*submit_request)(struct i915_request *rq);
 
        /* Call when the priority on a request has changed and it and its
         * dependencies may need rescheduling. Note the request itself may
@@ -443,8 +444,7 @@ struct intel_engine_cs {
         *
         * Called under the struct_mutex.
         */
-       void            (*schedule)(struct drm_i915_gem_request *request,
-                                   int priority);
+       void            (*schedule)(struct i915_request *request, int priority);
 
        /*
         * Cancel all requests on the hardware, or queued for execution.
@@ -512,9 +512,9 @@ struct intel_engine_cs {
                } mbox;
 
                /* AKA wait() */
-               int     (*sync_to)(struct drm_i915_gem_request *req,
-                                  struct drm_i915_gem_request *signal);
-               u32     *(*signal)(struct drm_i915_gem_request *req, u32 *cs);
+               int     (*sync_to)(struct i915_request *rq,
+                                  struct i915_request *signal);
+               u32     *(*signal)(struct i915_request *rq, u32 *cs);
        } semaphore;
 
        struct intel_engine_execlists execlists;
@@ -668,7 +668,7 @@ intel_engine_flag(const struct intel_engine_cs *engine)
 }
 
 static inline u32
-intel_read_status_page(struct intel_engine_cs *engine, int reg)
+intel_read_status_page(const struct intel_engine_cs *engine, int reg)
 {
        /* Ensure that the compiler doesn't optimize away the load. */
        return READ_ONCE(engine->status_page.page_addr[reg]);
@@ -735,14 +735,12 @@ void intel_engine_cleanup(struct intel_engine_cs *engine);
 
 void intel_legacy_submission_resume(struct drm_i915_private *dev_priv);
 
-int __must_check intel_ring_cacheline_align(struct drm_i915_gem_request *req);
+int __must_check intel_ring_cacheline_align(struct i915_request *rq);
 
 int intel_ring_wait_for_space(struct intel_ring *ring, unsigned int bytes);
-u32 __must_check *intel_ring_begin(struct drm_i915_gem_request *req,
-                                  unsigned int n);
+u32 __must_check *intel_ring_begin(struct i915_request *rq, unsigned int n);
 
-static inline void
-intel_ring_advance(struct drm_i915_gem_request *req, u32 *cs)
+static inline void intel_ring_advance(struct i915_request *rq, u32 *cs)
 {
        /* Dummy function.
         *
@@ -752,22 +750,20 @@ intel_ring_advance(struct drm_i915_gem_request *req, u32 *cs)
         * reserved for the command packet (i.e. the value passed to
         * intel_ring_begin()).
         */
-       GEM_BUG_ON((req->ring->vaddr + req->ring->emit) != cs);
+       GEM_BUG_ON((rq->ring->vaddr + rq->ring->emit) != cs);
 }
 
-static inline u32
-intel_ring_wrap(const struct intel_ring *ring, u32 pos)
+static inline u32 intel_ring_wrap(const struct intel_ring *ring, u32 pos)
 {
        return pos & (ring->size - 1);
 }
 
-static inline u32
-intel_ring_offset(const struct drm_i915_gem_request *req, void *addr)
+static inline u32 intel_ring_offset(const struct i915_request *rq, void *addr)
 {
        /* Don't write ring->size (equivalent to 0) as that hangs some GPUs. */
-       u32 offset = addr - req->ring->vaddr;
-       GEM_BUG_ON(offset > req->ring->size);
-       return intel_ring_wrap(req->ring, offset);
+       u32 offset = addr - rq->ring->vaddr;
+       GEM_BUG_ON(offset > rq->ring->size);
+       return intel_ring_wrap(rq->ring, offset);
 }
 
 static inline void
@@ -805,7 +801,7 @@ intel_ring_set_tail(struct intel_ring *ring, unsigned int tail)
 {
        /* Whilst writes to the tail are strictly order, there is no
         * serialisation between readers and the writers. The tail may be
-        * read by i915_gem_request_retire() just as it is being updated
+        * read by i915_request_retire() just as it is being updated
         * by execlists, as although the breadcrumb is complete, the context
         * switch hasn't been seen.
         */
@@ -826,8 +822,8 @@ int intel_init_bsd_ring_buffer(struct intel_engine_cs *engine);
 int intel_init_blt_ring_buffer(struct intel_engine_cs *engine);
 int intel_init_vebox_ring_buffer(struct intel_engine_cs *engine);
 
-u64 intel_engine_get_active_head(struct intel_engine_cs *engine);
-u64 intel_engine_get_last_batch_head(struct intel_engine_cs *engine);
+u64 intel_engine_get_active_head(const struct intel_engine_cs *engine);
+u64 intel_engine_get_last_batch_head(const struct intel_engine_cs *engine);
 
 static inline u32 intel_engine_get_seqno(struct intel_engine_cs *engine)
 {
@@ -847,7 +843,7 @@ static inline u32 intel_engine_last_submit(struct intel_engine_cs *engine)
 }
 
 int init_workarounds_ring(struct intel_engine_cs *engine);
-int intel_ring_workarounds_emit(struct drm_i915_gem_request *req);
+int intel_ring_workarounds_emit(struct i915_request *rq);
 
 void intel_engine_get_instdone(struct intel_engine_cs *engine,
                               struct intel_instdone *instdone);
@@ -875,7 +871,7 @@ static inline u32 intel_hws_preempt_done_address(struct intel_engine_cs *engine)
 int intel_engine_init_breadcrumbs(struct intel_engine_cs *engine);
 
 static inline void intel_wait_init(struct intel_wait *wait,
-                                  struct drm_i915_gem_request *rq)
+                                  struct i915_request *rq)
 {
        wait->tsk = current;
        wait->request = rq;
@@ -901,9 +897,9 @@ intel_wait_update_seqno(struct intel_wait *wait, u32 seqno)
 
 static inline bool
 intel_wait_update_request(struct intel_wait *wait,
-                         const struct drm_i915_gem_request *rq)
+                         const struct i915_request *rq)
 {
-       return intel_wait_update_seqno(wait, i915_gem_request_global_seqno(rq));
+       return intel_wait_update_seqno(wait, i915_request_global_seqno(rq));
 }
 
 static inline bool
@@ -914,9 +910,9 @@ intel_wait_check_seqno(const struct intel_wait *wait, u32 seqno)
 
 static inline bool
 intel_wait_check_request(const struct intel_wait *wait,
-                        const struct drm_i915_gem_request *rq)
+                        const struct i915_request *rq)
 {
-       return intel_wait_check_seqno(wait, i915_gem_request_global_seqno(rq));
+       return intel_wait_check_seqno(wait, i915_request_global_seqno(rq));
 }
 
 static inline bool intel_wait_complete(const struct intel_wait *wait)
@@ -928,9 +924,8 @@ bool intel_engine_add_wait(struct intel_engine_cs *engine,
                           struct intel_wait *wait);
 void intel_engine_remove_wait(struct intel_engine_cs *engine,
                              struct intel_wait *wait);
-void intel_engine_enable_signaling(struct drm_i915_gem_request *request,
-                                  bool wakeup);
-void intel_engine_cancel_signaling(struct drm_i915_gem_request *request);
+void intel_engine_enable_signaling(struct i915_request *request, bool wakeup);
+void intel_engine_cancel_signaling(struct i915_request *request);
 
 static inline bool intel_engine_has_waiter(const struct intel_engine_cs *engine)
 {