drm/i915/migrate: Account for the reserved_space
Subsystems (3)
PATCH v5 1/3 drm/i915/migrate: Account for the reserved_space
From: Chris Wilson <[email protected]>
If the ring is nearly full when calling into emit_pte(), we might incorrectly trample the reserved_space when constructing the packet to emit the PTEs. This then triggers the GEM_BUG_ON(rq->reserved_space > ring->space) when later submitting the request, since the request itself doesn't have enough space left in the ring to emit things like workarounds, breadcrumbs etc.
Testcase: igt@i915_selftests@live_emit_pte_full_ring
--- drivers/gpu/drm/i915/gt/intel_migrate.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/gt/intel_migrate.c +12 -4
@@ -342,6 +342,16 @@ static int emit_no_arbitration(struct i915_request *rq)return 0 ; } +static int max_pte_pkt_size (struct i915_request *rq,int pkt) +{ +struct intel_ring *ring = rq->ring; + + pkt =min_t (int, pkt, (ring->space - rq->reserved_space) /sizeof (u32) +5 ); + pkt =min_t (int, pkt, (ring->size - ring->emit) /sizeof (u32) +5 ); + +return pkt; +} + static int emit_pte(struct i915_request *rq, struct sgt_dma *it, enum i915_cache_level cache_level,
@@ -388,8 +398,7 @@ static int emit_pte(struct i915_request *rq,return PTR_ERR (cs);/* Pack as many PTE updates as possible into a single MI command */ - pkt =min_t (int, dword_length, ring->space /sizeof (u32) +5 ); - pkt =min_t (int, pkt, (ring->size - ring->emit) /sizeof (u32) +5 ); + pkt =max_pte_pkt_size (rq, dword_length); hdr = cs; *cs++ =MI_STORE_DATA_IMM |REG_BIT (21 );/* as qword elements */
@@ -422,8 +431,7 @@ static int emit_pte(struct i915_request *rq, } } - pkt =min_t (int, dword_rem, ring->space /sizeof (u32) +5 ); - pkt =min_t (int, pkt, (ring->size - ring->emit) /sizeof (u32) +5 ); + pkt =max_pte_pkt_size (rq, dword_rem); hdr = cs; *cs++ =MI_STORE_DATA_IMM |REG_BIT (21 );
Signature · 1 line
2.38.1
PATCH v5 2/3 drm/i915/selftests: use live_subtests for live_migrate
Probably a good idea to do an igt_flush_test() at the end of each subtest, just to be sure the previous work has been flushed and doesn't somehow interfere with the current subtest.
--- drivers/gpu/drm/i915/gt/selftest_migrate.c | 28 ++++++++++++++++------ 1 file changed, 21 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/gt/selftest_migrate.c +21 -7
@@ -486,7 +486,8 @@ global_clear(struct intel_migrate *migrate, u32 sz, struct rnd_state *prng)static int live_migrate_copy (void *arg) { -struct intel_migrate *migrate = arg; +struct intel_gt *gt = arg; +struct intel_migrate *migrate = >->migrate;struct drm_i915_private *i915 = migrate->context->engine->i915;I915_RND_STATE (prng);int i;
@@ -507,7 +508,8 @@ static int live_migrate_copy(void *arg)static int live_migrate_clear (void *arg) { -struct intel_migrate *migrate = arg; +struct intel_gt *gt = arg; +struct intel_migrate *migrate = >->migrate;struct drm_i915_private *i915 = migrate->context->engine->i915;I915_RND_STATE (prng);int i;
@@ -593,7 +595,10 @@ static int __thread_migrate_copy(void *arg)static int thread_migrate_copy (void *arg) { -return threaded_migrate (arg, __thread_migrate_copy,0 ); +struct intel_gt *gt = arg; +struct intel_migrate *migrate = >->migrate; + +return threaded_migrate (migrate, __thread_migrate_copy,0 ); }static int __thread_global_copy (void *arg)
@@ -605,7 +610,10 @@ static int __thread_global_copy(void *arg)static int thread_global_copy (void *arg) { -return threaded_migrate (arg, __thread_global_copy,0 ); +struct intel_gt *gt = arg; +struct intel_migrate *migrate = >->migrate; + +return threaded_migrate (migrate, __thread_global_copy,0 ); }static int __thread_migrate_clear (void *arg)
@@ -624,12 +632,18 @@ static int __thread_global_clear(void *arg)static int thread_migrate_clear (void *arg) { -return threaded_migrate (arg, __thread_migrate_clear,0 ); +struct intel_gt *gt = arg; +struct intel_migrate *migrate = >->migrate; + +return threaded_migrate (migrate, __thread_migrate_clear,0 ); }static int thread_global_clear (void *arg) { -return threaded_migrate (arg, __thread_global_clear,0 ); +struct intel_gt *gt = arg; +struct intel_migrate *migrate = >->migrate; + +return threaded_migrate (migrate, __thread_global_clear,0 ); }int intel_migrate_live_selftests (struct drm_i915_private *i915)
@@ -647,7 +661,7 @@ int intel_migrate_live_selftests(struct drm_i915_private *i915)if (!gt->migrate.context)return 0 ; -return i915_subtests (tests, >->migrate); +return intel_gt_live_subtests (tests, gt); } static struct drm_i915_gem_object *
Signature · 1 line
2.38.1
PATCH v5 3/3 drm/i915/selftests: exercise emit_pte() with nearly full ring
In reply to Matthew AuldSimple regression test to check that we don't trample the rq->reserved_space when returning from emit_pte(), if the ring is nearly full.
v2: Make spinner_kill() static
v3: Reduce the ring size further, which should mean we need to execute less
noops; hopefully this appeases bsw. Also add some debug logging.
v4: Fix the min request construction to account for reserved_space +
I915_EMIT_PTE_NUM_DWORDS
v5: Use a simple on-stack timer to kill the spinner instead of kthread (Chris)
References: https://gitlab.freedesktop.org/drm/intel/-/issues/7535
References: https://gitlab.freedesktop.org/drm/intel/-/issues/6889
--- drivers/gpu/drm/i915/gt/intel_migrate.c | 6 +- drivers/gpu/drm/i915/gt/selftest_migrate.c | 145 +++++++++++++++++++++ 2 files changed, 149 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/gt/intel_migrate.c +4 -2
@@ -352,6 +352,8 @@ static int max_pte_pkt_size(struct i915_request *rq, int pkt)return pkt; } +#define I915_EMIT_PTE_NUM_DWORDS 6 + static int emit_pte(struct i915_request *rq, struct sgt_dma *it, enum i915_cache_level cache_level,
@@ -393,7 +395,7 @@ static int emit_pte(struct i915_request *rq, offset += (u64 )rq->engine->instance <<32 ; - cs =intel_ring_begin (rq,6 ); + cs =intel_ring_begin (rq,I915_EMIT_PTE_NUM_DWORDS );if (IS_ERR (cs))return PTR_ERR (cs);
@@ -416,7 +418,7 @@ static int emit_pte(struct i915_request *rq,intel_ring_advance (rq, cs);intel_ring_update_space (ring); - cs =intel_ring_begin (rq,6 ); + cs =intel_ring_begin (rq,I915_EMIT_PTE_NUM_DWORDS );if (IS_ERR (cs))return PTR_ERR (cs);
drivers/gpu/drm/i915/gt/selftest_migrate.c +145 -0
163 lines not on this page · raw message
Signature · 1 line
2.38.1
Patchwork
CI[Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [v5,1/3] drm/i915/migrate: Account for the reserved_space
In reply to Matthew Auld== Series Details ==
== Series Details ==
Series: series starting with [v5,1/3] drm/i915/migrate: Account for the reserved_space
URL : https://patchwork.freedesktop.org/series/111577/
State : warning
== Summary ==
Error: dim checkpatch failed977e2603928c drm/i915/migrate: Account for the reserved_space -:36: WARNING:LEADING_SPACE: please, no spaces at the start of a line #36: FILE: drivers/gpu/drm/i915/gt/intel_migrate.c:347:
+ struct intel_ring *ring = rq->ring;$
-:38: WARNING:LEADING_SPACE: please, no spaces at the start of a line #38: FILE: drivers/gpu/drm/i915/gt/intel_migrate.c:349:
+ pkt = min_t(int, pkt, (ring->space - rq->reserved_space) / sizeof(u32) + 5);$
-:39: WARNING:LEADING_SPACE: please, no spaces at the start of a line #39: FILE: drivers/gpu/drm/i915/gt/intel_migrate.c:350:
+ pkt = min_t(int, pkt, (ring->size - ring->emit) / sizeof(u32) + 5);$
-:41: WARNING:LEADING_SPACE: please, no spaces at the start of a line #41: FILE: drivers/gpu/drm/i915/gt/intel_migrate.c:352:
+ return pkt;$
total: 0 errors, 4 warnings, 0 checks, 34 lines checkedbce28e11b423 drm/i915/selftests: use live_subtests for live_migrated5c2ffdf5bf0 drm/i915/selftests: exercise emit_pte() with nearly full ring
-:15: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line) #15:
v5: Use a simple on-stack timer to kill the spinner instead of kthread (Chris)
-:82: WARNING:TRACING_LOGGING: Unnecessary ftrace-like logging - prefer using ftrace #82: FILE: drivers/gpu/drm/i915/gt/selftest_migrate.c:543:
+ pr_info("%s\n", __func__);
total: 0 errors, 2 warnings, 0 checks, 187 lines checked
Patchwork
CI[Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [v5,1/3] drm/i915/migrate: Account for the reserved_space
In reply to Matthew Auld== Series Details ==
== Series Details ==
Series: series starting with [v5,1/3] drm/i915/migrate: Account for the reserved_space
URL : https://patchwork.freedesktop.org/series/111577/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_12462 -> Patchwork_111577v1
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_111577v1 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_111577v1, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/index.html
Participating hosts (42 -> 44)
------------------------------
Additional (3): fi-hsw-4770 bat-dg1-7 fi-tgl-dsi
Missing (1): fi-ilk-m540
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_111577v1:
### IGT changes ###
#### Possible regressions ####
* igt@i915_selftest@live@late_gt_pm:
- fi-kbl-soraka: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12462/fi-kbl-soraka/igt@i915_selftest@live@late_gt_pm.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/fi-kbl-soraka/igt@i915_selftest@live@late_gt_pm.html
Known issues
------------
Here are the changes found in Patchwork_111577v1 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@gem_softpin@allocator-basic-reserve:
- fi-hsw-4770: NOTRUN -> [SKIP][3] ([fdo#109271]) +11 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/fi-hsw-4770/igt@[email protected]
* igt@i915_selftest@live@gt_heartbeat:
- fi-apl-guc: [PASS][4] -> [DMESG-FAIL][5] ([i915#5334])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12462/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/fi-apl-guc/igt@i915_selftest@live@gt_heartbeat.html
* igt@i915_selftest@live@hangcheck:
- fi-hsw-4770: NOTRUN -> [INCOMPLETE][6] ([i915#4785])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/fi-hsw-4770/igt@i915_selftest@[email protected]
* igt@kms_chamelium@dp-crc-fast:
- fi-hsw-4770: NOTRUN -> [SKIP][7] ([fdo#109271] / [fdo#111827]) +7 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/fi-hsw-4770/igt@[email protected]
* igt@kms_psr@sprite_plane_onoff:
- fi-hsw-4770: NOTRUN -> [SKIP][8] ([fdo#109271] / [i915#1072]) +3 similar issues
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/fi-hsw-4770/igt@kms_psr@sprite_plane_onoff.html
* igt@runner@aborted:
- fi-hsw-4770: NOTRUN -> [FAIL][9] ([fdo#109271] / [i915#4312] / [i915#5594])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/fi-hsw-4770/igt@[email protected]
#### Possible fixes ####
* igt@fbdev@read:
- {bat-rpls-2}: [SKIP][10] ([i915#2582]) -> [PASS][11] +4 similar issues
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12462/bat-rpls-2/igt@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/bat-rpls-2/igt@[email protected]
* igt@gem_exec_suspend@basic-s3@smem:
- {bat-rplp-1}: [DMESG-WARN][12] ([i915#2867]) -> [PASS][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12462/bat-rplp-1/igt@gem_exec_suspend@[email protected]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/bat-rplp-1/igt@gem_exec_suspend@[email protected]
* igt@i915_selftest@live@gt_heartbeat:
- fi-kbl-soraka: [DMESG-FAIL][14] ([i915#5334]) -> [PASS][15]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12462/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/fi-kbl-soraka/igt@i915_selftest@live@gt_heartbeat.html
* igt@i915_selftest@live@requests:
- {bat-rpls-2}: [INCOMPLETE][16] ([i915#4983] / [i915#6257]) -> [PASS][17]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12462/bat-rpls-2/igt@i915_selftest@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/bat-rpls-2/igt@i915_selftest@[email protected]
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor@atomic-transitions:
- fi-bsw-kefka: [FAIL][18] ([i915#6298]) -> [PASS][19]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12462/fi-bsw-kefka/igt@kms_cursor_legacy@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/fi-bsw-kefka/igt@kms_cursor_legacy@[email protected]
* igt@kms_psr@primary_page_flip:
- fi-kbl-soraka: [DMESG-WARN][20] ([i915#1982]) -> [PASS][21]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_12462/fi-kbl-soraka/igt@kms_psr@primary_page_flip.html
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/fi-kbl-soraka/igt@kms_psr@primary_page_flip.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109295]: https://bugs.freedesktop.org/show_bug.cgi?id=109295
[fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1072]: https://gitlab.freedesktop.org/drm/intel/issues/1072
[i915#1759]: https://gitlab.freedesktop.org/drm/intel/issues/1759
[i915#1845]: https://gitlab.freedesktop.org/drm/intel/issues/1845
[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2582]: https://gitlab.freedesktop.org/drm/intel/issues/2582
[i915#2867]: https://gitlab.freedesktop.org/drm/intel/issues/2867
[i915#3301]: https://gitlab.freedesktop.org/drm/intel/issues/3301
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4078]: https://gitlab.freedesktop.org/drm/intel/issues/4078
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4103]: https://gitlab.freedesktop.org/drm/intel/issues/4103
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4215]: https://gitlab.freedesktop.org/drm/intel/issues/4215
[i915#4303]: https://gitlab.freedesktop.org/drm/intel/issues/4303
[i915#4312]: https://gitlab.freedesktop.org/drm/intel/issues/4312
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#4785]: https://gitlab.freedesktop.org/drm/intel/issues/4785
[i915#4873]: https://gitlab.freedesktop.org/drm/intel/issues/4873
[i915#4983]: https://gitlab.freedesktop.org/drm/intel/issues/4983
[i915#5334]: https://gitlab.freedesktop.org/drm/intel/issues/5334
[i915#5594]: https://gitlab.freedesktop.org/drm/intel/issues/5594
[i915#6257]: https://gitlab.freedesktop.org/drm/intel/issues/6257
[i915#6298]: https://gitlab.freedesktop.org/drm/intel/issues/6298
[i915#6367]: https://gitlab.freedesktop.org/drm/intel/issues/6367
[i915#6434]: https://gitlab.freedesktop.org/drm/intel/issues/6434
[i915#6559]: https://gitlab.freedesktop.org/drm/intel/issues/6559
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#6949]: https://gitlab.freedesktop.org/drm/intel/issues/6949
[i915#7058]: https://gitlab.freedesktop.org/drm/intel/issues/7058
[i915#7346]: https://gitlab.freedesktop.org/drm/intel/issues/7346
[i915#7456]: https://gitlab.freedesktop.org/drm/intel/issues/7456
[i915#7561]: https://gitlab.freedesktop.org/drm/intel/issues/7561
Build changes
-------------
* Linux: CI_DRM_12462 -> Patchwork_111577v1
CI-20190529: 20190529
CI_DRM_12462: 00b10bdfd8b9edc9b2c681d806fbb6ae2e5f31a3 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7078: 71bce31c26998d5d53cff3138049261fd6c4fbaf @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_111577v1: 00b10bdfd8b9edc9b2c681d806fbb6ae2e5f31a3 @ git://anongit.freedesktop.org/gfx-ci/linux
### Linux commits
2bbc58efd4b3 drm/i915/selftests: exercise emit_pte() with nearly full ring afcc5a5e20fe drm/i915/selftests: use live_subtests for live_migrate 44c500a4e067 drm/i915/migrate: Account for the reserved_space
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_111577v1/index.html