All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Roper <matthew.d.roper@intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [RFC 7/8] drm/i915: Allow final wm programming to be scheduled after next vblank (v2)
Date: Wed,  1 Jul 2015 19:26:00 -0700	[thread overview]
Message-ID: <1435803961-30079-8-git-send-email-matthew.d.roper@intel.com> (raw)
In-Reply-To: <1435803961-30079-1-git-send-email-matthew.d.roper@intel.com>

Add a simple mechanism to trigger final watermark updates in an
asynchronous manner once the next vblank occurs.  No platform types
actually support atomic watermark programming until a future patch, so
there should be no functional change yet; individual platforms will be
converted to use this mechanism one-by-one in future patches.

Note that we'll probably expand this to cover other post-vblank async
tasks (like unpinning) at some point in the future.

v2: Much simpler vblank mechanism than was used in the previous series;
    no need to allocate new heap structures.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h      |  7 +++++++
 drivers/gpu/drm/i915/i915_irq.c      |  9 +++++++++
 drivers/gpu/drm/i915/intel_display.c | 30 ++++++++++++++++++++++++++----
 drivers/gpu/drm/i915/intel_drv.h     |  4 ++++
 4 files changed, 46 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 2774976..5ad942e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -628,6 +628,7 @@ struct drm_i915_display_funcs {
 				 struct drm_crtc *crtc,
 				 uint32_t sprite_width, uint32_t sprite_height,
 				 int pixel_size, bool enable, bool scaled);
+	void (*program_watermarks)(struct drm_i915_private *dev_priv);
 	int (*modeset_calc_cdclk)(struct drm_atomic_state *state);
 	void (*modeset_commit_cdclk)(struct drm_atomic_state *state);
 	/* Returns the active state of the crtc, and if the crtc is active,
@@ -2567,6 +2568,12 @@ struct drm_i915_cmd_table {
 #define HAS_L3_DPF(dev) (IS_IVYBRIDGE(dev) || IS_HASWELL(dev))
 #define NUM_L3_SLICES(dev) (IS_HSW_GT3(dev) ? 2 : HAS_L3_DPF(dev))
 
+/*
+ * FIXME:  Not all platforms have been transitioned to atomic watermark
+ * updates yet.
+ */
+#define HAS_ATOMIC_WM(dev_priv) (dev_priv->display.program_watermarks != NULL)
+
 #define GT_FREQUENCY_MULTIPLIER 50
 #define GEN9_FREQ_SCALER 3
 
diff --git a/drivers/gpu/drm/i915/i915_irq.c b/drivers/gpu/drm/i915/i915_irq.c
index a6fbe64..20c7260 100644
--- a/drivers/gpu/drm/i915/i915_irq.c
+++ b/drivers/gpu/drm/i915/i915_irq.c
@@ -1452,6 +1452,15 @@ static void gen6_rps_irq_handler(struct drm_i915_private *dev_priv, u32 pm_iir)
 
 static bool intel_pipe_handle_vblank(struct drm_device *dev, enum pipe pipe)
 {
+	struct drm_i915_private *dev_priv = to_i915(dev);
+	struct drm_crtc *crtc = dev_priv->pipe_to_crtc_mapping[pipe];
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+
+	if (intel_crtc->need_vblank_wm_update) {
+		queue_work(dev_priv->wq, &intel_crtc->wm_work);
+		intel_crtc->need_vblank_wm_update = false;
+	}
+
 	if (!drm_handle_vblank(dev, pipe))
 		return false;
 
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 46b62cc..fa4373e 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4737,6 +4737,10 @@ static void intel_post_plane_update(struct intel_crtc *crtc)
 	struct drm_device *dev = crtc->base.dev;
 	struct drm_plane *plane;
 
+	if (HAS_ATOMIC_WM(to_i915(dev)))
+		/* vblank handler will kick off workqueue task to update wm's */
+		crtc->need_vblank_wm_update = true;
+
 	if (atomic->wait_vblank)
 		intel_wait_for_vblank(dev, crtc->pipe);
 
@@ -4745,7 +4749,7 @@ static void intel_post_plane_update(struct intel_crtc *crtc)
 	if (atomic->disable_cxsr)
 		cstate->wm.cxsr_allowed = true;
 
-	if (crtc->atomic.update_wm_post)
+	if (!HAS_ATOMIC_WM(to_i915(dev)) && crtc->atomic.update_wm_post)
 		intel_update_watermarks(&crtc->base);
 
 	if (atomic->update_fbc) {
@@ -4757,9 +4761,10 @@ static void intel_post_plane_update(struct intel_crtc *crtc)
 	if (atomic->post_enable_primary)
 		intel_post_enable_primary(&crtc->base);
 
-	drm_for_each_plane_mask(plane, dev, atomic->update_sprite_watermarks)
-		intel_update_sprite_watermarks(plane, &crtc->base,
-					       0, 0, 0, false, false);
+	if (!HAS_ATOMIC_WM(to_i915(dev)))
+		drm_for_each_plane_mask(plane, dev, atomic->update_sprite_watermarks)
+			intel_update_sprite_watermarks(plane, &crtc->base,
+						       0, 0, 0, false, false);
 
 	memset(atomic, 0, sizeof(*atomic));
 }
@@ -14070,6 +14075,21 @@ static void skl_init_scalers(struct drm_device *dev, struct intel_crtc *intel_cr
 	scaler_state->scaler_id = -1;
 }
 
+/* FIXME: This may expand to cover other tasks like unpinning in the future... */
+static void wm_work_func(struct work_struct *work)
+{
+	struct intel_crtc *intel_crtc =
+		container_of(work, struct intel_crtc, wm_work);
+	struct drm_i915_private *dev_priv = to_i915(intel_crtc->base.dev);
+
+	if (WARN_ON(!HAS_ATOMIC_WM(dev_priv)))
+		return;
+	if (WARN_ON(!intel_crtc->base.state->active))
+		return;
+
+	dev_priv->display.program_watermarks(dev_priv);
+}
+
 static void intel_crtc_init(struct drm_device *dev, int pipe)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -14142,6 +14162,8 @@ static void intel_crtc_init(struct drm_device *dev, int pipe)
 	dev_priv->plane_to_crtc_mapping[intel_crtc->plane] = &intel_crtc->base;
 	dev_priv->pipe_to_crtc_mapping[intel_crtc->pipe] = &intel_crtc->base;
 
+	INIT_WORK(&intel_crtc->wm_work, wm_work_func);
+
 	drm_crtc_helper_add(&intel_crtc->base, &intel_helper_funcs);
 
 	WARN_ON(drm_crtc_index(&intel_crtc->base) != intel_crtc->pipe);
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 335b24b..775e3d0 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -586,6 +586,10 @@ struct intel_crtc {
 	int num_scalers;
 
 	struct vlv_wm_state wm_state;
+
+	/* Do we need to program watermark values after the next vblank? */
+	bool need_vblank_wm_update;
+	struct work_struct wm_work;
 };
 
 struct intel_plane_wm_parameters {
-- 
2.1.4

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

  parent reply	other threads:[~2015-07-02  2:26 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-02  2:25 [RFC 0/8] Atomic watermark updates (v2) Matt Roper
2015-07-02  2:25 ` [RFC 1/8] drm/i915: Eliminate usage of plane_wm_parameters from ILK-style WM code Matt Roper
2015-07-02  2:25 ` [RFC 2/8] drm/i915: Eliminate usage of pipe_wm_parameters from ILK-style WM Matt Roper
2015-07-02  2:25 ` [RFC 3/8] drm/i915/ivb: Move WaCxSRDisabledForSpriteScaling w/a to atomic check Matt Roper
2015-10-02 16:03   ` Egbert Eich
2015-10-06  8:23     ` Daniel Vetter
2015-07-02  2:25 ` [RFC 4/8] drm/i915: Refactor ilk_update_wm (v3) Matt Roper
2015-07-02  2:25 ` [RFC 5/8] drm/i915: Move active watermarks into CRTC state Matt Roper
2015-07-20  9:19   ` Maarten Lankhorst
2015-07-02  2:25 ` [RFC 6/8] drm/i915: Calculate ILK-style watermarks during atomic check (v2) Matt Roper
2015-07-06  9:13   ` Daniel Vetter
2015-07-02  2:26 ` Matt Roper [this message]
2015-07-06  9:07   ` [RFC 7/8] drm/i915: Allow final wm programming to be scheduled after next vblank (v2) Daniel Vetter
2015-07-06 11:23     ` Ville Syrjälä
2015-07-20  8:10   ` Maarten Lankhorst
2015-07-02  2:26 ` [RFC 8/8] drm/i915: Add two-stage ILK-style watermark programming (v2) Matt Roper
2015-07-06  9:11   ` Daniel Vetter
2015-07-06 12:20   ` Maarten Lankhorst
2015-07-06 12:26     ` Daniel Vetter

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=1435803961-30079-8-git-send-email-matthew.d.roper@intel.com \
    --to=matthew.d.roper@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.