From: Ben Widawsky <ben@bwidawsk.net>
To: Jesse Barnes <jbarnes@virtuousgeek.org>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 12/26] drm/i915: program drain latency regs on ValleyView
Date: Sun, 25 Mar 2012 18:50:33 -0700 [thread overview]
Message-ID: <20120326015032.GA6534@seagal.kumite> (raw)
In-Reply-To: <1332452348-8814-13-git-send-email-jbarnes@virtuousgeek.org>
On Thu, Mar 22, 2012 at 02:38:54PM -0700, Jesse Barnes wrote:
> From: Gajanan Bhat <gajanan.bhat@intel.com>
>
> This patch adds support for programming drain latency registers of Pondicherry
> memory arbiter of Valleyview.
>
> v2: clarify function names (Daniel)
> fix summary typo (Daniel)
>
> Signed-off-by: Gajanan Bhat <gajanan.bhat@intel.com>
> Reviewed-by: Shobhit Kumar <shobhit.kumar@intel.com>
> Reviewed-by: Vijay Purushothaman <vijay.a.purushothaman@intel.com>
> Reviewed-by: Jesse Barnes <jesse.barnes@intel.com>
> Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
> ---
> drivers/gpu/drm/i915/i915_reg.h | 16 +++++++
> drivers/gpu/drm/i915/intel_display.c | 76 ++++++++++++++++++++++++++++++++++
> 2 files changed, 92 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index be11d39..57e8980 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -2605,6 +2605,22 @@
> #define DSPFW_HPLL_CURSOR_MASK (0x3f<<16)
> #define DSPFW_HPLL_SR_MASK (0x1ff)
>
> +/* drain latency register values*/
> +#define DRAIN_LATENCY_PRECISION_32 32
> +#define DRAIN_LATENCY_PRECISION_16 16
> +#define VLV_DDL1 0x70050
> +#define DDL_CURSORA_PRECISION_32 (1<<31)
> +#define DDL_CURSORA_PRECISION_16 (0<<31)
> +#define DDL_CURSORA_SHIFT 24
> +#define DDL_PLANEA_PRECISION_32 (1<<7)
> +#define DDL_PLANEA_PRECISION_16 (0<<7)
> +#define VLV_DDL2 0x70054
> +#define DDL_CURSORB_PRECISION_32 (1<<31)
> +#define DDL_CURSORB_PRECISION_16 (0<<31)
> +#define DDL_CURSORB_SHIFT 24
> +#define DDL_PLANEB_PRECISION_32 (1<<7)
> +#define DDL_PLANEB_PRECISION_16 (0<<7)
> +
> /* FIFO watermark sizes etc */
> #define G4X_FIFO_LINE_SIZE 64
> #define I915_FIFO_LINE_SIZE 64
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 6bed629..4b5905c 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -4337,6 +4337,80 @@ static bool g4x_compute_srwm(struct drm_device *dev,
> display, cursor);
> }
>
> +static int vlv_compute_drain_latency(struct drm_device *dev,
> + int plane,
> + int *plane_prec_mult,
> + int *plane_dl,
> + int *cursor_prec_mult,
> + int *cursor_dl)
> +{
> + struct drm_crtc *crtc;
> + int clock, pixel_size;
> + int entries;
> +
> + crtc = intel_get_crtc_for_plane(dev, plane);
> + if (crtc->fb == NULL || !crtc->enabled)
> + return false;
> +
> + clock = crtc->mode.clock; /* VESA DOT Clock */
> + pixel_size = crtc->fb->bits_per_pixel / 8; /* BPP */
> +
> + entries = (clock / 1000) * pixel_size;
> + *plane_prec_mult = (entries > 256) ?
> + DRAIN_LATENCY_PRECISION_32 : DRAIN_LATENCY_PRECISION_16;
> + *plane_dl = (64 * *plane_prec_mult * 4) / ((clock / 1000) * pixel_size);
> +
> + entries = (clock / 1000) * 4; /* BPP is always 4 for cursor */
> + *cursor_prec_mult = (entries > 256) ?
> + DRAIN_LATENCY_PRECISION_32 : DRAIN_LATENCY_PRECISION_16;
> + *cursor_dl = (64 * *cursor_prec_mult * 4) / ((clock / 1000) * 4);
Can we add some parentheses around *cursor_prec_mult here (two places
above)?
> +
> + return true;
> +}
It doesn't produce a warning for me, but 0, and 1 are more typically
returned when using ints. I'd just change the return type to bool.
> +
> +/*
> + * Update drain latency registers of memory arbiter
> + *
> + * Valleyview SoC has a new memory arbiter and needs drain latency registers
> + * to be programmed. Each plane has a drain latency multiplier and a drain
> + * latency value.
> + */
Better than this comment would have been how the arbiter's drain latency
functions.
> +
> +static void vlv_update_drain_latency(struct drm_device *dev)
> +{
> + struct drm_i915_private *dev_priv = dev->dev_private;
> + int planea_prec, planea_dl, planeb_prec, planeb_dl;
> + int cursora_prec, cursora_dl, cursorb_prec, cursorb_dl;
> + int plane_prec_mult, cursor_prec_mult; /* Precision multiplier is
> + either 16 or 32 */
> +
> + /* For plane A, Cursor A */
> + if (vlv_compute_drain_latency(dev, 0, &plane_prec_mult, &planea_dl,
> + &cursor_prec_mult, &cursora_dl)) {
> + cursora_prec = (cursor_prec_mult == DRAIN_LATENCY_PRECISION_32) ?
> + DDL_CURSORA_PRECISION_32 : DDL_CURSORA_PRECISION_16;
> + planea_prec = (plane_prec_mult == DRAIN_LATENCY_PRECISION_32) ?
> + DDL_PLANEA_PRECISION_32 : DDL_PLANEA_PRECISION_16;
> +
> + I915_WRITE(VLV_DDL1, cursora_prec |
> + (cursora_dl << DDL_CURSORA_SHIFT) |
> + planea_prec | planea_dl);
> + }
> +
> + /* For plane B, Cursor B */
> + if (vlv_compute_drain_latency(dev, 1, &plane_prec_mult, &planeb_dl,
> + &cursor_prec_mult, &cursorb_dl)) {
> + cursorb_prec = (cursor_prec_mult == DRAIN_LATENCY_PRECISION_32) ?
> + DDL_CURSORB_PRECISION_32 : DDL_CURSORB_PRECISION_16;
> + planeb_prec = (plane_prec_mult == DRAIN_LATENCY_PRECISION_32) ?
> + DDL_PLANEB_PRECISION_32 : DDL_PLANEB_PRECISION_16;
> +
> + I915_WRITE(VLV_DDL2, cursorb_prec |
> + (cursorb_dl << DDL_CURSORB_SHIFT) |
> + planeb_prec | planeb_dl);
> + }
> +}
> +
> #define single_plane_enabled(mask) is_power_of_2(mask)
>
> static void valleyview_update_wm(struct drm_device *dev)
> @@ -4347,6 +4421,8 @@ static void valleyview_update_wm(struct drm_device *dev)
> int plane_sr, cursor_sr;
> unsigned int enabled = 0;
>
> + vlv_update_drain_latency(dev);
> +
> if (g4x_compute_wm0(dev, 0,
> &valleyview_wm_info, latency_ns,
> &valleyview_cursor_wm_info, latency_ns,
Couldn't find the registers in docs, so only
Acked-by: Ben Widawsky <ben@bwidawsk.net>
next prev parent reply other threads:[~2012-03-26 1:51 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-03-22 21:38 [RFCv2] ValleyView support Jesse Barnes
2012-03-22 21:38 ` [PATCH 01/26] drm/i915: move NEEDS_FORCE_WAKE to i915_drv.c Jesse Barnes
2012-03-22 22:20 ` Ben Widawsky
2012-03-23 22:46 ` Daniel Vetter
2012-03-22 21:38 ` [PATCH 02/26] drm/i915: re-order GT IIR bit definitions Jesse Barnes
2012-03-22 22:25 ` Ben Widawsky
2012-03-23 22:46 ` Daniel Vetter
2012-03-22 21:38 ` [PATCH 03/26] drm/i915: add ValleyView driver structs and IS_VALLEYVIEW macro Jesse Barnes
2012-03-22 22:31 ` Ben Widawsky
2012-03-22 21:38 ` [PATCH 04/26] drm/i915: ValleyView watermark support Jesse Barnes
2012-03-23 3:29 ` Ben Widawsky
2012-03-23 9:51 ` Daniel Vetter
2012-03-24 2:46 ` Ben Widawsky
2012-03-22 21:38 ` [PATCH 05/26] drm/i915: PLL defines for VLV Jesse Barnes
2012-03-23 3:35 ` Ben Widawsky
2012-03-22 21:38 ` [PATCH 06/26] drm/i915: interrupt bit definitions " Jesse Barnes
2012-03-22 21:38 ` [PATCH 07/26] drm/i915: add ValleyView clock gating init Jesse Barnes
2012-03-22 23:25 ` Ben Widawsky
2012-03-22 21:38 ` [PATCH 08/26] drm/i915: add DPIO read/write functions for ValleyView Jesse Barnes
2012-03-23 4:03 ` Ben Widawsky
2012-03-23 17:29 ` Eugeni Dodonov
2012-03-22 21:38 ` [PATCH 09/26] drm/i915: split PLL update code out of i9xx_crtc_mode_set Jesse Barnes
2012-03-23 4:16 ` Ben Widawsky
2012-03-23 23:00 ` Daniel Vetter
2012-03-22 21:38 ` [PATCH 10/26] drm/i915: split LVDS " Jesse Barnes
2012-03-23 23:04 ` Daniel Vetter
2012-03-22 21:38 ` [PATCH 11/26] drm/i915: ValleyView mode setting limits and PLL functions Jesse Barnes
2012-03-22 21:38 ` [PATCH 12/26] drm/i915: program drain latency regs on ValleyView Jesse Barnes
2012-03-26 1:50 ` Ben Widawsky [this message]
2012-03-22 21:38 ` [PATCH 13/26] drm/i915: Enable DP panel power sequencing for ValleyView Jesse Barnes
2012-03-22 21:38 ` [PATCH 14/26] drm/i915: Enable HDMI on ValleyView Jesse Barnes
2012-03-22 21:38 ` [PATCH 15/26] agp/intel: map more registers for use by the GTT code Jesse Barnes
2012-03-26 2:05 ` Ben Widawsky
2012-03-26 7:06 ` Daniel Vetter
2012-03-22 21:38 ` [PATCH 16/26] agp/intel: add ValleyView AGP driver Jesse Barnes
2012-03-26 2:16 ` Ben Widawsky
2012-03-26 7:08 ` Daniel Vetter
2012-03-26 18:17 ` Ben Widawsky
2012-03-22 21:38 ` [PATCH 17/26] agp/intel: bind " Jesse Barnes
2012-03-22 21:39 ` [PATCH 18/26] drm/i915: add ValleyView specific CRT detect function Jesse Barnes
2012-03-23 17:11 ` Eugeni Dodonov
2012-03-22 21:39 ` [PATCH 19/26] drm/i915: add ValleyView specific force wake get/put functions Jesse Barnes
2012-03-23 17:20 ` Eugeni Dodonov
2012-03-26 18:20 ` Ben Widawsky
2012-03-22 21:39 ` [PATCH 20/26] drm/i915: ValleyView has limited cacheability Jesse Barnes
2012-03-22 23:31 ` Jesse Barnes
2012-03-26 18:34 ` Ben Widawsky
2012-03-26 18:49 ` Daniel Vetter
2012-03-28 17:43 ` Jesse Barnes
2012-03-22 21:39 ` [PATCH 21/26] drm/i915: ValleyView IRQ support Jesse Barnes
2012-03-22 21:39 ` [PATCH 22/26] drm/i915: display regs are at 0x180000 on ValleyView Jesse Barnes
2012-03-22 21:39 ` [PATCH 23/26] drm/i915: check for disabled interrupts " Jesse Barnes
2012-03-22 21:39 ` [PATCH 24/26] drm/i915: add HDMI and DP port enumeration " Jesse Barnes
2012-03-22 21:39 ` [PATCH 25/26] drm/i915: disable turbo on ValleyView for now Jesse Barnes
2012-03-23 17:04 ` Eugeni Dodonov
2012-03-22 21:39 ` [PATCH 26/26] drm/i915: bind driver to ValleyView chipsets Jesse Barnes
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=20120326015032.GA6534@seagal.kumite \
--to=ben@bwidawsk.net \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jbarnes@virtuousgeek.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox