intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@linux.intel.com>
To: Matt Roper <matthew.d.roper@intel.com>, intel-gfx@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: Re: [PATCH 14/15] drm/i915: Sanitize watermarks after	hardware state readout
Date: Thu, 01 Oct 2015 16:58:38 +0300	[thread overview]
Message-ID: <874miabshd.fsf@intel.com> (raw)
In-Reply-To: <1443135200-9870-15-git-send-email-matthew.d.roper@intel.com>

On Fri, 25 Sep 2015, Matt Roper <matthew.d.roper@intel.com> wrote:
> Although we can do a good job of reading out hardware state, the
> graphics firmware may have programmed the watermarks in a creative way
> that doesn't match how i915 would have chosen to program them.  We
> shouldn't trust the firmware's watermark programming, but should rather
> re-calculate how we think WM's should be programmed and then shove those
> values into the hardware.
>
> We can do this pretty easily by creating a dummy top-level state,
> running it through the check process to calculate all the values, and
> then just programming the watermarks for each CRTC.
>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>

Bisect tells me this patch, i.e.

commit c103f2b83dfa3b6fb6b5819ae0362fee6cf4b242
Author: Matt Roper <matthew.d.roper@intel.com>
Date:   Thu Sep 24 15:53:19 2015 -0700

    drm/i915: Sanitize watermarks after hardware state readout

gives me black screen on a BDW NUC pciid=0x1616.

Daniel, please drop it.

BR,
Jani.


> ---
> Maarten, does this solve the problem you were seeing on Ironlake?  You
> indicated that your firmware had sprite watermarks programmed even though
> sprites themselves were off and I don't have any kind of system that can
> reproduce that setup.  I'm hoping this will patch will do the trick.
>
>  drivers/gpu/drm/i915/i915_drv.h      |  1 +
>  drivers/gpu/drm/i915/intel_display.c | 51 ++++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/i915/intel_pm.c      | 14 +++++-----
>  3 files changed, 60 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 8b7c8f9..a9bac1e 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -629,6 +629,7 @@ struct drm_i915_display_funcs {
>  			  struct dpll *best_clock);
>  	int (*compute_pipe_wm)(struct intel_crtc *crtc,
>  			       struct drm_atomic_state *state);
> +	void (*program_watermarks)(struct intel_crtc_state *cstate);
>  	void (*update_wm)(struct drm_crtc *crtc);
>  	int (*modeset_calc_cdclk)(struct drm_atomic_state *state);
>  	void (*modeset_commit_cdclk)(struct drm_atomic_state *state);
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index e2a0777..0c3783c 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -15310,6 +15310,54 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
>  	}
>  }
>  
> +/*
> + * Calculate what we think the watermarks should be for the state we've read
> + * out of the hardware and then immediately program those watermarks so that
> + * we ensure the hardware settings match our internal state.
> + */
> +static void sanitize_watermarks(struct drm_device *dev)
> +{
> +	struct drm_i915_private *dev_priv = to_i915(dev);
> +	struct drm_atomic_state *state;
> +	struct drm_crtc *crtc;
> +	struct drm_crtc_state *cstate;
> +	int ret;
> +	int i;
> +
> +	/* Only supported on platforms that use atomic watermark design */
> +	if (!dev_priv->display.program_watermarks)
> +		return;
> +
> +	/*
> +	 * Calculate what we think WM's should be by creating a dummy state and
> +	 * running it through the atomic check code.
> +	 */
> +	state = drm_atomic_helper_duplicate_state(dev,
> +						  dev->mode_config.acquire_ctx);
> +	if (WARN_ON(IS_ERR(state)))
> +		return;
> +
> +	ret = intel_atomic_check(dev, state);
> +	if (ret) {
> +		/*
> +		 * Just give up and leave watermarks untouched if we get an
> +		 * error back from 'check'
> +		 */
> +		DRM_DEBUG_KMS("Could not determine valid watermarks for inherited state\n");
> +		return;
> +	}
> +
> +	/* Write calculated watermark values back */
> +	to_i915(dev)->wm.config = to_intel_atomic_state(state)->wm_config;
> +	for_each_crtc_in_state(state, crtc, cstate, i) {
> +		struct intel_crtc_state *cs = to_intel_crtc_state(cstate);
> +
> +		dev_priv->display.program_watermarks(cs);
> +	}
> +
> +	drm_atomic_state_free(state);
> +}
> +
>  /* Scan out the current hw modeset state,
>   * and sanitizes it to the current state
>   */
> @@ -15365,6 +15413,9 @@ intel_modeset_setup_hw_state(struct drm_device *dev)
>  			modeset_put_power_domains(dev_priv, put_domains);
>  	}
>  	intel_display_set_init_power(dev_priv, false);
> +
> +	/* Make sure hardware watermarks really match the state we read out */
> +	sanitize_watermarks(dev);
>  }
>  
>  void intel_display_resume(struct drm_device *dev)
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index f3652bb..988893e 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -3664,15 +3664,19 @@ static void skl_update_wm(struct drm_crtc *crtc)
>  	dev_priv->wm.skl_hw = *results;
>  }
>  
> -static void ilk_program_watermarks(struct drm_i915_private *dev_priv)
> +static void ilk_program_watermarks(struct intel_crtc_state *cstate)
>  {
> -	struct drm_device *dev = dev_priv->dev;
> +	struct drm_crtc *crtc = cstate->base.crtc;
> +	struct drm_device *dev = crtc->dev;
> +	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_pipe_wm lp_wm_1_2 = {}, lp_wm_5_6 = {}, *best_lp_wm;
>  	struct ilk_wm_maximums max;
>  	struct intel_wm_config *config = &dev_priv->wm.config;
>  	struct ilk_wm_values results = {};
>  	enum intel_ddb_partitioning partitioning;
>  
> +	to_intel_crtc(crtc)->wm.active.ilk = cstate->wm.optimal.ilk;
> +
>  	ilk_compute_wm_maximums(dev, 1, config, INTEL_DDB_PART_1_2, &max);
>  	ilk_wm_merge(dev, config, &max, &lp_wm_1_2);
>  
> @@ -3697,7 +3701,6 @@ static void ilk_program_watermarks(struct drm_i915_private *dev_priv)
>  
>  static void ilk_update_wm(struct drm_crtc *crtc)
>  {
> -	struct drm_i915_private *dev_priv = to_i915(crtc->dev);
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  	struct intel_crtc_state *cstate = to_intel_crtc_state(crtc->state);
>  
> @@ -3715,9 +3718,7 @@ static void ilk_update_wm(struct drm_crtc *crtc)
>  		intel_wait_for_vblank(crtc->dev, intel_crtc->pipe);
>  	}
>  
> -	intel_crtc->wm.active.ilk = cstate->wm.optimal.ilk;
> -
> -	ilk_program_watermarks(dev_priv);
> +	ilk_program_watermarks(cstate);
>  }
>  
>  static void skl_pipe_wm_active_state(uint32_t val,
> @@ -7051,6 +7052,7 @@ 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.compute_pipe_wm = ilk_compute_pipe_wm;
> +			dev_priv->display.program_watermarks = ilk_program_watermarks;
>  		} else {
>  			DRM_DEBUG_KMS("Failed to read display plane latency. "
>  				      "Disable CxSR\n");
> -- 
> 2.1.4
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2015-10-01 13:55 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-24 22:53 [PATCH 00/15] Atomic watermark updates (v5) Matt Roper
2015-09-24 22:53 ` [PATCH 01/15] drm/i915: Drop redundant watermark programming Matt Roper
2015-09-24 22:53 ` [PATCH 02/15] drm/i915: Eliminate usage of plane_wm_parameters from ILK-style WM code (v2) Matt Roper
2016-01-05 12:49   ` Flicker caused by "drm/i915: Eliminate usage of plane_wm_parameters from ILK-style WM code (v2)" Jan Niehusmann
2016-01-05 21:58     ` Matt Roper
2016-01-06  0:46       ` Jan Niehusmann
2015-09-24 22:53 ` [PATCH 03/15] drm/i915: Eliminate usage of pipe_wm_parameters from ILK-style WM (v2) Matt Roper
2015-09-24 22:53 ` [PATCH 04/15] drm/i915: Determine I915_MAX_PLANES from plane enum Matt Roper
2015-09-24 22:53 ` [PATCH 05/15] drm/i915/skl: Simplify wm structures slightly (v2) Matt Roper
2015-09-30 15:13   ` Daniel Vetter
2015-09-24 22:53 ` [PATCH 06/15] drm/i915/skl: Eliminate usage of pipe_wm_parameters from SKL-style WM (v3) Matt Roper
2015-09-24 22:53 ` [PATCH 07/15] drm/i915/ivb: Move WaCxSRDisabledForSpriteScaling w/a to atomic check Matt Roper
2015-09-24 22:53 ` [PATCH 08/15] drm/i915: Drop intel_update_sprite_watermarks Matt Roper
2015-09-24 22:53 ` [PATCH 09/15] drm/i915: Refactor ilk_update_wm (v3) Matt Roper
2015-09-24 22:53 ` [PATCH 10/15] drm/i915: Calculate pipe watermarks into CRTC state (v3) Matt Roper
2015-09-24 22:53 ` [PATCH 11/15] drm/i915: Calculate ILK-style watermarks during atomic check (v3) Matt Roper
2015-09-24 22:53 ` [PATCH 12/15] drm/i915: Don't set plane visible during HW readout if CRTC is off Matt Roper
2015-09-24 22:53 ` [PATCH 13/15] drm/i915: Calculate watermark configuration during atomic check (v2) Matt Roper
2015-09-24 22:53 ` [PATCH 14/15] drm/i915: Sanitize watermarks after hardware state readout Matt Roper
2015-10-01 13:58   ` Jani Nikula [this message]
2015-10-01 16:12     ` Daniel Vetter
2015-10-01 16:53     ` [PATCH] drm/i915: Convert hsw_compute_linetime_wm to use in-flight state Matt Roper
2015-10-06 14:34       ` Jani Nikula
2015-09-24 22:53 ` [PATCH 15/15] drm/i915: Add two-stage ILK-style watermark programming (v5) Matt Roper
2015-09-30 15:20 ` [PATCH 00/15] Atomic watermark updates (v5) Daniel Vetter
2015-09-30 22:21   ` Zanoni, Paulo R
2015-10-01 23:03     ` [PATCH] fixup! drm/i915/skl: Eliminate usage of pipe_wm_parameters from SKL-style WM (v3) Matt Roper
2015-10-02 18:43       ` Zanoni, Paulo R
2015-10-06 10:13         ` [PATCH] fixup! drm/i915/skl: Eliminate usage of pipe_wm_parameters from SKL-style WM (v3) [regression] 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=874miabshd.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.d.roper@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;
as well as URLs for NNTP newsgroup(s).