diff options
Diffstat (limited to 'drivers/gpu/drm/i915/i915_request.h')
-rw-r--r-- | drivers/gpu/drm/i915/i915_request.h | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h index c0f084ca4f29..ade010fe6e26 100644 --- a/drivers/gpu/drm/i915/i915_request.h +++ b/drivers/gpu/drm/i915/i915_request.h | |||
@@ -130,6 +130,13 @@ struct i915_request { | |||
130 | struct i915_sched_node sched; | 130 | struct i915_sched_node sched; |
131 | struct i915_dependency dep; | 131 | struct i915_dependency dep; |
132 | 132 | ||
133 | /* | ||
134 | * A convenience pointer to the current breadcrumb value stored in | ||
135 | * the HW status page (or our timeline's local equivalent). The full | ||
136 | * path would be rq->hw_context->ring->timeline->hwsp_seqno. | ||
137 | */ | ||
138 | const u32 *hwsp_seqno; | ||
139 | |||
133 | /** | 140 | /** |
134 | * GEM sequence number associated with this request on the | 141 | * GEM sequence number associated with this request on the |
135 | * global execution timeline. It is zero when the request is not | 142 | * global execution timeline. It is zero when the request is not |
@@ -285,11 +292,6 @@ static inline bool i915_request_signaled(const struct i915_request *rq) | |||
285 | return test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &rq->fence.flags); | 292 | return test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &rq->fence.flags); |
286 | } | 293 | } |
287 | 294 | ||
288 | static inline bool intel_engine_has_started(struct intel_engine_cs *engine, | ||
289 | u32 seqno); | ||
290 | static inline bool intel_engine_has_completed(struct intel_engine_cs *engine, | ||
291 | u32 seqno); | ||
292 | |||
293 | /** | 295 | /** |
294 | * Returns true if seq1 is later than seq2. | 296 | * Returns true if seq1 is later than seq2. |
295 | */ | 297 | */ |
@@ -298,6 +300,35 @@ static inline bool i915_seqno_passed(u32 seq1, u32 seq2) | |||
298 | return (s32)(seq1 - seq2) >= 0; | 300 | return (s32)(seq1 - seq2) >= 0; |
299 | } | 301 | } |
300 | 302 | ||
303 | static inline u32 __hwsp_seqno(const struct i915_request *rq) | ||
304 | { | ||
305 | return READ_ONCE(*rq->hwsp_seqno); | ||
306 | } | ||
307 | |||
308 | /** | ||
309 | * hwsp_seqno - the current breadcrumb value in the HW status page | ||
310 | * @rq: the request, to chase the relevant HW status page | ||
311 | * | ||
312 | * The emphasis in naming here is that hwsp_seqno() is not a property of the | ||
313 | * request, but an indication of the current HW state (associated with this | ||
314 | * request). Its value will change as the GPU executes more requests. | ||
315 | * | ||
316 | * Returns the current breadcrumb value in the associated HW status page (or | ||
317 | * the local timeline's equivalent) for this request. The request itself | ||
318 | * has the associated breadcrumb value of rq->fence.seqno, when the HW | ||
319 | * status page has that breadcrumb or later, this request is complete. | ||
320 | */ | ||
321 | static inline u32 hwsp_seqno(const struct i915_request *rq) | ||
322 | { | ||
323 | u32 seqno; | ||
324 | |||
325 | rcu_read_lock(); /* the HWSP may be freed at runtime */ | ||
326 | seqno = __hwsp_seqno(rq); | ||
327 | rcu_read_unlock(); | ||
328 | |||
329 | return seqno; | ||
330 | } | ||
331 | |||
301 | /** | 332 | /** |
302 | * i915_request_started - check if the request has begun being executed | 333 | * i915_request_started - check if the request has begun being executed |
303 | * @rq: the request | 334 | * @rq: the request |
@@ -315,14 +346,14 @@ static inline bool i915_request_started(const struct i915_request *rq) | |||
315 | if (!seqno) /* not yet submitted to HW */ | 346 | if (!seqno) /* not yet submitted to HW */ |
316 | return false; | 347 | return false; |
317 | 348 | ||
318 | return intel_engine_has_started(rq->engine, seqno); | 349 | return i915_seqno_passed(hwsp_seqno(rq), seqno - 1); |
319 | } | 350 | } |
320 | 351 | ||
321 | static inline bool | 352 | static inline bool |
322 | __i915_request_completed(const struct i915_request *rq, u32 seqno) | 353 | __i915_request_completed(const struct i915_request *rq, u32 seqno) |
323 | { | 354 | { |
324 | GEM_BUG_ON(!seqno); | 355 | GEM_BUG_ON(!seqno); |
325 | return intel_engine_has_completed(rq->engine, seqno) && | 356 | return i915_seqno_passed(hwsp_seqno(rq), seqno) && |
326 | seqno == i915_request_global_seqno(rq); | 357 | seqno == i915_request_global_seqno(rq); |
327 | } | 358 | } |
328 | 359 | ||