Skip to contentSkip to conversation

drm/i915/gtt: Setup guards in scratch page

PATCH New Mika Kuoppala 3 participants 6 messages Aug 22, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915/gtt: Setup guards in scratch page

There have been cases where GPU engine has managed to run past execbuffer ending due to reasons unknown at that time:
coherency problems, page table setup errors, hw glitches.

Let's try to contain a wild engine head by putting batch buffer end commands into start and end of scratch page. Leave two nops at start of page so it would catch the eye on error dumps.

Cc Chris Wilson <[email protected]>
Cc Matthew Auld <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.c +18 -0
index 4137af4bd8f5..56399dbf4558 100644
@@ -617,6 +617,21 @@ static void fill_page_dma_32(struct i915_address_space *vm,
 	fill_page_dma(vm, p, (u64)v << 32 | v);
 }
 
+static void setup_scratch_page_guards(struct i915_address_space *vm)
+{
+	struct i915_page_dma const *p = &vm->scratch_page;
+	u32 *scratch;
+	const unsigned int size = BIT(p->order) << PAGE_SHIFT;
+	const unsigned int last_idx = size / sizeof(*scratch) - 1;
+
+	scratch = kmap_atomic(p->page);
+
+	scratch[2] = MI_BATCH_BUFFER_END;
+	scratch[last_idx] = MI_BATCH_BUFFER_END;
+
+	kunmap_atomic(scratch);
+}
+
 static int
 setup_scratch_page(struct i915_address_space *vm, gfp_t gfp)
 {
@@ -665,6 +680,9 @@ setup_scratch_page(struct i915_address_space *vm, gfp_t gfp)
 		vm->scratch_page.page = page;
 		vm->scratch_page.daddr = addr;
 		vm->scratch_page.order = order;
+
+		setup_scratch_page_guards(vm);
+
 		return 0;
 
 unmap_page:
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH 1/1 drm/i915/gtt: Setup guards in scratch page

There have been cases where GPU engine has managed to run past execbuffer ending due to reasons unknown at that time:
coherency problems, page table setup errors, hw glitches.

Let's try to contain a wild engine head by putting batch buffer end commands into start and end of scratch page.

v2: add more signature

Cc Chris Wilson <[email protected]>
Cc Matthew Auld <[email protected]>
---
 drivers/gpu/drm/i915/i915_gem_gtt.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
drivers/gpu/drm/i915/i915_gem_gtt.c +21 -0
index 4137af4bd8f5..3c617874ee7c 100644
@@ -617,6 +617,24 @@ static void fill_page_dma_32(struct i915_address_space *vm,
 	fill_page_dma(vm, p, (u64)v << 32 | v);
 }
 
+static void setup_scratch_page_guards(struct i915_address_space *vm)
+{
+	struct i915_page_dma const *p = &vm->scratch_page;
+	u32 *scratch;
+	const unsigned int size = BIT(p->order) << PAGE_SHIFT;
+	const unsigned int last_idx = size / sizeof(*scratch) - 1;
+
+	scratch = kmap_atomic(p->page);
+
+	scratch[0] = MI_BATCH_BUFFER_END;
+	scratch[1] = MI_BATCH_BUFFER_END;
+
+	scratch[last_idx - 1] = MI_BATCH_BUFFER_END;
+	scratch[last_idx] = MI_BATCH_BUFFER_END;
+
+	kunmap_atomic(scratch);
+}
+
 static int
 setup_scratch_page(struct i915_address_space *vm, gfp_t gfp)
 {
@@ -665,6 +683,9 @@ setup_scratch_page(struct i915_address_space *vm, gfp_t gfp)
 		vm->scratch_page.page = page;
 		vm->scratch_page.daddr = addr;
 		vm->scratch_page.order = order;
+
+		setup_scratch_page_guards(vm);
+
 		return 0;
 
 unmap_page:
Signature · 6 lines
2.17.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Quoting Mika Kuoppala (2018-08-22 14:27:14)

Quoted 3 lines

There have been cases where GPU engine has managed to run past execbuffer ending due to reasons unknown at that time:
coherency problems, page table setup errors, hw glitches.

You are trading an obvious error for a subtle one; if userspace got its batch wrong and doesn't die, the output will likely be wrong instead.

mesa/src/intel/tools/intel_sanitize_gpu for how userspace could do this detection itself. You can intercept the execbuf, place a canary after the batch and report if the canary gets written.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

✗ Fi.CI.SPARSE: warning for drm/i915/gtt: Setup guards in scratch page (rev2)

In reply to Mika Kuoppala
== Series Details ==

== Series Details ==

Series: drm/i915/gtt: Setup guards in scratch page (rev2)
URL : https://patchwork.freedesktop.org/series/48565/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Commit: drm/i915/gtt: Setup guards in scratch page
+drivers/gpu/drm/i915/i915_gem_gtt.c:1017:9: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/i915_gem_gtt.c:1017:9: warning: expression using sizeof(void)
-drivers/gpu/drm/i915/i915_gem_gtt.c:1017:9: warning: expression using sizeof(void)
-drivers/gpu/drm/i915/i915_gem_gtt.c:1017:9: warning: expression using sizeof(void)

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

✓ Fi.CI.BAT: success for drm/i915/gtt: Setup guards in scratch page (rev2)

In reply to Mika Kuoppala
== Series Details ==

== Series Details ==

Series: drm/i915/gtt: Setup guards in scratch page (rev2)
URL : https://patchwork.freedesktop.org/series/48565/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4695 -> Patchwork_9990 =

== Summary - SUCCESS ==

No regressions found.

External URL: https://patchwork.freedesktop.org/api/1.0/series/48565/revisions/2/mbox/

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_9990:

=== IGT changes ===

    ==== Possible regressions ====

    {igt@pm_rpm@module-reload}:
      fi-byt-j1900:       NOTRUN -> DMESG-WARN

== Known issues ==

Here are the changes found in Patchwork_9990 that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_coherency:
      fi-gdg-551:         PASS -> DMESG-FAIL (fdo#107164)

    igt@drv_selftest@live_hangcheck:
      fi-kbl-7560u:       PASS -> DMESG-FAIL (fdo#106947, fdo#106560)
      fi-skl-guc:         PASS -> DMESG-FAIL (fdo#107174)

    {igt@kms_psr@primary_page_flip}:
      {fi-icl-u}:         NOTRUN -> FAIL (fdo#107383) +3

    {igt@pm_rpm@module-reload}:
      fi-cnl-psr:         PASS -> WARN (fdo#107602)

    
    ==== Possible fixes ====

    igt@drv_selftest@live_hangcheck:
      {fi-cfl-8109u}:     DMESG-FAIL (fdo#106560) -> PASS

    igt@kms_frontbuffer_tracking@basic:
      {fi-byt-clapper}:   FAIL (fdo#103167) -> PASS

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
fdo#106947 https://bugs.freedesktop.org/show_bug.cgi?id=106947
fdo#107164 https://bugs.freedesktop.org/show_bug.cgi?id=107164
fdo#107174 https://bugs.freedesktop.org/show_bug.cgi?id=107174
fdo#107383 https://bugs.freedesktop.org/show_bug.cgi?id=107383
fdo#107602 https://bugs.freedesktop.org/show_bug.cgi?id=107602

== Participating hosts (52 -> 48) ==

Additional (2): fi-byt-j1900 fi-icl-u
Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-bdw-samus

== Build changes ==

* Linux: CI_DRM_4695 -> Patchwork_9990

CI_DRM_4695: f352837700ec39dbaf00cdf727650851993d754b @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4608: 94ebd21177feedf03e8f6dd1e73dca1a6ec7a0ac @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9990: 39443beee0c02518071ab487cb3aa557dd9d5ce1 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

39443beee0c0 drm/i915/gtt: Setup guards in scratch page

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9990/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

✓ Fi.CI.IGT: success for drm/i915/gtt: Setup guards in scratch page (rev2)

In reply to Mika Kuoppala
== Series Details ==

== Series Details ==

Series: drm/i915/gtt: Setup guards in scratch page (rev2)
URL : https://patchwork.freedesktop.org/series/48565/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4695_full -> Patchwork_9990_full =

== Summary - WARNING ==

Minor unknown changes coming with Patchwork_9990_full need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_9990_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.

== Possible new issues ==

Here are the unknown changes that may have been introduced in Patchwork_9990_full:

=== IGT changes ===

    ==== Warnings ====

    igt@kms_chv_cursor_fail@pipe-a-128x128-right-edge:
      shard-snb:          PASS -> SKIP +2

== Known issues ==

Here are the changes found in Patchwork_9990_full that come from known issues:

=== IGT changes ===

    ==== Issues hit ====

    igt@kms_setmode@basic:
      shard-apl:          PASS -> FAIL (fdo#99912)

    
    ==== Possible fixes ====

    igt@kms_flip@flip-vs-expired-vblank:
      shard-glk:          FAIL (fdo#105363) -> PASS

fdo#105363 https://bugs.freedesktop.org/show_bug.cgi?id=105363
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912

== Participating hosts (5 -> 5) ==

No changes in participating hosts

== Build changes ==

* Linux: CI_DRM_4695 -> Patchwork_9990

CI_DRM_4695: f352837700ec39dbaf00cdf727650851993d754b @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4608: 94ebd21177feedf03e8f6dd1e73dca1a6ec7a0ac @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_9990: 39443beee0c02518071ab487cb3aa557dd9d5ce1 @ 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_9990/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx