drm/i915/guc: Check for ct enabled while waiting for response
authorZhanjun Dong <zhanjun.dong@intel.com>
Fri, 15 Jul 2022 21:13:13 +0000 (14:13 -0700)
committerJohn Harrison <John.C.Harrison@Intel.com>
Thu, 28 Jul 2022 18:57:34 +0000 (11:57 -0700)
We are seeing error message of "No response for request". Some cases
happened while waiting for response and reset/suspend action was triggered.
In this case, no response is not an error, active requests will be
cancelled.

This patch will handle this condition and change the error message into
debug message.

Signed-off-by: Zhanjun Dong <zhanjun.dong@intel.com>
Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: John Harrison <John.C.Harrison@Intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220715211313.143645-1-zhanjun.dong@intel.com
drivers/gpu/drm/i915/gt/uc/intel_guc_ct.c

index f01325c..74194c1 100644 (file)
@@ -455,6 +455,7 @@ corrupted:
 
 /**
  * wait_for_ct_request_update - Wait for CT request state update.
+ * @ct:                pointer to CT
  * @req:       pointer to pending request
  * @status:    placeholder for status
  *
@@ -467,9 +468,10 @@ corrupted:
  * *   0 response received (status is valid)
  * *   -ETIMEDOUT no response within hardcoded timeout
  */
-static int wait_for_ct_request_update(struct ct_request *req, u32 *status)
+static int wait_for_ct_request_update(struct intel_guc_ct *ct, struct ct_request *req, u32 *status)
 {
        int err;
+       bool ct_enabled;
 
        /*
         * Fast commands should complete in less than 10us, so sample quickly
@@ -481,12 +483,15 @@ static int wait_for_ct_request_update(struct ct_request *req, u32 *status)
 #define GUC_CTB_RESPONSE_TIMEOUT_SHORT_MS 10
 #define GUC_CTB_RESPONSE_TIMEOUT_LONG_MS 1000
 #define done \
-       (FIELD_GET(GUC_HXG_MSG_0_ORIGIN, READ_ONCE(req->status)) == \
+       (!(ct_enabled = intel_guc_ct_enabled(ct)) || \
+        FIELD_GET(GUC_HXG_MSG_0_ORIGIN, READ_ONCE(req->status)) == \
         GUC_HXG_ORIGIN_GUC)
        err = wait_for_us(done, GUC_CTB_RESPONSE_TIMEOUT_SHORT_MS);
        if (err)
                err = wait_for(done, GUC_CTB_RESPONSE_TIMEOUT_LONG_MS);
 #undef done
+       if (!ct_enabled)
+               err = -ENODEV;
 
        *status = req->status;
        return err;
@@ -703,11 +708,18 @@ retry:
 
        intel_guc_notify(ct_to_guc(ct));
 
-       err = wait_for_ct_request_update(&request, status);
+       err = wait_for_ct_request_update(ct, &request, status);
        g2h_release_space(ct, GUC_CTB_HXG_MSG_MAX_LEN);
        if (unlikely(err)) {
-               CT_ERROR(ct, "No response for request %#x (fence %u)\n",
-                        action[0], request.fence);
+               if (err == -ENODEV)
+                       /* wait_for_ct_request_update returns -ENODEV on reset/suspend in progress.
+                        * In this case, output is debug rather than error info
+                        */
+                       CT_DEBUG(ct, "Request %#x (fence %u) cancelled as CTB is disabled\n",
+                                action[0], request.fence);
+               else
+                       CT_ERROR(ct, "No response for request %#x (fence %u)\n",
+                                action[0], request.fence);
                goto unlink;
        }
 
@@ -771,8 +783,9 @@ int intel_guc_ct_send(struct intel_guc_ct *ct, const u32 *action, u32 len,
 
        ret = ct_send(ct, action, len, response_buf, response_buf_size, &status);
        if (unlikely(ret < 0)) {
-               CT_ERROR(ct, "Sending action %#x failed (%pe) status=%#X\n",
-                        action[0], ERR_PTR(ret), status);
+               if (ret != -ENODEV)
+                       CT_ERROR(ct, "Sending action %#x failed (%pe) status=%#X\n",
+                                action[0], ERR_PTR(ret), status);
        } else if (unlikely(ret)) {
                CT_DEBUG(ct, "send action %#x returned %d (%#x)\n",
                         action[0], ret, ret);