* [Intel-gfx] [PATCH 1/3] drm/i915/gem: Use chained reloc batches
@ 2020-05-01 10:18 Chris Wilson
2020-05-01 10:18 ` [Intel-gfx] [PATCH 2/3] drm/i915/gem: Use a single chained reloc batches for a single execbuf Chris Wilson
` (4 more replies)
0 siblings, 5 replies; 12+ messages in thread
From: Chris Wilson @ 2020-05-01 10:18 UTC (permalink / raw)
To: intel-gfx; +Cc: Chris Wilson
The ring is a precious resource: we anticipate to only use a few hundred
bytes for a request, and only try to reserve that before we start. If we
go beyond our guess in building the request, then instead of waiting at
the start of execbuf before we hold any locks or other resources, we
may trigger a wait inside a critical region. One example is in using gpu
relocations, where currently we emit a new MI_BB_START from the ring
every time we overflow a page of relocation entries. However, instead of
insert the command into the precious ring, we can chain the next page of
relocation entries as MI_BB_START from the end of the previous.
v2: Delay the emit_bb_start until after all the chained vma
synchronisation is complete. Since the buffer pool batches are idle, this
_should_ be a no-op, but one day we may some fancy async GPU bindings
for new vma!
Testcase: igt/gem_exec_reloc/basic-many-active
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
.../gpu/drm/i915/gem/i915_gem_execbuffer.c | 130 +++++++++++++++---
1 file changed, 111 insertions(+), 19 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index 414859fa2673..293bf06b65b2 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -271,6 +271,7 @@ struct i915_execbuffer {
struct i915_request *rq;
u32 *rq_cmd;
unsigned int rq_size;
+ struct i915_vma *rq_vma;
} reloc_cache;
u64 invalid_flags; /** Set of execobj.flags that are invalid */
@@ -975,20 +976,111 @@ static inline struct i915_ggtt *cache_to_ggtt(struct reloc_cache *cache)
return &i915->ggtt;
}
+static int reloc_gpu_chain(struct reloc_cache *cache)
+{
+ struct intel_gt_buffer_pool_node *pool;
+ struct i915_request *rq = cache->rq;
+ struct i915_vma *batch;
+ u32 *cmd;
+ int err;
+
+ pool = intel_gt_get_buffer_pool(rq->engine->gt, PAGE_SIZE);
+ if (IS_ERR(pool))
+ return PTR_ERR(pool);
+
+ batch = i915_vma_instance(pool->obj, rq->context->vm, NULL);
+ if (IS_ERR(batch)) {
+ err = PTR_ERR(batch);
+ goto out_pool;
+ }
+
+ err = i915_vma_pin(batch, 0, 0, PIN_USER | PIN_NONBLOCK);
+ if (err)
+ goto out_pool;
+
+ cmd = cache->rq_cmd + cache->rq_size;
+ *cmd++ = MI_ARB_CHECK;
+ if (cache->gen >= 8) {
+ *cmd++ = MI_BATCH_BUFFER_START_GEN8;
+ *cmd++ = lower_32_bits(batch->node.start);
+ *cmd++ = upper_32_bits(batch->node.start);
+ } else {
+ *cmd++ = MI_BATCH_BUFFER_START;
+ *cmd++ = lower_32_bits(batch->node.start);
+ }
+ i915_gem_object_flush_map(cache->rq_vma->obj);
+ i915_gem_object_unpin_map(cache->rq_vma->obj);
+ cache->rq_vma = NULL;
+
+ err = intel_gt_buffer_pool_mark_active(pool, rq);
+ if (err == 0) {
+ i915_vma_lock(batch);
+ err = i915_request_await_object(rq, batch->obj, false);
+ if (err == 0)
+ err = i915_vma_move_to_active(batch, rq, 0);
+ i915_vma_unlock(batch);
+ }
+ i915_vma_unpin(batch);
+ if (err)
+ goto out_pool;
+
+ cmd = i915_gem_object_pin_map(pool->obj,
+ cache->has_llc ?
+ I915_MAP_FORCE_WB :
+ I915_MAP_FORCE_WC);
+ if (IS_ERR(cmd)) {
+ err = PTR_ERR(cmd);
+ goto out_pool;
+ }
+
+ /* Return with batch mapping (cmd) still pinned */
+ cache->rq_cmd = cmd;
+ cache->rq_size = 0;
+ cache->rq_vma = batch;
+
+out_pool:
+ intel_gt_buffer_pool_put(pool);
+ return err;
+}
+
+static unsigned int reloc_bb_flags(const struct reloc_cache *cache)
+{
+ return cache->gen > 5 ? 0 : I915_DISPATCH_SECURE;
+}
+
static void reloc_gpu_flush(struct reloc_cache *cache)
{
- struct drm_i915_gem_object *obj = cache->rq->batch->obj;
+ struct i915_request *rq;
+ int err;
- GEM_BUG_ON(cache->rq_size >= obj->base.size / sizeof(u32));
- cache->rq_cmd[cache->rq_size] = MI_BATCH_BUFFER_END;
+ rq = fetch_and_zero(&cache->rq);
+ if (!rq)
+ return;
- __i915_gem_object_flush_map(obj, 0, sizeof(u32) * (cache->rq_size + 1));
- i915_gem_object_unpin_map(obj);
+ if (cache->rq_vma) {
+ struct drm_i915_gem_object *obj = cache->rq_vma->obj;
- intel_gt_chipset_flush(cache->rq->engine->gt);
+ GEM_BUG_ON(cache->rq_size >= obj->base.size / sizeof(u32));
+ cache->rq_cmd[cache->rq_size++] = MI_BATCH_BUFFER_END;
- i915_request_add(cache->rq);
- cache->rq = NULL;
+ __i915_gem_object_flush_map(obj,
+ 0, sizeof(u32) * cache->rq_size);
+ i915_gem_object_unpin_map(obj);
+ }
+
+ err = 0;
+ if (rq->engine->emit_init_breadcrumb)
+ err = rq->engine->emit_init_breadcrumb(rq);
+ if (!err)
+ err = rq->engine->emit_bb_start(rq,
+ rq->batch->node.start,
+ PAGE_SIZE,
+ reloc_bb_flags(cache));
+ if (err)
+ i915_request_set_error_once(rq, err);
+
+ intel_gt_chipset_flush(rq->engine->gt);
+ i915_request_add(rq);
}
static void reloc_cache_reset(struct reloc_cache *cache)
@@ -1237,12 +1329,6 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
if (err)
goto err_request;
- err = eb->engine->emit_bb_start(rq,
- batch->node.start, PAGE_SIZE,
- cache->gen > 5 ? 0 : I915_DISPATCH_SECURE);
- if (err)
- goto skip_request;
-
i915_vma_lock(batch);
err = i915_request_await_object(rq, batch->obj, false);
if (err == 0)
@@ -1257,6 +1343,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
cache->rq = rq;
cache->rq_cmd = cmd;
cache->rq_size = 0;
+ cache->rq_vma = batch;
/* Return with batch mapping (cmd) still pinned */
goto out_pool;
@@ -1280,13 +1367,9 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
{
struct reloc_cache *cache = &eb->reloc_cache;
u32 *cmd;
-
- if (cache->rq_size > PAGE_SIZE/sizeof(u32) - (len + 1))
- reloc_gpu_flush(cache);
+ int err;
if (unlikely(!cache->rq)) {
- int err;
-
if (!intel_engine_can_store_dword(eb->engine))
return ERR_PTR(-ENODEV);
@@ -1295,6 +1378,15 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
return ERR_PTR(err);
}
+ if (unlikely(cache->rq_size + len > PAGE_SIZE / sizeof(u32) - 4)) {
+ err = reloc_gpu_chain(cache);
+ if (unlikely(err)) {
+ i915_request_set_error_once(cache->rq, err);
+ return ERR_PTR(err);
+ }
+ }
+
+ GEM_BUG_ON(cache->rq_size + len >= PAGE_SIZE / sizeof(u32));
cmd = cache->rq_cmd + cache->rq_size;
cache->rq_size += len;
--
2.20.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 12+ messages in thread* [Intel-gfx] [PATCH 2/3] drm/i915/gem: Use a single chained reloc batches for a single execbuf
2020-05-01 10:18 [Intel-gfx] [PATCH 1/3] drm/i915/gem: Use chained reloc batches Chris Wilson
@ 2020-05-01 10:18 ` Chris Wilson
2020-05-01 12:46 ` Tvrtko Ursulin
2020-05-01 10:19 ` [Intel-gfx] [PATCH 3/3] drm/i915/gem: Try an alternate engine for relocations Chris Wilson
` (3 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Chris Wilson @ 2020-05-01 10:18 UTC (permalink / raw)
To: intel-gfx; +Cc: Chris Wilson
As we can now keep chaining together a relocation batch to process any
number of relocations, we can keep building that relocation batch for
all of the target vma. This avoiding emitting a new request into the
ring for each target, consuming precious ring space and a potential
stall.
Testcase: igt/gem_exec_reloc/basic-wide-active
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
.../gpu/drm/i915/gem/i915_gem_execbuffer.c | 23 +++++++++++--------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index 293bf06b65b2..b224a453e2a3 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -268,6 +268,7 @@ struct i915_execbuffer {
bool has_fence : 1;
bool needs_unfenced : 1;
+ struct i915_vma *target;
struct i915_request *rq;
u32 *rq_cmd;
unsigned int rq_size;
@@ -1087,9 +1088,6 @@ static void reloc_cache_reset(struct reloc_cache *cache)
{
void *vaddr;
- if (cache->rq)
- reloc_gpu_flush(cache);
-
if (!cache->vaddr)
return;
@@ -1282,7 +1280,6 @@ static int reloc_move_to_gpu(struct i915_request *rq, struct i915_vma *vma)
}
static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
- struct i915_vma *vma,
unsigned int len)
{
struct reloc_cache *cache = &eb->reloc_cache;
@@ -1305,7 +1302,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
goto out_pool;
}
- batch = i915_vma_instance(pool->obj, vma->vm, NULL);
+ batch = i915_vma_instance(pool->obj, eb->context->vm, NULL);
if (IS_ERR(batch)) {
err = PTR_ERR(batch);
goto err_unmap;
@@ -1325,10 +1322,6 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
if (err)
goto err_request;
- err = reloc_move_to_gpu(rq, vma);
- if (err)
- goto err_request;
-
i915_vma_lock(batch);
err = i915_request_await_object(rq, batch->obj, false);
if (err == 0)
@@ -1373,9 +1366,17 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
if (!intel_engine_can_store_dword(eb->engine))
return ERR_PTR(-ENODEV);
- err = __reloc_gpu_alloc(eb, vma, len);
+ err = __reloc_gpu_alloc(eb, len);
+ if (unlikely(err))
+ return ERR_PTR(err);
+ }
+
+ if (vma != cache->target) {
+ err = reloc_move_to_gpu(cache->rq, vma);
if (unlikely(err))
return ERR_PTR(err);
+
+ cache->target = vma;
}
if (unlikely(cache->rq_size + len > PAGE_SIZE / sizeof(u32) - 4)) {
@@ -1694,6 +1695,8 @@ static int eb_relocate(struct i915_execbuffer *eb)
if (err)
return err;
}
+
+ reloc_gpu_flush(&eb->reloc_cache);
}
return 0;
--
2.20.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [Intel-gfx] [PATCH 2/3] drm/i915/gem: Use a single chained reloc batches for a single execbuf
2020-05-01 10:18 ` [Intel-gfx] [PATCH 2/3] drm/i915/gem: Use a single chained reloc batches for a single execbuf Chris Wilson
@ 2020-05-01 12:46 ` Tvrtko Ursulin
0 siblings, 0 replies; 12+ messages in thread
From: Tvrtko Ursulin @ 2020-05-01 12:46 UTC (permalink / raw)
To: Chris Wilson, intel-gfx
On 01/05/2020 11:18, Chris Wilson wrote:
> As we can now keep chaining together a relocation batch to process any
> number of relocations, we can keep building that relocation batch for
> all of the target vma. This avoiding emitting a new request into the
> ring for each target, consuming precious ring space and a potential
> stall.
>
> Testcase: igt/gem_exec_reloc/basic-wide-active
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 23 +++++++++++--------
> 1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> index 293bf06b65b2..b224a453e2a3 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> @@ -268,6 +268,7 @@ struct i915_execbuffer {
> bool has_fence : 1;
> bool needs_unfenced : 1;
>
> + struct i915_vma *target;
> struct i915_request *rq;
> u32 *rq_cmd;
> unsigned int rq_size;
> @@ -1087,9 +1088,6 @@ static void reloc_cache_reset(struct reloc_cache *cache)
> {
> void *vaddr;
>
> - if (cache->rq)
> - reloc_gpu_flush(cache);
> -
> if (!cache->vaddr)
> return;
>
> @@ -1282,7 +1280,6 @@ static int reloc_move_to_gpu(struct i915_request *rq, struct i915_vma *vma)
> }
>
> static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
> - struct i915_vma *vma,
> unsigned int len)
> {
> struct reloc_cache *cache = &eb->reloc_cache;
> @@ -1305,7 +1302,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
> goto out_pool;
> }
>
> - batch = i915_vma_instance(pool->obj, vma->vm, NULL);
> + batch = i915_vma_instance(pool->obj, eb->context->vm, NULL);
> if (IS_ERR(batch)) {
> err = PTR_ERR(batch);
> goto err_unmap;
> @@ -1325,10 +1322,6 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
> if (err)
> goto err_request;
>
> - err = reloc_move_to_gpu(rq, vma);
> - if (err)
> - goto err_request;
> -
> i915_vma_lock(batch);
> err = i915_request_await_object(rq, batch->obj, false);
> if (err == 0)
> @@ -1373,9 +1366,17 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
> if (!intel_engine_can_store_dword(eb->engine))
> return ERR_PTR(-ENODEV);
>
> - err = __reloc_gpu_alloc(eb, vma, len);
> + err = __reloc_gpu_alloc(eb, len);
> + if (unlikely(err))
> + return ERR_PTR(err);
> + }
> +
> + if (vma != cache->target) {
> + err = reloc_move_to_gpu(cache->rq, vma);
> if (unlikely(err))
> return ERR_PTR(err);
> +
> + cache->target = vma;
> }
>
> if (unlikely(cache->rq_size + len > PAGE_SIZE / sizeof(u32) - 4)) {
> @@ -1694,6 +1695,8 @@ static int eb_relocate(struct i915_execbuffer *eb)
> if (err)
> return err;
> }
> +
> + reloc_gpu_flush(&eb->reloc_cache);
> }
>
> return 0;
>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Intel-gfx] [PATCH 3/3] drm/i915/gem: Try an alternate engine for relocations
2020-05-01 10:18 [Intel-gfx] [PATCH 1/3] drm/i915/gem: Use chained reloc batches Chris Wilson
2020-05-01 10:18 ` [Intel-gfx] [PATCH 2/3] drm/i915/gem: Use a single chained reloc batches for a single execbuf Chris Wilson
@ 2020-05-01 10:19 ` Chris Wilson
2020-05-01 12:47 ` Tvrtko Ursulin
2020-05-01 11:13 ` [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/3] drm/i915/gem: Use chained reloc batches Patchwork
` (2 subsequent siblings)
4 siblings, 1 reply; 12+ messages in thread
From: Chris Wilson @ 2020-05-01 10:19 UTC (permalink / raw)
To: intel-gfx; +Cc: Chris Wilson
If at first we don't succeed, try try again.
No all engines may support the MI ops we need to perform asynchronous
relocation patching, and so we end up failing back to a synchronous
operation that has a liability of blocking. However, Tvrtko pointed out
we don't need to use the same engine to perform the relocations as we
are planning to execute the execbuf on, and so if we switch over to a
working engine, we can perform the relocation asynchronously. The user
execbuf will be queued after the relocations by virtue of fencing.
This patch creates a new context per execbuf requiring asynchronous
relocations on an unusable engines. This is perhaps a bit excessive and
can be amoriated by a small context cache, but for the moment we only
need it for working around a little used engine on Sandybridge, and only
if relocations are actually required.
Now we just need to teach the relocation code to handle physical
addressing for gen2/3, and we should then have universal support!
Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Testcase: igt/gem_exec_reloc/basic-spin # snb
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
.../gpu/drm/i915/gem/i915_gem_execbuffer.c | 32 ++++++++++++++++---
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index b224a453e2a3..6d649de3a796 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -1280,6 +1280,7 @@ static int reloc_move_to_gpu(struct i915_request *rq, struct i915_vma *vma)
}
static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
+ struct intel_engine_cs *engine,
unsigned int len)
{
struct reloc_cache *cache = &eb->reloc_cache;
@@ -1289,7 +1290,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
u32 *cmd;
int err;
- pool = intel_gt_get_buffer_pool(eb->engine->gt, PAGE_SIZE);
+ pool = intel_gt_get_buffer_pool(engine->gt, PAGE_SIZE);
if (IS_ERR(pool))
return PTR_ERR(pool);
@@ -1312,7 +1313,23 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
if (err)
goto err_unmap;
- rq = i915_request_create(eb->context);
+ if (engine == eb->context->engine) {
+ rq = i915_request_create(eb->context);
+ } else {
+ struct intel_context *ce;
+
+ ce = intel_context_create(engine);
+ if (IS_ERR(ce)) {
+ err = PTR_ERR(rq);
+ goto err_unpin;
+ }
+
+ i915_vm_put(ce->vm);
+ ce->vm = i915_vm_get(eb->context->vm);
+
+ rq = intel_context_create_request(ce);
+ intel_context_put(ce);
+ }
if (IS_ERR(rq)) {
err = PTR_ERR(rq);
goto err_unpin;
@@ -1363,10 +1380,15 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
int err;
if (unlikely(!cache->rq)) {
- if (!intel_engine_can_store_dword(eb->engine))
- return ERR_PTR(-ENODEV);
+ struct intel_engine_cs *engine = eb->engine;
+
+ if (!intel_engine_can_store_dword(engine)) {
+ engine = engine->gt->engine_class[COPY_ENGINE_CLASS][0];
+ if (!engine || !intel_engine_can_store_dword(engine))
+ return ERR_PTR(-ENODEV);
+ }
- err = __reloc_gpu_alloc(eb, len);
+ err = __reloc_gpu_alloc(eb, engine, len);
if (unlikely(err))
return ERR_PTR(err);
}
--
2.20.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 12+ messages in thread* Re: [Intel-gfx] [PATCH 3/3] drm/i915/gem: Try an alternate engine for relocations
2020-05-01 10:19 ` [Intel-gfx] [PATCH 3/3] drm/i915/gem: Try an alternate engine for relocations Chris Wilson
@ 2020-05-01 12:47 ` Tvrtko Ursulin
2020-05-01 12:53 ` Chris Wilson
0 siblings, 1 reply; 12+ messages in thread
From: Tvrtko Ursulin @ 2020-05-01 12:47 UTC (permalink / raw)
To: Chris Wilson, intel-gfx
On 01/05/2020 11:19, Chris Wilson wrote:
> If at first we don't succeed, try try again.
>
> No all engines may support the MI ops we need to perform asynchronous
> relocation patching, and so we end up failing back to a synchronous
> operation that has a liability of blocking. However, Tvrtko pointed out
> we don't need to use the same engine to perform the relocations as we
> are planning to execute the execbuf on, and so if we switch over to a
> working engine, we can perform the relocation asynchronously. The user
> execbuf will be queued after the relocations by virtue of fencing.
>
> This patch creates a new context per execbuf requiring asynchronous
> relocations on an unusable engines. This is perhaps a bit excessive and
> can be amoriated by a small context cache, but for the moment we only
> need it for working around a little used engine on Sandybridge, and only
> if relocations are actually required.
>
> Now we just need to teach the relocation code to handle physical
> addressing for gen2/3, and we should then have universal support!
>
> Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Testcase: igt/gem_exec_reloc/basic-spin # snb
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
> .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 32 ++++++++++++++++---
> 1 file changed, 27 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> index b224a453e2a3..6d649de3a796 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> @@ -1280,6 +1280,7 @@ static int reloc_move_to_gpu(struct i915_request *rq, struct i915_vma *vma)
> }
>
> static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
> + struct intel_engine_cs *engine,
> unsigned int len)
> {
> struct reloc_cache *cache = &eb->reloc_cache;
> @@ -1289,7 +1290,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
> u32 *cmd;
> int err;
>
> - pool = intel_gt_get_buffer_pool(eb->engine->gt, PAGE_SIZE);
> + pool = intel_gt_get_buffer_pool(engine->gt, PAGE_SIZE);
> if (IS_ERR(pool))
> return PTR_ERR(pool);
>
> @@ -1312,7 +1313,23 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
> if (err)
> goto err_unmap;
>
> - rq = i915_request_create(eb->context);
> + if (engine == eb->context->engine) {
> + rq = i915_request_create(eb->context);
> + } else {
> + struct intel_context *ce;
> +
> + ce = intel_context_create(engine);
> + if (IS_ERR(ce)) {
> + err = PTR_ERR(rq);
> + goto err_unpin;
> + }
> +
> + i915_vm_put(ce->vm);
> + ce->vm = i915_vm_get(eb->context->vm);
> +
> + rq = intel_context_create_request(ce);
> + intel_context_put(ce);
> + }
> if (IS_ERR(rq)) {
> err = PTR_ERR(rq);
> goto err_unpin;
> @@ -1363,10 +1380,15 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
> int err;
>
> if (unlikely(!cache->rq)) {
> - if (!intel_engine_can_store_dword(eb->engine))
> - return ERR_PTR(-ENODEV);
> + struct intel_engine_cs *engine = eb->engine;
> +
> + if (!intel_engine_can_store_dword(engine)) {
> + engine = engine->gt->engine_class[COPY_ENGINE_CLASS][0];
> + if (!engine || !intel_engine_can_store_dword(engine))
> + return ERR_PTR(-ENODEV);
> + }
>
> - err = __reloc_gpu_alloc(eb, len);
> + err = __reloc_gpu_alloc(eb, engine, len);
> if (unlikely(err))
> return ERR_PTR(err);
> }
>
If you are not worried about the context create dance on SNB, and it is
limited to VCS, then neither am I.
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Intel-gfx] [PATCH 3/3] drm/i915/gem: Try an alternate engine for relocations
2020-05-01 12:47 ` Tvrtko Ursulin
@ 2020-05-01 12:53 ` Chris Wilson
0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2020-05-01 12:53 UTC (permalink / raw)
To: Tvrtko Ursulin, intel-gfx
Quoting Tvrtko Ursulin (2020-05-01 13:47:36)
>
> On 01/05/2020 11:19, Chris Wilson wrote:
> If you are not worried about the context create dance on SNB, and it is
> limited to VCS, then neither am I.
In the short term, since it's limited to vcs on SNB so that means it is
just a plain kmalloc (as there is no logical state), I'm not worrying.
Longer term, I do intend on having a pool of logical states cached on
the engine.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/3] drm/i915/gem: Use chained reloc batches
2020-05-01 10:18 [Intel-gfx] [PATCH 1/3] drm/i915/gem: Use chained reloc batches Chris Wilson
2020-05-01 10:18 ` [Intel-gfx] [PATCH 2/3] drm/i915/gem: Use a single chained reloc batches for a single execbuf Chris Wilson
2020-05-01 10:19 ` [Intel-gfx] [PATCH 3/3] drm/i915/gem: Try an alternate engine for relocations Chris Wilson
@ 2020-05-01 11:13 ` Patchwork
2020-05-01 12:33 ` [Intel-gfx] [PATCH 1/3] " Tvrtko Ursulin
2020-05-01 13:39 ` [Intel-gfx] ✓ Fi.CI.IGT: success for series starting with [1/3] " Patchwork
4 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2020-05-01 11:13 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: series starting with [1/3] drm/i915/gem: Use chained reloc batches
URL : https://patchwork.freedesktop.org/series/76813/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_8405 -> Patchwork_17538
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/index.html
Known issues
------------
Here are the changes found in Patchwork_17538 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@kms_chamelium@dp-crc-fast:
- fi-cml-u2: [PASS][1] -> [FAIL][2] ([i915#262])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/fi-cml-u2/igt@kms_chamelium@dp-crc-fast.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/fi-cml-u2/igt@kms_chamelium@dp-crc-fast.html
#### Possible fixes ####
* igt@i915_selftest@live@hugepages:
- fi-bwr-2160: [INCOMPLETE][3] ([i915#489]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/fi-bwr-2160/igt@i915_selftest@live@hugepages.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/fi-bwr-2160/igt@i915_selftest@live@hugepages.html
[i915#262]: https://gitlab.freedesktop.org/drm/intel/issues/262
[i915#489]: https://gitlab.freedesktop.org/drm/intel/issues/489
Participating hosts (50 -> 43)
------------------------------
Missing (7): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper fi-bdw-samus
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_8405 -> Patchwork_17538
CI-20190529: 20190529
CI_DRM_8405: 83efffba539b475ce7e3fb96aeae7ee744309ff7 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5623: 8838c73169ea249e6e86aaed35e5178f60f4ef7d @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_17538: 91008ee19b392a99ff3cc190aa6c12b2c1959c11 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
91008ee19b39 drm/i915/gem: Try an alternate engine for relocations
7b4c8219a242 drm/i915/gem: Use a single chained reloc batches for a single execbuf
20503d783f12 drm/i915/gem: Use chained reloc batches
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Intel-gfx] [PATCH 1/3] drm/i915/gem: Use chained reloc batches
2020-05-01 10:18 [Intel-gfx] [PATCH 1/3] drm/i915/gem: Use chained reloc batches Chris Wilson
` (2 preceding siblings ...)
2020-05-01 11:13 ` [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/3] drm/i915/gem: Use chained reloc batches Patchwork
@ 2020-05-01 12:33 ` Tvrtko Ursulin
2020-05-01 12:38 ` Chris Wilson
2020-05-01 13:39 ` [Intel-gfx] ✓ Fi.CI.IGT: success for series starting with [1/3] " Patchwork
4 siblings, 1 reply; 12+ messages in thread
From: Tvrtko Ursulin @ 2020-05-01 12:33 UTC (permalink / raw)
To: Chris Wilson, intel-gfx
On 01/05/2020 11:18, Chris Wilson wrote:
> The ring is a precious resource: we anticipate to only use a few hundred
> bytes for a request, and only try to reserve that before we start. If we
> go beyond our guess in building the request, then instead of waiting at
> the start of execbuf before we hold any locks or other resources, we
> may trigger a wait inside a critical region. One example is in using gpu
> relocations, where currently we emit a new MI_BB_START from the ring
> every time we overflow a page of relocation entries. However, instead of
> insert the command into the precious ring, we can chain the next page of
> relocation entries as MI_BB_START from the end of the previous.
>
> v2: Delay the emit_bb_start until after all the chained vma
> synchronisation is complete. Since the buffer pool batches are idle, this
> _should_ be a no-op, but one day we may some fancy async GPU bindings
> for new vma!
>
> Testcase: igt/gem_exec_reloc/basic-many-active
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
> .../gpu/drm/i915/gem/i915_gem_execbuffer.c | 130 +++++++++++++++---
> 1 file changed, 111 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> index 414859fa2673..293bf06b65b2 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
> @@ -271,6 +271,7 @@ struct i915_execbuffer {
> struct i915_request *rq;
> u32 *rq_cmd;
> unsigned int rq_size;
> + struct i915_vma *rq_vma;
> } reloc_cache;
>
> u64 invalid_flags; /** Set of execobj.flags that are invalid */
> @@ -975,20 +976,111 @@ static inline struct i915_ggtt *cache_to_ggtt(struct reloc_cache *cache)
> return &i915->ggtt;
> }
>
> +static int reloc_gpu_chain(struct reloc_cache *cache)
> +{
> + struct intel_gt_buffer_pool_node *pool;
> + struct i915_request *rq = cache->rq;
> + struct i915_vma *batch;
> + u32 *cmd;
> + int err;
> +
> + pool = intel_gt_get_buffer_pool(rq->engine->gt, PAGE_SIZE);
> + if (IS_ERR(pool))
> + return PTR_ERR(pool);
> +
> + batch = i915_vma_instance(pool->obj, rq->context->vm, NULL);
> + if (IS_ERR(batch)) {
> + err = PTR_ERR(batch);
> + goto out_pool;
> + }
> +
> + err = i915_vma_pin(batch, 0, 0, PIN_USER | PIN_NONBLOCK);
> + if (err)
> + goto out_pool;
> +
> + cmd = cache->rq_cmd + cache->rq_size;
> + *cmd++ = MI_ARB_CHECK;
> + if (cache->gen >= 8) {
> + *cmd++ = MI_BATCH_BUFFER_START_GEN8;
> + *cmd++ = lower_32_bits(batch->node.start);
> + *cmd++ = upper_32_bits(batch->node.start);
> + } else {
> + *cmd++ = MI_BATCH_BUFFER_START;
> + *cmd++ = lower_32_bits(batch->node.start);
> + }
> + i915_gem_object_flush_map(cache->rq_vma->obj);
> + i915_gem_object_unpin_map(cache->rq_vma->obj);
> + cache->rq_vma = NULL;
> +
> + err = intel_gt_buffer_pool_mark_active(pool, rq);
> + if (err == 0) {
> + i915_vma_lock(batch);
> + err = i915_request_await_object(rq, batch->obj, false);
> + if (err == 0)
> + err = i915_vma_move_to_active(batch, rq, 0);
> + i915_vma_unlock(batch);
> + }
> + i915_vma_unpin(batch);
> + if (err)
> + goto out_pool;
> +
> + cmd = i915_gem_object_pin_map(pool->obj,
batch->obj maybe to be consistent in this block? Few lines above you get
to it via batch.
> + cache->has_llc ?
> + I915_MAP_FORCE_WB :
> + I915_MAP_FORCE_WC);
> + if (IS_ERR(cmd)) {
> + err = PTR_ERR(cmd);
> + goto out_pool;
> + }
> +
> + /* Return with batch mapping (cmd) still pinned */
> + cache->rq_cmd = cmd;
> + cache->rq_size = 0;
> + cache->rq_vma = batch;
> +
> +out_pool:
> + intel_gt_buffer_pool_put(pool);
> + return err;
> +}
> +
> +static unsigned int reloc_bb_flags(const struct reloc_cache *cache)
> +{
> + return cache->gen > 5 ? 0 : I915_DISPATCH_SECURE;
> +}
> +
> static void reloc_gpu_flush(struct reloc_cache *cache)
> {
> - struct drm_i915_gem_object *obj = cache->rq->batch->obj;
> + struct i915_request *rq;
> + int err;
>
> - GEM_BUG_ON(cache->rq_size >= obj->base.size / sizeof(u32));
> - cache->rq_cmd[cache->rq_size] = MI_BATCH_BUFFER_END;
> + rq = fetch_and_zero(&cache->rq);
> + if (!rq)
> + return;
>
> - __i915_gem_object_flush_map(obj, 0, sizeof(u32) * (cache->rq_size + 1));
> - i915_gem_object_unpin_map(obj);
> + if (cache->rq_vma) {
> + struct drm_i915_gem_object *obj = cache->rq_vma->obj;
>
> - intel_gt_chipset_flush(cache->rq->engine->gt);
> + GEM_BUG_ON(cache->rq_size >= obj->base.size / sizeof(u32));
> + cache->rq_cmd[cache->rq_size++] = MI_BATCH_BUFFER_END;
>
> - i915_request_add(cache->rq);
> - cache->rq = NULL;
> + __i915_gem_object_flush_map(obj,
> + 0, sizeof(u32) * cache->rq_size);
> + i915_gem_object_unpin_map(obj);
> + }
> +
> + err = 0;
> + if (rq->engine->emit_init_breadcrumb)
> + err = rq->engine->emit_init_breadcrumb(rq);
> + if (!err)
> + err = rq->engine->emit_bb_start(rq,
> + rq->batch->node.start,
> + PAGE_SIZE,
> + reloc_bb_flags(cache));
> + if (err)
> + i915_request_set_error_once(rq, err);
Will this error propagate and fail the execbuf?
> +
> + intel_gt_chipset_flush(rq->engine->gt);
> + i915_request_add(rq);
> }
>
> static void reloc_cache_reset(struct reloc_cache *cache)
> @@ -1237,12 +1329,6 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
> if (err)
> goto err_request;
>
> - err = eb->engine->emit_bb_start(rq,
> - batch->node.start, PAGE_SIZE,
> - cache->gen > 5 ? 0 : I915_DISPATCH_SECURE);
> - if (err)
> - goto skip_request;
> -
> i915_vma_lock(batch);
> err = i915_request_await_object(rq, batch->obj, false);
> if (err == 0)
> @@ -1257,6 +1343,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
> cache->rq = rq;
> cache->rq_cmd = cmd;
> cache->rq_size = 0;
> + cache->rq_vma = batch;
>
> /* Return with batch mapping (cmd) still pinned */
> goto out_pool;
> @@ -1280,13 +1367,9 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
> {
> struct reloc_cache *cache = &eb->reloc_cache;
> u32 *cmd;
> -
> - if (cache->rq_size > PAGE_SIZE/sizeof(u32) - (len + 1))
> - reloc_gpu_flush(cache);
> + int err;
>
> if (unlikely(!cache->rq)) {
> - int err;
> -
> if (!intel_engine_can_store_dword(eb->engine))
> return ERR_PTR(-ENODEV);
>
> @@ -1295,6 +1378,15 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
> return ERR_PTR(err);
> }
>
> + if (unlikely(cache->rq_size + len > PAGE_SIZE / sizeof(u32) - 4)) {
4 dwords for the chain, ok.
> + err = reloc_gpu_chain(cache);
> + if (unlikely(err)) {
> + i915_request_set_error_once(cache->rq, err);
> + return ERR_PTR(err);
> + }
> + }
> +
> + GEM_BUG_ON(cache->rq_size + len >= PAGE_SIZE / sizeof(u32));
> cmd = cache->rq_cmd + cache->rq_size;
> cache->rq_size += len;
>
>
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread* Re: [Intel-gfx] [PATCH 1/3] drm/i915/gem: Use chained reloc batches
2020-05-01 12:33 ` [Intel-gfx] [PATCH 1/3] " Tvrtko Ursulin
@ 2020-05-01 12:38 ` Chris Wilson
2020-05-01 12:44 ` Chris Wilson
0 siblings, 1 reply; 12+ messages in thread
From: Chris Wilson @ 2020-05-01 12:38 UTC (permalink / raw)
To: Tvrtko Ursulin, intel-gfx
Quoting Tvrtko Ursulin (2020-05-01 13:33:14)
>
> On 01/05/2020 11:18, Chris Wilson wrote:
> > +
> > + err = 0;
> > + if (rq->engine->emit_init_breadcrumb)
> > + err = rq->engine->emit_init_breadcrumb(rq);
> > + if (!err)
> > + err = rq->engine->emit_bb_start(rq,
> > + rq->batch->node.start,
> > + PAGE_SIZE,
> > + reloc_bb_flags(cache));
> > + if (err)
> > + i915_request_set_error_once(rq, err);
>
> Will this error propagate and fail the execbuf?
It fails the execution, but not the execbuf... I was thinking it was too
late for the execbuf, but return err at the end propagates nicely!
>
> > +
> > + intel_gt_chipset_flush(rq->engine->gt);
> > + i915_request_add(rq);
> > }
Thanks,
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [Intel-gfx] [PATCH 1/3] drm/i915/gem: Use chained reloc batches
2020-05-01 12:38 ` Chris Wilson
@ 2020-05-01 12:44 ` Chris Wilson
0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2020-05-01 12:44 UTC (permalink / raw)
To: Tvrtko Ursulin, intel-gfx
Quoting Chris Wilson (2020-05-01 13:38:03)
> Quoting Tvrtko Ursulin (2020-05-01 13:33:14)
> >
> > On 01/05/2020 11:18, Chris Wilson wrote:
> > > +
> > > + err = 0;
> > > + if (rq->engine->emit_init_breadcrumb)
> > > + err = rq->engine->emit_init_breadcrumb(rq);
> > > + if (!err)
> > > + err = rq->engine->emit_bb_start(rq,
> > > + rq->batch->node.start,
> > > + PAGE_SIZE,
> > > + reloc_bb_flags(cache));
> > > + if (err)
> > > + i915_request_set_error_once(rq, err);
> >
> > Will this error propagate and fail the execbuf?
>
> It fails the execution, but not the execbuf... I was thinking it was too
> late for the execbuf, but return err at the end propagates nicely!
This is much easier in #2, so I'll let the bug slide for a patch.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Intel-gfx] ✓ Fi.CI.IGT: success for series starting with [1/3] drm/i915/gem: Use chained reloc batches
2020-05-01 10:18 [Intel-gfx] [PATCH 1/3] drm/i915/gem: Use chained reloc batches Chris Wilson
` (3 preceding siblings ...)
2020-05-01 12:33 ` [Intel-gfx] [PATCH 1/3] " Tvrtko Ursulin
@ 2020-05-01 13:39 ` Patchwork
4 siblings, 0 replies; 12+ messages in thread
From: Patchwork @ 2020-05-01 13:39 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: series starting with [1/3] drm/i915/gem: Use chained reloc batches
URL : https://patchwork.freedesktop.org/series/76813/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_8405_full -> Patchwork_17538_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_17538_full:
### IGT changes ###
#### Suppressed ####
The following results come from untrusted machines, tests, or statuses.
They do not affect the overall result.
* {igt@gem_exec_reloc@basic-parallel}:
- shard-hsw: [PASS][1] -> [FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-hsw7/igt@gem_exec_reloc@basic-parallel.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-hsw6/igt@gem_exec_reloc@basic-parallel.html
- shard-kbl: [PASS][3] -> [TIMEOUT][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-kbl6/igt@gem_exec_reloc@basic-parallel.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-kbl6/igt@gem_exec_reloc@basic-parallel.html
- shard-snb: [PASS][5] -> [FAIL][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-snb1/igt@gem_exec_reloc@basic-parallel.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-snb1/igt@gem_exec_reloc@basic-parallel.html
- shard-tglb: [PASS][7] -> [TIMEOUT][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-tglb2/igt@gem_exec_reloc@basic-parallel.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-tglb5/igt@gem_exec_reloc@basic-parallel.html
- shard-skl: NOTRUN -> [INCOMPLETE][9]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-skl9/igt@gem_exec_reloc@basic-parallel.html
- shard-apl: [PASS][10] -> [TIMEOUT][11]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-apl7/igt@gem_exec_reloc@basic-parallel.html
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-apl3/igt@gem_exec_reloc@basic-parallel.html
- shard-iclb: [PASS][12] -> [TIMEOUT][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-iclb5/igt@gem_exec_reloc@basic-parallel.html
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-iclb6/igt@gem_exec_reloc@basic-parallel.html
- shard-glk: [PASS][14] -> [TIMEOUT][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-glk5/igt@gem_exec_reloc@basic-parallel.html
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-glk2/igt@gem_exec_reloc@basic-parallel.html
* {igt@gem_mmap_offset@ptrace@gtt}:
- shard-snb: NOTRUN -> [FAIL][16] +3 similar issues
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-snb1/igt@gem_mmap_offset@ptrace@gtt.html
Known issues
------------
Here are the changes found in Patchwork_17538_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@kms_cursor_crc@pipe-a-cursor-256x85-sliding:
- shard-skl: [PASS][17] -> [FAIL][18] ([i915#54])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-skl7/igt@kms_cursor_crc@pipe-a-cursor-256x85-sliding.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-skl4/igt@kms_cursor_crc@pipe-a-cursor-256x85-sliding.html
* igt@kms_cursor_crc@pipe-c-cursor-suspend:
- shard-apl: [PASS][19] -> [DMESG-WARN][20] ([i915#180]) +2 similar issues
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-apl6/igt@kms_cursor_crc@pipe-c-cursor-suspend.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-apl2/igt@kms_cursor_crc@pipe-c-cursor-suspend.html
* igt@kms_cursor_legacy@flip-vs-cursor-busy-crc-atomic:
- shard-glk: [PASS][21] -> [FAIL][22] ([IGT#5])
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-glk6/igt@kms_cursor_legacy@flip-vs-cursor-busy-crc-atomic.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-glk4/igt@kms_cursor_legacy@flip-vs-cursor-busy-crc-atomic.html
* igt@kms_hdr@bpc-switch:
- shard-skl: [PASS][23] -> [FAIL][24] ([i915#1188])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-skl9/igt@kms_hdr@bpc-switch.html
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-skl7/igt@kms_hdr@bpc-switch.html
* igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
- shard-kbl: [PASS][25] -> [DMESG-WARN][26] ([i915#180] / [i915#93] / [i915#95])
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-kbl4/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-kbl3/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b.html
* igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min:
- shard-skl: [PASS][27] -> [FAIL][28] ([fdo#108145] / [i915#265])
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-skl7/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-skl4/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html
* igt@kms_psr@psr2_cursor_mmap_cpu:
- shard-iclb: [PASS][29] -> [SKIP][30] ([fdo#109441]) +2 similar issues
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-iclb2/igt@kms_psr@psr2_cursor_mmap_cpu.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-iclb3/igt@kms_psr@psr2_cursor_mmap_cpu.html
* igt@kms_vblank@pipe-a-ts-continuation-suspend:
- shard-kbl: [PASS][31] -> [DMESG-WARN][32] ([i915#180]) +2 similar issues
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-kbl4/igt@kms_vblank@pipe-a-ts-continuation-suspend.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-kbl6/igt@kms_vblank@pipe-a-ts-continuation-suspend.html
#### Possible fixes ####
* {igt@gem_exec_reloc@basic-many-active@bcs0}:
- shard-skl: [FAIL][33] -> [PASS][34] +6 similar issues
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-skl1/igt@gem_exec_reloc@basic-many-active@bcs0.html
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-skl3/igt@gem_exec_reloc@basic-many-active@bcs0.html
* {igt@gem_exec_reloc@basic-many-active@rcs0}:
- shard-apl: [FAIL][35] -> [PASS][36] +7 similar issues
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-apl2/igt@gem_exec_reloc@basic-many-active@rcs0.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-apl2/igt@gem_exec_reloc@basic-many-active@rcs0.html
- shard-tglb: [FAIL][37] -> [PASS][38] +9 similar issues
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-tglb6/igt@gem_exec_reloc@basic-many-active@rcs0.html
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-tglb3/igt@gem_exec_reloc@basic-many-active@rcs0.html
- shard-glk: [FAIL][39] -> [PASS][40] +7 similar issues
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-glk7/igt@gem_exec_reloc@basic-many-active@rcs0.html
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-glk7/igt@gem_exec_reloc@basic-many-active@rcs0.html
- shard-hsw: [INCOMPLETE][41] ([i915#61]) -> [PASS][42] +1 similar issue
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-hsw6/igt@gem_exec_reloc@basic-many-active@rcs0.html
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-hsw1/igt@gem_exec_reloc@basic-many-active@rcs0.html
* {igt@gem_exec_reloc@basic-many-active@vcs0}:
- shard-kbl: [FAIL][43] -> [PASS][44] +9 similar issues
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-kbl4/igt@gem_exec_reloc@basic-many-active@vcs0.html
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-kbl7/igt@gem_exec_reloc@basic-many-active@vcs0.html
* {igt@gem_exec_reloc@basic-spin@vcs0}:
- shard-snb: [FAIL][45] ([i915#757]) -> [PASS][46]
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-snb4/igt@gem_exec_reloc@basic-spin@vcs0.html
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-snb6/igt@gem_exec_reloc@basic-spin@vcs0.html
* {igt@gem_exec_reloc@basic-wide-active@rcs0}:
- shard-snb: [INCOMPLETE][47] ([i915#82]) -> [PASS][48] +1 similar issue
[47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-snb2/igt@gem_exec_reloc@basic-wide-active@rcs0.html
[48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-snb5/igt@gem_exec_reloc@basic-wide-active@rcs0.html
- shard-iclb: [FAIL][49] -> [PASS][50] +7 similar issues
[49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-iclb4/igt@gem_exec_reloc@basic-wide-active@rcs0.html
[50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-iclb7/igt@gem_exec_reloc@basic-wide-active@rcs0.html
* {igt@kms_flip@flip-vs-expired-vblank@c-hdmi-a2}:
- shard-glk: [FAIL][51] ([i915#79]) -> [PASS][52]
[51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-glk4/igt@kms_flip@flip-vs-expired-vblank@c-hdmi-a2.html
[52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-glk8/igt@kms_flip@flip-vs-expired-vblank@c-hdmi-a2.html
* {igt@kms_flip@flip-vs-suspend-interruptible@b-edp1}:
- shard-skl: [INCOMPLETE][53] ([i915#198]) -> [PASS][54]
[53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-skl3/igt@kms_flip@flip-vs-suspend-interruptible@b-edp1.html
[54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-skl7/igt@kms_flip@flip-vs-suspend-interruptible@b-edp1.html
* {igt@kms_flip@flip-vs-suspend-interruptible@c-dp1}:
- shard-apl: [DMESG-WARN][55] ([i915#180]) -> [PASS][56]
[55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-apl1/igt@kms_flip@flip-vs-suspend-interruptible@c-dp1.html
[56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-apl3/igt@kms_flip@flip-vs-suspend-interruptible@c-dp1.html
* {igt@kms_flip@flip-vs-suspend@c-dp1}:
- shard-kbl: [DMESG-WARN][57] ([i915#180]) -> [PASS][58] +9 similar issues
[57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-kbl6/igt@kms_flip@flip-vs-suspend@c-dp1.html
[58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-kbl3/igt@kms_flip@flip-vs-suspend@c-dp1.html
* igt@kms_hdr@bpc-switch-dpms:
- shard-skl: [FAIL][59] ([i915#1188]) -> [PASS][60]
[59]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-skl6/igt@kms_hdr@bpc-switch-dpms.html
[60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-skl10/igt@kms_hdr@bpc-switch-dpms.html
* igt@kms_plane@plane-panning-bottom-right-suspend-pipe-c-planes:
- shard-skl: [INCOMPLETE][61] ([i915#69]) -> [PASS][62]
[61]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-skl5/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-c-planes.html
[62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-skl3/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-c-planes.html
* igt@kms_psr@psr2_primary_page_flip:
- shard-iclb: [SKIP][63] ([fdo#109441]) -> [PASS][64] +2 similar issues
[63]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-iclb1/igt@kms_psr@psr2_primary_page_flip.html
[64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-iclb2/igt@kms_psr@psr2_primary_page_flip.html
#### Warnings ####
* igt@i915_pm_dc@dc3co-vpb-simulation:
- shard-iclb: [SKIP][65] ([i915#588]) -> [SKIP][66] ([i915#658])
[65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-iclb2/igt@i915_pm_dc@dc3co-vpb-simulation.html
[66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-iclb3/igt@i915_pm_dc@dc3co-vpb-simulation.html
* igt@i915_pm_rpm@gem-execbuf-stress-pc8:
- shard-snb: [INCOMPLETE][67] ([i915#82]) -> [SKIP][68] ([fdo#109271])
[67]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8405/shard-snb5/igt@i915_pm_rpm@gem-execbuf-stress-pc8.html
[68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/shard-snb1/igt@i915_pm_rpm@gem-execbuf-stress-pc8.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[IGT#5]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/5
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[i915#1188]: https://gitlab.freedesktop.org/drm/intel/issues/1188
[i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
[i915#198]: https://gitlab.freedesktop.org/drm/intel/issues/198
[i915#265]: https://gitlab.freedesktop.org/drm/intel/issues/265
[i915#34]: https://gitlab.freedesktop.org/drm/intel/issues/34
[i915#54]: https://gitlab.freedesktop.org/drm/intel/issues/54
[i915#588]: https://gitlab.freedesktop.org/drm/intel/issues/588
[i915#61]: https://gitlab.freedesktop.org/drm/intel/issues/61
[i915#658]: https://gitlab.freedesktop.org/drm/intel/issues/658
[i915#69]: https://gitlab.freedesktop.org/drm/intel/issues/69
[i915#757]: https://gitlab.freedesktop.org/drm/intel/issues/757
[i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
[i915#82]: https://gitlab.freedesktop.org/drm/intel/issues/82
[i915#93]: https://gitlab.freedesktop.org/drm/intel/issues/93
[i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95
Participating hosts (10 -> 10)
------------------------------
No changes in participating hosts
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_8405 -> Patchwork_17538
CI-20190529: 20190529
CI_DRM_8405: 83efffba539b475ce7e3fb96aeae7ee744309ff7 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5623: 8838c73169ea249e6e86aaed35e5178f60f4ef7d @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_17538: 91008ee19b392a99ff3cc190aa6c12b2c1959c11 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17538/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 12+ messages in thread
* [Intel-gfx] [PATCH 1/3] drm/i915/gem: Use chained reloc batches
@ 2020-05-01 13:02 Chris Wilson
2020-05-01 13:02 ` [Intel-gfx] [PATCH 3/3] drm/i915/gem: Try an alternate engine for relocations Chris Wilson
0 siblings, 1 reply; 12+ messages in thread
From: Chris Wilson @ 2020-05-01 13:02 UTC (permalink / raw)
To: intel-gfx; +Cc: Chris Wilson
The ring is a precious resource: we anticipate to only use a few hundred
bytes for a request, and only try to reserve that before we start. If we
go beyond our guess in building the request, then instead of waiting at
the start of execbuf before we hold any locks or other resources, we
may trigger a wait inside a critical region. One example is in using gpu
relocations, where currently we emit a new MI_BB_START from the ring
every time we overflow a page of relocation entries. However, instead of
insert the command into the precious ring, we can chain the next page of
relocation entries as MI_BB_START from the end of the previous.
v2: Delay the emit_bb_start until after all the chained vma
synchronisation is complete. Since the buffer pool batches are idle, this
_should_ be a no-op, but one day we may some fancy async GPU bindings
for new vma!
v3: Use pool/batch consitently, once we start thinking in terms of the
batch vma, use batch->obj.
v4: Explain the magic number 4.
Tvrtko spotted that we lose propagation of the error for failing to
submit the relocation request; that's easier to fix up in the next
patch.
Testcase: igt/gem_exec_reloc/basic-many-active
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
.../gpu/drm/i915/gem/i915_gem_execbuffer.c | 134 +++++++++++++++---
1 file changed, 115 insertions(+), 19 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index 414859fa2673..0874976b1cf7 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -271,6 +271,7 @@ struct i915_execbuffer {
struct i915_request *rq;
u32 *rq_cmd;
unsigned int rq_size;
+ struct i915_vma *rq_vma;
} reloc_cache;
u64 invalid_flags; /** Set of execobj.flags that are invalid */
@@ -975,20 +976,114 @@ static inline struct i915_ggtt *cache_to_ggtt(struct reloc_cache *cache)
return &i915->ggtt;
}
+#define RELOC_TAIL 4
+
+static int reloc_gpu_chain(struct reloc_cache *cache)
+{
+ struct intel_gt_buffer_pool_node *pool;
+ struct i915_request *rq = cache->rq;
+ struct i915_vma *batch;
+ u32 *cmd;
+ int err;
+
+ pool = intel_gt_get_buffer_pool(rq->engine->gt, PAGE_SIZE);
+ if (IS_ERR(pool))
+ return PTR_ERR(pool);
+
+ batch = i915_vma_instance(pool->obj, rq->context->vm, NULL);
+ if (IS_ERR(batch)) {
+ err = PTR_ERR(batch);
+ goto out_pool;
+ }
+
+ err = i915_vma_pin(batch, 0, 0, PIN_USER | PIN_NONBLOCK);
+ if (err)
+ goto out_pool;
+
+ GEM_BUG_ON(cache->rq_size + RELOC_TAIL > PAGE_SIZE / sizeof(u32));
+ cmd = cache->rq_cmd + cache->rq_size;
+ *cmd++ = MI_ARB_CHECK;
+ if (cache->gen >= 8) {
+ *cmd++ = MI_BATCH_BUFFER_START_GEN8;
+ *cmd++ = lower_32_bits(batch->node.start);
+ *cmd++ = upper_32_bits(batch->node.start);
+ } else {
+ *cmd++ = MI_BATCH_BUFFER_START;
+ *cmd++ = lower_32_bits(batch->node.start);
+ }
+ i915_gem_object_flush_map(cache->rq_vma->obj);
+ i915_gem_object_unpin_map(cache->rq_vma->obj);
+ cache->rq_vma = NULL;
+
+ err = intel_gt_buffer_pool_mark_active(pool, rq);
+ if (err == 0) {
+ i915_vma_lock(batch);
+ err = i915_request_await_object(rq, batch->obj, false);
+ if (err == 0)
+ err = i915_vma_move_to_active(batch, rq, 0);
+ i915_vma_unlock(batch);
+ }
+ i915_vma_unpin(batch);
+ if (err)
+ goto out_pool;
+
+ cmd = i915_gem_object_pin_map(batch->obj,
+ cache->has_llc ?
+ I915_MAP_FORCE_WB :
+ I915_MAP_FORCE_WC);
+ if (IS_ERR(cmd)) {
+ err = PTR_ERR(cmd);
+ goto out_pool;
+ }
+
+ /* Return with batch mapping (cmd) still pinned */
+ cache->rq_cmd = cmd;
+ cache->rq_size = 0;
+ cache->rq_vma = batch;
+
+out_pool:
+ intel_gt_buffer_pool_put(pool);
+ return err;
+}
+
+static unsigned int reloc_bb_flags(const struct reloc_cache *cache)
+{
+ return cache->gen > 5 ? 0 : I915_DISPATCH_SECURE;
+}
+
static void reloc_gpu_flush(struct reloc_cache *cache)
{
- struct drm_i915_gem_object *obj = cache->rq->batch->obj;
+ struct i915_request *rq;
+ int err;
- GEM_BUG_ON(cache->rq_size >= obj->base.size / sizeof(u32));
- cache->rq_cmd[cache->rq_size] = MI_BATCH_BUFFER_END;
+ rq = fetch_and_zero(&cache->rq);
+ if (!rq)
+ return;
- __i915_gem_object_flush_map(obj, 0, sizeof(u32) * (cache->rq_size + 1));
- i915_gem_object_unpin_map(obj);
+ if (cache->rq_vma) {
+ struct drm_i915_gem_object *obj = cache->rq_vma->obj;
- intel_gt_chipset_flush(cache->rq->engine->gt);
+ GEM_BUG_ON(cache->rq_size >= obj->base.size / sizeof(u32));
+ cache->rq_cmd[cache->rq_size++] = MI_BATCH_BUFFER_END;
- i915_request_add(cache->rq);
- cache->rq = NULL;
+ __i915_gem_object_flush_map(obj,
+ 0, sizeof(u32) * cache->rq_size);
+ i915_gem_object_unpin_map(obj);
+ }
+
+ err = 0;
+ if (rq->engine->emit_init_breadcrumb)
+ err = rq->engine->emit_init_breadcrumb(rq);
+ if (!err)
+ err = rq->engine->emit_bb_start(rq,
+ rq->batch->node.start,
+ PAGE_SIZE,
+ reloc_bb_flags(cache));
+ if (err)
+ i915_request_set_error_once(rq, err);
+
+ intel_gt_chipset_flush(rq->engine->gt);
+ i915_request_add(rq);
}
static void reloc_cache_reset(struct reloc_cache *cache)
@@ -1237,12 +1332,6 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
if (err)
goto err_request;
- err = eb->engine->emit_bb_start(rq,
- batch->node.start, PAGE_SIZE,
- cache->gen > 5 ? 0 : I915_DISPATCH_SECURE);
- if (err)
- goto skip_request;
-
i915_vma_lock(batch);
err = i915_request_await_object(rq, batch->obj, false);
if (err == 0)
@@ -1257,6 +1346,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
cache->rq = rq;
cache->rq_cmd = cmd;
cache->rq_size = 0;
+ cache->rq_vma = batch;
/* Return with batch mapping (cmd) still pinned */
goto out_pool;
@@ -1280,13 +1370,9 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
{
struct reloc_cache *cache = &eb->reloc_cache;
u32 *cmd;
-
- if (cache->rq_size > PAGE_SIZE/sizeof(u32) - (len + 1))
- reloc_gpu_flush(cache);
+ int err;
if (unlikely(!cache->rq)) {
- int err;
-
if (!intel_engine_can_store_dword(eb->engine))
return ERR_PTR(-ENODEV);
@@ -1295,6 +1381,16 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
return ERR_PTR(err);
}
+ if (unlikely(cache->rq_size + len >
+ PAGE_SIZE / sizeof(u32) - RELOC_TAIL)) {
+ err = reloc_gpu_chain(cache);
+ if (unlikely(err)) {
+ i915_request_set_error_once(cache->rq, err);
+ return ERR_PTR(err);
+ }
+ }
+
+ GEM_BUG_ON(cache->rq_size + len >= PAGE_SIZE / sizeof(u32));
cmd = cache->rq_cmd + cache->rq_size;
cache->rq_size += len;
--
2.20.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 12+ messages in thread* [Intel-gfx] [PATCH 3/3] drm/i915/gem: Try an alternate engine for relocations
2020-05-01 13:02 [Intel-gfx] [PATCH 1/3] " Chris Wilson
@ 2020-05-01 13:02 ` Chris Wilson
0 siblings, 0 replies; 12+ messages in thread
From: Chris Wilson @ 2020-05-01 13:02 UTC (permalink / raw)
To: intel-gfx; +Cc: Chris Wilson
If at first we don't succeed, try try again.
Not all engines may support the MI ops we need to perform asynchronous
relocation patching, and so we end up falling back to a synchronous
operation that has a liability of blocking. However, Tvrtko pointed out
we don't need to use the same engine to perform the relocations as we
are planning to execute the execbuf on, and so if we switch over to a
working engine, we can perform the relocation asynchronously. The user
execbuf will be queued after the relocations by virtue of fencing.
This patch creates a new context per execbuf requiring asynchronous
relocations on an unusable engines. This is perhaps a bit excessive and
can be ameliorated by a small context cache, but for the moment we only
need it for working around a little used engine on Sandybridge, and only
if relocations are actually required to an active batch buffer.
Now we just need to teach the relocation code to handle physical
addressing for gen2/3, and we should then have universal support!
Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Testcase: igt/gem_exec_reloc/basic-spin # snb
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
.../gpu/drm/i915/gem/i915_gem_execbuffer.c | 32 ++++++++++++++++---
1 file changed, 27 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index 4c4b9e0e75bc..3e02922bf68e 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -1285,6 +1285,7 @@ static int reloc_move_to_gpu(struct i915_request *rq, struct i915_vma *vma)
}
static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
+ struct intel_engine_cs *engine,
unsigned int len)
{
struct reloc_cache *cache = &eb->reloc_cache;
@@ -1294,7 +1295,7 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
u32 *cmd;
int err;
- pool = intel_gt_get_buffer_pool(eb->engine->gt, PAGE_SIZE);
+ pool = intel_gt_get_buffer_pool(engine->gt, PAGE_SIZE);
if (IS_ERR(pool))
return PTR_ERR(pool);
@@ -1317,7 +1318,23 @@ static int __reloc_gpu_alloc(struct i915_execbuffer *eb,
if (err)
goto err_unmap;
- rq = i915_request_create(eb->context);
+ if (engine == eb->context->engine) {
+ rq = i915_request_create(eb->context);
+ } else {
+ struct intel_context *ce;
+
+ ce = intel_context_create(engine);
+ if (IS_ERR(ce)) {
+ err = PTR_ERR(rq);
+ goto err_unpin;
+ }
+
+ i915_vm_put(ce->vm);
+ ce->vm = i915_vm_get(eb->context->vm);
+
+ rq = intel_context_create_request(ce);
+ intel_context_put(ce);
+ }
if (IS_ERR(rq)) {
err = PTR_ERR(rq);
goto err_unpin;
@@ -1368,10 +1385,15 @@ static u32 *reloc_gpu(struct i915_execbuffer *eb,
int err;
if (unlikely(!cache->rq)) {
- if (!intel_engine_can_store_dword(eb->engine))
- return ERR_PTR(-ENODEV);
+ struct intel_engine_cs *engine = eb->engine;
+
+ if (!intel_engine_can_store_dword(engine)) {
+ engine = engine->gt->engine_class[COPY_ENGINE_CLASS][0];
+ if (!engine || !intel_engine_can_store_dword(engine))
+ return ERR_PTR(-ENODEV);
+ }
- err = __reloc_gpu_alloc(eb, len);
+ err = __reloc_gpu_alloc(eb, engine, len);
if (unlikely(err))
return ERR_PTR(err);
}
--
2.20.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 12+ messages in thread
end of thread, other threads:[~2020-05-01 13:39 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-01 10:18 [Intel-gfx] [PATCH 1/3] drm/i915/gem: Use chained reloc batches Chris Wilson
2020-05-01 10:18 ` [Intel-gfx] [PATCH 2/3] drm/i915/gem: Use a single chained reloc batches for a single execbuf Chris Wilson
2020-05-01 12:46 ` Tvrtko Ursulin
2020-05-01 10:19 ` [Intel-gfx] [PATCH 3/3] drm/i915/gem: Try an alternate engine for relocations Chris Wilson
2020-05-01 12:47 ` Tvrtko Ursulin
2020-05-01 12:53 ` Chris Wilson
2020-05-01 11:13 ` [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/3] drm/i915/gem: Use chained reloc batches Patchwork
2020-05-01 12:33 ` [Intel-gfx] [PATCH 1/3] " Tvrtko Ursulin
2020-05-01 12:38 ` Chris Wilson
2020-05-01 12:44 ` Chris Wilson
2020-05-01 13:39 ` [Intel-gfx] ✓ Fi.CI.IGT: success for series starting with [1/3] " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2020-05-01 13:02 [Intel-gfx] [PATCH 1/3] " Chris Wilson
2020-05-01 13:02 ` [Intel-gfx] [PATCH 3/3] drm/i915/gem: Try an alternate engine for relocations Chris Wilson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox