drm/i915: Support for forceful flush of GuC log buffer
authorSagar Arun Kamble <sagar.a.kamble@intel.com>
Wed, 12 Oct 2016 16:24:40 +0000 (21:54 +0530)
committerTvrtko Ursulin <tvrtko.ursulin@intel.com>
Tue, 25 Oct 2016 08:34:23 +0000 (09:34 +0100)
GuC firmware sends a flush interrupt to Host when the log buffer is half
full and at that time only it updates the log buffer state.
But in certain cases, as described below, it could be useful to have all
that even when log buffer is only partially full. For that there is a force
log buffer flush Host2GuC action supported by GuC firmware.

For Validation requirements, a forceful flush is needed to collect the
left over logs on disabling logging. The same can be done before proceeding
with GPU/GuC reset as there could be some data in log buffer which is yet
to be captured and those logs would be particularly useful to understand
that why the reset was initiated.

Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@intel.com>
Signed-off-by: Akash Goel <akash.goel@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
drivers/gpu/drm/i915/i915_guc_submission.c
drivers/gpu/drm/i915/intel_guc.h

index 7fb0077aedcd08e822027d016e3b45b5bd9a2664..9fd9a3ae12290d28e8b4b048030bbc244c4b7e76 100644 (file)
@@ -183,6 +183,16 @@ static int host2guc_logbuffer_flush_complete(struct intel_guc *guc)
        return host2guc_action(guc, data, 1);
 }
 
+static int host2guc_force_logbuffer_flush(struct intel_guc *guc)
+{
+       u32 data[2];
+
+       data[0] = HOST2GUC_ACTION_FORCE_LOG_BUFFER_FLUSH;
+       data[1] = 0;
+
+       return host2guc_action(guc, data, 2);
+}
+
 /*
  * Initialise, update, or clear doorbell data shared with the GuC
  *
@@ -1556,6 +1566,26 @@ void i915_guc_capture_logs(struct drm_i915_private *dev_priv)
        intel_runtime_pm_put(dev_priv);
 }
 
+void i915_guc_flush_logs(struct drm_i915_private *dev_priv)
+{
+       if (!i915.enable_guc_submission || (i915.guc_log_level < 0))
+               return;
+
+       /* First disable the interrupts, will be renabled afterwards */
+       gen9_disable_guc_interrupts(dev_priv);
+
+       /* Before initiating the forceful flush, wait for any pending/ongoing
+        * flush to complete otherwise forceful flush may not actually happen.
+        */
+       flush_work(&dev_priv->guc.log.flush_work);
+
+       /* Ask GuC to update the log buffer state */
+       host2guc_force_logbuffer_flush(&dev_priv->guc);
+
+       /* GuC would have updated log buffer by now, so capture it */
+       i915_guc_capture_logs(dev_priv);
+}
+
 void i915_guc_unregister(struct drm_i915_private *dev_priv)
 {
        if (!i915.enable_guc_submission)
index d034c9845a2269e8a607826e4d35aca0a6e92f1c..71da75e7f6b44fc4f94a8d083775d37ecce292ff 100644 (file)
@@ -185,6 +185,7 @@ void i915_guc_wq_unreserve(struct drm_i915_gem_request *request);
 void i915_guc_submission_disable(struct drm_i915_private *dev_priv);
 void i915_guc_submission_fini(struct drm_i915_private *dev_priv);
 void i915_guc_capture_logs(struct drm_i915_private *dev_priv);
+void i915_guc_flush_logs(struct drm_i915_private *dev_priv);
 void i915_guc_register(struct drm_i915_private *dev_priv);
 void i915_guc_unregister(struct drm_i915_private *dev_priv);