diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2019-02-05 08:00:05 -0500 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2019-02-05 12:20:11 -0500 |
commit | 21950ee7cc8f13c5350bda0cae22cdb7ac7e3058 (patch) | |
tree | 83c07ae5da83aa7ef95c5f8821b5ab8cf2b7dd08 /drivers/gpu/drm/i915/i915_request.c | |
parent | 5f5c139d6900b3338963bddcd8a567dcad33cf92 (diff) |
drm/i915: Pull i915_gem_active into the i915_active family
Looking forward, we need to break the struct_mutex dependency on
i915_gem_active. In the meantime, external use of i915_gem_active is
quite beguiling, little do new users suspect that it implies a barrier
as each request it tracks must be ordered wrt the previous one. As one
of many, it can be used to track activity across multiple timelines, a
shared fence, which fits our unordered request submission much better. We
need to steer external users away from the singular, exclusive fence
imposed by i915_gem_active to i915_active instead. As part of that
process, we move i915_gem_active out of i915_request.c into
i915_active.c to start separating the two concepts, and rename it to
i915_active_request (both to tie it to the concept of tracking just one
request, and to give it a longer, less appealing name).
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190205130005.2807-5-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_request.c')
-rw-r--r-- | drivers/gpu/drm/i915/i915_request.c | 35 |
1 files changed, 11 insertions, 24 deletions
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c index 6512630b59b8..c2a5c48c7541 100644 --- a/drivers/gpu/drm/i915/i915_request.c +++ b/drivers/gpu/drm/i915/i915_request.c | |||
@@ -29,6 +29,7 @@ | |||
29 | #include <linux/sched/signal.h> | 29 | #include <linux/sched/signal.h> |
30 | 30 | ||
31 | #include "i915_drv.h" | 31 | #include "i915_drv.h" |
32 | #include "i915_active.h" | ||
32 | #include "i915_reset.h" | 33 | #include "i915_reset.h" |
33 | 34 | ||
34 | static const char *i915_fence_get_driver_name(struct dma_fence *fence) | 35 | static const char *i915_fence_get_driver_name(struct dma_fence *fence) |
@@ -125,12 +126,6 @@ static void unreserve_gt(struct drm_i915_private *i915) | |||
125 | i915_gem_park(i915); | 126 | i915_gem_park(i915); |
126 | } | 127 | } |
127 | 128 | ||
128 | void i915_gem_retire_noop(struct i915_gem_active *active, | ||
129 | struct i915_request *request) | ||
130 | { | ||
131 | /* Space left intentionally blank */ | ||
132 | } | ||
133 | |||
134 | static void advance_ring(struct i915_request *request) | 129 | static void advance_ring(struct i915_request *request) |
135 | { | 130 | { |
136 | struct intel_ring *ring = request->ring; | 131 | struct intel_ring *ring = request->ring; |
@@ -244,7 +239,7 @@ static void __retire_engine_upto(struct intel_engine_cs *engine, | |||
244 | 239 | ||
245 | static void i915_request_retire(struct i915_request *request) | 240 | static void i915_request_retire(struct i915_request *request) |
246 | { | 241 | { |
247 | struct i915_gem_active *active, *next; | 242 | struct i915_active_request *active, *next; |
248 | 243 | ||
249 | GEM_TRACE("%s fence %llx:%lld, global=%d, current %d:%d\n", | 244 | GEM_TRACE("%s fence %llx:%lld, global=%d, current %d:%d\n", |
250 | request->engine->name, | 245 | request->engine->name, |
@@ -278,10 +273,10 @@ static void i915_request_retire(struct i915_request *request) | |||
278 | * we may spend an inordinate amount of time simply handling | 273 | * we may spend an inordinate amount of time simply handling |
279 | * the retirement of requests and processing their callbacks. | 274 | * the retirement of requests and processing their callbacks. |
280 | * Of which, this loop itself is particularly hot due to the | 275 | * Of which, this loop itself is particularly hot due to the |
281 | * cache misses when jumping around the list of i915_gem_active. | 276 | * cache misses when jumping around the list of |
282 | * So we try to keep this loop as streamlined as possible and | 277 | * i915_active_request. So we try to keep this loop as |
283 | * also prefetch the next i915_gem_active to try and hide | 278 | * streamlined as possible and also prefetch the next |
284 | * the likely cache miss. | 279 | * i915_active_request to try and hide the likely cache miss. |
285 | */ | 280 | */ |
286 | prefetchw(next); | 281 | prefetchw(next); |
287 | 282 | ||
@@ -526,17 +521,9 @@ out: | |||
526 | return kmem_cache_alloc(ce->gem_context->i915->requests, GFP_KERNEL); | 521 | return kmem_cache_alloc(ce->gem_context->i915->requests, GFP_KERNEL); |
527 | } | 522 | } |
528 | 523 | ||
529 | static int add_barrier(struct i915_request *rq, struct i915_gem_active *active) | ||
530 | { | ||
531 | struct i915_request *barrier = | ||
532 | i915_gem_active_raw(active, &rq->i915->drm.struct_mutex); | ||
533 | |||
534 | return barrier ? i915_request_await_dma_fence(rq, &barrier->fence) : 0; | ||
535 | } | ||
536 | |||
537 | static int add_timeline_barrier(struct i915_request *rq) | 524 | static int add_timeline_barrier(struct i915_request *rq) |
538 | { | 525 | { |
539 | return add_barrier(rq, &rq->timeline->barrier); | 526 | return i915_request_await_active_request(rq, &rq->timeline->barrier); |
540 | } | 527 | } |
541 | 528 | ||
542 | /** | 529 | /** |
@@ -595,7 +582,7 @@ i915_request_alloc(struct intel_engine_cs *engine, struct i915_gem_context *ctx) | |||
595 | * We use RCU to look up requests in flight. The lookups may | 582 | * We use RCU to look up requests in flight. The lookups may |
596 | * race with the request being allocated from the slab freelist. | 583 | * race with the request being allocated from the slab freelist. |
597 | * That is the request we are writing to here, may be in the process | 584 | * That is the request we are writing to here, may be in the process |
598 | * of being read by __i915_gem_active_get_rcu(). As such, | 585 | * of being read by __i915_active_request_get_rcu(). As such, |
599 | * we have to be very careful when overwriting the contents. During | 586 | * we have to be very careful when overwriting the contents. During |
600 | * the RCU lookup, we change chase the request->engine pointer, | 587 | * the RCU lookup, we change chase the request->engine pointer, |
601 | * read the request->global_seqno and increment the reference count. | 588 | * read the request->global_seqno and increment the reference count. |
@@ -937,8 +924,8 @@ void i915_request_add(struct i915_request *request) | |||
937 | * see a more recent value in the hws than we are tracking. | 924 | * see a more recent value in the hws than we are tracking. |
938 | */ | 925 | */ |
939 | 926 | ||
940 | prev = i915_gem_active_raw(&timeline->last_request, | 927 | prev = i915_active_request_raw(&timeline->last_request, |
941 | &request->i915->drm.struct_mutex); | 928 | &request->i915->drm.struct_mutex); |
942 | if (prev && !i915_request_completed(prev)) { | 929 | if (prev && !i915_request_completed(prev)) { |
943 | i915_sw_fence_await_sw_fence(&request->submit, &prev->submit, | 930 | i915_sw_fence_await_sw_fence(&request->submit, &prev->submit, |
944 | &request->submitq); | 931 | &request->submitq); |
@@ -954,7 +941,7 @@ void i915_request_add(struct i915_request *request) | |||
954 | spin_unlock_irq(&timeline->lock); | 941 | spin_unlock_irq(&timeline->lock); |
955 | 942 | ||
956 | GEM_BUG_ON(timeline->seqno != request->fence.seqno); | 943 | GEM_BUG_ON(timeline->seqno != request->fence.seqno); |
957 | i915_gem_active_set(&timeline->last_request, request); | 944 | __i915_active_request_set(&timeline->last_request, request); |
958 | 945 | ||
959 | list_add_tail(&request->ring_link, &ring->request_list); | 946 | list_add_tail(&request->ring_link, &ring->request_list); |
960 | if (list_is_first(&request->ring_link, &ring->request_list)) { | 947 | if (list_is_first(&request->ring_link, &ring->request_list)) { |