All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matt Roper <matthew.d.roper@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: shobhit.kumar@intel.com
Subject: [PATCH 8/8] drm/i915/skl: WA for watermark calculation based on Arbitrated Display BW (v4)
Date: Mon,  7 Mar 2016 17:05:46 -0800	[thread overview]
Message-ID: <1457399146-4578-9-git-send-email-matthew.d.roper@intel.com> (raw)
In-Reply-To: <1457399146-4578-1-git-send-email-matthew.d.roper@intel.com>

From: "Kumar, Mahesh" <mahesh1.kumar@intel.com>

 If the arbitary display bandwidth is > 60% of memory bandwith, for
 x-tile we should increase latency at all levels by 15us.

 If the arbitary dsplay bandwidth is greater than 20% of memory bandwith
 in case of y-tile  being enabled, double the scan lines

v2: Update the commit message to explain the WA (shobhit)

v3: - Address Damien's comment, use DIV_ROUND_UP_ULL macro
    - Check both mem_speed and mem_channel to be valid before applying
      WA(shobhit)

v4 (by Matt):
 - Adjust calculations now that skl_plane_downscale_amount() returns
   a 16.16 fixed point value
 - Use pstate->visible instead of pstate->fb != NULL for determining
   whether a plane is active

Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
Signed-off-by: Kumar, Mahesh <mahesh1.kumar@intel.com>
Signed-off-by: Shobhit Kumar <shobhit.kumar@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h |  9 ++++
 drivers/gpu/drm/i915/intel_pm.c | 97 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 106 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index a2a7d8d..63b621a 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1669,6 +1669,12 @@ enum intel_pipe_crc_source {
 	INTEL_PIPE_CRC_SOURCE_MAX,
 };
 
