drm/i915: Use ktime on wait_for
Subsystems (3)
PATCH 1/2 drm/i915: Use ktime on wait_for
We use jiffies to determine when wait expires. However Imre did find out that jiffies can and will do a >1 increments on certain situations [1]. When this happens in a wait_for loop, we return timeout errorneously much earlier than what the real wallclock would say.
We can't afford our waits to timeout prematurely. Discard jiffies and change to ktime to detect timeouts.
v2: added bugzilla entry (Imre), added stable (Chris)
References: https://lkml.org/lkml/2018/4/18/798 [1]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105771
--- drivers/gpu/drm/i915/intel_drv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +2 -2
@@ -49,12 +49,12 @@* check the condition before the timeout. */ #define __wait_for (OP ,COND ,US , Wmin, Wmax) ({ \ - unsigned long timeout__ = jiffies + usecs_to_jiffies(US) + 1; \ + const ktime_t end__ = ktime_add_ns(ktime_get_raw(), 1000ll * (US)); \ long wait__ = (Wmin);/* recommended min for usleep is 10 us */ \int ret__; \might_sleep (); \for (;;) { \ -bool expired__ =time_after (jiffies, timeout__); \ +const bool expired__ =ktime_after (ktime_get_raw (), end__); \OP ; \if (COND ) { \ ret__ =0 ; \
Signature · 1 line
2.14.1
PATCH 2/2 drm/i915: Add compiler barrier to wait_for
We need to be careful to not let compiler evaluate the expiration and the operation on it's terms.
Document and enforce that COND will be evaluated before checking timeout expiration.
--- drivers/gpu/drm/i915/intel_drv.h | 4 ++++ 1 file changed, 4 insertions(+)
drivers/gpu/drm/i915/intel_drv.h +4 -0
@@ -56,6 +56,8 @@for (;;) { \const bool expired__ =ktime_after (ktime_get_raw (), end__); \OP ; \ +/* Guarantee COND check prior to timeout */ \ +barrier (); \if (COND ) { \ ret__ =0 ; \break ; \
@@ -96,6 +98,8 @@u64 now =local_clock (); \if (!(ATOMIC )) \preempt_enable (); \ +/* Guarantee COND check prior to timeout */ \ +barrier (); \if (COND ) { \ ret =0 ; \break ; \
Signature · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 2/2] drm/i915: Add compiler barrier to wait_for
Quoting Mika Kuoppala (2018-04-20 14:45:50)
Quoted 18 lines
We need to be careful to not let compiler evaluate the expiration and the operation on it's terms.
Document and enforce that COND will be evaluated before checking timeout expiration.
Suggested-by Chris Wilson <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>--- drivers/gpu/drm/i915/intel_drv.h | 4 ++++ 1 file changed, 4 insertions(+)drivers/gpu/drm/i915/intel_drv.h +0
-0
drivers/gpu/drm/i915/intel_drv.h line 60
Quoted 5 lines
drivers/gpu/drm/i915/intel_drv.h +2
-0@@ -56,6 +56,8 @@for (;;) { \const bool expired__ =ktime_after (ktime_get_raw (), end__); \OP ; \ +/* Guarantee COND check prior to timeout */ \ +barrier (); \
Which side of OP is debatable, since OP is caller supplied and our constraint is targeted at expired__. However, it is likely to be more useful between OP/COND, so I can see some advantage there.
As Mika noted, moving to a function call should mean that the compiler has less freedom to reorder/re-evaluate but doesn't completely prevent it. As such being clear about the order of operations here is just as important for the reader. There is a long history of gotchas here, and this patch set continues the trend :)
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Use ktime on wait_for
In reply to Mika Kuoppala== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/i915: Use ktime on wait_for
URL : https://patchwork.freedesktop.org/series/42035/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4072 -> Patchwork_8764 =
== Summary - SUCCESS ==
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/42035/revisions/1/mbox/
== Known issues ==
Here are the changes found in Patchwork_8764 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@drv_module_reload@basic-no-display:
fi-cnl-psr: NOTRUN -> DMESG-WARN (fdo#105395) +2
igt@gem_exec_suspend@basic-s3:
fi-ivb-3520m: PASS -> DMESG-WARN (fdo#106084)
==== Possible fixes ====
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
fi-ivb-3520m: DMESG-WARN (fdo#106084) -> PASS fdo#105395 https://bugs.freedesktop.org/show_bug.cgi?id=105395
fdo#106084 https://bugs.freedesktop.org/show_bug.cgi?id=106084
== Participating hosts (33 -> 33) ==
Additional (2): fi-kbl-7560u fi-cnl-psr
Missing (2): fi-ilk-m540 fi-skl-6700hq
== Build changes ==
* Linux: CI_DRM_4072 -> Patchwork_8764
CI_DRM_4072: b35e59e5c6a9cae11d5183d2bf9c5c99ceedbc7c @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4442: 8168bb65d5e64d4df4e5d847d448bab2d2825d73 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_8764: ae064ac61a135c5543fec9fe7a171f68bfc1a28e @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4442: e60d247eb359f044caf0c09904da14e39d7adca1 @ git://anongit.freedesktop.org/piglit
== Linux commits ==
ae064ac61a13 drm/i915: Add compiler barrier to wait_for d5e6b76f3037 drm/i915: Use ktime on wait_for
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8764/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Patchwork
CI✗ Fi.CI.IGT: failure for series starting with [1/2] drm/i915: Use ktime on wait_for
In reply to Mika Kuoppala== Series Details ==
== Series Details ==
Series: series starting with [1/2] drm/i915: Use ktime on wait_for
URL : https://patchwork.freedesktop.org/series/42035/
State : failure
== Summary ==
= CI Bug Log - changes from CI_DRM_4072_full -> Patchwork_8764_full =
== Summary - FAILURE ==
Serious unknown changes coming with Patchwork_8764_full absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_8764_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.
External URL: https://patchwork.freedesktop.org/api/1.0/series/42035/revisions/1/mbox/
== Possible new issues ==
Here are the unknown changes that may have been introduced in Patchwork_8764_full:
=== IGT changes ===
==== Possible regressions ====
igt@gem_exec_suspend@basic-s3-devices:
shard-hsw: PASS -> DMESG-WARN
==== Warnings ====
igt@gem_mocs_settings@mocs-rc6-render:
shard-kbl: SKIP -> PASS
igt@kms_vblank@pipe-b-wait-forked-busy-hang:
shard-glk: SKIP -> PASS +85
igt@pm_rpm@modeset-non-lpsp:
shard-glk: PASS -> SKIP +58== Known issues ==
Here are the changes found in Patchwork_8764_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@gem_ppgtt@blt-vs-render-ctxn:
shard-kbl: PASS -> INCOMPLETE (fdo#103665, fdo#106023)
igt@kms_flip@flip-vs-wf_vblank-interruptible:
shard-glk: PASS -> FAIL (fdo#100368) +1
igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-blt:
shard-kbl: PASS -> DMESG-WARN (fdo#105602, fdo#103558) +38
==== Possible fixes ====
igt@kms_flip@dpms-vs-vblank-race-interruptible:
shard-glk: FAIL (fdo#103060) -> SKIP
igt@kms_flip@plain-flip-fb-recreate:
shard-hsw: FAIL (fdo#100368) -> PASS
igt@kms_flip@plain-flip-ts-check-interruptible:
shard-glk: FAIL (fdo#100368) -> PASS +1
igt@kms_setmode@basic:
shard-glk: FAIL (fdo#99912) -> PASS
igt@perf@blocking:
shard-hsw: FAIL (fdo#102252) -> PASS fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
== Participating hosts (6 -> 5) ==
Missing (1): shard-glkb
== Build changes ==
* Linux: CI_DRM_4072 -> Patchwork_8764
CI_DRM_4072: b35e59e5c6a9cae11d5183d2bf9c5c99ceedbc7c @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4442: 8168bb65d5e64d4df4e5d847d448bab2d2825d73 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_8764: ae064ac61a135c5543fec9fe7a171f68bfc1a28e @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4442: e60d247eb359f044caf0c09904da14e39d7adca1 @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8764/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✗ Fi.CI.IGT: failure for series starting with [1/2] drm/i915: Use ktime on wait_for
Quoted 23 lines · Patchwork
== Series Details ==
Series: series starting with [1/2] drm/i915: Use ktime on
wait_for
URL : https://patchwork.freedesktop.org/series/42035/
State : failure== Summary ==
= CI Bug Log - changes from
CI_DRM_4072_full->Patchwork_8764_full=== Summary - FAILURE ==
Serious unknown changes coming with
Patchwork_8764_fullabsolutely need to be verified manually.If you think the reported changes have nothing to do with the changes introduced in
Patchwork_8764_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.External URL: https://patchwork.freedesktop.org/api/1.0/series/42035/revisions/1/mbox/
== Possible new issues ==
Quoted 8 lines
Here are the unknown changes that may have been introduced in
Patchwork_8764_full:=== IGT changes ===
==== Possible regressions ==== igt@gem_exec_suspend@basic-s3-devices: shard-hsw: PASS -> DMESG-WARN
Looks like https://bugs.freedesktop.org/show_bug.cgi?id=106086
Quoted 74 lines
==== Warnings ==== igt@gem_mocs_settings@mocs-rc6-render: shard-kbl: SKIP -> PASS igt@kms_vblank@pipe-b-wait-forked-busy-hang: shard-glk: SKIP -> PASS +85 igt@pm_rpm@modeset-non-lpsp: shard-glk: PASS -> SKIP +58== Known issues ==
Here are the changes found in
Patchwork_8764_fullthat come from known issues:=== IGT changes ===
==== Issues hit ==== igt@gem_ppgtt@blt-vs-render-ctxn: shard-kbl: PASS -> INCOMPLETE (fdo#103665, fdo#106023) igt@kms_flip@flip-vs-wf_vblank-interruptible: shard-glk: PASS -> FAIL (fdo#100368) +1 igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-blt: shard-kbl: PASS -> DMESG-WARN (fdo#105602, fdo#103558) +38 ==== Possible fixes ==== igt@kms_flip@dpms-vs-vblank-race-interruptible: shard-glk: FAIL (fdo#103060) -> SKIP igt@kms_flip@plain-flip-fb-recreate: shard-hsw: FAIL (fdo#100368) -> PASS igt@kms_flip@plain-flip-ts-check-interruptible: shard-glk: FAIL (fdo#100368) -> PASS +1 igt@kms_setmode@basic: shard-glk: FAIL (fdo#99912) -> PASS igt@perf@blocking: shard-hsw: FAIL (fdo#102252) -> PASSfdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912== Participating hosts (6 -> 5) ==
Missing (1): shard-glkb
== Build changes ==
* Linux:
CI_DRM_4072->Patchwork_8764
CI_DRM_4072:b35e59e5c6a9cae11d5183d2bf9c5c99ceedbc7c@git://anongit.freedesktop.org/gfx-ci/linux
IGT_4442:8168bb65d5e64d4df4e5d847d448bab2d2825d73@git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_8764:ae064ac61a135c5543fec9fe7a171f68bfc1a28e@git://anongit.freedesktop.org/gfx-ci/linux
piglit_4442:e60d247eb359f044caf0c09904da14e39d7adca1@git://anongit.freedesktop.org/piglit
Quoted 8 lines
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8764/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: ✗ Fi.CI.IGT: failure for series starting with [1/2] drm/i915: Use ktime on wait_for
Quoted 26 lines · Martin Peres
Quoted 25 lines · Patchwork
== Series Details ==
Series: series starting with [1/2] drm/i915: Use ktime on
wait_for
URL : https://patchwork.freedesktop.org/series/42035/
State : failure== Summary ==
= CI Bug Log - changes from
CI_DRM_4072_full->Patchwork_8764_full=== Summary - FAILURE ==
Serious unknown changes coming with
Patchwork_8764_fullabsolutely need to be verified manually.If you think the reported changes have nothing to do with the changes introduced in
Patchwork_8764_full, please notify your bug team to allow them to document this new failure mode, which will reduce false positives in CI.External URL: https://patchwork.freedesktop.org/api/1.0/series/42035/revisions/1/mbox/
== Possible new issues ==
Here are the unknown changes that may have been introduced in
Patchwork_8764_full:
Quoted 8 lines
Quoted 6 lines
=== IGT changes ===
==== Possible regressions ==== igt@gem_exec_suspend@basic-s3-devices: shard-hsw: PASS -> DMESG-WARNLooks like https://bugs.freedesktop.org/show_bug.cgi?id=106086
Yes. As this patch has potential to affect timings across the i915, I wanted a second opinion. Thanks Martin!
-Mika
Quoted 75 lines
Quoted 75 lines
==== Warnings ==== igt@gem_mocs_settings@mocs-rc6-render: shard-kbl: SKIP -> PASS igt@kms_vblank@pipe-b-wait-forked-busy-hang: shard-glk: SKIP -> PASS +85 igt@pm_rpm@modeset-non-lpsp: shard-glk: PASS -> SKIP +58== Known issues ==
Here are the changes found in
Patchwork_8764_fullthat come from known issues:=== IGT changes ===
==== Issues hit ==== igt@gem_ppgtt@blt-vs-render-ctxn: shard-kbl: PASS -> INCOMPLETE (fdo#103665, fdo#106023) igt@kms_flip@flip-vs-wf_vblank-interruptible: shard-glk: PASS -> FAIL (fdo#100368) +1 igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-blt: shard-kbl: PASS -> DMESG-WARN (fdo#105602, fdo#103558) +38 ==== Possible fixes ==== igt@kms_flip@dpms-vs-vblank-race-interruptible: shard-glk: FAIL (fdo#103060) -> SKIP igt@kms_flip@plain-flip-fb-recreate: shard-hsw: FAIL (fdo#100368) -> PASS igt@kms_flip@plain-flip-ts-check-interruptible: shard-glk: FAIL (fdo#100368) -> PASS +1 igt@kms_setmode@basic: shard-glk: FAIL (fdo#99912) -> PASS igt@perf@blocking: shard-hsw: FAIL (fdo#102252) -> PASSfdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102252 https://bugs.freedesktop.org/show_bug.cgi?id=102252
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#103558 https://bugs.freedesktop.org/show_bug.cgi?id=103558
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#105602 https://bugs.freedesktop.org/show_bug.cgi?id=105602
fdo#106023 https://bugs.freedesktop.org/show_bug.cgi?id=106023
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912== Participating hosts (6 -> 5) ==
Missing (1): shard-glkb
== Build changes ==
* Linux:
CI_DRM_4072->Patchwork_8764
CI_DRM_4072:b35e59e5c6a9cae11d5183d2bf9c5c99ceedbc7c@git://anongit.freedesktop.org/gfx-ci/linux
IGT_4442:8168bb65d5e64d4df4e5d847d448bab2d2825d73@git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_8764:ae064ac61a135c5543fec9fe7a171f68bfc1a28e@git://anongit.freedesktop.org/gfx-ci/linux
piglit_4442:e60d247eb359f044caf0c09904da14e39d7adca1@git://anongit.freedesktop.org/piglit
Quoted 8 lines
Quoted 8 lines
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8764/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx