public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Michal Wajdeczko <michal.wajdeczko@intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Michal Wajdeczko <michal.wajdeczko@intel.com>
Subject: [PATCH 3/3] drm/xe/guc: Allow second H2G retry on FLR
Date: Tue, 20 Jan 2026 19:50:47 +0100	[thread overview]
Message-ID: <20260120185047.593-4-michal.wajdeczko@intel.com> (raw)
In-Reply-To: <20260120185047.593-1-michal.wajdeczko@intel.com>

During VF FLR the scratch registers could be cleared both by the
GuC and by the PF driver. Allow to retry more times once we find
out that the HXG header was cleared and wait at least 256ms before
resending the same message again to the GuC.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
---
 drivers/gpu/drm/xe/xe_guc.c | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_guc.c b/drivers/gpu/drm/xe/xe_guc.c
index 3ba0ea015611..f99716f4084c 100644
--- a/drivers/gpu/drm/xe/xe_guc.c
+++ b/drivers/gpu/drm/xe/xe_guc.c
@@ -1388,6 +1388,9 @@ int xe_guc_auth_huc(struct xe_guc *guc, u32 rsa_addr)
 	return xe_guc_ct_send_block(&guc->ct, action, ARRAY_SIZE(action));
 }
 
+#define MAX_RETRIES_ON_FLR	2
+#define MIN_SLEEP_MS_ON_FLR	256
+
 int xe_guc_mmio_send_recv(struct xe_guc *guc, const u32 *request,
 			  u32 len, u32 *response_buf)
 {
@@ -1398,7 +1401,7 @@ int xe_guc_mmio_send_recv(struct xe_guc *guc, const u32 *request,
 		MED_VF_SW_FLAG(0) : VF_SW_FLAG(0);
 	const u32 LAST_INDEX = VF_SW_FLAG_COUNT - 1;
 	unsigned int sleep_period_ms = 1;
-	bool lost = false;
+	unsigned int lost = 0;
 	u32 header;
 	int ret;
 	int i;
@@ -1434,10 +1437,15 @@ int xe_guc_mmio_send_recv(struct xe_guc *guc, const u32 *request,
 			     50000, &header, false);
 	if (ret) {
 		/* scratch registers might be cleared during FLR, try once more */
-		if (!header && !lost) {
+		if (!header) {
+			if (++lost > MAX_RETRIES_ON_FLR) {
+				xe_gt_err(gt, "GuC mmio request %#x: lost, too many retries %u\n",
+					  request[0], lost);
+				return -ENOLINK;
+			}
 			xe_gt_dbg(gt, "GuC mmio request %#x: lost, trying again\n", request[0]);
-			lost = true;
-			goto retry;
+			sleep_period_ms = max(sleep_period_ms, MIN_SLEEP_MS_ON_FLR);
+			goto sleep_and_retry;
 		}
 timeout:
 		xe_gt_err(gt, "GuC mmio request %#x: no reply %#x\n",
@@ -1481,6 +1489,7 @@ int xe_guc_mmio_send_recv(struct xe_guc *guc, const u32 *request,
 		xe_gt_dbg(gt, "GuC mmio request %#x: retrying after %u ms, reason %#x\n",
 			  request[0], sleep_period_ms, reason);
 
+sleep_and_retry:
 		msleep(sleep_period_ms);
 		if (sleep_period_ms < 1024)
 			sleep_period_ms <<= 1;
-- 
2.47.1


  parent reply	other threads:[~2026-01-20 18:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-20 18:50 [PATCH 0/3] drm/xe/guc: Make MMIO communication more robust Michal Wajdeczko
2026-01-20 18:50 ` [PATCH 1/3] drm/xe/guc: Drop redundant register read Michal Wajdeczko
2026-01-20 20:57   ` Matthew Brost
2026-01-20 18:50 ` [PATCH 2/3] drm/xe/guc: Wait before retrying sending H2G Michal Wajdeczko
2026-01-20 21:02   ` Matthew Brost
2026-01-20 21:36     ` Michal Wajdeczko
2026-01-20 18:50 ` Michal Wajdeczko [this message]
2026-01-20 19:29 ` ✓ CI.KUnit: success for drm/xe/guc: Make MMIO communication more robust Patchwork
2026-01-20 20:04 ` ✓ Xe.CI.BAT: " Patchwork
2026-01-21  2:42 ` ✗ Xe.CI.Full: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260120185047.593-4-michal.wajdeczko@intel.com \
    --to=michal.wajdeczko@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox