Skip to contentSkip to conversation

drm/i915/perf: Update handling of MMIO triggered reports

PATCH In review Umesh Nerlige Ramappa 3 participants 8 messages Dec 19, 2023 – Dec 22, 2023

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

PATCH 1/1 drm/i915/perf: Update handling of MMIO triggered reports

On XEHP platforms user is not able to find MMIO triggered reports in the OA buffer since i915 squashes the context ID fields. These context ID fields hold the MMIO trigger markers.

Update logic to not squash the context ID fields of MMIO triggered reports.

Fixes cba94bbcff08 ("drm/i915/perf: Determine context valid in OA reports")
---
 drivers/gpu/drm/i915/i915_perf.c | 39 ++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +34 -5
index 7b1c8de2f9cb..2d695818f006 100644
@@ -772,10 +772,6 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 		 * The reason field includes flags identifying what
 		 * triggered this specific report (mostly timer
 		 * triggered or e.g. due to a context switch).
-		 *
-		 * In MMIO triggered reports, some platforms do not set the
-		 * reason bit in this field and it is valid to have a reason
-		 * field of zero.
 		 */
 		reason = oa_report_reason(stream, report);
 		ctx_id = oa_context_id(stream, report32);
@@ -787,8 +783,41 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 		 *
 		 * Note: that we don't clear the valid_ctx_bit so userspace can
 		 * understand that the ID has been squashed by the kernel.
+		 *
+		 * Update:
+		 *
+		 * On XEHP platforms the behavior of context id valid bit has
+		 * changed compared to prior platforms. To describe this, we
+		 * define a few terms:
+		 *
+		 * context-switch-report: This is a report with the reason type
+		 * being context-switch. It is generated when a context switches
+		 * out.
+		 *
+		 * context-valid-bit: A bit that is set in the report ID field
+		 * to indicate that a valid context has been loaded.
+		 *
+		 * gpu-idle: A condition characterized by a
+		 * context-switch-report with context-valid-bit set to 0.
+		 *
+		 * On prior platforms, context-id-valid bit is set to 0 only
+		 * when GPU goes idle. In all other reports, it is set to 1.
+		 *
+		 * On XEHP platforms, context-valid-bit is set to 1 in a context
+		 * switch report if a new context switched in. For all other
+		 * reports it is set to 0.
+		 *
+		 * This change in behavior causes an issue with MMIO triggered
+		 * reports. MMIO triggered reports have the markers in the
+		 * context ID field and the context-valid-bit is 0. The logic
+		 * below to squash the context ID would render the report
+		 * useless since the user will not be able to find it in the OA
+		 * buffer. Since MMIO triggered reports exist only on XEHP,
+		 * we should avoid squashing these for XEHP platforms.
 		 */
