All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: keithp@keithp.com
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH 06/16] drm/i915: Replace ironlake_compute_wm0 with g4x_compute_wm0
Date: Thu, 12 May 2011 22:17:14 +0100	[thread overview]
Message-ID: <1305235044-9159-7-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1305235044-9159-1-git-send-email-chris@chris-wilson.co.uk>

The computation of the first-level watermarks for g4x and gen5+ are
based on the same algorithm, so we can refactor those code paths to
use a single function.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_display.c |   88 ++++++++--------------------------
 1 files changed, 20 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 784e52c..4e1042b 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3862,54 +3862,6 @@ static void i830_update_wm(struct drm_device *dev)
 #define ILK_LP0_PLANE_LATENCY		700
 #define ILK_LP0_CURSOR_LATENCY		1300
 
-static bool ironlake_compute_wm0(struct drm_device *dev,
-				 int pipe,
-				 const struct intel_watermark_params *display,
-				 int display_latency_ns,
-				 const struct intel_watermark_params *cursor,
-				 int cursor_latency_ns,
-				 int *plane_wm,
-				 int *cursor_wm)
-{
-	struct drm_crtc *crtc;
-	int htotal, hdisplay, clock, pixel_size;
-	int line_time_us, line_count;
-	int entries, tlb_miss;
-
-	crtc = intel_get_crtc_for_pipe(dev, pipe);
-	if (crtc->fb == NULL || !crtc->enabled)
-		return false;
-
-	htotal = crtc->mode.htotal;
-	hdisplay = crtc->mode.hdisplay;
-	clock = crtc->mode.clock;
-	pixel_size = crtc->fb->bits_per_pixel / 8;
-
-	/* Use the small buffer method to calculate plane watermark */
-	entries = ((clock * pixel_size / 1000) * display_latency_ns) / 1000;
-	tlb_miss = display->fifo_size*display->cacheline_size - hdisplay * 8;
-	if (tlb_miss > 0)
-		entries += tlb_miss;
-	entries = DIV_ROUND_UP(entries, display->cacheline_size);
-	*plane_wm = entries + display->guard_size;
-	if (*plane_wm > (int)display->max_wm)
-		*plane_wm = display->max_wm;
-
-	/* Use the large buffer method to calculate cursor watermark */
-	line_time_us = ((htotal * 1000) / clock);
-	line_count = (cursor_latency_ns / line_time_us + 1000) / 1000;
-	entries = line_count * 64 * pixel_size;
-	tlb_miss = cursor->fifo_size*cursor->cacheline_size - hdisplay * 8;
-	if (tlb_miss > 0)
-		entries += tlb_miss;
-	entries = DIV_ROUND_UP(entries, cursor->cacheline_size);
-	*cursor_wm = entries + cursor->guard_size;
-	if (*cursor_wm > (int)cursor->max_wm)
-		*cursor_wm = (int)cursor->max_wm;
-
-	return true;
-}
-
 /*
  * Check the wm result.
  *
@@ -4018,12 +3970,12 @@ static void ironlake_update_wm(struct drm_device *dev)
 	unsigned int enabled;
 
 	enabled = 0;
-	if (ironlake_compute_wm0(dev, 0,
-				 &ironlake_display_wm_info,
-				 ILK_LP0_PLANE_LATENCY,
-				 &ironlake_cursor_wm_info,
-				 ILK_LP0_CURSOR_LATENCY,
-				 &plane_wm, &cursor_wm)) {
+	if (g4x_compute_wm0(dev, 0,
+			    &ironlake_display_wm_info,
+			    ILK_LP0_PLANE_LATENCY,
+			    &ironlake_cursor_wm_info,
+			    ILK_LP0_CURSOR_LATENCY,
+			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEA_ILK,
 			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe A -"
@@ -4032,12 +3984,12 @@ static void ironlake_update_wm(struct drm_device *dev)
 		enabled |= 1;
 	}
 
-	if (ironlake_compute_wm0(dev, 1,
-				 &ironlake_display_wm_info,
-				 ILK_LP0_PLANE_LATENCY,
-				 &ironlake_cursor_wm_info,
-				 ILK_LP0_CURSOR_LATENCY,
-				 &plane_wm, &cursor_wm)) {
+	if (g4x_compute_wm0(dev, 1,
+			    &ironlake_display_wm_info,
+			    ILK_LP0_PLANE_LATENCY,
+			    &ironlake_cursor_wm_info,
+			    ILK_LP0_CURSOR_LATENCY,
+			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEB_ILK,
 			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe B -"
@@ -4102,10 +4054,10 @@ static void sandybridge_update_wm(struct drm_device *dev)
 	unsigned int enabled;
 
 	enabled = 0;
-	if (ironlake_compute_wm0(dev, 0,
-				 &sandybridge_display_wm_info, latency,
-				 &sandybridge_cursor_wm_info, latency,
-				 &plane_wm, &cursor_wm)) {
+	if (g4x_compute_wm0(dev, 0,
+			    &sandybridge_display_wm_info, latency,
+			    &sandybridge_cursor_wm_info, latency,
+			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEA_ILK,
 			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe A -"
@@ -4114,10 +4066,10 @@ static void sandybridge_update_wm(struct drm_device *dev)
 		enabled |= 1;
 	}
 
-	if (ironlake_compute_wm0(dev, 1,
-				 &sandybridge_display_wm_info, latency,
-				 &sandybridge_cursor_wm_info, latency,
-				 &plane_wm, &cursor_wm)) {
+	if (g4x_compute_wm0(dev, 1,
+			    &sandybridge_display_wm_info, latency,
+			    &sandybridge_cursor_wm_info, latency,
+			    &plane_wm, &cursor_wm)) {
 		I915_WRITE(WM0_PIPEB_ILK,
 			   (plane_wm << WM0_PIPE_PLANE_SHIFT) | cursor_wm);
 		DRM_DEBUG_KMS("FIFO watermarks For pipe B -"
-- 
1.7.5.1

  parent reply	other threads:[~2011-05-12 21:17 UTC|newest]

Thread overview: 56+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-12 21:17 Select patches for 2.6.40 Chris Wilson
2011-05-12 21:17 ` [PATCH 01/16] drm/i915: Cache GT fifo count for SandyBridge Chris Wilson
2011-05-12 21:17 ` [PATCH 02/16] drm/i915: Refactor pwrite/pread to use single copy of get_user_pages Chris Wilson
2011-05-13  0:21   ` Keith Packard
2011-05-15  8:00     ` Chris Wilson
2011-05-15 15:36       ` Keith Packard
2011-05-12 21:17 ` [PATCH 03/16] drm/i915: s/addr & ~PAGE_MASK/offset_in_page(addr)/ Chris Wilson
2011-05-13  0:26   ` Keith Packard
2011-05-12 21:17 ` [PATCH 04/16] drm/i915: Only print out the actual number of fences for i915_error_state Chris Wilson
2011-05-13  0:28   ` Keith Packard
2011-05-12 21:17 ` [PATCH 05/16] drm/i915/tv: Use a direct pointer for tv_mode Chris Wilson
2011-05-13  0:30   ` Keith Packard
2011-05-12 21:17 ` Chris Wilson [this message]
2011-05-13  0:34   ` [PATCH 06/16] drm/i915: Replace ironlake_compute_wm0 with g4x_compute_wm0 Keith Packard
2011-05-13  9:19     ` Chris Wilson
2011-05-13 15:00       ` Keith Packard
2011-05-12 21:17 ` [PATCH 07/16] drm/i915/crt: Explicitly return false if connected to a digital monitor Chris Wilson
2011-05-12 21:17 ` [PATCH 08/16] drm/i915/i2c: Convert from using GMBUS1 + reg_offset idiom to reg + 0 Chris Wilson
2011-05-13  0:36   ` Keith Packard
2011-05-13  0:40   ` Keith Packard
2011-05-13  9:28     ` Chris Wilson
2011-05-13 15:00       ` Keith Packard
2011-06-03 20:55         ` Keith Packard
2011-06-03 23:09           ` Chris Wilson
2011-06-03 23:48             ` Keith Packard
2011-07-13 18:33             ` Keith Packard
2011-07-13 19:22               ` Chris Wilson
2011-05-12 21:17 ` [PATCH 09/16] drm/i915/gmbus: Reset the controller on initialisation Chris Wilson
2011-05-13  0:41   ` Keith Packard
2011-05-13  9:32     ` Chris Wilson
2011-05-13 15:01       ` Keith Packard
2011-05-13 15:53         ` Chris Wilson
2011-06-03 20:56   ` Keith Packard
2011-05-12 21:17 ` [PATCH 10/16] drm/i915: Retire requests before disabling pagefaults Chris Wilson
2011-05-13  1:08   ` Keith Packard
2011-05-12 21:17 ` [PATCH 11/16] drm/i915: not finding a fence is a non-recoverable condition Chris Wilson
2011-05-13  1:10   ` Keith Packard
2011-05-15 20:38     ` Daniel Vetter
2011-05-12 21:17 ` [PATCH 12/16] drm/915: fix relaxed tiling on gen2: tile height Chris Wilson
2011-05-13  1:13   ` Keith Packard
2011-05-15 20:43     ` Daniel Vetter
2011-05-15 21:58       ` Keith Packard
2011-05-16 17:48         ` Daniel Vetter
2011-05-12 21:17 ` [PATCH 13/16] drm/i915: Remove unused enum "chip_family" Chris Wilson
2011-05-13  1:13   ` Keith Packard
2011-05-12 21:17 ` [PATCH 14/16] drm/i915: Use PCI-ID to identify Broadwater and Crestline Chris Wilson
2011-05-13  1:16   ` Keith Packard
2011-05-13  9:39     ` Chris Wilson
2011-05-15 20:49     ` Daniel Vetter
2011-05-15 22:01       ` Keith Packard
2011-06-03 20:59   ` Keith Packard
2011-05-12 21:17 ` [PATCH 15/16] drm/i915: Convert partial to full CPU read domain if we touch every page Chris Wilson
2011-05-13  1:17   ` Keith Packard
2011-05-12 21:17 ` [PATCH 16/16] drm/i915: Share the common force-audio property between connectors Chris Wilson
2011-05-13  1:21   ` Keith Packard
2011-05-13  3:39 ` Select patches for 2.6.40 Zou, Nanhai

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=1305235044-9159-7-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=keithp@keithp.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 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.