All of lore.kernel.org
 help / color / mirror / Atom feed
From: yu.dai@intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/6] drm/i915/guc: Add host2guc notification for suspend and resume
Date: Thu, 10 Sep 2015 16:56:09 -0700	[thread overview]
Message-ID: <1441929372-26140-4-git-send-email-yu.dai@intel.com> (raw)
In-Reply-To: <1441929372-26140-1-git-send-email-yu.dai@intel.com>

From: Alex Dai <yu.dai@intel.com>

Add host2guc interfaces to nofigy GuC power state changes when
enter or resume from power saving state.

Signed-off-by: Alex Dai <yu.dai@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.c            |  1 +
 drivers/gpu/drm/i915/i915_gem.c            |  1 +
 drivers/gpu/drm/i915/i915_guc_submission.c | 50 ++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/intel_guc.h           |  2 ++
 drivers/gpu/drm/i915/intel_guc_fwif.h      |  8 +++++
 drivers/gpu/drm/i915/intel_guc_loader.c    |  4 ++-
 6 files changed, 65 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index bdec64c..42a9752 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -735,6 +735,7 @@ static int i915_drm_resume(struct drm_device *dev)
 		DRM_ERROR("failed to re-initialize GPU, declaring wedged!\n");
 		atomic_set_mask(I915_WEDGED, &dev_priv->gpu_error.reset_counter);
 	}
+	intel_guc_resume(dev);
 	mutex_unlock(&dev->struct_mutex);
 
 	intel_modeset_init_hw(dev);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 41263cd..2e7fa12 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -4462,6 +4462,7 @@ i915_gem_suspend(struct drm_device *dev)
 	i915_gem_retire_requests(dev);
 
 	i915_gem_stop_ringbuffers(dev);
+	intel_guc_suspend(dev);
 	mutex_unlock(&dev->struct_mutex);
 
 	cancel_delayed_work_sync(&dev_priv->gpu_error.hangcheck_work);
diff --git a/drivers/gpu/drm/i915/i915_guc_submission.c b/drivers/gpu/drm/i915/i915_guc_submission.c
index 792d0b9..23c0a75 100644
--- a/drivers/gpu/drm/i915/i915_guc_submission.c
+++ b/drivers/gpu/drm/i915/i915_guc_submission.c
@@ -914,3 +914,53 @@ void i915_guc_submission_fini(struct drm_device *dev)
 	gem_release_guc_obj(guc->ctx_pool_obj);
 	guc->ctx_pool_obj = NULL;
 }
+
+/**
+ * intel_guc_suspend() - notify GuC entering suspend state
+ * @dev:	drm device
+ */
+int intel_guc_suspend(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_guc *guc = &dev_priv->guc;
+	struct intel_context *ctx;
+	u32 data[3];
+
+	if (!i915.enable_guc_submission)
+		return 0;
+
+	ctx = dev_priv->ring[RCS].default_context;
+
+	data[0] = HOST2GUC_ACTION_ENTER_S_STATE;
+	/* any value greater than GUC_POWER_D0 */
+	data[1] = GUC_POWER_D1;
+	/* first page is shared data with GuC */
+	data[2] = i915_gem_obj_ggtt_offset(ctx->engine[RCS].state);
+
+	return host2guc_action(guc, data, 3);
+}
+
+
+/**
+ * intel_guc_resume() - notify GuC resuming from suspend state
+ * @dev:	drm device
+ */
+int intel_guc_resume(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_guc *guc = &dev_priv->guc;
+	struct intel_context *ctx;
+	u32 data[3];
+
+	if (!i915.enable_guc_submission)
+		return 0;
+
+	ctx = dev_priv->ring[RCS].default_context;
+
+	data[0] = HOST2GUC_ACTION_EXIT_S_STATE;
+	data[1] = GUC_POWER_D0;
+	/* first page is shared data with GuC */
+	data[2] = i915_gem_obj_ggtt_offset(ctx->engine[RCS].state);
+
+	return host2guc_action(guc, data, 3);
+}
diff --git a/drivers/gpu/drm/i915/intel_guc.h b/drivers/gpu/drm/i915/intel_guc.h
index e1389fc..e90c156 100644
--- a/drivers/gpu/drm/i915/intel_guc.h
+++ b/drivers/gpu/drm/i915/intel_guc.h
@@ -110,6 +110,8 @@ extern void intel_guc_ucode_init(struct drm_device *dev);
 extern int intel_guc_ucode_load(struct drm_device *dev);
 extern void intel_guc_ucode_fini(struct drm_device *dev);
 extern const char *intel_guc_fw_status_repr(enum intel_guc_fw_status status);
+extern int intel_guc_suspend(struct drm_device *dev);
+extern int intel_guc_resume(struct drm_device *dev);
 
 /* i915_guc_submission.c */
 int i915_guc_submission_init(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/intel_guc_fwif.h b/drivers/gpu/drm/i915/intel_guc_fwif.h
index 006dc0d..f6d0aa4 100644
--- a/drivers/gpu/drm/i915/intel_guc_fwif.h
+++ b/drivers/gpu/drm/i915/intel_guc_fwif.h
@@ -254,12 +254,20 @@ struct guc_context_desc {
 	u64 desc_private;
 } __packed;
 
+#define GUC_POWER_UNSPECIFIED	0
+#define GUC_POWER_D0		1
+#define GUC_POWER_D1		2
+#define GUC_POWER_D2		3
+#define GUC_POWER_D3		4
+
 /* This Action will be programmed in C180 - SOFT_SCRATCH_O_REG */
 enum host2guc_action {
 	HOST2GUC_ACTION_DEFAULT = 0x0,
 	HOST2GUC_ACTION_SAMPLE_FORCEWAKE = 0x6,
 	HOST2GUC_ACTION_ALLOCATE_DOORBELL = 0x10,
 	HOST2GUC_ACTION_DEALLOCATE_DOORBELL = 0x20,
+	HOST2GUC_ACTION_ENTER_S_STATE = 0x501,
+	HOST2GUC_ACTION_EXIT_S_STATE = 0x502,
 	HOST2GUC_ACTION_SLPC_REQUEST = 0x3003,
 	HOST2GUC_ACTION_LIMIT
 };
diff --git a/drivers/gpu/drm/i915/intel_guc_loader.c b/drivers/gpu/drm/i915/intel_guc_loader.c
index 0c3c4c9..4eadcd2 100644
--- a/drivers/gpu/drm/i915/intel_guc_loader.c
+++ b/drivers/gpu/drm/i915/intel_guc_loader.c
@@ -407,7 +407,6 @@ int intel_guc_ucode_load(struct drm_device *dev)
 		intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
 
 	direct_interrupts_to_host(dev_priv);
-	i915_guc_submission_disable(dev);
 
 	if (guc_fw->guc_fw_fetch_status == GUC_FIRMWARE_NONE)
 		return 0;
@@ -457,6 +456,9 @@ int intel_guc_ucode_load(struct drm_device *dev)
 		intel_guc_fw_status_repr(guc_fw->guc_fw_load_status));
 
 	if (i915.enable_guc_submission) {
+		/* The execbuf_client will be recreated. Release it first. */
+		i915_guc_submission_disable(dev);
+
 		err = i915_guc_submission_enable(dev);
 		if (err)
 			goto fail;
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2015-09-10 23:57 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-10 23:56 [PATCH 0/6] Several GuC related patches yu.dai
2015-09-10 23:56 ` [PATCH 1/6] drm/i915/guc: Fix a bug in GuC status check yu.dai
2015-09-10 23:56 ` [PATCH 2/6] drm/i915/guc: Add GuC css header parser yu.dai
2015-09-14  9:28   ` Daniel Vetter
2015-09-10 23:56 ` yu.dai [this message]
2015-09-15 23:30   ` [PATCH 03/15] drm/i915/guc: Add host2guc notification for suspend and resume yu.dai
2015-09-10 23:56 ` [PATCH 4/6] drm/i915/guc: Don't send flips to GuC yu.dai
2015-09-11 12:44   ` [PATCH v2 1/1] drm/i915: Direct all DE interrupts to host Sagar Arun Kamble
2015-09-21 19:02     ` O'Rourke, Tom
2015-09-10 23:56 ` [PATCH 5/6] drm/i915/guc: Media domain bit needed when notify GuC rc6 state yu.dai
2015-09-14  9:32   ` Daniel Vetter
2015-09-15 23:31   ` [PATCH 05/15] " yu.dai
2015-09-10 23:56 ` [PATCH 6/6] drm/i915/guc: Enable GuC submission, where supported yu.dai
2015-09-22 20:48 ` [PATCH v2 0/6] Several GuC related patches yu.dai
2015-09-22 20:48   ` [PATCH v2 1/6] drm/i915/guc: Fix a bug in GuC status check yu.dai
2015-09-24  4:59     ` Kamble, Sagar A
2015-09-28  8:10       ` Daniel Vetter
2015-09-22 20:48   ` [PATCH v2 2/6] drm/i915/guc: Add GuC css header parser yu.dai
2015-09-24 14:23     ` Dave Gordon
2015-09-24 18:34       ` Yu Dai
2015-09-24 19:04         ` Dave Gordon
2015-09-24 20:23           ` Yu Dai
2015-09-25 14:45             ` Jani Nikula
2015-09-25 16:31               ` Yu Dai
2015-09-28  8:13                 ` Daniel Vetter
2015-09-22 20:48   ` [PATCH v2 3/6] drm/i915/guc: Add host2guc notification for suspend and resume yu.dai
2015-09-24  8:27     ` Kamble, Sagar A
2015-09-22 20:48   ` [PATCH v2 4/6] drm/i915/guc: Don't send flips to GuC yu.dai
2015-09-22 23:11     ` [PATCH] " yu.dai
2015-09-23  0:56       ` O'Rourke, Tom
2015-09-22 20:48   ` [PATCH v2 5/6] drm/i915/guc: Media domain bit needed when notify GuC rc6 state yu.dai
2015-09-23  0:59     ` O'Rourke, Tom
2015-09-23  8:37       ` Daniel Vetter
2015-09-22 20:48   ` [PATCH v2 6/6] drm/i915/guc: Enable GuC submission, where supported yu.dai
2015-09-22 23:13     ` [PATCH] " yu.dai

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=1441929372-26140-4-git-send-email-yu.dai@intel.com \
    --to=yu.dai@intel.com \
    --cc=intel-gfx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.