All of lore.kernel.org
 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: Michael Leuchtenburg <michael@slashhome.org>
Subject: Re: [PATCH 2/2] drm/i915: Don't assume primary & cursor are	always on for wm calculation
Date: Wed, 04 Mar 2015 10:18:57 +0200	[thread overview]
Message-ID: <877fux41la.fsf@intel.com> (raw)
In-Reply-To: <1425435313-31711-2-git-send-email-matthew.d.roper@intel.com>

On Wed, 04 Mar 2015, Matt Roper <matthew.d.roper@intel.com> wrote:
> Current ILK-style watermark code assumes the primary plane and cursor
> plane are always enabled.  This assumption, along with the combination
> of two independent commits that got merged at the same time, results in
> a NULL dereference.  The offending commits are:
>
>         commit fd2d61341bf39d1054256c07d6eddd624ebc4241
>         Author: Matt Roper <matthew.d.roper@intel.com>
>         Date:   Fri Feb 27 10:12:01 2015 -0800
>
>             drm/i915: Use plane->state->fb in watermark code (v2)
>
> and
>
>         commit 0fda65680e92545caea5be7805a7f0a617fb6c20
>         Author: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
>         Date:   Fri Feb 27 15:12:35 2015 +0000
>
>             drm/i915/skl: Update watermarks for Y tiling
>
> The first commit causes us to use the FB from plane->state->fb rather
> than the legacy plane->fb, which is updated a bit later in the process.
>
> The second commit includes a change that now triggers watermark
> reprogramming on primary plane enable/disable where we didn't have one
> before (which wasn't really correct, but we had been getting lucky
> because we always calculated as if the primary plane was on).
>
> Together, these two commits cause the watermark calculation to
> (properly) see plane->state->fb = NULL when we're in the process of
> disabling the primary plane.  However the existing watermark code
> assumes there's always a primary fb and tries to dereference it to find
> out pixel format / bpp information.
>
> The fix is to make ILK-style watermark calculation actually check the
> true status of primary & cursor planes and adjust our watermark logic
> accordingly.
>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Michael Leuchtenburg <michael@slashhome.org>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=89388
> Signed-off-by: Matt Roper <matthew.d.roper@intel.com>

Tested-by: lu hua <huax.lu@intel.com>

> ---
>  drivers/gpu/drm/i915/intel_pm.c | 22 +++++++++++++++++-----
>  1 file changed, 17 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index e710b43..93fd15f 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -1924,13 +1924,25 @@ static void ilk_compute_wm_parameters(struct drm_crtc *crtc,
>  	p->active = true;
>  	p->pipe_htotal = intel_crtc->config->base.adjusted_mode.crtc_htotal;
>  	p->pixel_rate = ilk_pipe_pixel_rate(dev, crtc);
> -	p->pri.bytes_per_pixel = crtc->primary->state->fb->bits_per_pixel / 8;
> -	p->cur.bytes_per_pixel = 4;
> +
> +	if (crtc->primary->state->fb) {
> +		p->pri.enabled = true;
> +		p->pri.bytes_per_pixel =
> +			crtc->primary->state->fb->bits_per_pixel / 8;
> +	} else {
> +		p->pri.enabled = false;
> +		p->pri.bytes_per_pixel = 0;
> +	}
> +
> +	if (crtc->cursor->state->fb) {
> +		p->cur.enabled = true;
> +		p->cur.bytes_per_pixel = 4;
> +	} else {
> +		p->cur.enabled = false;
> +		p->cur.bytes_per_pixel = 0;
> +	}
>  	p->pri.horiz_pixels = intel_crtc->config->pipe_src_w;
>  	p->cur.horiz_pixels = intel_crtc->base.cursor->state->crtc_w;
> -	/* TODO: for now, assume primary and cursor planes are always enabled. */
> -	p->pri.enabled = true;
> -	p->cur.enabled = true;
>  
>  	drm_for_each_legacy_plane(plane, &dev->mode_config.plane_list) {
>  		struct intel_plane *intel_plane = to_intel_plane(plane);
> -- 
> 1.8.5.1
>
> _______________________________________________
> 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-03-04  8:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-04  2:15 [PATCH 1/2] drm/i915: Don't require primary->fb in intel_crtc_active() Matt Roper
2015-03-04  2:15 ` [PATCH 2/2] drm/i915: Don't assume primary & cursor are always on for wm calculation Matt Roper
2015-03-04  8:18   ` Jani Nikula [this message]
2015-03-04 16:17   ` shuang.he
2015-03-04 17:29   ` Tvrtko Ursulin
2015-03-06  1:31     ` [PATCH 2/2] drm/i915: Don't assume primary & cursor are always on for wm calculation (v2) Matt Roper
2015-03-06  9:58       ` Tvrtko Ursulin
2015-03-06 12:57       ` Ville Syrjälä
2015-03-04  9:45 ` [PATCH 1/2] drm/i915: Don't require primary->fb in intel_crtc_active() Ville Syrjälä
2015-03-04 16:13   ` Daniel Vetter
2015-03-04 18:21     ` Ville Syrjälä
2015-03-05 12:20       ` Daniel Vetter
2015-03-05 12:48         ` Ville Syrjälä
2015-03-04 16:14 ` Daniel Vetter
2015-03-04 17:26 ` Tvrtko Ursulin
2015-03-04 17:42   ` Matt Roper
2015-03-05 15:07     ` Tvrtko Ursulin
2015-03-06 16:44       ` 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=877fux41la.fsf@intel.com \
    --to=jani.nikula@linux.intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.d.roper@intel.com \
    --cc=michael@slashhome.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.