-		if (oa_report_ctx_invalid(stream, report)) {
+
+		if (oa_report_ctx_invalid(stream, report) &&
+		    GRAPHICS_VER_FULL(stream->engine->i915) < IP_VER(12, 50)) {
 			ctx_id = INVALID_CTX_ID;
 			oa_context_id_squash(stream, report32);
 		}
Signature · 1 line
2.38.1
#1 lore raw

✗ Fi.CI.BAT: failure for drm/i915/perf: Update handling of MMIO triggered reports

== Series Details ==

== Series Details ==

Series: drm/i915/perf: Update handling of MMIO triggered reports
URL : https://patchwork.freedesktop.org/series/127946/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_14041 -> Patchwork_127946v1
====================================================

Summary
-------

**FAILURE**

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

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_127946v1, please notify your bug team ([email protected]) 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_127946v1/index.html

Participating hosts (36 -> 34)
------------------------------

Additional (1): bat-mtlp-8
Missing (3): fi-bsw-nick fi-snb-2520m fi-pnv-d510

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

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

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live@hugepages:
- bat-jsl-3: [PASS][1] -> [INCOMPLETE][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14041/bat-jsl-3/igt@i915_selftest@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-jsl-3/igt@i915_selftest@[email protected]

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

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

### IGT changes ###

#### Issues hit ####

* igt@debugfs_test@basic-hwmon:
- bat-mtlp-8: NOTRUN -> [SKIP][3] ([i915#9318])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@gem_lmem_swapping@verify-random:
- bat-mtlp-8: NOTRUN -> [SKIP][4] ([i915#4613]) +3 other tests skip
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@gem_mmap@basic:
- bat-mtlp-8: NOTRUN -> [SKIP][5] ([i915#4083])
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@gem_mmap_gtt@basic:
- bat-mtlp-8: NOTRUN -> [SKIP][6] ([i915#4077]) +2 other tests skip
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@gem_render_tiled_blits@basic:
- bat-mtlp-8: NOTRUN -> [SKIP][7] ([i915#4079]) +1 other test skip
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@i915_pm_rps@basic-api:
- bat-mtlp-8: NOTRUN -> [SKIP][8] ([i915#6621])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@i915_suspend@basic-s3-without-i915:
- bat-mtlp-8: NOTRUN -> [SKIP][9] ([i915#6645])
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@kms_addfb_basic@addfb25-y-tiled-small-legacy:
- bat-mtlp-8: NOTRUN -> [SKIP][10] ([i915#5190])
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@kms_addfb_basic@basic-y-tiled-legacy:
- bat-mtlp-8: NOTRUN -> [SKIP][11] ([i915#4212]) +8 other tests skip
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-legacy:
- bat-mtlp-8: NOTRUN -> [SKIP][12] ([i915#4213]) +1 other test skip
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@kms_dsc@dsc-basic:
- bat-mtlp-8: NOTRUN -> [SKIP][13] ([i915#3555] / [i915#3840] / [i915#9159])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@kms_force_connector_basic@force-load-detect:
- bat-mtlp-8: NOTRUN -> [SKIP][14] ([fdo#109285])
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@kms_force_connector_basic@prune-stale-modes:
- bat-mtlp-8: NOTRUN -> [SKIP][15] ([i915#5274])
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@kms_pipe_crc_basic@read-crc-frame-sequence:
- bat-dg2-11: NOTRUN -> [SKIP][16] ([i915#9197])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-dg2-11/igt@[email protected]

* igt@kms_setmode@basic-clone-single-crtc:
- bat-mtlp-8: NOTRUN -> [SKIP][17] ([i915#3555] / [i915#8809])
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@prime_vgem@basic-fence-mmap:
- bat-mtlp-8: NOTRUN -> [SKIP][18] ([i915#3708] / [i915#4077]) +1 other test skip
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

* igt@prime_vgem@basic-fence-read:
- bat-mtlp-8: NOTRUN -> [SKIP][19] ([i915#3708]) +2 other tests skip
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-mtlp-8/igt@[email protected]

#### Possible fixes ####

* igt@i915_selftest@live@workarounds:
- bat-dg2-11: [DMESG-FAIL][20] ([i915#9500]) -> [PASS][21]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_14041/bat-dg2-11/igt@i915_selftest@[email protected]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/bat-dg2-11/igt@i915_selftest@[email protected]

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

[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[i915#3555]: https://gitlab.freedesktop.org/drm/intel/issues/3555
[i915#3708]: https://gitlab.freedesktop.org/drm/intel/issues/3708
[i915#3840]: https://gitlab.freedesktop.org/drm/intel/issues/3840
[i915#4077]: https://gitlab.freedesktop.org/drm/intel/issues/4077
[i915#4079]: https://gitlab.freedesktop.org/drm/intel/issues/4079
[i915#4083]: https://gitlab.freedesktop.org/drm/intel/issues/4083
[i915#4212]: https://gitlab.freedesktop.org/drm/intel/issues/4212
[i915#4213]: https://gitlab.freedesktop.org/drm/intel/issues/4213
[i915#4613]: https://gitlab.freedesktop.org/drm/intel/issues/4613
[i915#5190]: https://gitlab.freedesktop.org/drm/intel/issues/5190
[i915#5274]: https://gitlab.freedesktop.org/drm/intel/issues/5274
[i915#6621]: https://gitlab.freedesktop.org/drm/intel/issues/6621
[i915#6645]: https://gitlab.freedesktop.org/drm/intel/issues/6645
[i915#8809]: https://gitlab.freedesktop.org/drm/intel/issues/8809
[i915#9159]: https://gitlab.freedesktop.org/drm/intel/issues/9159
[i915#9197]: https://gitlab.freedesktop.org/drm/intel/issues/9197
[i915#9318]: https://gitlab.freedesktop.org/drm/intel/issues/9318
[i915#9500]: https://gitlab.freedesktop.org/drm/intel/issues/9500
[i915#9688]: https://gitlab.freedesktop.org/drm/intel/issues/9688

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

* Linux: CI_DRM_14041 -> Patchwork_127946v1

CI-20190529: 20190529
CI_DRM_14041: 9c765da135371aa65d3f40c7effbea264300ea98 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7647: c5db51a88823962e79d41cff10fe1bdd8ea92d89 @ https://gitlab.freedesktop.org/drm/igt-gpu-tools.git
Patchwork_127946v1: 9c765da135371aa65d3f40c7effbea264300ea98 @ git://anongit.freedesktop.org/gfx-ci/linux

### Linux commits

153c3c051d99 drm/i915/perf: Update handling of MMIO triggered reports

== Logs ==

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

#2 lore raw

Re: ✗ Fi.CI.BAT: failure for drm/i915/perf: Update handling of MMIO triggered reports

Quoted 36 lines · Patchwork

Patch Details

Series:  drm/i915/perf: Update handling of MMIO triggered reports
URL:     [1]https://patchwork.freedesktop.org/series/127946/
State:   failure
Details: [2]https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_127946v1/index.html
         CI Bug Log - changes from CI_DRM_14041 -> Patchwork_127946v1

Summary

FAILURE

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

If you think the reported changes have nothing to do with the changes introduced in Patchwork_127946v1, please notify your bug team ([email protected]) 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_127946v1/index.html

Participating hosts (36 -> 34)

Additional (1): bat-mtlp-8
Missing (3): fi-bsw-nick fi-snb-2520m fi-pnv-d510

Possible new issues

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

Quoted 7 lines

IGT changes

   Possible regressions

    * igt@i915_selftest@live@hugepages:

         * bat-jsl-3: [3]PASS -> [4]INCOMPLETE

This is unrelated since the OA specific change is not exercised in BAT tests.

Umesh

Quoted 3 lines

Known issues

Reviewed-by on v1 1/1
#3 lore raw
In reply to Umesh Nerlige Ramappa
Quoted 1 line · Umesh Nerlige Ramappa

Hi Umesh,

Quoted 53 lines

On XEHP platforms user is not able to find MMIO triggered reports in the OA buffer since i915 squashes the context ID fields. These context ID fields hold the MMIO trigger markers.

Update logic to not squash the context ID fields of MMIO triggered reports.

Fixes cba94bbcff08 ("drm/i915/perf: Determine context valid in OA reports")
---
 drivers/gpu/drm/i915/i915_perf.c | 39 ++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +21 -4
index 7b1c8de2f9cb..2d695818f006 100644
@@ -772,10 +772,6 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 		 * The reason field includes flags identifying what
 		 * triggered this specific report (mostly timer
 		 * triggered or e.g. due to a context switch).
-		 *
-		 * In MMIO triggered reports, some platforms do not set the
-		 * reason bit in this field and it is valid to have a reason
-		 * field of zero.
 		 */
 		reason = oa_report_reason(stream, report);
 		ctx_id = oa_context_id(stream, report32);
@@ -787,8 +783,41 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 		 *
 		 * Note: that we don't clear the valid_ctx_bit so userspace can
 		 * understand that the ID has been squashed by the kernel.
+		 *
+		 * Update:
+		 *
+		 * On XEHP platforms the behavior of context id valid bit has
+		 * changed compared to prior platforms. To describe this, we
+		 * define a few terms:
+		 *
+		 * context-switch-report: This is a report with the reason type
+		 * being context-switch. It is generated when a context switches
+		 * out.
+		 *
+		 * context-valid-bit: A bit that is set in the report ID field
+		 * to indicate that a valid context has been loaded.
+		 *
+		 * gpu-idle: A condition characterized by a
+		 * context-switch-report with context-valid-bit set to 0.
+		 *
+		 * On prior platforms, context-id-valid bit is set to 0 only
+		 * when GPU goes idle. In all other reports, it is set to 1.
+		 *
+		 * On XEHP platforms, context-valid-bit is set to 1 in a context

drivers/gpu/drm/i915/i915_perf.c static int gen8_append_oa_reports(struct i915_perf_stream *stream, · line 816

Quoted 10 lines
drivers/gpu/drm/i915/i915_perf.c +10 -0
+		 * switch report if a new context switched in. For all other
+		 * reports it is set to 0.
+		 *
+		 * This change in behavior causes an issue with MMIO triggered
+		 * reports. MMIO triggered reports have the markers in the
+		 * context ID field and the context-valid-bit is 0. The logic
+		 * below to squash the context ID would render the report
+		 * useless since the user will not be able to find it in the OA
+		 * buffer. Since MMIO triggered reports exist only on XEHP,
+		 * we should avoid squashing these for XEHP platforms.

Hmm I am wondering if this is over-information and this comment should be made brief. For the record, here's the explanation of what is happening from Robert Krzemien's email (which at least makes it simpler for me to understand what is happening):

For Gen12HP+ (ATS/DG2/PVC/MTL+) platforms, context id valid bit is set only for context switch reports and when a context is being loaded. When exiting a context, a context switch report is generated, ctx id is not zero, but the bit is not set. It allows us to distinguish whether context switch reports are generated due to entering or exiting GPU contexts. Ctx id field is non-zero for context switches and mmio triggers. Other types always have ctx id set to 0.

For previous platforms (like Gen12LP, Gen9/11), the bit is set for all types of reports if a context is loaded. But those older platforms don’t have mmio triggers. Ctx id field is non-zero for all types of reports if a context is loaded.

I don’t understand why i915 needs to set ctx id to 0xffffffff if the flag is not set. It has been removed from XE KMD as I remember correctly.

drivers/gpu/drm/i915/i915_perf.c static int gen8_append_oa_reports(struct i915_perf_stream *stream, · line 823

Quoted 8 lines
drivers/gpu/drm/i915/i915_perf.c +3 -1
 		 */
-		if (oa_report_ctx_invalid(stream, report)) {
+
+		if (oa_report_ctx_invalid(stream, report) &&
+		    GRAPHICS_VER_FULL(stream->engine->i915) < IP_VER(12, 50)) {
 			ctx_id = INVALID_CTX_ID;
 			oa_context_id_squash(stream, report32);
 		}

So I am assuming there's some unknown reason (maybe not hearing from Mesa?) why we can't get rid of the squashing even for legacy platforms. But that's ok I guess. So this is:

#4 lore raw
Quoted 64 lines · Ashutosh
Quoted 1 line · Umesh Nerlige Ramappa

Hi Umesh,

Quoted 58 lines

On XEHP platforms user is not able to find MMIO triggered reports in the OA buffer since i915 squashes the context ID fields. These context ID fields hold the MMIO trigger markers.

Update logic to not squash the context ID fields of MMIO triggered reports.

Fixes cba94bbcff08 ("drm/i915/perf: Determine context valid in OA reports")
---
 drivers/gpu/drm/i915/i915_perf.c | 39 ++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +26 -4
index 7b1c8de2f9cb..2d695818f006 100644
@@ -772,10 +772,6 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 		 * The reason field includes flags identifying what
 		 * triggered this specific report (mostly timer
 		 * triggered or e.g. due to a context switch).
-		 *
-		 * In MMIO triggered reports, some platforms do not set the
-		 * reason bit in this field and it is valid to have a reason
-		 * field of zero.
 		 */
 		reason = oa_report_reason(stream, report);
 		ctx_id = oa_context_id(stream, report32);
@@ -787,8 +783,41 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 		 *
 		 * Note: that we don't clear the valid_ctx_bit so userspace can
 		 * understand that the ID has been squashed by the kernel.
+		 *
+		 * Update:
+		 *
+		 * On XEHP platforms the behavior of context id valid bit has
+		 * changed compared to prior platforms. To describe this, we
+		 * define a few terms:
+		 *
+		 * context-switch-report: This is a report with the reason type
+		 * being context-switch. It is generated when a context switches
+		 * out.
+		 *
+		 * context-valid-bit: A bit that is set in the report ID field
+		 * to indicate that a valid context has been loaded.
+		 *
+		 * gpu-idle: A condition characterized by a
+		 * context-switch-report with context-valid-bit set to 0.
+		 *
+		 * On prior platforms, context-id-valid bit is set to 0 only
+		 * when GPU goes idle. In all other reports, it is set to 1.
+		 *
+		 * On XEHP platforms, context-valid-bit is set to 1 in a context
+		 * switch report if a new context switched in. For all other
+		 * reports it is set to 0.
+		 *
+		 * This change in behavior causes an issue with MMIO triggered
+		 * reports. MMIO triggered reports have the markers in the
Quoted 8 lines

drivers/gpu/drm/i915/i915_perf.c static int gen8_append_oa_reports(struct i915_perf_stream *stream, · line 816

Quoted 5 lines
drivers/gpu/drm/i915/i915_perf.c +5 -0
+		 * context ID field and the context-valid-bit is 0. The logic
+		 * below to squash the context ID would render the report
+		 * useless since the user will not be able to find it in the OA
+		 * buffer. Since MMIO triggered reports exist only on XEHP,
+		 * we should avoid squashing these for XEHP platforms.

Hmm I am wondering if this is over-information and this comment should be made brief.

Let me try: "For Gen's >= 12.50, the context id valid bit is reset when a context switches out, but the context id is still valid. Because of this we cannot squash the context id in this case".

So this should affect both the regular as well as MMIO triggered cases afaiu.

Anyway, please do what you think is right with the comment. I just thought I'll chime in.

Quoted 36 lines

For the record, here's the explanation of what is happening from Robert Krzemien's email (which at least makes it simpler for me to understand what is happening):

For Gen12HP+ (ATS/DG2/PVC/MTL+) platforms, context id valid bit is set only for context switch reports and when a context is being loaded. When exiting a context, a context switch report is generated, ctx id is not zero, but the bit is not set. It allows us to distinguish whether context switch reports are generated due to entering or exiting GPU contexts. Ctx id field is non-zero for context switches and mmio triggers. Other types always have ctx id set to 0.

For previous platforms (like Gen12LP, Gen9/11), the bit is set for all types of reports if a context is loaded. But those older platforms don’t have mmio triggers. Ctx id field is non-zero for all types of reports if a context is loaded.

I don’t understand why i915 needs to set ctx id to 0xffffffff if the flag is not set. It has been removed from XE KMD as I remember correctly.

drivers/gpu/drm/i915/i915_perf.c static int gen8_append_oa_reports(struct i915_perf_stream *stream, · line 823

Quoted 8 lines
drivers/gpu/drm/i915/i915_perf.c +3 -1
 		 */
-		if (oa_report_ctx_invalid(stream, report)) {
+
+		if (oa_report_ctx_invalid(stream, report) &&
+		    GRAPHICS_VER_FULL(stream->engine->i915) < IP_VER(12, 50)) {
 			ctx_id = INVALID_CTX_ID;
 			oa_context_id_squash(stream, report32);
 		}

So I am assuming there's some unknown reason (maybe not hearing from Mesa?) why we can't get rid of the squashing even for legacy platforms. But that's ok I guess. So this is:

#5 lore raw
Quoted 78 lines · Ashutosh
Quoted 64 lines · Ashutosh
Quoted 1 line · Umesh Nerlige Ramappa

Hi Umesh,

Quoted 58 lines

On XEHP platforms user is not able to find MMIO triggered reports in the OA buffer since i915 squashes the context ID fields. These context ID fields hold the MMIO trigger markers.

Update logic to not squash the context ID fields of MMIO triggered reports.

Fixes cba94bbcff08 ("drm/i915/perf: Determine context valid in OA reports")
---
 drivers/gpu/drm/i915/i915_perf.c | 39 ++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +26 -4
index 7b1c8de2f9cb..2d695818f006 100644
@@ -772,10 +772,6 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 		 * The reason field includes flags identifying what
 		 * triggered this specific report (mostly timer
 		 * triggered or e.g. due to a context switch).
-		 *
-		 * In MMIO triggered reports, some platforms do not set the
-		 * reason bit in this field and it is valid to have a reason
-		 * field of zero.
 		 */
 		reason = oa_report_reason(stream, report);
 		ctx_id = oa_context_id(stream, report32);
@@ -787,8 +783,41 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 		 *
 		 * Note: that we don't clear the valid_ctx_bit so userspace can
 		 * understand that the ID has been squashed by the kernel.
+		 *
+		 * Update:
+		 *
+		 * On XEHP platforms the behavior of context id valid bit has
+		 * changed compared to prior platforms. To describe this, we
+		 * define a few terms:
+		 *
+		 * context-switch-report: This is a report with the reason type
+		 * being context-switch. It is generated when a context switches
+		 * out.
+		 *
+		 * context-valid-bit: A bit that is set in the report ID field
+		 * to indicate that a valid context has been loaded.
+		 *
+		 * gpu-idle: A condition characterized by a
+		 * context-switch-report with context-valid-bit set to 0.
+		 *
+		 * On prior platforms, context-id-valid bit is set to 0 only
+		 * when GPU goes idle. In all other reports, it is set to 1.
+		 *
+		 * On XEHP platforms, context-valid-bit is set to 1 in a context
+		 * switch report if a new context switched in. For all other
+		 * reports it is set to 0.
+		 *
+		 * This change in behavior causes an issue with MMIO triggered
+		 * reports. MMIO triggered reports have the markers in the
Quoted 8 lines

drivers/gpu/drm/i915/i915_perf.c static int gen8_append_oa_reports(struct i915_perf_stream *stream, · line 816

Quoted 5 lines
drivers/gpu/drm/i915/i915_perf.c +5 -0
+		 * context ID field and the context-valid-bit is 0. The logic
+		 * below to squash the context ID would render the report
+		 * useless since the user will not be able to find it in the OA
+		 * buffer. Since MMIO triggered reports exist only on XEHP,
+		 * we should avoid squashing these for XEHP platforms.

Hmm I am wondering if this is over-information and this comment should be made brief.

Let me try: "For Gen's >= 12.50, the context id valid bit is reset when a context switches out, but the context id is still valid. Because of this we cannot squash the context id in this case".

Quoted 5 lines

So this should affect both the regular as well as MMIO triggered cases afaiu.

Anyway, please do what you think is right with the comment. I just thought I'll chime in.

The long and descriptive comment is entirely for my benefit. There is a very good chance I will forget this, so putting it down in the code. Also, I don't see this described in the spec, so thinking that we will benefit from it by having it here. I can put it in the commit msg instead if that helps.

Thanks,
Umesh

Quoted 37 lines
Quoted 37 lines

For the record, here's the explanation of what is happening from Robert Krzemien's email (which at least makes it simpler for me to understand what is happening):

For Gen12HP+ (ATS/DG2/PVC/MTL+) platforms, context id valid bit is set only for context switch reports and when a context is being loaded. When exiting a context, a context switch report is generated, ctx id is not zero, but the bit is not set. It allows us to distinguish whether context switch reports are generated due to entering or exiting GPU contexts. Ctx id field is non-zero for context switches and mmio triggers. Other types always have ctx id set to 0.

For previous platforms (like Gen12LP, Gen9/11), the bit is set for all types of reports if a context is loaded. But those older platforms don’t have mmio triggers. Ctx id field is non-zero for all types of reports if a context is loaded.

I don’t understand why i915 needs to set ctx id to 0xffffffff if the flag is not set. It has been removed from XE KMD as I remember correctly.

drivers/gpu/drm/i915/i915_perf.c static int gen8_append_oa_reports(struct i915_perf_stream *stream, · line 823

Quoted 8 lines
drivers/gpu/drm/i915/i915_perf.c +3 -1
 		 */
-		if (oa_report_ctx_invalid(stream, report)) {
+
+		if (oa_report_ctx_invalid(stream, report) &&
+		    GRAPHICS_VER_FULL(stream->engine->i915) < IP_VER(12, 50)) {
 			ctx_id = INVALID_CTX_ID;
 			oa_context_id_squash(stream, report32);
 		}

So I am assuming there's some unknown reason (maybe not hearing from Mesa?) why we can't get rid of the squashing even for legacy platforms. But that's ok I guess. So this is:

#6 lore raw
Quoted 83 lines · Umesh Nerlige Ramappa
Quoted 81 lines · Ashutosh
Quoted 64 lines · Ashutosh
Quoted 1 line · Umesh Nerlige Ramappa

Hi Umesh,

Quoted 58 lines

On XEHP platforms user is not able to find MMIO triggered reports in the OA buffer since i915 squashes the context ID fields. These context ID fields hold the MMIO trigger markers.

Update logic to not squash the context ID fields of MMIO triggered reports.

Fixes cba94bbcff08 ("drm/i915/perf: Determine context valid in OA reports")
---
 drivers/gpu/drm/i915/i915_perf.c | 39 ++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 5 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +26 -4
index 7b1c8de2f9cb..2d695818f006 100644
@@ -772,10 +772,6 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 		 * The reason field includes flags identifying what
 		 * triggered this specific report (mostly timer
 		 * triggered or e.g. due to a context switch).
-		 *
-		 * In MMIO triggered reports, some platforms do not set the
-		 * reason bit in this field and it is valid to have a reason
-		 * field of zero.
 		 */
 		reason = oa_report_reason(stream, report);
 		ctx_id = oa_context_id(stream, report32);
@@ -787,8 +783,41 @@ static int gen8_append_oa_reports(struct i915_perf_stream *stream,
 		 *
 		 * Note: that we don't clear the valid_ctx_bit so userspace can
 		 * understand that the ID has been squashed by the kernel.
+		 *
+		 * Update:
+		 *
+		 * On XEHP platforms the behavior of context id valid bit has
+		 * changed compared to prior platforms. To describe this, we
+		 * define a few terms:
+		 *
+		 * context-switch-report: This is a report with the reason type
+		 * being context-switch. It is generated when a context switches
+		 * out.
+		 *
+		 * context-valid-bit: A bit that is set in the report ID field
+		 * to indicate that a valid context has been loaded.
+		 *
+		 * gpu-idle: A condition characterized by a
+		 * context-switch-report with context-valid-bit set to 0.
+		 *
+		 * On prior platforms, context-id-valid bit is set to 0 only
+		 * when GPU goes idle. In all other reports, it is set to 1.
+		 *
+		 * On XEHP platforms, context-valid-bit is set to 1 in a context
+		 * switch report if a new context switched in. For all other
+		 * reports it is set to 0.
+		 *
+		 * This change in behavior causes an issue with MMIO triggered
+		 * reports. MMIO triggered reports have the markers in the
Quoted 8 lines

drivers/gpu/drm/i915/i915_perf.c static int gen8_append_oa_reports(struct i915_perf_stream *stream, · line 816

Quoted 5 lines
drivers/gpu/drm/i915/i915_perf.c +5 -0
+		 * context ID field and the context-valid-bit is 0. The logic
+		 * below to squash the context ID would render the report
+		 * useless since the user will not be able to find it in the OA
+		 * buffer. Since MMIO triggered reports exist only on XEHP,
+		 * we should avoid squashing these for XEHP platforms.

Hmm I am wondering if this is over-information and this comment should be made brief.

Let me try: "For Gen's >= 12.50, the context id valid bit is reset when a context switches out, but the context id is still valid. Because of this we cannot squash the context id in this case".

So this should affect both the regular as well as MMIO triggered cases afaiu.

Quoted 8 lines
Quoted 2 lines

Anyway, please do what you think is right with the comment. I just thought I'll chime in.

The long and descriptive comment is entirely for my benefit. There is a very good chance I will forget this, so putting it down in the code. Also, I don't see this described in the spec, so thinking that we will benefit from it by having it here. I can put it in the commit msg instead if that helps.

I've already R-b'd the patch, so entirely your call. So do whatever you're comfortable with :)

Ashutosh

Quoted 38 lines
Quoted 38 lines
Quoted 38 lines

For the record, here's the explanation of what is happening from Robert Krzemien's email (which at least makes it simpler for me to understand what is happening):

For Gen12HP+ (ATS/DG2/PVC/MTL+) platforms, context id valid bit is set only for context switch reports and when a context is being loaded. When exiting a context, a context switch report is generated, ctx id is not zero, but the bit is not set. It allows us to distinguish whether context switch reports are generated due to entering or exiting GPU contexts. Ctx id field is non-zero for context switches and mmio triggers. Other types always have ctx id set to 0.

For previous platforms (like Gen12LP, Gen9/11), the bit is set for all types of reports if a context is loaded. But those older platforms don’t have mmio triggers. Ctx id field is non-zero for all types of reports if a context is loaded.

I don’t understand why i915 needs to set ctx id to 0xffffffff if the flag is not set. It has been removed from XE KMD as I remember correctly.

drivers/gpu/drm/i915/i915_perf.c static int gen8_append_oa_reports(struct i915_perf_stream *stream, · line 823

Quoted 8 lines
drivers/gpu/drm/i915/i915_perf.c +3 -1
 		 */
-		if (oa_report_ctx_invalid(stream, report)) {
+
+		if (oa_report_ctx_invalid(stream, report) &&
+		    GRAPHICS_VER_FULL(stream->engine->i915) < IP_VER(12, 50)) {
 			ctx_id = INVALID_CTX_ID;
 			oa_context_id_squash(stream, report32);
 		}

So I am assuming there's some unknown reason (maybe not hearing from Mesa?) why we can't get rid of the squashing even for legacy platforms. But that's ok I guess. So this is:

#7 lore raw
In reply to Umesh Nerlige Ramappa
Quoted 16 lines · Umesh Nerlige Ramappa

On XEHP platforms user is not able to find MMIO triggered reports in the OA buffer since i915 squashes the context ID fields. These context ID fields hold the MMIO trigger markers.

Update logic to not squash the context ID fields of MMIO triggered reports.

Fixes cba94bbcff08 ("drm/i915/perf: Determine context valid in OA reports")

---

Fi.CI.IGT failures.

Possible new issues
Here are the unknown changes that may have been introduced in Patchwork_127946v2_full:

Quoted 7 lines

IGT changes
Possible regressions
igt@gem_exec_suspend@basic-s3-devices@smem:
shard-mtlp: NOTRUN -> ABORT

igt@i915_selftest@live@gt_pm:
shard-rkl: PASS -> DMESG-FAIL

The above are unrelated and do not exercise the code path that has the fix.

Thanks,
Umesh

Quoted 2 lines

Known issues