All of lore.kernel.org
 help / color / mirror / Atom feed
From: Imre Deak <imre.deak@intel.com>
To: Gajanan Bhat <gajanan.bhat@intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 2/3] drm/i915: Generalize drain latency computation
Date: Thu, 31 Jul 2014 16:33:09 +0300	[thread overview]
Message-ID: <1406813589.18327.30.camel@intelbox> (raw)
In-Reply-To: <1405515245-14946-3-git-send-email-gajanan.bhat@intel.com>


[-- Attachment #1.1: Type: text/plain, Size: 5471 bytes --]

On Wed, 2014-07-16 at 18:24 +0530, Gajanan Bhat wrote:
> Modify drain latency computation to use it for any plane. Same function can be
> used for primary, cursor and sprite planes.
> 
> Signed-off-by: Gajanan Bhat <gajanan.bhat@intel.com>
> ---
>  drivers/gpu/drm/i915/i915_reg.h |    1 +
>  drivers/gpu/drm/i915/intel_pm.c |   82 ++++++++++++++++++++++-----------------
>  2 files changed, 47 insertions(+), 36 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index d2a220b..a1260a2 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -3877,6 +3877,7 @@ enum punit_power_well {
>  #define DDL_PLANE_PRECISION_64		(1<<7)
>  #define DDL_PLANE_PRECISION_32		(0<<7)
>  #define DDL_PLANE_SHIFT			0
> +#define DRAIN_LATENCY_MAX		0x7f

_MASK is the standard postfix in the driver.

>  
>  /* FIFO watermark sizes etc */
>  #define G4X_FIFO_LINE_SIZE	64
> diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
> index 90df1e8..f3a3e90 100644
> --- a/drivers/gpu/drm/i915/intel_pm.c
> +++ b/drivers/gpu/drm/i915/intel_pm.c
> @@ -1268,33 +1268,21 @@ static bool g4x_compute_srwm(struct drm_device *dev,
>  			      display, cursor);
>  }
>  
> -static bool vlv_compute_drain_latency(struct drm_device *dev,
> -				     int plane,
> -				     int *plane_prec_mult,
> -				     int *plane_dl,
> -				     int *cursor_prec_mult,
> -				     int *cursor_dl)
> +static bool vlv_compute_drain_latency(struct drm_crtc *crtc,
> +				      int pixel_size,
> +				      int *prec_mult,
> +				      int *drain_latency)
>  {
> -	struct drm_crtc *crtc;
> -	int clock, pixel_size;
>  	int entries;
> +	int clock = to_intel_crtc(crtc)->config.adjusted_mode.crtc_clock;
>  
> -	crtc = intel_get_crtc_for_plane(dev, plane);
> -	if (!intel_crtc_active(crtc))
> +	if (clock == 0 || pixel_size == 0)

This would mean a driver bug, so needs to be wrapped in a WARN().

>  		return false;
>  
> -	clock = to_intel_crtc(crtc)->config.adjusted_mode.crtc_clock;
> -	pixel_size = crtc->primary->fb->bits_per_pixel / 8;	/* BPP */
> -
> -	entries = (clock / 1000) * pixel_size;
> -	*plane_prec_mult = (entries > 128) ?
> -		DRAIN_LATENCY_PRECISION_64 : DRAIN_LATENCY_PRECISION_32;
> -	*plane_dl = (64 * (*plane_prec_mult) * 4) / entries;
> -
> -	entries = (clock / 1000) * 4;	/* BPP is always 4 for cursor */
> -	*cursor_prec_mult = (entries > 128) ?
> -		DRAIN_LATENCY_PRECISION_64 : DRAIN_LATENCY_PRECISION_32;
> -	*cursor_dl = (64 * (*cursor_prec_mult) * 4) / entries;
> +	entries = DIV_ROUND_UP(clock, 1000) * pixel_size;
> +	*prec_mult = (entries > 128) ? DRAIN_LATENCY_PRECISION_64 :
> +				       DRAIN_LATENCY_PRECISION_32;
> +	*drain_latency = (64 * (*prec_mult) * 4) / entries;
>  
>  	return true;
>  }
> @@ -1309,24 +1297,46 @@ static bool vlv_compute_drain_latency(struct drm_device *dev,
>  
>  static void vlv_update_drain_latency(struct drm_crtc *crtc)
>  {
> -	struct drm_device *dev = crtc->dev;
> -	struct drm_i915_private *dev_priv = dev->dev_private;
> +	struct drm_i915_private *dev_priv = crtc->dev->dev_private;
> +	int pixel_size;
> +	int drain_latency;
>  	enum pipe pipe = to_intel_crtc(crtc)->pipe;
> -	int plane_prec, plane_dl;
> -	int cursor_prec, cursor_dl;
> -	int plane_prec_mult, cursor_prec_mult;
> +	int plane_prec, prec_mult, plane_dl;
>  
> -	if (vlv_compute_drain_latency(dev, pipe, &plane_prec_mult, &plane_dl,
> -				      &cursor_prec_mult, &cursor_dl)) {
> -		cursor_prec = (cursor_prec_mult == DRAIN_LATENCY_PRECISION_64) ?
> -			DDL_CURSOR_PRECISION_64 : DDL_CURSOR_PRECISION_32;
> -		plane_prec = (plane_prec_mult == DRAIN_LATENCY_PRECISION_64) ?
> -			DDL_PLANE_PRECISION_64 : DDL_PLANE_PRECISION_32;
> +	plane_dl = I915_READ(VLV_DDL(pipe)) & ~DDL_PLANE_PRECISION_64 &
> +		   ~DRAIN_LATENCY_MAX & ~DDL_CURSOR_PRECISION_64 &
> +		   ~(DRAIN_LATENCY_MAX << DDL_CURSOR_SHIFT);

A tad simpler and more standard way for masking is ~(X | Y | Z).
 
> -		I915_WRITE(VLV_DDL(pipe), cursor_prec |
> -			   (cursor_dl << DDL_CURSOR_SHIFT) |
> -			   plane_prec | (plane_dl << DDL_PLANE_SHIFT));
> +	if (!intel_crtc_active(crtc)) {
> +		I915_WRITE(VLV_DDL(pipe), plane_dl);
> +		return;
>  	}
> +
> +	/* Primary plane Drain Latency */
> +	pixel_size = crtc->primary->fb->bits_per_pixel / 8;	/* BPP */
> +	if (vlv_compute_drain_latency(crtc, pixel_size, &prec_mult, &drain_latency)) {
> +		plane_prec = (prec_mult == DRAIN_LATENCY_PRECISION_64) ?
> +					   DDL_PLANE_PRECISION_64 :
> +					   DDL_PLANE_PRECISION_32;
> +		plane_dl = plane_dl | plane_prec | drain_latency;
> +	}
> +
> +	/* Cursor Drain Latency
> +	 * BPP is always 4 for cursor
> +	 */
> +	pixel_size = 4;
> +
> +	/* Program cursor DL only if it is enabled */
> +	if ((I915_READ(CURCNTR(pipe)) & CURSOR_MODE) &&

Checking intel_crtc->cursor_base would be cheaper.

> +	    vlv_compute_drain_latency(crtc, pixel_size, &prec_mult, &drain_latency)) {
> +		plane_prec = (prec_mult == DRAIN_LATENCY_PRECISION_64) ?
> +					   DDL_CURSOR_PRECISION_64 :
> +					   DDL_CURSOR_PRECISION_32;
> +		plane_dl = plane_dl | plane_prec |
> +			   drain_latency << DDL_CURSOR_SHIFT;

This would overwrite the above assignment of plane_dl.

> +	}
> +
> +	I915_WRITE(VLV_DDL(pipe), plane_dl);
>  }
>  
>  #define single_plane_enabled(mask) is_power_of_2(mask)


[-- Attachment #1.2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 159 bytes --]

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

  reply	other threads:[~2014-07-31 13:34 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-16 12:54 [PATCH 0/3] Update DDL code to support sprite watermarks Gajanan Bhat
2014-07-16 12:54 ` [PATCH 1/3] drm/i915: Update DDL only for current CRTC Gajanan Bhat
2014-07-31 12:53   ` Imre Deak
2014-07-16 12:54 ` [PATCH 2/3] drm/i915: Generalize drain latency computation Gajanan Bhat
2014-07-31 13:33   ` Imre Deak [this message]
2014-08-04 14:41   ` Ville Syrjälä
2014-08-05 17:45     ` [PATCH v2 1/2] " Gajanan Bhat
2014-08-05 12:56       ` Ville Syrjälä
2014-08-06 20:28         ` [PATCH v3] " Gajanan Bhat
2014-08-06 15:07           ` Ville Syrjälä
2014-08-06 19:49             ` Daniel Vetter
2014-08-05 17:45       ` [PATCH 2/2] drm/i915: Round-up clock and limit drain latency Gajanan Bhat
2014-08-05 12:46         ` Ville Syrjälä
2014-07-16 12:54 ` [PATCH 3/3] drm/i915: Add sprite watermark programming for VLV and CHV Gajanan Bhat
2014-07-31 13:44   ` Imre Deak
2014-08-07  5:56     ` Bhat, Gajanan
2014-08-07  9:51       ` Imre Deak

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=1406813589.18327.30.camel@intelbox \
    --to=imre.deak@intel.com \
    --cc=gajanan.bhat@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.