Skip to contentSkip to conversation

drm/i915/gt: Prevent immediate reuse of the last context tag

PATCH In review Chris Wilson 2 participants 4 messages Aug 5, 2020

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

PATCH 1/1 drm/i915/gt: Prevent immediate reuse of the last context tag

While we only release the context tag after we have processed the context-switch event away from the context, be paranoid in case that value remains live in HW and so avoid reusing the last tag for the next context after a brief idle.

---
 drivers/gpu/drm/i915/gt/intel_engine_types.h |  1 +
 drivers/gpu/drm/i915/gt/intel_lrc.c          | 20 ++++++++++++++++----
 2 files changed, 17 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/gt/intel_engine_types.h +1 -0
index c400aaa2287b..bfa0199b7a2c 100644
@@ -330,6 +330,7 @@ struct intel_engine_cs {
 	atomic_t fw_active;
 
 	unsigned long context_tag;
+	unsigned long context_last;
 
 	struct rb_node uabi_node;
 
drivers/gpu/drm/i915/gt/intel_lrc.c +16 -4
index 417f6b0c6c61..f8a0ee67d930 100644
@@ -1335,6 +1335,21 @@ static void intel_context_update_runtime(struct intel_context *ce)
 	ce->runtime.total += dt;
 }
 
+static unsigned int next_cyclic_tag(struct intel_engine_cs *engine)
+{
+	unsigned long tag, mask = ~0ul << engine->context_last;
+
+	/* Cyclically allocate unused ids, prevent immediate reuse of last */
+	tag = READ_ONCE(engine->context_tag);
+	tag = (tag & mask) ?: tag;
+	GEM_BUG_ON(tag == 0);
+
+	tag = __ffs(tag);
+	clear_bit(tag, &engine->context_tag);
+
+	return engine->context_last = tag + 1;
+}
+
 static inline struct intel_engine_cs *
 __execlists_schedule_in(struct i915_request *rq)
 {
@@ -1355,12 +1370,9 @@ __execlists_schedule_in(struct i915_request *rq)
 		ce->lrc.ccid = ce->tag;
 	} else {
 		/* We don't need a strict matching tag, just different values */
-		unsigned int tag = ffs(READ_ONCE(engine->context_tag));
+		unsigned int tag = next_cyclic_tag(engine);
 
-		GEM_BUG_ON(tag == 0 || tag >= BITS_PER_LONG);
-		clear_bit(tag - 1, &engine->context_tag);
 		ce->lrc.ccid = tag << (GEN11_SW_CTX_ID_SHIFT - 32);
-
 		BUILD_BUG_ON(BITS_PER_LONG > GEN12_MAX_CONTEXT_HW_ID);
 	}
 
Signature · 6 lines
2.20.1

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

Quoting Chris Wilson (2020-08-05 09:37:51)

Quoted 5 lines

While we only release the context tag after we have processed the context-switch event away from the context, be paranoid in case that value remains live in HW and so avoid reusing the last tag for the next context after a brief idle.

Fixes 5c4a53e3b1cb ("drm/i915/execlists: Track inflight CCID")
Quoted 2 lines

Cc: <[email protected]> # v5.5+
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#2 lore raw

[Intel-gfx] ✗ Fi.CI.SPARSE: warning for drm/i915/gt: Prevent immediate reuse of the last context tag

In reply to Chris Wilson
== Series Details ==

== Series Details ==

Series: drm/i915/gt: Prevent immediate reuse of the last context tag
URL : https://patchwork.freedesktop.org/series/80277/
State : warning

== Summary ==

$ dim sparse --fast origin/drm-tip
Sparse version: v0.6.0
Fast mode used, each commit won't be checked separately.

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

#3 lore raw

[Intel-gfx] ✗ Fi.CI.BAT: failure for drm/i915/gt: Prevent immediate reuse of the last context tag

In reply to Chris Wilson
== Series Details ==

== Series Details ==

Series: drm/i915/gt: Prevent immediate reuse of the last context tag
URL : https://patchwork.freedesktop.org/series/80277/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8844 -> Patchwork_18308
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_18308 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_18308, 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_18308/index.html

