public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: ville.syrjala@linux.intel.com, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 08/14] drm/i915: Skip useless watermark/FIFO related work on VLV/CHV when not needed
Date: Thu, 15 Dec 2016 16:37:53 +0100	[thread overview]
Message-ID: <a24a02b6-da42-e7b6-5cf9-c7f2865bdabc@linux.intel.com> (raw)
In-Reply-To: <1481574931-8658-9-git-send-email-ville.syrjala@linux.intel.com>

Op 12-12-16 om 21:35 schreef ville.syrjala@linux.intel.com:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Check whether anything relevant has actually change when we compute new
> watermarks for each plane in the state. If the watermarks for no
> primary/sprite planes changed we don't have to recompute the FIFO split
> or reprogram the DSBARB registers. And even the cursor watermarks didn't
> change we can skip the merge+invert step between all the planes on
> the pipe as well.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_atomic.c |  1 +
>  drivers/gpu/drm/i915/intel_drv.h    |  1 +
>  drivers/gpu/drm/i915/intel_pm.c     | 73 +++++++++++++++++++++++++++++--------
>  3 files changed, 60 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
> index c5a166752eda..df33f270b459 100644
> --- a/drivers/gpu/drm/i915/intel_atomic.c
> +++ b/drivers/gpu/drm/i915/intel_atomic.c
> @@ -99,6 +99,7 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc)
>  	crtc_state->update_wm_pre = false;
>  	crtc_state->update_wm_post = false;
>  	crtc_state->fb_changed = false;
> +	crtc_state->fifo_changed = false;
>  	crtc_state->wm.need_postvbl_update = false;
>  	crtc_state->fb_bits = 0;
This flag is only used in intel_pm.c, maybe put it in crtc_state->wm.vlv.fifo_changed, and clear it in the beginning of the wm recalculation?
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 66668c18a47a..a92857864ee8 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -560,6 +560,7 @@ struct intel_crtc_state {
>  	bool disable_cxsr;
>  	bool update_wm_pre, update_wm_post; /* watermarks are updated */
>  	bool fb_changed; /* fb on any of the planes is changed */
> +	bool fifo_changed; /* FIFO split is changed */
>  
>  	/* Pipe source size (ie. panel fitter input size)
>  	 * All planes will be positioned inside this space,
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index f68b46eed224..c7cc62cf51f6 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -1103,31 +1103,36 @@ static u16 vlv_invert_wm_value(u16 wm, u16 fifo_size)
>  }
>  
>  /* starting from 'level' set all higher levels to 'value' */
> -static void vlv_plane_wm_set(struct intel_crtc_state *crtc_state,
> +static bool vlv_plane_wm_set(struct intel_crtc_state *crtc_state,
>  			     int level, enum plane_id plane_id, u16 value)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(crtc_state->base.crtc->dev);
>  	int num_levels = vlv_num_wm_levels(dev_priv);
> +	bool dirty = false;
>  
>  	for (; level < num_levels; level++) {
>  		struct vlv_pipe_wm *noninverted =
>  			&crtc_state->wm.vlv.noninverted[level];
>  
> +		dirty |= noninverted->plane[plane_id] != value;
>  		noninverted->plane[plane_id] = value;
>  	}
> +
> +	return dirty;
>  }
>  
> -static void vlv_plane_wm_compute(struct intel_crtc_state *crtc_state,
> +static bool vlv_plane_wm_compute(struct intel_crtc_state *crtc_state,
>  				 const struct intel_plane_state *plane_state)
>  {
>  	struct intel_plane *plane = to_intel_plane(plane_state->base.plane);
>  	enum plane_id plane_id = plane->id;
>  	int num_levels = vlv_num_wm_levels(to_i915(plane->base.dev));
>  	int level;
> +	bool dirty = false;
>  
>  	if (!plane_state->base.visible) {
> -		vlv_plane_wm_set(crtc_state, 0, plane_id, 0);
> -		return;
> +		dirty |= vlv_plane_wm_set(crtc_state, 0, plane_id, 0);
> +		goto out;
>  	}
>  
>  	for (level = 0; level < num_levels; level++) {
> @@ -1143,17 +1148,22 @@ static void vlv_plane_wm_compute(struct intel_crtc_state *crtc_state,
>  		if (wm > max_wm)
>  			break;
>  
> +		dirty |= noninverted->plane[plane_id] != wm;
>  		noninverted->plane[plane_id] = wm;
>  	}
>  
>  	/* mark all higher levels as invalid */
> -	vlv_plane_wm_set(crtc_state, level, plane_id, USHRT_MAX);
> +	dirty |= vlv_plane_wm_set(crtc_state, level, plane_id, USHRT_MAX);
>  
> -	DRM_DEBUG_KMS("%s wms: [0]=%d,[1]=%d,[2]=%d\n",
> -		      plane->base.name,
> -		      crtc_state->wm.vlv.noninverted[VLV_WM_LEVEL_PM2].plane[plane_id],
> -		      crtc_state->wm.vlv.noninverted[VLV_WM_LEVEL_PM5].plane[plane_id],
> -		      crtc_state->wm.vlv.noninverted[VLV_WM_LEVEL_DDR_DVFS].plane[plane_id]);
> +out:
> +	if (dirty)
> +		DRM_DEBUG_KMS("%s wms: [0]=%d,[1]=%d,[2]=%d\n",
> +			      plane->base.name,
> +			      crtc_state->wm.vlv.noninverted[VLV_WM_LEVEL_PM2].plane[plane_id],
> +			      crtc_state->wm.vlv.noninverted[VLV_WM_LEVEL_PM5].plane[plane_id],
> +			      crtc_state->wm.vlv.noninverted[VLV_WM_LEVEL_DDR_DVFS].plane[plane_id]);
> +
> +	return dirty;
>  }
>  
>  static bool vlv_plane_wm_is_valid(const struct intel_crtc_state *crtc_state,
> @@ -1186,10 +1196,12 @@ static int vlv_compute_pipe_wm(struct intel_crtc_state *crtc_state)
>  		&crtc_state->wm.vlv.fifo_state;
>  	int num_active_planes = hweight32(crtc_state->active_planes &
>  					  ~BIT(PLANE_CURSOR));
> +	bool needs_modeset = drm_atomic_crtc_needs_modeset(&crtc_state->base);
>  	struct intel_plane_state *plane_state;
>  	struct intel_plane *plane;
>  	enum plane_id plane_id;
>  	int level, ret, i;
> +	unsigned int dirty = 0;
>  
>  	for_each_intel_plane_in_state(state, plane, plane_state, i) {
>  		const struct intel_plane_state *old_plane_state =
> @@ -1199,7 +1211,37 @@ static int vlv_compute_pipe_wm(struct intel_crtc_state *crtc_state)
>  		    old_plane_state->base.crtc != &crtc->base)
>  			continue;
>  
> -		vlv_plane_wm_compute(crtc_state, plane_state);
> +		if (vlv_plane_wm_compute(crtc_state, plane_state))
> +			dirty |= BIT(plane->id);
> +	}
> +
> +	/*
> +	 * DSPARB registers may have been reset due to the
> +	 * power well being turned off. Make sure we restore
> +	 * them to a consistent state even if no primary/sprite
> +	 * planes are initially active.
> +	 */
> +	if (needs_modeset)
> +		crtc_state->fifo_changed = true;
> +
> +	if (!dirty)
> +		return 0;
> +
> +	/* cursor changes don't warrant a FIFO recompute */
> +	if (dirty & ~BIT(PLANE_CURSOR)) {
> +		const struct intel_crtc_state *old_crtc_state =
> +			to_intel_crtc_state(crtc->base.state);
> +		const struct vlv_fifo_state *old_fifo_state =
> +			&old_crtc_state->wm.vlv.fifo_state;
> +
> +		ret = vlv_compute_fifo(crtc_state);
> +		if (ret)
> +			return ret;
> +
> +		if (needs_modeset ||
> +		    memcmp(old_fifo_state, fifo_state,
> +			   sizeof(*fifo_state)) != 0)
> +			crtc_state->fifo_changed = true;
>  	}
>  
>  	/* initially allow all levels */
> @@ -1212,10 +1254,6 @@ static int vlv_compute_pipe_wm(struct intel_crtc_state *crtc_state)
>  	wm_state->cxsr = crtc->pipe != PIPE_C &&
>  		crtc->wm.cxsr_allowed && num_active_planes == 1;
>  
> -	ret = vlv_compute_fifo(crtc_state);
> -	if (ret)
> -		return ret;
> -
>  	for (level = 0; level < wm_state->num_levels; level++) {
>  		const struct vlv_pipe_wm *noninverted =
>  			&crtc_state->wm.vlv.noninverted[level];
> @@ -1265,6 +1303,9 @@ static void vlv_atomic_update_fifo(struct intel_atomic_state *state,
>  		&crtc_state->wm.vlv.fifo_state;
>  	int sprite0_start, sprite1_start, fifo_size;
>  
> +	if (!crtc_state->fifo_changed)
> +		return;
> +
>  	sprite0_start = fifo_state->plane[PLANE_PRIMARY];
>  	sprite1_start = fifo_state->plane[PLANE_SPRITE0] + sprite0_start;
>  	fifo_size = fifo_state->plane[PLANE_SPRITE1] + sprite1_start;
> @@ -4631,6 +4672,8 @@ void vlv_wm_get_hw_state(struct drm_device *dev)
>  		active->num_levels = wm->level + 1;
>  		active->cxsr = wm->cxsr;
>  
> +		vlv_get_fifo_size(crtc_state);
> +
>  		/* FIXME sanitize things more */
>  		for (level = 0; level < active->num_levels; level++) {
>  			struct vlv_pipe_wm *noninverted =


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

  reply	other threads:[~2016-12-15 15:37 UTC|newest]

Thread overview: 47+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-12 20:35 [PATCH 00/14] drm/i915: VLV/CHV two-stage watermarks ville.syrjala
2016-12-12 20:35 ` [PATCH 01/14] drm/i915: Track visible planes in a bitmask ville.syrjala
2016-12-15 14:56   ` Maarten Lankhorst
2016-12-15 15:02     ` Ville Syrjälä
2016-12-15 17:11       ` Maarten Lankhorst
2016-12-15 17:20         ` Ville Syrjälä
2016-12-12 20:35 ` [PATCH 02/14] drm/i915: Track plane fifo sizes under intel_crtc ville.syrjala
2016-12-15 14:58   ` Maarten Lankhorst
2017-02-16 17:48     ` Ville Syrjälä
2016-12-12 20:35 ` [PATCH 03/14] drm/i915: Move vlv wms from crtc->wm_state to crtc->wm.active.vlv ville.syrjala
2016-12-12 20:35 ` [PATCH 04/14] drm/i915: Plop vlv wm state into crtc_state ville.syrjala
2016-12-12 20:35 ` [PATCH 05/14] drm/i915: Plop vlv/chv fifo sizes into crtc state ville.syrjala
2016-12-12 20:35 ` [PATCH 06/14] drm/i915: Compute VLV/CHV FIFO sizes based on the PM2 watermarks ville.syrjala
2016-12-12 20:35 ` [PATCH 07/14] drm/i915: Compute vlv/chv wms the atomic way ville.syrjala
2016-12-15 15:30   ` Maarten Lankhorst
2016-12-15 15:38     ` Ville Syrjälä
2016-12-15 15:45       ` Maarten Lankhorst
2016-12-15 16:09         ` Ville Syrjälä
2016-12-15 17:12           ` Maarten Lankhorst
2016-12-15 17:17             ` Ville Syrjälä
2016-12-29 15:42           ` Maarten Lankhorst
2016-12-12 20:35 ` [PATCH 08/14] drm/i915: Skip useless watermark/FIFO related work on VLV/CHV when not needed ville.syrjala
2016-12-15 15:37   ` Maarten Lankhorst [this message]
2017-02-16 17:54     ` Ville Syrjälä
2016-12-12 20:35 ` [PATCH 09/14] drm/i915: Compute proper intermediate wms for vlv/cvh ville.syrjala
2016-12-12 20:35 ` [PATCH 10/14] drm/i915: Nuke crtc->wm.cxsr_allowed ville.syrjala
2016-12-12 20:35 ` [PATCH 11/14] drm/i915: Only use update_wm_{pre, post} for pre-ilk platforms ville.syrjala
2016-12-12 20:35 ` [PATCH 12/14] drm/i915: Sanitize VLV/CHV watermarks properly ville.syrjala
2016-12-12 20:35 ` [PATCH 13/14] drm/i915: Workaround VLV/CHV sprite1->sprite0 enable underrun ville.syrjala
2016-12-15 15:34   ` Maarten Lankhorst
2016-12-15 15:47     ` Ville Syrjälä
2016-12-15 16:13       ` Maarten Lankhorst
2016-12-15 16:18         ` Ville Syrjälä
2016-12-12 20:35 ` [PATCH 14/14] drm/i915: Kill level 0 wm hack for VLV/CHV ville.syrjala
2016-12-15 17:10   ` Maarten Lankhorst
2016-12-12 20:35 ` [PATCH i-g-t] tests: Add kms_plane_blinker ville.syrjala
2016-12-15 15:17   ` Maarten Lankhorst
2016-12-15 15:23     ` Ville Syrjälä
2016-12-15 15:28       ` Maarten Lankhorst
2016-12-15 15:36         ` Ville Syrjälä
2016-12-15 15:41           ` Maarten Lankhorst
2016-12-15 16:42             ` Ville Syrjälä
2016-12-15 17:26               ` Ville Syrjälä
2016-12-19  7:07                 ` Maarten Lankhorst
2016-12-12 21:15 ` ✗ Fi.CI.BAT: warning for drm/i915: VLV/CHV two-stage watermarks Patchwork
2016-12-13  7:42   ` Saarinen, Jani
2016-12-13  8:40     ` Chris Wilson

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=a24a02b6-da42-e7b6-5cf9-c7f2865bdabc@linux.intel.com \
    --to=maarten.lankhorst@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=ville.syrjala@linux.intel.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox