Skip to content

Commit 1b5a433

Browse files
johnharr-inteldanvet
authored andcommitted
drm/i915: Convert 'i915_seqno_passed' calls into 'i915_gem_request_completed'
Almost everywhere that caled i915_seqno_passed() was really asking 'has the given seqno popped out of the hardware yet?'. Thus it had to query the current hardware seqno and then do a signed delta comparison (which copes with wrapping around zero but not with seqno values more than 2GB apart, although the latter is unlikely!). Now that the majority of seqno instances have been replaced with request structures, it is possible to convert this test to be request based as well. There is now a 'i915_gem_request_completed()' function which takes a request and returns true or false as appropriate. Note that this currently just wraps up the original _passed() test but a later patch in the series will reduce this to simply returning a cached internal value, i.e.: _completed(req) { return req->completed; }' This checkin converts almost all _seqno_passed() calls. The only one left is in the semaphore code which still requires seqnos not request structures. For: VIZ-4377 Signed-off-by: John Harrison <John.C.Harrison@Intel.com> Reviewed-by: Thomas Daniel <Thomas.Daniel@intel.com> [danvet: Drop hunk touching the trace_irq code since I've dropped the patch which converts that, and resolve resulting conflict.] Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
1 parent ff79e85 commit 1b5a433

File tree

5 files changed

+29
-27
lines changed

5 files changed

+29
-27
lines changed

