* [Intel-gfx] [PATCH v2] drm/i915/selftests: Try to detect rollback during batchbuffer preemption
@ 2020-04-22 10:09 Chris Wilson
2020-04-22 11:26 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/selftests: Try to detect rollback during batchbuffer preemption (rev2) Patchwork
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Chris Wilson @ 2020-04-22 10:09 UTC (permalink / raw)
To: intel-gfx; +Cc: Chris Wilson
Since batch buffers dominant execution time, most preemption requests
should naturally occur during execution of a batch buffer. We wish to
verify that should a preemption occur within a batch buffer, when we
come to restart that batch buffer, it occurs at the interrupted
instruction and most importantly does not rollback to an earlier point.
v2: Do not clear the GPR at the start of the batch, but rely on them
being clear for new contexts.
Suggested-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
drivers/gpu/drm/i915/gt/selftest_lrc.c | 329 ++++++++++++++++++++++++-
1 file changed, 328 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
index 6f5e35afe1b2..fc3f9a248764 100644
--- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
+++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
@@ -21,7 +21,8 @@
#include "gem/selftests/mock_context.h"
#define CS_GPR(engine, n) ((engine)->mmio_base + 0x600 + (n) * 4)
-#define NUM_GPR_DW (16 * 2) /* each GPR is 2 dwords */
+#define NUM_GPR 16
+#define NUM_GPR_DW (NUM_GPR * 2) /* each GPR is 2 dwords */
static struct i915_vma *create_scratch(struct intel_gt *gt)
{
@@ -2791,6 +2792,331 @@ static int live_preempt_gang(void *arg)
return 0;
}
+static struct i915_vma *
+create_gpr_user(struct intel_engine_cs *engine,
+ struct i915_vma *result,
+ unsigned int offset)
+{
+ struct drm_i915_gem_object *obj;
+ struct i915_vma *vma;
+ u32 *cs;
+ int err;
+ int i;
+
+ obj = i915_gem_object_create_internal(engine->i915, 4096);
+ if (IS_ERR(obj))
+ return ERR_CAST(obj);
+
+ vma = i915_vma_instance(obj, result->vm, NULL);
+ if (IS_ERR(vma)) {
+ i915_gem_object_put(obj);
+ return vma;
+ }
+
+ err = i915_vma_pin(vma, 0, 0, PIN_USER);
+ if (err) {
+ i915_vma_put(vma);
+ return ERR_PTR(err);
+ }
+
+ cs = i915_gem_object_pin_map(obj, I915_MAP_WC);
+ if (IS_ERR(cs)) {
+ i915_vma_put(vma);
+ return ERR_CAST(cs);
+ }
+
+ /* All GPR are clear for new contexts. We use GPR(0) as a constant */
+ *cs++ = MI_LOAD_REGISTER_IMM(1);
+ *cs++ = CS_GPR(engine, 0);
+ *cs++ = 1;
+
+ for (i = 1; i < NUM_GPR; i++) {
+ u64 addr;
+
+ /*
+ * Perform: GPR[i]++
+ *
+ * As we read and write into the context saved GPR[i], if
+ * we restart this batch buffer from an earlier point, we
+ * will repeat the increment and store a value > 1.
+ */
+ *cs++ = MI_MATH(4);
+ *cs++ = MI_MATH_LOAD(MI_MATH_REG_SRCA, MI_MATH_REG(i));
+ *cs++ = MI_MATH_LOAD(MI_MATH_REG_SRCB, MI_MATH_REG(0));
+ *cs++ = MI_MATH_ADD;
+ *cs++ = MI_MATH_STORE(MI_MATH_REG(i), MI_MATH_REG_ACCU);
+
+ addr = result->node.start + offset + i * sizeof(*cs);
+ *cs++ = MI_STORE_REGISTER_MEM_GEN8;
+ *cs++ = CS_GPR(engine, 2 * i);
+ *cs++ = lower_32_bits(addr);
+ *cs++ = upper_32_bits(addr);
+
+ *cs++ = MI_SEMAPHORE_WAIT |
+ MI_SEMAPHORE_POLL |
+ MI_SEMAPHORE_SAD_GTE_SDD;
+ *cs++ = i;
+ *cs++ = lower_32_bits(result->node.start);
+ *cs++ = upper_32_bits(result->node.start);
+ }
+
+ *cs++ = MI_BATCH_BUFFER_END;
+ i915_gem_object_flush_map(obj);
+ i915_gem_object_unpin_map(obj);
+
+ return vma;
+}
+
+static struct i915_vma *create_global(struct intel_gt *gt, size_t sz)
+{
+ struct drm_i915_gem_object *obj;
+ struct i915_vma *vma;
+ int err;
+
+ obj = i915_gem_object_create_internal(gt->i915, sz);
+ if (IS_ERR(obj))
+ return ERR_CAST(obj);
+
+ vma = i915_vma_instance(obj, >->ggtt->vm, NULL);
+ if (IS_ERR(vma)) {
+ i915_gem_object_put(obj);
+ return vma;
+ }
+
+ err = i915_ggtt_pin(vma, 0, 0);
+ if (err) {
+ i915_vma_put(vma);
+ return ERR_PTR(err);
+ }
+
+ return vma;
+}
+
+static struct i915_request *
+create_gpr_client(struct intel_engine_cs *engine,
+ struct i915_vma *global,
+ unsigned int offset)
+{
+ struct i915_vma *batch, *vma;
+ struct intel_context *ce;
+ struct i915_request *rq;
+ int err;
+
+ ce = intel_context_create(engine);
+ if (IS_ERR(ce))
+ return ERR_CAST(ce);
+
+ vma = i915_vma_instance(global->obj, ce->vm, NULL);
+ if (IS_ERR(vma)) {
+ err = PTR_ERR(vma);
+ goto out_ce;
+ }
+
+ err = i915_vma_pin(vma, 0, 0, PIN_USER);
+ if (err)
+ goto out_ce;
+
+ batch = create_gpr_user(engine, vma, offset);
+ if (IS_ERR(batch)) {
+ err = PTR_ERR(batch);
+ goto out_vma;
+ }
+
+ rq = intel_context_create_request(ce);
+ if (IS_ERR(rq)) {
+ err = PTR_ERR(rq);
+ goto out_batch;
+ }
+
+ i915_vma_lock(vma);
+ err = i915_request_await_object(rq, vma->obj, false);
+ if (!err)
+ err = i915_vma_move_to_active(vma, rq, 0);
+ i915_vma_unlock(vma);
+
+ i915_vma_lock(batch);
+ if (!err)
+ err = i915_request_await_object(rq, batch->obj, false);
+ if (!err)
+ err = i915_vma_move_to_active(batch, rq, 0);
+ if (!err)
+ err = rq->engine->emit_bb_start(rq,
+ batch->node.start,
+ PAGE_SIZE, 0);
+ i915_vma_unlock(batch);
+ i915_vma_unpin(batch);
+
+ if (!err)
+ i915_request_get(rq);
+ i915_request_add(rq);
+
+out_batch:
+ i915_vma_put(batch);
+out_vma:
+ i915_vma_unpin(vma);
+out_ce:
+ intel_context_put(ce);
+ return err ? ERR_PTR(err) : rq;
+}
+
+static int preempt_user(struct intel_engine_cs *engine,
+ struct i915_vma *global,
+ int id)
+{
+ struct i915_sched_attr attr = {
+ .priority = I915_PRIORITY_MAX
+ };
+ struct i915_request *rq;
+ int err = 0;
+ u32 *cs;
+
+ rq = intel_engine_create_kernel_request(engine);
+ if (IS_ERR(rq))
+ return PTR_ERR(rq);
+
+ cs = intel_ring_begin(rq, 4);
+ if (IS_ERR(cs)) {
+ i915_request_add(rq);
+ return PTR_ERR(cs);
+ }
+
+ *cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
+ *cs++ = i915_ggtt_offset(global);
+ *cs++ = 0;
+ *cs++ = id;
+
+ intel_ring_advance(rq, cs);
+
+ i915_request_get(rq);
+ i915_request_add(rq);
+
+ engine->schedule(rq, &attr);
+
+ if (i915_request_wait(rq, 0, HZ / 2) < 0)
+ err = -ETIME;
+ i915_request_put(rq);
+
+ return err;
+}
+
+static int live_preempt_user(void *arg)
+{
+ struct intel_gt *gt = arg;
+ struct intel_engine_cs *engine;
+ struct i915_vma *global;
+ enum intel_engine_id id;
+ u32 *result;
+ int err = 0;
+
+ if (!HAS_LOGICAL_RING_PREEMPTION(gt->i915))
+ return 0;
+
+ /*
+ * In our other tests, we look at preemption in carefully
+ * controlled conditions in the ringbuffer. Since most of the
+ * time is spent in user batches, most of our preemptions naturally
+ * occur there. We want to verify that when we preempt inside a batch
+ * we continue on from the current instruction and do not roll back
+ * to the start, or another earlier arbitration point.
+ *
+ * To verify this, we create a batch which is a mixture of
+ * MI_MATH (gpr++) MI_SRM (gpr) and preemption points. Then with
+ * a few preempting contexts thrown into the mix, we look for any
+ * repeated instructions (which show up as incorrect values).
+ */
+
+ global = create_global(gt, 4096);
+ if (IS_ERR(global))
+ return PTR_ERR(global);
+
+ result = i915_gem_object_pin_map(global->obj, I915_MAP_WC);
+ if (IS_ERR(result)) {
+ i915_vma_unpin_and_release(&global, 0);
+ return PTR_ERR(result);
+ }
+
+ for_each_engine(engine, gt, id) {
+ struct i915_request *client[3] = {};
+ struct igt_live_test t;
+ int i;
+
+ if (!intel_engine_has_preemption(engine))
+ continue;
+
+ if (IS_GEN(gt->i915, 8) && engine->class != RENDER_CLASS)
+ continue; /* we need per-context GPR */
+
+ if (igt_live_test_begin(&t, gt->i915, __func__, engine->name)) {
+ err = -EIO;
+ break;
+ }
+
+ memset(result, 0, 4096);
+
+ for (i = 0; i < ARRAY_SIZE(client); i++) {
+ struct i915_request *rq;
+
+ rq = create_gpr_client(engine, global,
+ NUM_GPR * i * sizeof(u32));
+ if (IS_ERR(rq))
+ goto end_test;
+
+ client[i] = rq;
+ }
+
+ /* Continuously preempt the set of 3 running contexts */
+ for (i = 1; i <= NUM_GPR; i++) {
+ err = preempt_user(engine, global, i);
+ if (err)
+ goto end_test;
+ }
+
+ if (READ_ONCE(result[0]) != NUM_GPR) {
+ pr_err("%s: Failed to release semaphore\n",
+ engine->name);
+ err = -EIO;
+ goto end_test;
+ }
+
+ for (i = 0; i < ARRAY_SIZE(client); i++) {
+ int gpr;
+
+ if (i915_request_wait(client[i], 0, HZ / 2) < 0) {
+ err = -ETIME;
+ goto end_test;
+ }
+
+ for (gpr = 1; gpr < NUM_GPR; gpr++) {
+ if (result[NUM_GPR * i + gpr] != 1) {
+ pr_err("%s: Invalid result, client %d, gpr %d, result: %d\n",
+ engine->name,
+ i, gpr, result[NUM_GPR * i + gpr]);
+ err = -EINVAL;
+ goto end_test;
+ }
+ }
+ }
+
+end_test:
+ for (i = 0; i < ARRAY_SIZE(client); i++) {
+ if (!client[i])
+ break;
+
+ i915_request_put(client[i]);
+ }
+
+ /* Flush the semaphores on error */
+ smp_store_mb(result[0], -1);
+ if (igt_live_test_end(&t))
+ err = -EIO;
+ if (err)
+ break;
+ }
+
+ i915_vma_unpin_and_release(&global, I915_VMA_RELEASE_MAP);
+ return err;
+}
+
static int live_preempt_timeout(void *arg)
{
struct intel_gt *gt = arg;
@@ -3998,6 +4324,7 @@ int intel_execlists_live_selftests(struct drm_i915_private *i915)
SUBTEST(live_chain_preempt),
SUBTEST(live_preempt_gang),
SUBTEST(live_preempt_timeout),
+ SUBTEST(live_preempt_user),
SUBTEST(live_preempt_smoke),
SUBTEST(live_virtual_engine),
SUBTEST(live_virtual_mask),
--
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] 4+ messages in thread
* [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/selftests: Try to detect rollback during batchbuffer preemption (rev2)
2020-04-22 10:09 [Intel-gfx] [PATCH v2] drm/i915/selftests: Try to detect rollback during batchbuffer preemption Chris Wilson
@ 2020-04-22 11:26 ` Patchwork
2020-04-22 13:04 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2020-04-22 14:14 ` [Intel-gfx] [PATCH v2] drm/i915/selftests: Try to detect rollback during batchbuffer preemption Mika Kuoppala
2 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2020-04-22 11:26 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: drm/i915/selftests: Try to detect rollback during batchbuffer preemption (rev2)
URL : https://patchwork.freedesktop.org/series/76279/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_8348 -> Patchwork_17417
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/index.html
Known issues
------------
Here are the changes found in Patchwork_17417 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_selftest@live@requests:
- fi-snb-2600: [PASS][1] -> [FAIL][2] ([i915#1763])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/fi-snb-2600/igt@i915_selftest@live@requests.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/fi-snb-2600/igt@i915_selftest@live@requests.html
#### Possible fixes ####
* igt@i915_selftest@live@hugepages:
- fi-snb-2600: [FAIL][3] ([i915#1763]) -> [PASS][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/fi-snb-2600/igt@i915_selftest@live@hugepages.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/fi-snb-2600/igt@i915_selftest@live@hugepages.html
[i915#1763]: https://gitlab.freedesktop.org/drm/intel/issues/1763
Participating hosts (48 -> 42)
------------------------------
Missing (6): fi-cml-u2 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-byt-clapper fi-bdw-samus
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_8348 -> Patchwork_17417
CI-20190529: 20190529
CI_DRM_8348: 71482e0c1b4ce12ad43e790a0c03d671caf1eb54 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5604: 18cc19ece602ba552a8386222b49e7e82820f9aa @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_17417: 1f59338755f11ce43bafa2dc0dbd4a1d68c3d1b5 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
1f59338755f1 drm/i915/selftests: Try to detect rollback during batchbuffer preemption
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Intel-gfx] ✓ Fi.CI.IGT: success for drm/i915/selftests: Try to detect rollback during batchbuffer preemption (rev2)
2020-04-22 10:09 [Intel-gfx] [PATCH v2] drm/i915/selftests: Try to detect rollback during batchbuffer preemption Chris Wilson
2020-04-22 11:26 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/selftests: Try to detect rollback during batchbuffer preemption (rev2) Patchwork
@ 2020-04-22 13:04 ` Patchwork
2020-04-22 14:14 ` [Intel-gfx] [PATCH v2] drm/i915/selftests: Try to detect rollback during batchbuffer preemption Mika Kuoppala
2 siblings, 0 replies; 4+ messages in thread
From: Patchwork @ 2020-04-22 13:04 UTC (permalink / raw)
To: Chris Wilson; +Cc: intel-gfx
== Series Details ==
Series: drm/i915/selftests: Try to detect rollback during batchbuffer preemption (rev2)
URL : https://patchwork.freedesktop.org/series/76279/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_8348_full -> Patchwork_17417_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
Known issues
------------
Here are the changes found in Patchwork_17417_full that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@i915_selftest@perf@engine_cs:
- shard-snb: [PASS][1] -> [FAIL][2] ([i915#1763])
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-snb4/igt@i915_selftest@perf@engine_cs.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-snb2/igt@i915_selftest@perf@engine_cs.html
* igt@kms_cursor_crc@pipe-a-cursor-64x21-random:
- shard-skl: [PASS][3] -> [FAIL][4] ([i915#54])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-skl7/igt@kms_cursor_crc@pipe-a-cursor-64x21-random.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-skl6/igt@kms_cursor_crc@pipe-a-cursor-64x21-random.html
* igt@kms_cursor_crc@pipe-a-cursor-64x64-onscreen:
- shard-kbl: [PASS][5] -> [FAIL][6] ([i915#54] / [i915#93] / [i915#95])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-kbl7/igt@kms_cursor_crc@pipe-a-cursor-64x64-onscreen.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-kbl2/igt@kms_cursor_crc@pipe-a-cursor-64x64-onscreen.html
* igt@kms_draw_crc@draw-method-rgb565-mmap-wc-xtiled:
- shard-glk: [PASS][7] -> [FAIL][8] ([i915#52] / [i915#54]) +1 similar issue
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-glk2/igt@kms_draw_crc@draw-method-rgb565-mmap-wc-xtiled.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-glk1/igt@kms_draw_crc@draw-method-rgb565-mmap-wc-xtiled.html
* igt@kms_flip_tiling@flip-to-y-tiled:
- shard-skl: [PASS][9] -> [FAIL][10] ([i915#167])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-skl6/igt@kms_flip_tiling@flip-to-y-tiled.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-skl4/igt@kms_flip_tiling@flip-to-y-tiled.html
* igt@kms_frontbuffer_tracking@psr-1p-offscren-pri-shrfb-draw-mmap-wc:
- shard-skl: [PASS][11] -> [FAIL][12] ([i915#49])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-skl7/igt@kms_frontbuffer_tracking@psr-1p-offscren-pri-shrfb-draw-mmap-wc.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-skl6/igt@kms_frontbuffer_tracking@psr-1p-offscren-pri-shrfb-draw-mmap-wc.html
* igt@kms_hdr@bpc-switch-suspend:
- shard-kbl: [PASS][13] -> [DMESG-WARN][14] ([i915#180]) +2 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-kbl3/igt@kms_hdr@bpc-switch-suspend.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-kbl3/igt@kms_hdr@bpc-switch-suspend.html
* igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min:
- shard-skl: [PASS][15] -> [FAIL][16] ([fdo#108145] / [i915#265])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-skl7/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-skl6/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html
* igt@kms_vblank@pipe-a-ts-continuation-suspend:
- shard-apl: [PASS][17] -> [DMESG-WARN][18] ([i915#180]) +1 similar issue
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-apl1/igt@kms_vblank@pipe-a-ts-continuation-suspend.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-apl4/igt@kms_vblank@pipe-a-ts-continuation-suspend.html
#### Possible fixes ####
* {igt@gem_ctx_isolation@preservation-s3@bcs0}:
- shard-kbl: [DMESG-WARN][19] ([i915#180]) -> [PASS][20] +4 similar issues
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-kbl6/igt@gem_ctx_isolation@preservation-s3@bcs0.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-kbl7/igt@gem_ctx_isolation@preservation-s3@bcs0.html
* igt@gem_exec_balancer@bonded-slice:
- shard-kbl: [FAIL][21] ([i915#1292] / [i915#93] / [i915#95]) -> [PASS][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-kbl4/igt@gem_exec_balancer@bonded-slice.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-kbl6/igt@gem_exec_balancer@bonded-slice.html
* igt@gem_exec_params@invalid-bsd-ring:
- shard-iclb: [SKIP][23] ([fdo#109276]) -> [PASS][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-iclb3/igt@gem_exec_params@invalid-bsd-ring.html
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-iclb1/igt@gem_exec_params@invalid-bsd-ring.html
* igt@i915_selftest@live@hangcheck:
- shard-iclb: [INCOMPLETE][25] ([i915#1580]) -> [PASS][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-iclb5/igt@i915_selftest@live@hangcheck.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-iclb4/igt@i915_selftest@live@hangcheck.html
* igt@kms_big_fb@x-tiled-16bpp-rotate-0:
- shard-glk: [FAIL][27] ([i915#1119]) -> [PASS][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-glk5/igt@kms_big_fb@x-tiled-16bpp-rotate-0.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-glk7/igt@kms_big_fb@x-tiled-16bpp-rotate-0.html
* {igt@kms_flip@flip-vs-expired-vblank@c-edp1}:
- shard-skl: [FAIL][29] ([i915#79]) -> [PASS][30]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-skl3/igt@kms_flip@flip-vs-expired-vblank@c-edp1.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-skl10/igt@kms_flip@flip-vs-expired-vblank@c-edp1.html
* igt@kms_hdr@bpc-switch:
- shard-skl: [FAIL][31] ([i915#1188]) -> [PASS][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-skl3/igt@kms_hdr@bpc-switch.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-skl10/igt@kms_hdr@bpc-switch.html
* igt@kms_psr@psr2_sprite_plane_move:
- shard-iclb: [SKIP][33] ([fdo#109441]) -> [PASS][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-iclb5/igt@kms_psr@psr2_sprite_plane_move.html
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-iclb2/igt@kms_psr@psr2_sprite_plane_move.html
* {igt@perf@blocking-parameterized}:
- shard-hsw: [FAIL][35] ([i915#1542]) -> [PASS][36]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-hsw6/igt@perf@blocking-parameterized.html
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-hsw4/igt@perf@blocking-parameterized.html
#### Warnings ####
* igt@i915_pm_rpm@cursor-dpms:
- shard-snb: [INCOMPLETE][37] ([i915#82]) -> [SKIP][38] ([fdo#109271])
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-snb6/igt@i915_pm_rpm@cursor-dpms.html
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-snb6/igt@i915_pm_rpm@cursor-dpms.html
* igt@kms_cursor_crc@pipe-c-cursor-suspend:
- shard-kbl: [DMESG-WARN][39] ([i915#180]) -> [INCOMPLETE][40] ([i915#155])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8348/shard-kbl7/igt@kms_cursor_crc@pipe-c-cursor-suspend.html
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17417/shard-kbl1/igt@kms_cursor_crc@pipe-c-cursor-suspend.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
[fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
[i915#1119]: https://gitlab.freedesktop.org/drm/intel/issues/1119
[i915#1188]: https://gitlab.freedesktop.org/drm/intel/issues/1188
[i915#1292]: https://gitlab.freedesktop.org/drm/intel/issues/1292
[i915#1542]: https://gitlab.freedesktop.org/drm/intel/issues/1542
[i915#155]: https://gitlab.freedesktop.org/drm/intel/issues/155
[i915#1580]: https://gitlab.freedesktop.org/drm/intel/issues/1580
[i915#167]: https://gitlab.freedesktop.org/drm/intel/issues/167
[i915#1763]: https://gitlab.freedesktop.org/drm/intel/issues/1763
[i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
[i915#265]: https://gitlab.freedesktop.org/drm/intel/issues/265
[i915#34]: https://gitlab.freedesktop.org/drm/intel/issues/34
[i915#46]: https://gitlab.freedesktop.org/drm/intel/issues/46
[i915#49]: https://gitlab.freedesktop.org/drm/intel/issues/49
[i915#52]: https://gitlab.freedesktop.org/drm/intel/issues/52
[i915#54]: https://gitlab.freedesktop.org/drm/intel/issues/54
[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_8348 -> Patchwork_17417
CI-20190529: 20190529
CI_DRM_8348: 71482e0c1b4ce12ad43e790a0c03d671caf1eb54 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5604: 18cc19ece602ba552a8386222b49e7e82820f9aa @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_17417: 1f59338755f11ce43bafa2dc0dbd4a1d68c3d1b5 @ 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_17417/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Intel-gfx] [PATCH v2] drm/i915/selftests: Try to detect rollback during batchbuffer preemption
2020-04-22 10:09 [Intel-gfx] [PATCH v2] drm/i915/selftests: Try to detect rollback during batchbuffer preemption Chris Wilson
2020-04-22 11:26 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/selftests: Try to detect rollback during batchbuffer preemption (rev2) Patchwork
2020-04-22 13:04 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
@ 2020-04-22 14:14 ` Mika Kuoppala
2 siblings, 0 replies; 4+ messages in thread
From: Mika Kuoppala @ 2020-04-22 14:14 UTC (permalink / raw)
To: Chris Wilson, intel-gfx; +Cc: Chris Wilson
Chris Wilson <chris@chris-wilson.co.uk> writes:
> Since batch buffers dominant execution time, most preemption requests
> should naturally occur during execution of a batch buffer. We wish to
> verify that should a preemption occur within a batch buffer, when we
> come to restart that batch buffer, it occurs at the interrupted
> instruction and most importantly does not rollback to an earlier point.
>
> v2: Do not clear the GPR at the start of the batch, but rely on them
> being clear for new contexts.
>
> Suggested-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> ---
> drivers/gpu/drm/i915/gt/selftest_lrc.c | 329 ++++++++++++++++++++++++-
> 1 file changed, 328 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/selftest_lrc.c b/drivers/gpu/drm/i915/gt/selftest_lrc.c
> index 6f5e35afe1b2..fc3f9a248764 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_lrc.c
> @@ -21,7 +21,8 @@
> #include "gem/selftests/mock_context.h"
>
> #define CS_GPR(engine, n) ((engine)->mmio_base + 0x600 + (n) * 4)
> -#define NUM_GPR_DW (16 * 2) /* each GPR is 2 dwords */
> +#define NUM_GPR 16
> +#define NUM_GPR_DW (NUM_GPR * 2) /* each GPR is 2 dwords */
>
> static struct i915_vma *create_scratch(struct intel_gt *gt)
> {
> @@ -2791,6 +2792,331 @@ static int live_preempt_gang(void *arg)
> return 0;
> }
>
> +static struct i915_vma *
> +create_gpr_user(struct intel_engine_cs *engine,
> + struct i915_vma *result,
> + unsigned int offset)
> +{
> + struct drm_i915_gem_object *obj;
> + struct i915_vma *vma;
> + u32 *cs;
> + int err;
> + int i;
> +
> + obj = i915_gem_object_create_internal(engine->i915, 4096);
> + if (IS_ERR(obj))
> + return ERR_CAST(obj);
> +
> + vma = i915_vma_instance(obj, result->vm, NULL);
> + if (IS_ERR(vma)) {
> + i915_gem_object_put(obj);
> + return vma;
> + }
> +
> + err = i915_vma_pin(vma, 0, 0, PIN_USER);
> + if (err) {
> + i915_vma_put(vma);
> + return ERR_PTR(err);
> + }
> +
> + cs = i915_gem_object_pin_map(obj, I915_MAP_WC);
> + if (IS_ERR(cs)) {
> + i915_vma_put(vma);
> + return ERR_CAST(cs);
> + }
> +
> + /* All GPR are clear for new contexts. We use GPR(0) as a constant */
> + *cs++ = MI_LOAD_REGISTER_IMM(1);
> + *cs++ = CS_GPR(engine, 0);
> + *cs++ = 1;
> +
> + for (i = 1; i < NUM_GPR; i++) {
> + u64 addr;
> +
> + /*
> + * Perform: GPR[i]++
> + *
> + * As we read and write into the context saved GPR[i], if
> + * we restart this batch buffer from an earlier point, we
> + * will repeat the increment and store a value > 1.
> + */
Yes, this should show restarting from wrong spot.
I did ponder to put a conditional batch buffer start in the
end to replay the last addition to smoketest the test.
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> + *cs++ = MI_MATH(4);
> + *cs++ = MI_MATH_LOAD(MI_MATH_REG_SRCA, MI_MATH_REG(i));
> + *cs++ = MI_MATH_LOAD(MI_MATH_REG_SRCB, MI_MATH_REG(0));
> + *cs++ = MI_MATH_ADD;
> + *cs++ = MI_MATH_STORE(MI_MATH_REG(i), MI_MATH_REG_ACCU);
> +
> + addr = result->node.start + offset + i * sizeof(*cs);
> + *cs++ = MI_STORE_REGISTER_MEM_GEN8;
> + *cs++ = CS_GPR(engine, 2 * i);
> + *cs++ = lower_32_bits(addr);
> + *cs++ = upper_32_bits(addr);
> +
> + *cs++ = MI_SEMAPHORE_WAIT |
> + MI_SEMAPHORE_POLL |
> + MI_SEMAPHORE_SAD_GTE_SDD;
> + *cs++ = i;
> + *cs++ = lower_32_bits(result->node.start);
> + *cs++ = upper_32_bits(result->node.start);
> + }
> +
> + *cs++ = MI_BATCH_BUFFER_END;
> + i915_gem_object_flush_map(obj);
> + i915_gem_object_unpin_map(obj);
> +
> + return vma;
> +}
> +
> +static struct i915_vma *create_global(struct intel_gt *gt, size_t sz)
> +{
> + struct drm_i915_gem_object *obj;
> + struct i915_vma *vma;
> + int err;
> +
> + obj = i915_gem_object_create_internal(gt->i915, sz);
> + if (IS_ERR(obj))
> + return ERR_CAST(obj);
> +
> + vma = i915_vma_instance(obj, >->ggtt->vm, NULL);
> + if (IS_ERR(vma)) {
> + i915_gem_object_put(obj);
> + return vma;
> + }
> +
> + err = i915_ggtt_pin(vma, 0, 0);
> + if (err) {
> + i915_vma_put(vma);
> + return ERR_PTR(err);
> + }
> +
> + return vma;
> +}
> +
> +static struct i915_request *
> +create_gpr_client(struct intel_engine_cs *engine,
> + struct i915_vma *global,
> + unsigned int offset)
> +{
> + struct i915_vma *batch, *vma;
> + struct intel_context *ce;
> + struct i915_request *rq;
> + int err;
> +
> + ce = intel_context_create(engine);
> + if (IS_ERR(ce))
> + return ERR_CAST(ce);
> +
> + vma = i915_vma_instance(global->obj, ce->vm, NULL);
> + if (IS_ERR(vma)) {
> + err = PTR_ERR(vma);
> + goto out_ce;
> + }
> +
> + err = i915_vma_pin(vma, 0, 0, PIN_USER);
> + if (err)
> + goto out_ce;
> +
> + batch = create_gpr_user(engine, vma, offset);
> + if (IS_ERR(batch)) {
> + err = PTR_ERR(batch);
> + goto out_vma;
> + }
> +
> + rq = intel_context_create_request(ce);
> + if (IS_ERR(rq)) {
> + err = PTR_ERR(rq);
> + goto out_batch;
> + }
> +
> + i915_vma_lock(vma);
> + err = i915_request_await_object(rq, vma->obj, false);
> + if (!err)
> + err = i915_vma_move_to_active(vma, rq, 0);
> + i915_vma_unlock(vma);
> +
> + i915_vma_lock(batch);
> + if (!err)
> + err = i915_request_await_object(rq, batch->obj, false);
> + if (!err)
> + err = i915_vma_move_to_active(batch, rq, 0);
> + if (!err)
> + err = rq->engine->emit_bb_start(rq,
> + batch->node.start,
> + PAGE_SIZE, 0);
> + i915_vma_unlock(batch);
> + i915_vma_unpin(batch);
> +
> + if (!err)
> + i915_request_get(rq);
> + i915_request_add(rq);
> +
> +out_batch:
> + i915_vma_put(batch);
> +out_vma:
> + i915_vma_unpin(vma);
> +out_ce:
> + intel_context_put(ce);
> + return err ? ERR_PTR(err) : rq;
> +}
> +
> +static int preempt_user(struct intel_engine_cs *engine,
> + struct i915_vma *global,
> + int id)
> +{
> + struct i915_sched_attr attr = {
> + .priority = I915_PRIORITY_MAX
> + };
> + struct i915_request *rq;
> + int err = 0;
> + u32 *cs;
> +
> + rq = intel_engine_create_kernel_request(engine);
> + if (IS_ERR(rq))
> + return PTR_ERR(rq);
> +
> + cs = intel_ring_begin(rq, 4);
> + if (IS_ERR(cs)) {
> + i915_request_add(rq);
> + return PTR_ERR(cs);
> + }
> +
> + *cs++ = MI_STORE_DWORD_IMM_GEN4 | MI_USE_GGTT;
> + *cs++ = i915_ggtt_offset(global);
> + *cs++ = 0;
> + *cs++ = id;
> +
> + intel_ring_advance(rq, cs);
> +
> + i915_request_get(rq);
> + i915_request_add(rq);
> +
> + engine->schedule(rq, &attr);
> +
> + if (i915_request_wait(rq, 0, HZ / 2) < 0)
> + err = -ETIME;
> + i915_request_put(rq);
> +
> + return err;
> +}
> +
> +static int live_preempt_user(void *arg)
> +{
> + struct intel_gt *gt = arg;
> + struct intel_engine_cs *engine;
> + struct i915_vma *global;
> + enum intel_engine_id id;
> + u32 *result;
> + int err = 0;
> +
> + if (!HAS_LOGICAL_RING_PREEMPTION(gt->i915))
> + return 0;
> +
> + /*
> + * In our other tests, we look at preemption in carefully
> + * controlled conditions in the ringbuffer. Since most of the
> + * time is spent in user batches, most of our preemptions naturally
> + * occur there. We want to verify that when we preempt inside a batch
> + * we continue on from the current instruction and do not roll back
> + * to the start, or another earlier arbitration point.
> + *
> + * To verify this, we create a batch which is a mixture of
> + * MI_MATH (gpr++) MI_SRM (gpr) and preemption points. Then with
> + * a few preempting contexts thrown into the mix, we look for any
> + * repeated instructions (which show up as incorrect values).
> + */
> +
> + global = create_global(gt, 4096);
> + if (IS_ERR(global))
> + return PTR_ERR(global);
> +
> + result = i915_gem_object_pin_map(global->obj, I915_MAP_WC);
> + if (IS_ERR(result)) {
> + i915_vma_unpin_and_release(&global, 0);
> + return PTR_ERR(result);
> + }
> +
> + for_each_engine(engine, gt, id) {
> + struct i915_request *client[3] = {};
> + struct igt_live_test t;
> + int i;
> +
> + if (!intel_engine_has_preemption(engine))
> + continue;
> +
> + if (IS_GEN(gt->i915, 8) && engine->class != RENDER_CLASS)
> + continue; /* we need per-context GPR */
> +
> + if (igt_live_test_begin(&t, gt->i915, __func__, engine->name)) {
> + err = -EIO;
> + break;
> + }
> +
> + memset(result, 0, 4096);
> +
> + for (i = 0; i < ARRAY_SIZE(client); i++) {
> + struct i915_request *rq;
> +
> + rq = create_gpr_client(engine, global,
> + NUM_GPR * i * sizeof(u32));
> + if (IS_ERR(rq))
> + goto end_test;
> +
> + client[i] = rq;
> + }
> +
> + /* Continuously preempt the set of 3 running contexts */
> + for (i = 1; i <= NUM_GPR; i++) {
> + err = preempt_user(engine, global, i);
> + if (err)
> + goto end_test;
> + }
> +
> + if (READ_ONCE(result[0]) != NUM_GPR) {
> + pr_err("%s: Failed to release semaphore\n",
> + engine->name);
> + err = -EIO;
> + goto end_test;
> + }
> +
> + for (i = 0; i < ARRAY_SIZE(client); i++) {
> + int gpr;
> +
> + if (i915_request_wait(client[i], 0, HZ / 2) < 0) {
> + err = -ETIME;
> + goto end_test;
> + }
> +
> + for (gpr = 1; gpr < NUM_GPR; gpr++) {
> + if (result[NUM_GPR * i + gpr] != 1) {
> + pr_err("%s: Invalid result, client %d, gpr %d, result: %d\n",
> + engine->name,
> + i, gpr, result[NUM_GPR * i + gpr]);
> + err = -EINVAL;
> + goto end_test;
> + }
> + }
> + }
> +
> +end_test:
> + for (i = 0; i < ARRAY_SIZE(client); i++) {
> + if (!client[i])
> + break;
> +
> + i915_request_put(client[i]);
> + }
> +
> + /* Flush the semaphores on error */
> + smp_store_mb(result[0], -1);
> + if (igt_live_test_end(&t))
> + err = -EIO;
> + if (err)
> + break;
> + }
> +
> + i915_vma_unpin_and_release(&global, I915_VMA_RELEASE_MAP);
> + return err;
> +}
> +
> static int live_preempt_timeout(void *arg)
> {
> struct intel_gt *gt = arg;
> @@ -3998,6 +4324,7 @@ int intel_execlists_live_selftests(struct drm_i915_private *i915)
> SUBTEST(live_chain_preempt),
> SUBTEST(live_preempt_gang),
> SUBTEST(live_preempt_timeout),
> + SUBTEST(live_preempt_user),
> SUBTEST(live_preempt_smoke),
> SUBTEST(live_virtual_engine),
> SUBTEST(live_virtual_mask),
> --
> 2.20.1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-04-22 14:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-22 10:09 [Intel-gfx] [PATCH v2] drm/i915/selftests: Try to detect rollback during batchbuffer preemption Chris Wilson
2020-04-22 11:26 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/selftests: Try to detect rollback during batchbuffer preemption (rev2) Patchwork
2020-04-22 13:04 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2020-04-22 14:14 ` [Intel-gfx] [PATCH v2] drm/i915/selftests: Try to detect rollback during batchbuffer preemption Mika Kuoppala
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.