drm/i915/gt: Use poll_timeout_us in place of sliding sleep window
Subsystems (2)
PATCH v3 1/1 drm/i915/gt: Use poll_timeout_us in place of sliding sleep window
The functions intel_guc_send_busy_loop and ct_send can theoretically loop forever. In the former case, intel_guc_send_busy_loop can iterate forever if intel_guc_send_nb repeatedly returns -EBUSY. In the latter case, ct_send can loop forever if the guc-to-host or host-to-guc buffers get stuck in a full state.
Rework the functions to use the poll_timeout_us family of functions instead of calculating sleep_period_ms repeatedly. In both cases now, if the loop condition is not met after 10 minutes, the function will report it as a failure.
This also resolves a static analysis issue involving sleep_period_ms overflowing after several shift-left-logical calls.
v2:
- Reduce default sleep/udelay duration (jcavitt)
v3:
- Use atomic in ct_send (jcavitt)
--- drivers/gpu/drm/i915/gt/uc/intel_guc.h | 32 +++++++++++------------ drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c | 19 +++++--------- 2 files changed, 23 insertions(+), 28 deletions(-)
drivers/gpu/drm/i915/gt/uc/intel_guc.h +16 -16
@@ -7,6 +7,7 @@#define _INTEL_GUC_H_#include <linux/delay.h> +#include <linux/iopoll.h> #include <linux/iosys-map.h> #include <linux/xarray.h>
@@ -360,8 +361,7 @@ static inline int intel_guc_send_busy_loop(struct intel_guc *guc,u32 g2h_len_dw, bool loop) { - int err; -unsigned int sleep_period_ms =1 ; + int err, timedout;bool not_atomic = !in_atomic () && !irqs_disabled ();/*
@@ -374,20 +374,20 @@ static inline int intel_guc_send_busy_loop(struct intel_guc *guc,/* No sleeping with spin locks, just busy loop */ might_sleep_if (loop && not_atomic); -retry: - err =intel_guc_send_nb (guc, action, len, g2h_len_dw); -if (unlikely (err == -EBUSY && loop)) { -if (likely (not_atomic)) { -if (msleep_interruptible (sleep_period_ms)) -return -EINTR ; - sleep_period_ms = sleep_period_ms <<1 ; - }else { -cpu_relax (); - } - goto retry; - } - -return err; +if (!loop) +return intel_guc_send_nb (guc, action, len, g2h_len_dw); + +if (not_atomic) + timedout =poll_timeout_us (err =intel_guc_send_nb (guc, action, + len, g2h_len_dw), + err != -EBUSY ,USEC_PER_MSEC , +600 *USEC_PER_SEC , false); +else + timedout =poll_timeout_us_atomic (err =intel_guc_send_nb (guc, action, + len, g2h_len_dw), + err != -EBUSY ,USEC_PER_MSEC , +600 *USEC_PER_SEC , false); +return timedout ?: err; }/* Only call this from the interrupt handler code */
drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c +7 -12
@@ -716,7 +716,6 @@ static int ct_send(struct intel_guc_ct *ct,struct intel_guc_ct_buffer *ctb = &ct->ctbs.send;struct ct_request request;unsigned long flags; -unsigned int sleep_period_ms =1 ;bool send_again;u32 fence;int err;
@@ -736,22 +735,18 @@ static int ct_send(struct intel_guc_ct *ct,* rare. Reserving the maximum size in the G2H credits as we don't know * how big the response is going to be. */ -retry:spin_lock_irqsave (&ctb->lock, flags); -if (unlikely (!h2g_has_room (ct, len +GUC_CTB_HDR_LEN ) || - !g2h_has_room (ct,GUC_CTB_HXG_MSG_MAX_LEN ))) { + err =poll_timeout_us_atomic (err =0 , + !h2g_has_room (ct, len +GUC_CTB_HDR_LEN ) || + !g2h_has_room (ct,GUC_CTB_HXG_MSG_MAX_LEN ), +USEC_PER_MSEC ,600 *USEC_PER_SEC , false); + +if (err) {if (ct->stall_time ==KTIME_MAX ) ct->stall_time =ktime_get ();spin_unlock_irqrestore (&ctb->lock, flags); -if (unlikely (ct_deadlocked (ct))) -return -EPIPE ; - -if (msleep_interruptible (sleep_period_ms)) -return -EINTR ; - sleep_period_ms = sleep_period_ms <<1 ; - - goto retry; +return unlikely (ct_deadlocked (ct)) ? -EPIPE : err; } ct->stall_time =KTIME_MAX ;
Signature · 1 line
2.53.0
Patchwork
CI✗ i915.CI.BAT: failure for drm/i915/gt: Use poll_timeout_us in place of sliding sleep window (rev3)
== Series Details ==
== Series Details ==
Series: drm/i915/gt: Use poll_timeout_us in place of sliding sleep window (rev3)
URL : https://patchwork.freedesktop.org/series/169454/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_18736 -> Patchwork_169454v3
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_169454v3 absolutely need to be verified manually.
If you think the reported changes have nothing to do with the changes
introduced in Patchwork_169454v3, 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_169454v3/index.html
Participating hosts (41 -> 40)
------------------------------
Additional (1): bat-adls-6
Missing (2): bat-dg2-13 fi-snb-2520m
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_169454v3:
### CI changes ###
#### Possible regressions ####
* boot:
- bat-dg2-8: [PASS][1] -> [FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-dg2-8/boot.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-dg2-8/boot.html
- bat-arls-6: [PASS][3] -> [FAIL][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-arls-6/boot.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-arls-6/boot.html
- bat-mtlp-8: [PASS][5] -> [FAIL][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-mtlp-8/boot.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-mtlp-8/boot.html
- bat-arlh-2: [PASS][7] -> [FAIL][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-arlh-2/boot.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-arlh-2/boot.html
- bat-atsm-1: [PASS][9] -> [FAIL][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-atsm-1/boot.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-atsm-1/boot.html
- bat-adlp-9: [PASS][11] -> [FAIL][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-adlp-9/boot.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-adlp-9/boot.html
- bat-rpls-4: [PASS][13] -> [FAIL][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-rpls-4/boot.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-rpls-4/boot.html
### IGT changes ###
#### Possible regressions ####
* igt@i915_module_load@load:
- bat-adlp-6: [PASS][15] -> [ABORT][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-adlp-6/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-adlp-6/igt@[email protected]
- bat-arlh-3: [PASS][17] -> [ABORT][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-arlh-3/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-arlh-3/igt@[email protected]
- bat-dg1-7: [PASS][19] -> [INCOMPLETE][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-dg1-7/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-dg1-7/igt@[email protected]
- bat-twl-2: [PASS][21] -> [INCOMPLETE][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-twl-2/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-twl-2/igt@[email protected]
- bat-twl-1: [PASS][23] -> [INCOMPLETE][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-twl-1/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-twl-1/igt@[email protected]
- bat-dg2-14: [PASS][25] -> [INCOMPLETE][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-dg2-14/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-dg2-14/igt@[email protected]
- bat-arls-5: [PASS][27] -> [ABORT][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-arls-5/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-arls-5/igt@[email protected]
- bat-rplp-1: [PASS][29] -> [INCOMPLETE][30]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-rplp-1/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-rplp-1/igt@[email protected]
- fi-cfl-guc: [PASS][31] -> [INCOMPLETE][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/fi-cfl-guc/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/fi-cfl-guc/igt@[email protected]
- bat-mtlp-9: [PASS][33] -> [ABORT][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-mtlp-9/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-mtlp-9/igt@[email protected]
- bat-dg2-9: [PASS][35] -> [INCOMPLETE][36]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-dg2-9/igt@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-dg2-9/igt@[email protected]
- bat-adlp-11: [PASS][37] -> [ABORT][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-adlp-11/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-adlp-11/igt@[email protected]
- bat-dg1-6: [PASS][39] -> [INCOMPLETE][40]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18736/bat-dg1-6/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-dg1-6/igt@[email protected]
- bat-adls-6: NOTRUN -> [INCOMPLETE][41]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/bat-adls-6/igt@[email protected]
Build changes
-------------
* Linux: CI_DRM_18736 -> Patchwork_169454v3
CI-20190529: 20190529
CI_DRM_18736: 7100870965845da8c31005c07fd1b390bbe96b20 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_8988: 8988
Patchwork_169454v3: 7100870965845da8c31005c07fd1b390bbe96b20 @ git://anongit.freedesktop.org/gfx-ci/linux
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v3/index.html
Hi Jonathan,
Quoted 66 lines · Jonathan Cavitt
The functions
intel_guc_send_busy_loopandct_sendcan theoretically loop forever. In the former case,intel_guc_send_busy_loopcan iterate forever ifintel_guc_send_nbrepeatedly returns-EBUSY. In the latter case,ct_sendcan loop forever if the guc-to-host or host-to-guc buffers get stuck in a full state.Rework the functions to use the
poll_timeout_usfamily of functions instead of calculatingsleep_period_msrepeatedly. In both cases now, if the loop condition is not met after 10 minutes, the function will report it as a failure.This also resolves a static analysis issue involving
sleep_period_msoverflowing after several shift-left-logical calls.v2:
- Reduce default sleep/udelay duration (jcavitt)v3:
- Use atomic inct_send(jcavitt)Suggested-by Jani Nikula <[email protected]>Signed-off-by Jonathan Cavitt <[email protected]>Cc Andi Shyti <[email protected]>--- drivers/gpu/drm/i915/gt/uc/intel_guc.h | 32 +++++++++++------------ drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c | 19 +++++--------- 2 files changed, 23 insertions(+), 28 deletions(-)drivers/gpu/drm/i915/gt/uc/intel_guc.h +2
-14@@ -7,6 +7,7 @@#define _INTEL_GUC_H_#include <linux/delay.h> +#include <linux/iopoll.h> #include <linux/iosys-map.h> #include <linux/xarray.h> @@ -360,8 +361,7 @@ static inline int intel_guc_send_busy_loop(struct intel_guc *guc,u32 g2h_len_dw, bool loop) { - int err; -unsigned int sleep_period_ms =1 ; + int err, timedout;bool not_atomic = !in_atomic () && !irqs_disabled ();/* @@ -374,20 +374,20 @@ static inline int intel_guc_send_busy_loop(struct intel_guc *guc,/* No sleeping with spin locks, just busy loop */ might_sleep_if (loop && not_atomic); -retry: - err =intel_guc_send_nb (guc, action, len, g2h_len_dw); -if (unlikely (err == -EBUSY && loop)) { -if (likely (not_atomic)) { -if (msleep_interruptible (sleep_period_ms)) -return -EINTR ; - sleep_period_ms = sleep_period_ms <<1 ; - }else { -cpu_relax (); - } - goto retry; - }
drivers/gpu/drm/i915/gt/uc/intel_guc.h static inline int intel_guc_send_busy_loop(struct intel_guc *guc, · line 384
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_guc.h +8
-2- -return err; +if (!loop) +return intel_guc_send_nb (guc, action, len, g2h_len_dw); + +if (not_atomic) + timedout =poll_timeout_us (err =intel_guc_send_nb (guc, action, + len, g2h_len_dw), + err != -EBUSY ,USEC_PER_MSEC , +600 *USEC_PER_SEC , false);
Was there a reason for choosing 10 minutes or wat that more of a "should be long enough" decision?
Also, since you use this magic number in multiple places, it might be beneficial to put it behind a #define symbol that is easily trackable in git history.
Signature · 2 lines
Best Regards, Krzysztof
-----Original Message-----
From: Karas, Krzysztof <[email protected]>
Sent: Wednesday, July 1, 2026 1:36 AM
To: Cavitt, Jonathan <[email protected]>
Cc: [email protected]; Zuo, Alex <[email protected]>; [email protected]; Shyti, Andi <[email protected]>
Subject: Re: [PATCH v3] drm/i915/gt: Use poll_timeout_us in place of sliding sleep window
Quoted 74 lines
Hi Jonathan,
Quoted 70 lines · Jonathan Cavitt
The functions
intel_guc_send_busy_loopandct_sendcan theoretically loop forever. In the former case,intel_guc_send_busy_loopcan iterate forever ifintel_guc_send_nbrepeatedly returns-EBUSY. In the latter case,ct_sendcan loop forever if the guc-to-host or host-to-guc buffers get stuck in a full state.Rework the functions to use the
poll_timeout_usfamily of functions instead of calculatingsleep_period_msrepeatedly. In both cases now, if the loop condition is not met after 10 minutes, the function will report it as a failure.This also resolves a static analysis issue involving
sleep_period_msoverflowing after several shift-left-logical calls.v2:
- Reduce default sleep/udelay duration (jcavitt)v3:
- Use atomic inct_send(jcavitt)Suggested-by Jani Nikula <[email protected]>Signed-off-by Jonathan Cavitt <[email protected]>Cc Andi Shyti <[email protected]>--- drivers/gpu/drm/i915/gt/uc/intel_guc.h | 32 +++++++++++------------ drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c | 19 +++++--------- 2 files changed, 23 insertions(+), 28 deletions(-)drivers/gpu/drm/i915/gt/uc/intel_guc.h +4
-16@@ -7,6 +7,7 @@#define _INTEL_GUC_H_#include <linux/delay.h> +#include <linux/iopoll.h> #include <linux/iosys-map.h> #include <linux/xarray.h> @@ -360,8 +361,7 @@ static inline int intel_guc_send_busy_loop(struct intel_guc *guc,u32 g2h_len_dw, bool loop) { - int err; -unsigned int sleep_period_ms =1 ; + int err, timedout;bool not_atomic = !in_atomic () && !irqs_disabled ();/* @@ -374,20 +374,20 @@ static inline int intel_guc_send_busy_loop(struct intel_guc *guc,/* No sleeping with spin locks, just busy loop */ might_sleep_if (loop && not_atomic); -retry: - err =intel_guc_send_nb (guc, action, len, g2h_len_dw); -if (unlikely (err == -EBUSY && loop)) { -if (likely (not_atomic)) { -if (msleep_interruptible (sleep_period_ms)) -return -EINTR ; - sleep_period_ms = sleep_period_ms <<1 ; - }else { -cpu_relax (); - } - goto retry; - } - -return err; +if (!loop) +return intel_guc_send_nb (guc, action, len, g2h_len_dw);
Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_guc.h static inline int intel_guc_send_busy_loop(struct intel_guc *guc, · line 384
Quoted 6 lines
drivers/gpu/drm/i915/gt/uc/intel_guc.h +6
-0+ +if (not_atomic) + timedout =poll_timeout_us (err =intel_guc_send_nb (guc, action, + len, g2h_len_dw), + err != -EBUSY ,USEC_PER_MSEC , +600 *USEC_PER_SEC , false);Was there a reason for choosing 10 minutes or wat that more of a "should be long enough" decision?
Yes.
Quoted 3 lines
Also, since you use this magic number in multiple places, it might be beneficial to put it behind a #define symbol that is easily trackable in git history.
I'll do that as soon as I figure out why poll_timeout_us is causing the driver to fail loading. Or, alternatively, I'll apply this revision note to https://patchwork.freedesktop.org/series/162517/ once it receives better than lukewarm approval.
I should also note that all this effort is being put towards preventing an integer overflow that isn't even particularly likely to happen in the first place. By all accounts, it might be better to just close the report internally and be done with it.
-Jonathan Cavitt
Quoted 5 lines
Signature · 3 lines
-- Best Regards, Krzysztof
Quoted 89 lines · Jonathan
-----Original Message-----
From: Karas, Krzysztof <[email protected]>
Sent: Wednesday, July 1, 2026 1:36 AM
To: Cavitt, Jonathan <[email protected]>
Cc: [email protected]; Zuo, Alex <[email protected]>; [email protected]; Shyti, Andi <[email protected]>
Subject: Re: [PATCH v3] drm/i915/gt: Usepoll_timeout_usin place of sliding sleep windowQuoted 74 lines
Hi Jonathan,
Quoted 70 lines · Jonathan Cavitt
The functions
intel_guc_send_busy_loopandct_sendcan theoretically loop forever. In the former case,intel_guc_send_busy_loopcan iterate forever ifintel_guc_send_nbrepeatedly returns-EBUSY. In the latter case,ct_sendcan loop forever if the guc-to-host or host-to-guc buffers get stuck in a full state.Rework the functions to use the
poll_timeout_usfamily of functions instead of calculatingsleep_period_msrepeatedly. In both cases now, if the loop condition is not met after 10 minutes, the function will report it as a failure.This also resolves a static analysis issue involving
sleep_period_msoverflowing after several shift-left-logical calls.v2:
- Reduce default sleep/udelay duration (jcavitt)v3:
- Use atomic inct_send(jcavitt)Suggested-by Jani Nikula <[email protected]>Signed-off-by Jonathan Cavitt <[email protected]>Cc Andi Shyti <[email protected]>--- drivers/gpu/drm/i915/gt/uc/intel_guc.h | 32 +++++++++++------------ drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c | 19 +++++--------- 2 files changed, 23 insertions(+), 28 deletions(-)drivers/gpu/drm/i915/gt/uc/intel_guc.h +4
-16@@ -7,6 +7,7 @@#define _INTEL_GUC_H_#include <linux/delay.h> +#include <linux/iopoll.h> #include <linux/iosys-map.h> #include <linux/xarray.h> @@ -360,8 +361,7 @@ static inline int intel_guc_send_busy_loop(struct intel_guc *guc,u32 g2h_len_dw, bool loop) { - int err; -unsigned int sleep_period_ms =1 ; + int err, timedout;bool not_atomic = !in_atomic () && !irqs_disabled ();/* @@ -374,20 +374,20 @@ static inline int intel_guc_send_busy_loop(struct intel_guc *guc,/* No sleeping with spin locks, just busy loop */ might_sleep_if (loop && not_atomic); -retry: - err =intel_guc_send_nb (guc, action, len, g2h_len_dw); -if (unlikely (err == -EBUSY && loop)) { -if (likely (not_atomic)) { -if (msleep_interruptible (sleep_period_ms)) -return -EINTR ; - sleep_period_ms = sleep_period_ms <<1 ; - }else { -cpu_relax (); - } - goto retry; - } - -return err; +if (!loop) +return intel_guc_send_nb (guc, action, len, g2h_len_dw);Quoted 8 lines
drivers/gpu/drm/i915/gt/uc/intel_guc.h static inline int intel_guc_send_busy_loop(struct intel_guc *guc, · line 384
Quoted 6 lines
drivers/gpu/drm/i915/gt/uc/intel_guc.h +6
-0+ +if (not_atomic) + timedout =poll_timeout_us (err =intel_guc_send_nb (guc, action, + len, g2h_len_dw), + err != -EBUSY ,USEC_PER_MSEC , +600 *USEC_PER_SEC , false);Was there a reason for choosing 10 minutes or wat that more of a "should be long enough" decision?
Quoted 1 line
Yes.
Okay, thanks for clarifying.
Quoted 10 lines
Quoted 4 lines
Also, since you use this magic number in multiple places, it might be beneficial to put it behind a #define symbol that is easily trackable in git history.
I'll do that as soon as I figure out why
poll_timeout_usis causing the driver to fail loading. Or, alternatively, I'll apply this revision note to https://patchwork.freedesktop.org/series/162517/ once it receives better than lukewarm approval.
Quoted 5 lines
I should also note that all this effort is being put towards preventing an integer overflow that isn't even particularly likely to happen in the first place. By all accounts, it might be better to just close the report internally and be done with it.
-Jonathan Cavitt
If you decide to make another version, I'll be happy to review it ;)
Quoted 6 lines
Quoted 6 lines
Signature · 3 lines
-- Best Regards, Krzysztof
Signature · 2 lines
Best Regards, Krzysztof
Hi Jonathan,
...
Quoted 14 lines
drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c +0
-1@@ -716,7 +716,6 @@ static int ct_send(struct intel_guc_ct *ct,struct intel_guc_ct_buffer *ctb = &ct->ctbs.send;struct ct_request request;unsigned long flags; -unsigned int sleep_period_ms =1 ;bool send_again;u32 fence;int err;@@ -736,22 +735,18 @@ static int ct_send(struct intel_guc_ct *ct,* rare. Reserving the maximum size in the G2H credits as we don't know
drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c static int ct_send(struct intel_guc_ct *ct, · line 742
Quoted 10 lines
drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c +4
-3* how big the response is going to be. */ -retry:spin_lock_irqsave (&ctb->lock, flags); -if (unlikely (!h2g_has_room (ct, len +GUC_CTB_HDR_LEN ) || - !g2h_has_room (ct,GUC_CTB_HXG_MSG_MAX_LEN ))) { + err =poll_timeout_us_atomic (err =0 , + !h2g_has_room (ct, len +GUC_CTB_HDR_LEN ) || + !g2h_has_room (ct,GUC_CTB_HXG_MSG_MAX_LEN ), +USEC_PER_MSEC ,600 *USEC_PER_SEC , false);
This changes the original flow quite a bit.
Before, the code checks whether there is room in the buffers. If there is not, it drops the lock, checks for deadlock, sleeps, and retries.
With this change, we keep polling for room until timeout, and only then check for deadlock. On top of that, the polling is done while holding the spinlock and with interrupts disabled.
I do not think this is a good tradeoff.
If we want to use poll_timeout_us_atomic(), I think the better approach would be to move the current retry logic into a small helper or callback replacing the condition inside poll_timeout_use_atomic() that:
- takes the lock
- checks whether there is room
- drops the lock
- checks for deadlock
- returns the condition to the poll_timeout_timeout_us_atomic()
That would keep the old logic intact.
Andi