Skip to contentSkip to conversation

drm/i915/gt: Use poll_timeout_us in place of sliding sleep window

PATCH Superseded Jonathan Cavitt 2 participants 2 messages Jun 29

Subsystems (2)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 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)

---
 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
index 053780f562c1..13be4f7e7ab7 100644
@@ -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
index 1c455d84bf9d..965239c4b3c8 100644
@@ -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(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
#1 lore raw

✗ i915.CI.BAT: failure for drm/i915/gt: Use poll_timeout_us in place of sliding sleep window (rev2)

== Series Details ==

== Series Details ==

Series: drm/i915/gt: Use poll_timeout_us in place of sliding sleep window (rev2)
URL : https://patchwork.freedesktop.org/series/169454/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_18726 -> Patchwork_169454v2
====================================================

Summary
-------

**FAILURE**

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

If you think the reported changes have nothing to do with the changes
introduced in Patchwork_169454v2, 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_169454v2/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_169454v2:

### IGT changes ###

#### Possible regressions ####

* igt@i915_module_load@load:
- bat-adlp-6: [PASS][1] -> [ABORT][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-adlp-6/igt@[email protected]
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-adlp-6/igt@[email protected]
- bat-arlh-2: [PASS][3] -> [ABORT][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-arlh-2/igt@[email protected]
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-arlh-2/igt@[email protected]
- bat-arlh-3: [PASS][5] -> [ABORT][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-arlh-3/igt@[email protected]
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-arlh-3/igt@[email protected]
- bat-dg1-7: [PASS][7] -> [ABORT][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-dg1-7/igt@[email protected]
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-dg1-7/igt@[email protected]
- bat-adlp-9: [PASS][9] -> [ABORT][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-adlp-9/igt@[email protected]
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-adlp-9/igt@[email protected]
- bat-twl-2: [PASS][11] -> [ABORT][12]
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-twl-2/igt@[email protected]
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-twl-2/igt@[email protected]
- bat-rpls-4: [PASS][13] -> [ABORT][14]
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-rpls-4/igt@[email protected]
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-rpls-4/igt@[email protected]
- bat-twl-1: [PASS][15] -> [ABORT][16]
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-twl-1/igt@[email protected]
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-twl-1/igt@[email protected]
- bat-dg2-14: [PASS][17] -> [ABORT][18]
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-dg2-14/igt@[email protected]
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-dg2-14/igt@[email protected]
- bat-arls-5: [PASS][19] -> [ABORT][20]
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-arls-5/igt@[email protected]
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-arls-5/igt@[email protected]
- bat-rplp-1: [PASS][21] -> [ABORT][22]
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-rplp-1/igt@[email protected]
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-rplp-1/igt@[email protected]
- bat-atsm-1: [PASS][23] -> [ABORT][24]
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-atsm-1/igt@[email protected]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-atsm-1/igt@[email protected]
- fi-cfl-guc: [PASS][25] -> [ABORT][26]
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/fi-cfl-guc/igt@[email protected]
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/fi-cfl-guc/igt@[email protected]
- bat-mtlp-9: [PASS][27] -> [ABORT][28]
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-mtlp-9/igt@[email protected]
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-mtlp-9/igt@[email protected]
- bat-arls-6: [PASS][29] -> [ABORT][30]
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-arls-6/igt@[email protected]
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-arls-6/igt@[email protected]
- bat-dg2-9: [PASS][31] -> [ABORT][32]
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-dg2-9/igt@[email protected]
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-dg2-9/igt@[email protected]
- bat-adlp-11: [PASS][33] -> [ABORT][34]
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-adlp-11/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-adlp-11/igt@[email protected]
- bat-mtlp-8: [PASS][35] -> [ABORT][36]
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-mtlp-8/igt@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-mtlp-8/igt@[email protected]
- bat-dg1-6: [PASS][37] -> [ABORT][38]
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-dg1-6/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-dg1-6/igt@[email protected]
- bat-dg2-8: [PASS][39] -> [ABORT][40]
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_18726/bat-dg2-8/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-dg2-8/igt@[email protected]
- bat-adls-6: NOTRUN -> [ABORT][41]
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_169454v2/bat-adls-6/igt@[email protected]

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

* Linux: CI_DRM_18726 -> Patchwork_169454v2

CI-20190529: 20190529
CI_DRM_18726: 03288b34f48c3fe60055353c30da4aacab572cdc @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_8988: 8988
Patchwork_169454v2: 03288b34f48c3fe60055353c30da4aacab572cdc @ git://anongit.freedesktop.org/gfx-ci/linux

== Logs ==

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