drivers/gpu/drm/i915/i915_debugfs.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -547,8 +547,7 @@ static int i915_gem_pageflip_info(struct seq_file *m, void *data)
547547
i915_gem_request_get_seqno(work->flip_queued_req),
548548
dev_priv->next_seqno,
549549
work->flip_queued_ring->get_seqno(work->flip_queued_ring, true),
550-
i915_seqno_passed(work->flip_queued_ring->get_seqno(work->flip_queued_ring, true),
551-
i915_gem_request_get_seqno(work->flip_queued_req)));
550+
i915_gem_request_completed(work->flip_queued_req, true));
552551
} else
553552
seq_printf(m, "Flip not associated with any ring\n");
554553
seq_printf(m, "Flip queued on frame %d, (was ready on frame %d), now %d\n",

drivers/gpu/drm/i915/i915_drv.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2062,6 +2062,12 @@ static inline void i915_gem_request_assign(struct drm_i915_gem_request **pdst,
20622062
*pdst = src;
20632063
}
20642064

2065+
/*
2066+
* XXX: i915_gem_request_completed should be here but currently needs the
2067+
* definition of i915_seqno_passed() which is below. It will be moved in
2068+
* a later patch when the call to i915_seqno_passed() is obsoleted...
2069+
*/
2070+
20652071
struct drm_i915_file_private {
20662072
struct drm_i915_private *dev_priv;
20672073
struct drm_file *file;
@@ -2563,6 +2569,18 @@ i915_seqno_passed(uint32_t seq1, uint32_t seq2)
25632569
return (int32_t)(seq1 - seq2) >= 0;
25642570
}
25652571

2572+
static inline bool i915_gem_request_completed(struct drm_i915_gem_request *req,
2573+
bool lazy_coherency)
2574+
{
2575+
u32 seqno;
2576+
2577+
BUG_ON(req == NULL);
2578+
2579+
seqno = req->ring->get_seqno(req->ring, lazy_coherency);
2580+
2581+
return i915_seqno_passed(seqno, req->seqno);
2582+
}
2583+
25662584
int __must_check i915_gem_get_seqno(struct drm_device *dev, u32 *seqno);
25672585
int __must_check i915_gem_set_seqno(struct drm_device *dev, u32 seqno);
25682586
int __must_check i915_gem_object_get_fence(struct drm_i915_gem_object *obj);

drivers/gpu/drm/i915/i915_gem.c

Lines changed: 8 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1223,8 +1223,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
12231223

12241224
WARN(!intel_irqs_enabled(dev_priv), "IRQs disabled");
12251225

1226-
if (i915_seqno_passed(ring->get_seqno(ring, true),
1227-
i915_gem_request_get_seqno(req)))
1226+
if (i915_gem_request_completed(req, true))
12281227
return 0;
12291228

12301229
timeout_expire = timeout ? jiffies + nsecs_to_jiffies((u64)*timeout) : 0;
@@ -1260,8 +1259,7 @@ int __i915_wait_request(struct drm_i915_gem_request *req,
12601259
break;
12611260
}
12621261

1263-
if (i915_seqno_passed(ring->get_seqno(ring, false),
1264-
i915_gem_request_get_seqno(req))) {
1262+
if (i915_gem_request_completed(req, false)) {
12651263
ret = 0;
12661264
break;
12671265
}
@@ -2333,8 +2331,7 @@ i915_gem_object_retire(struct drm_i915_gem_object *obj)
23332331
if (ring == NULL)
23342332
return;
23352333

2336-
if (i915_seqno_passed(ring->get_seqno(ring, true),
2337-
i915_gem_request_get_seqno(obj->last_read_req)))
2334+
if (i915_gem_request_completed(obj->last_read_req, true))
23382335
i915_gem_object_move_to_inactive(obj);
23392336
}
23402337

@@ -2601,12 +2598,9 @@ struct drm_i915_gem_request *
26012598
i915_gem_find_active_request(struct intel_engine_cs *ring)
26022599
{
26032600
struct drm_i915_gem_request *request;
2604-
u32 completed_seqno;
2605-
2606-
completed_seqno = ring->get_seqno(ring, false);
26072601

26082602
list_for_each_entry(request, &ring->request_list, list) {
2609-
if (i915_seqno_passed(completed_seqno, request->seqno))
2603+
if (i915_gem_request_completed(request, false))
26102604
continue;
26112605

26122606
return request;
@@ -2734,15 +2728,11 @@ void i915_gem_reset(struct drm_device *dev)
27342728
void
27352729
i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
27362730
{
2737-
uint32_t seqno;
2738-
27392731
if (list_empty(&ring->request_list))
27402732
return;
27412733

27422734
WARN_ON(i915_verify_lists(ring->dev));
27432735

2744-
seqno = ring->get_seqno(ring, true);
2745-
27462736
/* Move any buffers on the active list that are no longer referenced
27472737
* by the ringbuffer to the flushing/inactive lists as appropriate,
27482738
* before we free the context associated with the requests.
@@ -2754,8 +2744,7 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
27542744
struct drm_i915_gem_object,
27552745
ring_list);
27562746

2757-
if (!i915_seqno_passed(seqno,
2758-
i915_gem_request_get_seqno(obj->last_read_req)))
2747+
if (!i915_gem_request_completed(obj->last_read_req, true))
27592748
break;
27602749

27612750
i915_gem_object_move_to_inactive(obj);
@@ -2770,7 +2759,7 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
27702759
struct drm_i915_gem_request,
27712760
list);
27722761

2773-
if (!i915_seqno_passed(seqno, request->seqno))
2762+
if (!i915_gem_request_completed(request, true))
27742763
break;
27752764

27762765
trace_i915_gem_request_retire(request);
@@ -2797,7 +2786,8 @@ i915_gem_retire_requests_ring(struct intel_engine_cs *ring)
27972786
}
27982787

27992788
if (unlikely(ring->trace_irq_seqno &&
2800-
i915_seqno_passed(seqno, ring->trace_irq_seqno))) {
2789+
i915_seqno_passed(ring->get_seqno(ring, true),
2790+
ring->trace_irq_seqno))) {
28012791
ring->irq_put(ring);
28022792
ring->trace_irq_seqno = 0;
28032793
}

drivers/gpu/drm/i915/i915_irq.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,8 +2760,7 @@ static bool
27602760
ring_idle(struct intel_engine_cs *ring)
27612761
{
27622762
return (list_empty(&ring->request_list) ||
2763-
i915_seqno_passed(ring->get_seqno(ring, false),
2764-
i915_gem_request_get_seqno(ring_last_request(ring))));
2763+
i915_gem_request_completed(ring_last_request(ring), false));
27652764
}
27662765

27672766
static bool

drivers/gpu/drm/i915/intel_display.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9742,11 +9742,7 @@ static bool __intel_pageflip_stall_check(struct drm_device *dev,
97429742

97439743
if (work->flip_ready_vblank == 0) {
97449744
if (work->flip_queued_ring) {
9745-
uint32_t s1 = work->flip_queued_ring->get_seqno(
9746-
work->flip_queued_ring, true);
9747-
uint32_t s2 = i915_gem_request_get_seqno(
9748-
work->flip_queued_req);
9749-
if (!i915_seqno_passed(s1, s2))
9745+
if (!i915_gem_request_completed(work->flip_queued_req, true))
97509746
return false;
97519747
}
97529748

0 commit comments

Comments
 (0)