Possible new issues
-------------------

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_pm_rpm@module-reload:
- fi-hsw-4770: [PASS][1] -> [DMESG-WARN][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8844/fi-hsw-4770/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-hsw-4770/igt@[email protected]

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* igt@i915_pm_rpm@module-reload:
- {fi-kbl-7560u}: [PASS][3] -> [DMESG-WARN][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8844/fi-kbl-7560u/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-kbl-7560u/igt@[email protected]

* igt@runner@aborted:
- {fi-tgl-dsi}: NOTRUN -> [FAIL][5]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-tgl-dsi/igt@[email protected]

Known issues
------------

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

### IGT changes ###

#### Issues hit ####

* igt@kms_busy@basic@flip:
- fi-kbl-x1275: [PASS][6] -> [DMESG-WARN][7] ([i915#62] / [i915#92] / [i915#95])
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8844/fi-kbl-x1275/igt@kms_busy@[email protected]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-kbl-x1275/igt@kms_busy@[email protected]

#### Possible fixes ####

* igt@i915_pm_rpm@basic-pci-d3-state:
- fi-bsw-kefka: [DMESG-WARN][8] ([i915#1982]) -> [PASS][9]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8844/fi-bsw-kefka/igt@[email protected]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-bsw-kefka/igt@[email protected]

* igt@i915_selftest@live@execlists:
- fi-kbl-guc: [INCOMPLETE][10] ([i915#794]) -> [PASS][11]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8844/fi-kbl-guc/igt@i915_selftest@[email protected]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-kbl-guc/igt@i915_selftest@[email protected]

* igt@i915_selftest@live@gem_contexts:
- fi-tgl-u2: [INCOMPLETE][12] ([i915#2045]) -> [PASS][13]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8844/fi-tgl-u2/igt@i915_selftest@live@gem_contexts.html
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-tgl-u2/igt@i915_selftest@live@gem_contexts.html

* igt@kms_flip@basic-flip-vs-wf_vblank@c-edp1:
- fi-icl-u2: [DMESG-WARN][14] ([i915#1982]) -> [PASS][15] +1 similar issue
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8844/fi-icl-u2/igt@kms_flip@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-icl-u2/igt@kms_flip@[email protected]

* igt@kms_flip@basic-flip-vs-wf_vblank@c-hdmi-a2:
- fi-skl-guc: [DMESG-WARN][16] ([i915#2203]) -> [PASS][17]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8844/fi-skl-guc/igt@kms_flip@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-skl-guc/igt@kms_flip@[email protected]

#### Warnings ####

* igt@i915_pm_rpm@module-reload:
- fi-kbl-guc: [DMESG-FAIL][18] ([i915#2203]) -> [DMESG-WARN][19] ([i915#2203])
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8844/fi-kbl-guc/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-kbl-guc/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- fi-kbl-x1275: [DMESG-WARN][20] ([i915#62] / [i915#92] / [i915#95]) -> [DMESG-WARN][21] ([i915#62] / [i915#92]) +6 similar issues
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8844/fi-kbl-x1275/igt@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-kbl-x1275/igt@[email protected]

* igt@kms_force_connector_basic@prune-stale-modes:
- fi-kbl-x1275: [DMESG-WARN][22] ([i915#62] / [i915#92]) -> [DMESG-WARN][23] ([i915#62] / [i915#92] / [i915#95]) +4 similar issues
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8844/fi-kbl-x1275/igt@[email protected]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/fi-kbl-x1275/igt@[email protected]

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

[i915#1982]: https://gitlab.freedesktop.org/drm/intel/issues/1982
[i915#2045]: https://gitlab.freedesktop.org/drm/intel/issues/2045
[i915#2203]: https://gitlab.freedesktop.org/drm/intel/issues/2203
[i915#62]: https://gitlab.freedesktop.org/drm/intel/issues/62
[i915#794]: https://gitlab.freedesktop.org/drm/intel/issues/794
[i915#92]: https://gitlab.freedesktop.org/drm/intel/issues/92
[i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95

Participating hosts (43 -> 37)
------------------------------

Missing (6): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-byt-clapper

Build changes
-------------

* Linux: CI_DRM_8844 -> Patchwork_18308

CI-20190529: 20190529
CI_DRM_8844: 078ec38d6385937203c8e431671bd99453223bd2 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5758: bb34603947667cb44ed9ff0db8dccbb9d3f42357 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_18308: ac0f01189cfc2dbb998b2adf08a797ef46b0546b @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

ac0f01189cfc drm/i915/gt: Prevent immediate reuse of the last context tag

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_18308/index.html

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