+enum watermark_memory_wa {
+	WATERMARK_WA_NONE,
+	WATERMARK_WA_X_TILED,
+	WATERMARK_WA_Y_TILED,
+};
+
 struct intel_pipe_crc_entry {
 	uint32_t frame;
 	uint32_t crc[5];
@@ -1973,6 +1979,9 @@ struct drm_i915_private {
 		/* Committed wm config */
 		struct intel_wm_config config;
 
+		/* This stores if WaterMark memory workaround is needed */
+		enum watermark_memory_wa mem_wa;
+
 		/*
 		 * The skl_wm_values structure is a bit too big for stack
 		 * allocation, so we keep the staging struct where we store
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 29d37d3..c1700af 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -3286,6 +3286,11 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 	if (latency == 0 || !cstate->base.active || !intel_pstate->visible)
 		return false;
 
+	if (dev_priv->wm.mem_wa != WATERMARK_WA_NONE) {
+		if (fb->modifier[0] == I915_FORMAT_MOD_X_TILED)
+			latency += 15;
+	}
+
 	width = drm_rect_width(&intel_pstate->src) >> 16;
 	height = drm_rect_height(&intel_pstate->src) >> 16;
 
@@ -3325,6 +3330,9 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 				WARN(1, "Unsupported pixel depth for rotation");
 			}
 		}
+		if (dev_priv->wm.mem_wa == WATERMARK_WA_Y_TILED)
+			min_scanlines *= 2;
+
 		y_tile_minimum = plane_blocks_per_line * min_scanlines;
 		selected_result = max(method2, y_tile_minimum);
 	} else {
@@ -3776,6 +3784,94 @@ static void skl_set_plane_pixel_rate(struct drm_crtc *crtc)
 
 }
 
+static void
+skl_set_display_memory_wa(struct drm_device *dev)
+{
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_crtc *intel_crtc = NULL;
+	struct intel_plane *intel_plane = NULL;
+	uint32_t num_active_crtc = 0;
+	uint64_t max_pixel_rate_pipe = 0;
+	uint64_t display_bw = 0, available_bw = 0;
+	bool y_tile_enabled = false;
+	int memory_portion = 0;
+
+	/* Verify that we got proper memory information */
+	if (!dev_priv->dmi.valid) {
+		dev_priv->wm.mem_wa = WATERMARK_WA_NONE;
+		return;
+	}
+
+	for_each_intel_crtc(dev, intel_crtc) {
+		uint64_t max_pixel_rate_plane = 0;
+		uint64_t pipe_bw;
+		uint32_t num_active_plane = 0;
+		const struct intel_crtc_state *cstate = NULL;
+
+		if (!intel_crtc->active)
+			continue;
+
+		cstate = to_intel_crtc_state(intel_crtc->base.state);
+		num_active_crtc++;
+
+		for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
+			struct drm_plane *plane = &intel_plane->base;
+			struct drm_framebuffer *fb = plane->state->fb;
+			struct intel_plane_state *intel_pstate =
+				to_intel_plane_state(plane->state);
+			uint64_t plane_bw, interm_bw;
+
+			if (!intel_pstate->visible)
+				continue;
+			if (plane->type == DRM_PLANE_TYPE_CURSOR)
+				continue;
+
+			num_active_plane++;
+
+			if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED)
+				y_tile_enabled = true;
+
+			/*
+			 * planeBW = pixel_rate(MHz) * BPP * plane downscale
+			 *		amount * pipe downscale amount;
+			 *
+			 * skl_pipe_pixel_rate returns the adjusted value
+			 * according to the downscaling amount
+			 *
+			 * pixel rate is in KHz so divide it by 1000
+			 *
+			 * downscale factor is in 16.16 fixed point so shift
+			 * the result accordingly
+			 */
+			interm_bw = skl_pipe_pixel_rate(cstate)/1000 *
+				drm_format_plane_cpp(fb->pixel_format, 0) *
+				skl_plane_downscale_amount(intel_plane);
+
+			if (fb->pixel_format == DRM_FORMAT_NV12)
+				interm_bw += skl_pipe_pixel_rate(cstate)/1000 *
+					drm_format_plane_cpp(fb->pixel_format, 1) *
+					skl_plane_downscale_amount(intel_plane);
+
+			plane_bw = interm_bw >> 16;
+			max_pixel_rate_plane = max(max_pixel_rate_plane,
+						   plane_bw);
+		}
+		pipe_bw = max_pixel_rate_plane * num_active_plane;
+		max_pixel_rate_pipe = max(max_pixel_rate_pipe, pipe_bw);
+	}
+
+	display_bw = max_pixel_rate_pipe * num_active_crtc;
+	available_bw = dev_priv->dmi.mem_channel * dev_priv->dmi.mem_speed * 8;
+	memory_portion = DIV_ROUND_UP_ULL((display_bw * 100), available_bw);
+
+	if (y_tile_enabled && (memory_portion >= 20))
+		dev_priv->wm.mem_wa = WATERMARK_WA_Y_TILED;
+	else if (memory_portion >= 60)
+		dev_priv->wm.mem_wa = WATERMARK_WA_X_TILED;
+	else
+		dev_priv->wm.mem_wa = WATERMARK_WA_NONE;
+}
+
 static void skl_clear_wm(struct skl_wm_values *watermarks, enum pipe pipe)
 {
 	watermarks->wm_linetime[pipe] = 0;
@@ -3814,6 +3910,7 @@ static void skl_update_wm(struct drm_crtc *crtc)
 
 	/* Calculate plane pixel rate for each plane in advance */
 	skl_set_plane_pixel_rate(crtc);
+	skl_set_display_memory_wa(dev);
 
 	if (!skl_update_pipe_wm(crtc, &results->ddb, pipe_wm))
 		goto out;
-- 
2.1.4

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

  parent reply	other threads:[~2016-03-08  1:07 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-08  1:05 [PATCH 0/8] SKL WM fixes and Arbitrated Display Bandwidth WA Matt Roper
2016-03-08  1:05 ` [PATCH 1/8] drm/i915/skl+: Use plane size for relative data rate calculation Matt Roper
2016-03-08  1:05 ` [PATCH 2/8] drm/i915/skl+: calculate ddb minimum allocation (v3) Matt Roper
2016-03-08  1:05 ` [PATCH 3/8] drm/i915/skl+: calculate plane pixel rate (v3) Matt Roper
2016-03-08  1:05 ` [PATCH 4/8] drm/i915/skl+: Use scaling amount for plane data rate calculation (v3) Matt Roper
2016-04-13 20:58   ` Sripada, Radhakrishna
2016-03-08  1:05 ` [PATCH 5/8] drm/i915/gen9: Hold wm_mutex around SKL watermark updates Matt Roper
2016-03-08  1:05 ` [PATCH 6/8] dmi: Move memdev_dmi_entry definition to dmi.h Matt Roper
2016-03-08 12:37   ` Jean Delvare
2016-03-08 12:37     ` Jean Delvare
2016-03-08 18:32     ` [PATCH 6/8] dmi: Move memdev_dmi_entry definition to dmi.h (v2) Matt Roper
2016-03-08 18:32       ` Matt Roper
2016-03-17 14:18       ` Jean Delvare
2017-07-31  8:36         ` Jean Delvare
2017-07-31  8:36           ` Jean Delvare
2017-08-09 16:18           ` Matt Roper
2017-08-09 16:18             ` Matt Roper
2017-08-10  9:39             ` Jean Delvare
2017-08-10  9:39               ` Jean Delvare
2016-03-08  1:05 ` [PATCH 7/8] drm/i915: Add support to parse DMI table and get platform memory info (v3) Matt Roper
2016-03-08 18:49   ` Ville Syrjälä
2016-03-08 18:55     ` Matt Roper
2016-03-08 19:00   ` [PATCH 7/8] drm/i915: Add support to parse DMI table and get platform memory info (v4) Matt Roper
2016-03-08  1:05 ` Matt Roper [this message]
2016-03-08  5:07 ` [PATCH 0/8] SKL WM fixes and Arbitrated Display Bandwidth WA Kumar, Shobhit
2016-03-08  7:57 ` ✗ Fi.CI.BAT: failure for " Patchwork
2016-03-08 18:51   ` Matt Roper
2016-03-09  7:01 ` ✗ Fi.CI.BAT: failure for SKL WM fixes and Arbitrated Display Bandwidth WA (rev3) Patchwork

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=1457399146-4578-9-git-send-email-matthew.d.roper@intel.com \
    --to=matthew.d.roper@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=shobhit.kumar@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 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.