All of lore.kernel.org
 help / color / mirror / Atom feed
From: ville.syrjala@linux.intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2 08/16] drm/i915: Split watermark programming into pre and post steps
Date: Thu, 22 May 2014 17:48:13 +0300	[thread overview]
Message-ID: <1400770101-14277-9-git-send-email-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <1400770101-14277-1-git-send-email-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

We need to perform watermark programming before and after changing the
plane configuration. Add two new vfuncs to do that. The pre phase is
supposed to switch over to the intermediate watermarks which are
computed so that they can deal with both the old and new plane
configurations. The post phase will arm the vblank based update
systems to switch over to the optimal target watermarks after the
plane configuration has for sure changed.

v2: Pass around intel_crtc and s/intel_crtc/crtc/

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h  |  5 +++
 drivers/gpu/drm/i915/intel_drv.h | 11 +++++
 drivers/gpu/drm/i915/intel_pm.c  | 88 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 104 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index c90d5ac..d4f8ae8 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -407,6 +407,7 @@ struct intel_plane_config;
 struct intel_crtc;
 struct intel_limit;
 struct dpll;
+struct intel_crtc_wm_config;
 
 struct drm_i915_display_funcs {
 	bool (*fbc_enabled)(struct drm_device *dev);
@@ -437,6 +438,10 @@ struct drm_i915_display_funcs {
 				 struct drm_crtc *crtc,
 				 uint32_t sprite_width, int pixel_size,
 				 bool enable, bool scaled);
+	void (*program_wm_pre)(struct intel_crtc *crtc,
+			       const struct intel_crtc_wm_config *config);
+	void (*program_wm_post)(struct intel_crtc *crtc,
+				const struct intel_crtc_wm_config *config);
 	void (*modeset_global_resources)(struct drm_device *dev);
 	/* Returns the active state of the crtc, and if the crtc is active,
 	 * fills out the pipe-config with the hw state. */
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 72f01b1..4b59be3 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -358,6 +358,13 @@ struct intel_pipe_wm {
 	bool sprites_scaled;
 };
 
+struct intel_crtc_wm_config {
+	/* target watermarks for the pipe */
+	struct intel_pipe_wm target;
+	/* intermediate watermarks for pending/active->target transition */
+	struct intel_pipe_wm intm;
+};
+
 struct intel_crtc {
 	struct drm_crtc base;
 	enum pipe pipe;
@@ -1001,6 +1008,10 @@ void intel_init_runtime_pm(struct drm_i915_private *dev_priv);
 void intel_fini_runtime_pm(struct drm_i915_private *dev_priv);
 void ilk_wm_get_hw_state(struct drm_device *dev);
 void ilk_update_pipe_wm(struct drm_device *dev, enum pipe pipe);
+void intel_program_watermarks_pre(struct intel_crtc *crtc,
+				  const struct intel_crtc_wm_config *config);
+void intel_program_watermarks_post(struct intel_crtc *crtc,
+				   const struct intel_crtc_wm_config *config);
 
 
 /* intel_sdvo.c */
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 6fc6416..ccf920a 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -2950,6 +2950,20 @@ void ilk_update_pipe_wm(struct drm_device *dev, enum pipe pipe)
 	spin_unlock(&crtc->wm.lock);
 }
 
+static void ilk_wm_cancel(struct intel_crtc *crtc)
+{
+	struct drm_device *dev = crtc->base.dev;
+
+	assert_spin_locked(&crtc->wm.lock);
+
+	crtc->wm.dirty = false;
+
+	if (crtc->wm.vblank) {
+		drm_vblank_put(dev, crtc->pipe);
+		crtc->wm.vblank = false;
+	}
+}
+
 static void ilk_update_sprite_wm(struct drm_plane *plane,
 				     struct drm_crtc *crtc,
 				     uint32_t sprite_width, int pixel_size,
@@ -3084,6 +3098,24 @@ void intel_update_sprite_watermarks(struct drm_plane *plane,
 						   pixel_size, enabled, scaled);
 }
 
+void intel_program_watermarks_pre(struct intel_crtc *crtc,
+				  const struct intel_crtc_wm_config *config)
+{
+	struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+
+	if (dev_priv->display.program_wm_pre)
+		dev_priv->display.program_wm_pre(crtc, config);
+}
+
+void intel_program_watermarks_post(struct intel_crtc *crtc,
+				   const struct intel_crtc_wm_config *config)
+{
+	struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
+
+	if (dev_priv->display.program_wm_post)
+		dev_priv->display.program_wm_post(crtc, config);
+}
+
 static struct drm_i915_gem_object *
 intel_alloc_context_page(struct drm_device *dev)
 {
@@ -6522,6 +6554,60 @@ void intel_fini_runtime_pm(struct drm_i915_private *dev_priv)
 	pm_runtime_disable(device);
 }
 
+static void ilk_program_wm_pre(struct intel_crtc *crtc,
+			       const struct intel_crtc_wm_config *config)
+{
+	struct drm_device *dev = crtc->base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+
+	mutex_lock(&dev_priv->wm.mutex);
+
+	spin_lock_irq(&crtc->wm.lock);
+	ilk_wm_cancel(crtc);
+	spin_unlock_irq(&crtc->wm.lock);
+
+	/* pending update (if any) got cancelled */
+	crtc->wm.pending = crtc->wm.active;
+
+	if (!memcmp(&crtc->wm.active, &config->intm, sizeof(config->intm)))
+		goto unlock;
+
+	crtc->wm.active = config->intm;
+
+	/* use the most up to date watermarks for other pipes */
+	ilk_refresh_pending_watermarks(dev);
+
+	/* switch over to the intermediate watermarks */
+	ilk_program_watermarks(dev);
+
+ unlock:
+	mutex_unlock(&dev_priv->wm.mutex);
+}
+
+static void ilk_program_wm_post(struct intel_crtc *crtc,
+				const struct intel_crtc_wm_config *config)
+{
+	struct drm_device *dev = crtc->base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	u32 vbl_count;
+
+	/*
+	 * FIXME sample this inside the atomic section to avoid
+	 * needlessly long periods w/ sub-par watermarks
+	 */
+	vbl_count = dev->driver->get_vblank_counter(dev, crtc->pipe);
+
+	mutex_lock(&dev_priv->wm.mutex);
+
+	/*
+	 * We can switch over to the target
+	 * watermarks after the next vblank.
+	 */
+	ilk_setup_pending_watermarks(crtc, &config->target, vbl_count);
+
+	mutex_unlock(&dev_priv->wm.mutex);
+}
+
 /* Set up chip specific power management-related functions */
 void intel_init_pm(struct drm_device *dev)
 {
@@ -6569,6 +6655,8 @@ void intel_init_pm(struct drm_device *dev)
 		     dev_priv->wm.spr_latency[0] && dev_priv->wm.cur_latency[0])) {
 			dev_priv->display.update_wm = ilk_update_wm;
 			dev_priv->display.update_sprite_wm = ilk_update_sprite_wm;
+			dev_priv->display.program_wm_pre = ilk_program_wm_pre;
+			dev_priv->display.program_wm_post = ilk_program_wm_post;
 		} else {
 			DRM_DEBUG_KMS("Failed to read display plane latency. "
 				      "Disable CxSR\n");
-- 
1.8.5.5

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

  parent reply	other threads:[~2014-05-22 14:48 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-22 14:48 [PATCH v2 00/16] drm/i915: Two part watermark update for ILK+, part 2 ville.syrjala
2014-05-22 14:48 ` [PATCH v2 01/16] drm/i915: Keep vblank interrupts enabled while enabling/disabling planes ville.syrjala
2014-05-26 13:56   ` Daniel Vetter
2014-06-04  6:00     ` Arun Murthy
2014-06-10 16:22       ` Ville Syrjälä
2014-05-22 14:48 ` [PATCH 02/16] drm/i915: Leave interrupts enabled while disabling crtcs during suspend ville.syrjala
2014-05-22 14:48 ` [PATCH 03/16] drm/i915: Check hw vs. sw watermark state after programming ville.syrjala
2014-05-22 14:48 ` [PATCH 04/16] drm/i915: Refactor ilk_validate_pipe_wm() ville.syrjala
2014-05-22 14:48 ` [PATCH v2 05/16] drm/i915: Refactor ilk_update_wm ville.syrjala
2014-05-22 14:48 ` [PATCH 06/16] drm/i915: Add dev_priv->wm.mutex ville.syrjala
2014-05-22 14:48 ` [PATCH v2 07/16] drm/i915: Add vblank based delayed watermark update mechanism ville.syrjala
2014-06-03 18:50   ` Paulo Zanoni
2014-06-03 19:32     ` Ville Syrjälä
2014-06-04 14:01       ` Paulo Zanoni
2014-06-04 16:10         ` Daniel Vetter
2014-06-09 15:01           ` Ville Syrjälä
2014-05-22 14:48 ` ville.syrjala [this message]
2014-06-03 20:51   ` [PATCH v2 08/16] drm/i915: Split watermark programming into pre and post steps Paulo Zanoni
2014-06-04 16:22     ` Daniel Vetter
2014-06-09 17:03       ` Ville Syrjälä
2014-06-10 11:46         ` Jani Nikula
2014-05-22 14:48 ` [PATCH v2 09/16] drm/i915: Actually perform the watermark update in two phases ville.syrjala
2014-06-03 22:47   ` Paulo Zanoni
2014-06-09 18:28     ` Ville Syrjälä
2014-05-22 14:48 ` [PATCH v2 10/16] drm/i915: Wait for watermark updates to finish before disabling a pipe ville.syrjala
2014-06-04 13:54   ` Paulo Zanoni
2014-05-22 14:48 ` [PATCH 11/16] drm/i915: Refactor get_other_active_crtc() ville.syrjala
2014-06-04 16:59   ` Paulo Zanoni
2014-05-22 14:48 ` [PATCH 12/16] drm/i915: Disable LP1+ watermarks while changing the number of active pipes ville.syrjala
2014-06-04 18:24   ` Paulo Zanoni
2014-06-09 16:51     ` Ville Syrjälä
2014-05-22 14:48 ` [PATCH v2 13/16] drm/i915: Keep track of who disabled LP1+ watermarks ville.syrjala
2014-06-04 18:30   ` Paulo Zanoni
2014-05-22 14:48 ` [PATCH 14/16] drm/i915: Prefer the 5/6 DDB split when primary is disabled ville.syrjala
2014-06-04 18:34   ` Paulo Zanoni
2014-05-22 14:48 ` [PATCH 15/16] drm/i915: Add a workaround for sprite only <-> primary only switching ville.syrjala
2014-06-04 18:44   ` Paulo Zanoni
2014-05-22 14:48 ` [PATCH 16/16] drm/i915: Don't disable LP1+ watermarks for every frame when scaled ville.syrjala
2014-06-04 18:49   ` Paulo Zanoni

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=1400770101-14277-9-git-send-email-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.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.