drm/i915: Use ktime on wait_for
Subsystems (2)
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 · 6 lines
2.14.1 _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
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
Patchwork
CI✓ Fi.CI.BAT: success for series starting with [CI,1/2] drm/i915: Use ktime on wait_for
In reply to Mika Kuoppala== Series Details ==
== Series Details ==
Series: series starting with [CI,1/2] drm/i915: Use ktime on wait_for
URL : https://patchwork.freedesktop.org/series/42115/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4078 -> Patchwork_8774 =
== Summary - SUCCESS ==
No regressions found.
External URL: https://patchwork.freedesktop.org/api/1.0/series/42115/revisions/1/mbox/
== Known issues ==
Here are the changes found in Patchwork_8774 that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
fi-cnl-y3: PASS -> DMESG-WARN (fdo#104951)
==== Possible fixes ====
igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
fi-ivb-3520m: DMESG-WARN (fdo#106084) -> PASS fdo#104951 https://bugs.freedesktop.org/show_bug.cgi?id=104951
fdo#106084 https://bugs.freedesktop.org/show_bug.cgi?id=106084
== Participating hosts (36 -> 33) ==
Missing (3): fi-ctg-p8600 fi-ilk-m540 fi-skl-6700hq
== Build changes ==
* Linux: CI_DRM_4078 -> Patchwork_8774
CI_DRM_4078: 9391010824b34ec58217f816ba5e314e7312191d @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4444: dcc44347494231feabc588c2a76998cbc9afdf8c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_8774: d8fac5f69e93f2197dc4bd591b196a524873a795 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4444: a2f486679f467cd6e82578384f56d4aabaa8cf2e @ git://anongit.freedesktop.org/piglit
== Linux commits ==
d8fac5f69e93 drm/i915: Add compiler barrier to wait_for 4dbef50fbcf3 drm/i915: Use ktime on wait_for
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8774/issues.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 7 lines · Mika Kuoppala
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_forloop, we return timeout errorneously much earlier than what the real wallclock would say.We can't afford our waits to timeout prematurely.
Isn't this also the reason why we have *_to_jiffies_timeout() family of functions? Should those
be converted as well?
Lucas De Marchi
Quoted 43 lines
Discard jiffies and change to ktime to detect timeouts.
v2: added bugzilla entry (Imre), added stable (Chris)
Reported-by Imre Deak <[email protected]>References: https://lkml.org/lkml/2018/4/18/798 [1]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105771Cc Imre Deak <[email protected]>Cc Chris Wilson <[email protected]>Cc Ville Syrjälä <[email protected]>Cc <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>Reviewed-by Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/intel_drv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_drv.h +2
-3@@ -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 ; \ --2.14.1
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 5 lines
Lucas De Marchi _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 8 lines · Lucas De Marchi
Quoted 6 lines · Mika Kuoppala
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_forloop, we return timeout errorneously much earlier than what the real wallclock would say.
Quoted 4 lines
Quoted 1 line
We can't afford our waits to timeout prematurely.
Isn't this also the reason why we have
*_to_jiffies_timeout()family of functions?
The reason for those is that you can sample jiffies between two clock tick updates and calculate a short expiry time. So a different issue than missed updates of jiffies due to some latency.
Quoted 43 lines
Should those be converted as well?
Lucas De Marchi
Quoted 39 lines
Discard jiffies and change to ktime to detect timeouts.
v2: added bugzilla entry (Imre), added stable (Chris)
Reported-by Imre Deak <[email protected]>References: https://lkml.org/lkml/2018/4/18/798 [1]
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105771Cc Imre Deak <[email protected]>Cc Chris Wilson <[email protected]>Cc Ville Syrjälä <[email protected]>Cc <[email protected]>Signed-off-by Mika Kuoppala <[email protected]>Reviewed-by Chris Wilson <[email protected]>--- drivers/gpu/drm/i915/intel_drv.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/i915/intel_drv.h +2
-3@@ -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 ; \ --2.14.1
Quoted 13 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfxSignature · 5 lines
Lucas De Marchi _______________________________________________ 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
Patchwork
CI✓ Fi.CI.IGT: success for series starting with [CI,1/2] drm/i915: Use ktime on wait_for
In reply to Mika Kuoppala== Series Details ==
== Series Details ==
Series: series starting with [CI,1/2] drm/i915: Use ktime on wait_for
URL : https://patchwork.freedesktop.org/series/42115/
State : success
== Summary ==
= CI Bug Log - changes from CI_DRM_4078_full -> Patchwork_8774_full =
== Summary - WARNING ==
Minor unknown changes coming with Patchwork_8774_full need to be verified manually.
If you think the reported changes have nothing to do with the changes introduced in Patchwork_8774_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/42115/revisions/1/mbox/
== Possible new issues ==
Here are the unknown changes that may have been introduced in Patchwork_8774_full:
=== IGT changes ===
==== Warnings ====
igt@gem_exec_schedule@deep-bsd2:
shard-kbl: SKIP -> PASS
igt@gem_mocs_settings@mocs-rc6-vebox:
shard-kbl: PASS -> SKIP +1
igt@kms_atomic_transition@plane-all-transition-nonblocking:
shard-snb: PASS -> SKIP +2
igt@kms_vblank@pipe-b-wait-forked-busy-hang:
shard-glk: SKIP -> PASS +79
igt@kms_vblank@pipe-c-wait-forked-busy:
shard-glk: PASS -> SKIP +103== Known issues ==
Here are the changes found in Patchwork_8774_full that come from known issues:
=== IGT changes ===
==== Issues hit ====
igt@kms_flip@2x-flip-vs-wf_vblank-interruptible:
shard-hsw: PASS -> FAIL (fdo#100368)
igt@kms_flip@flip-vs-wf_vblank-interruptible:
shard-glk: PASS -> FAIL (fdo#105312)
igt@kms_flip@plain-flip-ts-check:
shard-glk: PASS -> FAIL (fdo#100368)
igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-indfb-draw-mmap-wc:
shard-kbl: PASS -> INCOMPLETE (fdo#103665)
igt@kms_vblank@pipe-c-accuracy-idle:
shard-hsw: PASS -> FAIL (fdo#102583)
==== Possible fixes ====
igt@gem_eio@suspend:
shard-kbl: DMESG-WARN -> PASS
igt@kms_atomic_transition@1x-modeset-transitions-nonblocking-fencing:
shard-apl: FAIL (fdo#103207) -> PASS
igt@kms_flip@2x-flip-vs-absolute-wf_vblank-interruptible:
shard-hsw: FAIL (fdo#100368) -> PASS
igt@kms_flip@blocking-absolute-wf_vblank-interruptible:
shard-glk: FAIL (fdo#106134) -> SKIP
igt@kms_flip@flip-vs-absolute-wf_vblank-interruptible:
shard-glk: FAIL (fdo#105312) -> PASS
igt@kms_flip@modeset-vs-vblank-race:
shard-hsw: FAIL (fdo#103060) -> PASS
igt@kms_flip@wf_vblank-ts-check-interruptible:
shard-glk: FAIL (fdo#103933) -> PASS
igt@kms_setmode@basic:
shard-glk: FAIL (fdo#99912) -> PASS fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
fdo#102583 https://bugs.freedesktop.org/show_bug.cgi?id=102583
fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
fdo#103207 https://bugs.freedesktop.org/show_bug.cgi?id=103207
fdo#103665 https://bugs.freedesktop.org/show_bug.cgi?id=103665
fdo#103933 https://bugs.freedesktop.org/show_bug.cgi?id=103933
fdo#105312 https://bugs.freedesktop.org/show_bug.cgi?id=105312
fdo#106134 https://bugs.freedesktop.org/show_bug.cgi?id=106134
fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
== Participating hosts (6 -> 5) ==
Missing (1): shard-glkb
== Build changes ==
* Linux: CI_DRM_4078 -> Patchwork_8774
CI_DRM_4078: 9391010824b34ec58217f816ba5e314e7312191d @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_4444: dcc44347494231feabc588c2a76998cbc9afdf8c @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_8774: d8fac5f69e93f2197dc4bd591b196a524873a795 @ git://anongit.freedesktop.org/gfx-ci/linux
piglit_4444: a2f486679f467cd6e82578384f56d4aabaa8cf2e @ git://anongit.freedesktop.org/piglit
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_8774/shards.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx