i915/perf: Start hrtimer only if sampling the OA buffer
Subsystems (2)
PATCH 1/1 i915/perf: Start hrtimer only if sampling the OA buffer
SAMPLE_OA parameter enables sampling of OA buffer and results in a call to init the OA buffer which initializes the OA unit head/tail pointers. The OA_EXPONENT parameter controls the periodicity of the OA reports in the OA buffer and results in starting a hrtimer.
Before gen12, all use cases required the use of the OA buffer and i915 enforced this setting when vetting out the parameters passed. In these platforms the hrtimer was enabled if OA_EXPONENT was passed. This worked fine since it was implied that SAMPLE_OA is always passed.
With gen12, this changed. Users can use perf without enabling the OA buffer as in OAR use cases. While an OAR use case should ideally not start the hrtimer, we see that passing an OA_EXPONENT parameter will start the hrtimer even though SAMPLE_OA is not specified. This results in an uninitialized OA buffer, so the head/tail pointers used to track the buffer are zero.
This itself does not fail, but if we ran a use-case that SAMPLED the OA buffer previously, then the OA_TAIL register is still pointing to an old value. When the timer callback runs, it ends up calculating a wrong/large number of available reports. Since we do a spinlock_irq_save and start processing a large number of reports, NMI watchdog fires and causes a crash.
Start the timer only if SAMPLE_OA is specified.
v2:
- Drop SAMPLE OA check when appending samples (Ashutosh)
- Prevent read if OA buffer is not being sampled
--- drivers/gpu/drm/i915/i915_perf.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_perf.c +5 -8
@@ -595,7 +595,6 @@ static int append_oa_sample(struct i915_perf_stream *stream, {int report_size = stream->oa_buffer.format_size;struct drm_i915_perf_record_header header; -u32 sample_flags = stream->sample_flags; header.type =DRM_I915_PERF_RECORD_SAMPLE ; header.pad =0 ;
@@ -609,10 +608,8 @@ static int append_oa_sample(struct i915_perf_stream *stream,return -EFAULT ; buf +=sizeof (header); -if (sample_flags &SAMPLE_OA_REPORT ) { -if (copy_to_user (buf, report, report_size)) -return -EFAULT ; - } +if (copy_to_user (buf, report, report_size)) +return -EFAULT ; (*offset) += header.size;
@@ -2669,7 +2666,7 @@ static void i915_oa_stream_enable(struct i915_perf_stream *stream) stream->perf->ops.oa_enable (stream); -if (stream->periodic) +if (stream->sample_flags &SAMPLE_OA_REPORT )hrtimer_start (&stream->poll_check_timer,ns_to_ktime (stream->poll_oa_period),HRTIMER_MODE_REL_PINNED );
@@ -2732,7 +2729,7 @@ static void i915_oa_stream_disable(struct i915_perf_stream *stream) { stream->perf->ops.oa_disable (stream); -if (stream->periodic) +if (stream->sample_flags &SAMPLE_OA_REPORT )hrtimer_cancel (&stream->poll_check_timer); }
@@ -3015,7 +3012,7 @@ static ssize_t i915_perf_read(struct file *file,* disabled stream as an error. In particular it might otherwise lead * to a deadlock for blocking file descriptors... */ -if (!stream->enabled) +if (!stream->enabled || !(stream->sample_flags &SAMPLE_OA_REPORT ))return -EIO ;if (!(file->f_flags &O_NONBLOCK )) {
Signature · 6 lines
2.20.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 25 lines · Umesh
SAMPLE_OAparameter enables sampling of OA buffer and results in a call to init the OA buffer which initializes the OA unit head/tail pointers. TheOA_EXPONENTparameter controls the periodicity of the OA reports in the OA buffer and results in starting a hrtimer.Before gen12, all use cases required the use of the OA buffer and i915 enforced this setting when vetting out the parameters passed. In these platforms the hrtimer was enabled if
OA_EXPONENTwas passed. This worked fine since it was implied thatSAMPLE_OAis always passed.With gen12, this changed. Users can use perf without enabling the OA buffer as in OAR use cases. While an OAR use case should ideally not start the hrtimer, we see that passing an
OA_EXPONENTparameter will start the hrtimer even thoughSAMPLE_OAis not specified. This results in an uninitialized OA buffer, so the head/tail pointers used to track the buffer are zero.This itself does not fail, but if we ran a use-case that SAMPLED the OA buffer previously, then the
OA_TAILregister is still pointing to an old value. When the timer callback runs, it ends up calculating a wrong/large number of available reports. Since we do aspinlock_irq_saveand start processing a large number of reports, NMI watchdog fires and causes a crash.
Quoted 4 lines
Start the timer only if
SAMPLE_OAis specified. v2:
- Drop SAMPLE OA check when appending samples (Ashutosh)
- Prevent read if OA buffer is not being sampled
Quoted 59 lines
Fixes 00a7f0d7155c ("drm/i915/tgl: Add perf support on TGL")Signed-off-by Umesh Nerlige Ramappa <[email protected]>--- drivers/gpu/drm/i915/i915_perf.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)drivers/gpu/drm/i915/i915_perf.c +5
-9@@ -595,7 +595,6 @@ static int append_oa_sample(struct i915_perf_stream *stream, {int report_size = stream->oa_buffer.format_size;struct drm_i915_perf_record_header header; -u32 sample_flags = stream->sample_flags; header.type =DRM_I915_PERF_RECORD_SAMPLE ; header.pad =0 ;@@ -609,10 +608,8 @@ static int append_oa_sample(struct i915_perf_stream *stream,return -EFAULT ; buf +=sizeof (header); -if (sample_flags &SAMPLE_OA_REPORT ) { -if (copy_to_user (buf, report, report_size)) -return -EFAULT ; - } +if (copy_to_user (buf, report, report_size)) +return -EFAULT ; (*offset) += header.size;@@ -2669,7 +2666,7 @@ static void i915_oa_stream_enable(struct i915_perf_stream *stream) stream->perf->ops.oa_enable (stream); -if (stream->periodic) +if (stream->sample_flags &SAMPLE_OA_REPORT )hrtimer_start (&stream->poll_check_timer,ns_to_ktime (stream->poll_oa_period),HRTIMER_MODE_REL_PINNED );@@ -2732,7 +2729,7 @@ static void i915_oa_stream_disable(struct i915_perf_stream *stream) { stream->perf->ops.oa_disable (stream); -if (stream->periodic) +if (stream->sample_flags &SAMPLE_OA_REPORT )hrtimer_cancel (&stream->poll_check_timer); }@@ -3015,7 +3012,7 @@ static ssize_t i915_perf_read(struct file *file,* disabled stream as an error. In particular it might otherwise lead * to a deadlock for blocking file descriptors... */ -if (!stream->enabled) +if (!stream->enabled || !(stream->sample_flags &SAMPLE_OA_REPORT ))return -EIO ;if (!(file->f_flags &O_NONBLOCK )) { --
Quoted 2 lines
2.20.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✓ Fi.CI.BAT: success for i915/perf: Start hrtimer only if sampling the OA buffer
In reply to Umesh Nerlige Ramappa== Series Details ==
== Series Details ==
Series: i915/perf: Start hrtimer only if sampling the OA buffer
URL : https://patchwork.freedesktop.org/series/87524/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_9818 -> Patchwork_19738
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/index.html
Known issues
------------
Here are the changes found in Patchwork_19738 that come from known issues:
### IGT changes ###
#### Issues hit ####
* igt@amdgpu/amd_basic@semaphore:
- fi-icl-y: NOTRUN -> [SKIP][1] ([fdo#109315]) +17 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-icl-y/igt@amdgpu/[email protected]
* igt@gem_exec_fence@basic-busy@bcs0:
- fi-apl-guc: NOTRUN -> [SKIP][2] ([fdo#109271]) +1 similar issue
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-apl-guc/igt@gem_exec_fence@[email protected]
* igt@gem_huc_copy@huc-copy:
- fi-icl-y: NOTRUN -> [SKIP][3] ([i915#2190])
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-icl-y/igt@[email protected]
* igt@i915_hangman@error-state-basic:
- fi-apl-guc: NOTRUN -> [DMESG-WARN][4] ([i915#1610])
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-apl-guc/igt@[email protected]
* igt@kms_chamelium@dp-crc-fast:
- fi-icl-y: NOTRUN -> [SKIP][5] ([fdo#109284] / [fdo#111827]) +8 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-icl-y/igt@[email protected]
* igt@kms_chamelium@hdmi-crc-fast:
- fi-bsw-n3050: NOTRUN -> [SKIP][6] ([fdo#109271] / [fdo#111827]) +8 similar issues
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-bsw-n3050/igt@[email protected]
* igt@kms_force_connector_basic@force-load-detect:
- fi-icl-y: NOTRUN -> [SKIP][7] ([fdo#109285])
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-icl-y/igt@[email protected]
* igt@kms_pipe_crc_basic@compare-crc-sanitycheck-pipe-d:
- fi-icl-y: NOTRUN -> [SKIP][8] ([fdo#109278])
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-icl-y/igt@[email protected]
* igt@kms_pipe_crc_basic@hang-read-crc-pipe-a:
- fi-bsw-n3050: NOTRUN -> [SKIP][9] ([fdo#109271]) +39 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-bsw-n3050/igt@[email protected]
* igt@kms_psr@primary_mmap_gtt:
- fi-icl-y: NOTRUN -> [SKIP][10] ([fdo#110189]) +3 similar issues
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-icl-y/igt@kms_psr@primary_mmap_gtt.html
* igt@prime_vgem@basic-write:
- fi-tgl-y: [PASS][11] -> [DMESG-WARN][12] ([i915#402])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9818/fi-tgl-y/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-tgl-y/igt@[email protected]
* igt@runner@aborted:
- fi-apl-guc: NOTRUN -> [FAIL][13] ([i915#2426])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-apl-guc/igt@[email protected]
#### Possible fixes ####
* igt@fbdev@read:
- fi-tgl-y: [DMESG-WARN][14] ([i915#402]) -> [PASS][15] +2 similar issues
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9818/fi-tgl-y/igt@[email protected]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-tgl-y/igt@[email protected]
* igt@gem_exec_gttfill@basic:
- fi-kbl-8809g: [TIMEOUT][16] -> [PASS][17]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9818/fi-kbl-8809g/igt@[email protected]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-kbl-8809g/igt@[email protected]
* igt@kms_chamelium@hdmi-edid-read:
- fi-kbl-7500u: [FAIL][18] ([i915#2128]) -> [PASS][19]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_9818/fi-kbl-7500u/igt@[email protected]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/fi-kbl-7500u/igt@[email protected]
[fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
[fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
[fdo#109284]: https://bugs.freedesktop.org/show_bug.cgi?id=109284
[fdo#109285]: https://bugs.freedesktop.org/show_bug.cgi?id=109285
[fdo#109315]: https://bugs.freedesktop.org/show_bug.cgi?id=109315
[fdo#110189]: https://bugs.freedesktop.org/show_bug.cgi?id=110189
[fdo#111827]: https://bugs.freedesktop.org/show_bug.cgi?id=111827
[i915#1610]: https://gitlab.freedesktop.org/drm/intel/issues/1610
[i915#2128]: https://gitlab.freedesktop.org/drm/intel/issues/2128
[i915#2190]: https://gitlab.freedesktop.org/drm/intel/issues/2190
[i915#2426]: https://gitlab.freedesktop.org/drm/intel/issues/2426
[i915#402]: https://gitlab.freedesktop.org/drm/intel/issues/402
Participating hosts (42 -> 41)
------------------------------
Additional (3): fi-icl-y fi-apl-guc fi-bsw-n3050
Missing (4): fi-ctg-p8600 fi-ilk-m540 fi-bsw-cyan fi-bdw-samus
Build changes
-------------
* Linux: CI_DRM_9818 -> Patchwork_19738
CI-20190529: 20190529
CI_DRM_9818: fb3b93df7979b1cf6b69ac801d1703c0bf1dde66 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6016: 2107b0a53692fb329175bc16169c3699712187aa @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_19738: 45970a8fbfdfc8a84e71aef847cbfa0bb3ac0966 @ git://anongit.freedesktop.org/gfx-ci/linux
== Linux commits ==
45970a8fbfdf i915/perf: Start hrtimer only if sampling the OA buffer
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI[Intel-gfx] ✓ Fi.CI.IGT: success for i915/perf: Start hrtimer only if sampling the OA buffer
In reply to Umesh Nerlige Ramappa== Series Details ==
== Series Details ==
Series: i915/perf: Start hrtimer only if sampling the OA buffer
URL : https://patchwork.freedesktop.org/series/87524/
State : success
== Summary ==
CI Bug Log - changes from CI_DRM_9818_full -> Patchwork_19738_full
====================================================
Summary
-------
**SUCCESS**
No regressions found.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_19738/index.html
Changes
-------
No changes found
Participating hosts (10 -> 8)
------------------------------
Missing (2): pig-kbl-iris pig-icl-1065g7
Build changes
-------------
* CI: CI-20190529 -> None
* Linux: CI_DRM_9818 -> Patchwork_19738
* Piglit: piglit_4509 -> None
CI-20190529: 20190529
CI_DRM_9818: fb3b93df7979b1cf6b69ac801d1703c0bf1dde66 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_6016: 2107b0a53692fb329175bc16169c3699712187aa @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_19738: 45970a8fbfdfc8a84e71aef847cbfa0bb3ac0966 @ 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_19738/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx