Skip to contentSkip to conversation

drm/i915/skl: Use proper plane dimensions for DDB and WM calculations

PATCH In review Matt Roper 3 participants 6 messages Dec 21, 2015 – Jan 12, 2016

Subsystems (2)
lore
Share & tools
lore

Matt Roper

author
#0 lore raw

PATCH 1/1 drm/i915/skl: Use proper plane dimensions for DDB and WM calculations

In commit

commit 024c9045221fe45482863c47c4b4c47d37f97cbf
Author: Matt Roper <[email protected]>
Date: Thu Sep 24 15:53:11 2015 -0700

drm/i915/skl: Eliminate usage of pipe_wm_parameters from SKL-style WM (v4)

I fumbled while converting the dimensions stored in the plane_parameters structure to the values stored in plane state and accidentally replaced the plane dimensions with the pipe dimensions in both the DDB allocation function and the WM calculation function. On the DDB side this is harmless since we effectively treat all of our non-cursor planes as full-screen which may not be optimal, but generally won't cause any problems either (and in 99% of the cases where there's no sprite plane usage or primary plane windowing, there's no effect at all). On the WM calculation side there's more potential for this fumble to cause actual problems since cursors also get miscalculated.

Cc Ville Syrjälä <[email protected]>
Cc "Kondapally, Kalyan" <[email protected]>
Cc Radhakrishna Sripada <[email protected]>
---
 drivers/gpu/drm/i915/intel_pm.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +13 -11
index 8d0d6f5..f4d4cc7 100644
@@ -2845,25 +2845,22 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 			     const struct drm_plane_state *pstate,
 			     int y)
 {
-	struct intel_crtc *intel_crtc = to_intel_crtc(cstate->base.crtc);
+	struct intel_plane_state *intel_pstate = to_intel_plane_state(pstate);
 	struct drm_framebuffer *fb = pstate->fb;
+	unsigned w = drm_rect_width(&intel_pstate->dst);
+	unsigned h = drm_rect_height(&intel_pstate->dst);
 
 	/* for planar format */
 	if (fb->pixel_format == DRM_FORMAT_NV12) {
 		if (y)  /* y-plane data rate */
-			return intel_crtc->config->pipe_src_w *
-				intel_crtc->config->pipe_src_h *
-				drm_format_plane_cpp(fb->pixel_format, 0);
+			return w * h * drm_format_plane_cpp(fb->pixel_format, 0);
 		else    /* uv-plane data rate */
-			return (intel_crtc->config->pipe_src_w/2) *
-				(intel_crtc->config->pipe_src_h/2) *
+			return (w/2) * (h/2) *
 				drm_format_plane_cpp(fb->pixel_format, 1);
 	}
 
 	/* for packed formats */
-	return intel_crtc->config->pipe_src_w *
-		intel_crtc->config->pipe_src_h *
-		drm_format_plane_cpp(fb->pixel_format, 0);
+	return w * h * drm_format_plane_cpp(fb->pixel_format, 0);
 }
 
 /*
@@ -2960,6 +2957,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
 	 * FIXME: we may not allocate every single block here.
 	 */
 	total_data_rate = skl_get_total_relative_data_rate(cstate);
+	if (!total_data_rate)
+		return;
 
 	start = alloc->start;
 	for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
@@ -3093,12 +3092,15 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 {
 	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);
 	uint32_t latency = dev_priv->wm.skl_latency[level];
 	uint32_t method1, method2;
 	uint32_t plane_bytes_per_line, plane_blocks_per_line;
 	uint32_t res_blocks, res_lines;
 	uint32_t selected_result;
 	uint8_t bytes_per_pixel;
+	unsigned w = drm_rect_width(&intel_pstate->dst);
 
 	if (latency == 0 || !cstate->base.active || !fb)
 		return false;
@@ -3109,12 +3111,12 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 				 latency);
 	method2 = skl_wm_method2(skl_pipe_pixel_rate(cstate),
 				 cstate->base.adjusted_mode.crtc_htotal,
-				 cstate->pipe_src_w,
+				 w,
 				 bytes_per_pixel,
 				 fb->modifier[0],
 				 latency);
 
-	plane_bytes_per_line = cstate->pipe_src_w * bytes_per_pixel;
+	plane_bytes_per_line = w * bytes_per_pixel;
 	plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512);
 
 	if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

✗ warning: Fi.CI.BAT

== Summary ==

== Summary ==

Built on 78deeec98b10627fe2050ce8ebfa2ea2d5b9e6c7 drm-intel-nightly: 2015y-12m-21d-16h-03m-57s UTC integration manifest

Test gem_mmap_gtt:

        Subgroup basic-small-bo:
                dmesg-warn -> PASS       (bdw-nuci7)
Test gem_storedw_loop:
        Subgroup basic-render:
                dmesg-warn -> PASS       (skl-i7k-2)
Test kms_flip:
        Subgroup basic-flip-vs-modeset:
                pass       -> DMESG-WARN (skl-i5k-2)
                pass       -> DMESG-WARN (hsw-xps12)
                dmesg-warn -> PASS       (hsw-brixbox)
                skip       -> PASS       (bdw-nuci7)
                pass       -> DMESG-WARN (ilk-hp8440p)
        Subgroup basic-plain-flip:
                skip       -> PASS       (bdw-nuci7)
                pass       -> DMESG-WARN (byt-nuc)
Test kms_pipe_crc_basic:
        Subgroup read-crc-pipe-a:
                pass       -> DMESG-WARN (snb-x220t)
                skip       -> PASS       (bdw-nuci7)
                dmesg-warn -> PASS       (byt-nuc)
        Subgroup read-crc-pipe-a-frame-sequence:
                skip       -> PASS       (bdw-nuci7)
                pass       -> DMESG-WARN (byt-nuc)
        Subgroup read-crc-pipe-b:
                dmesg-warn -> PASS       (skl-i5k-2)
                dmesg-warn -> PASS       (hsw-xps12)
                pass       -> DMESG-WARN (snb-dellxps)
                skip       -> PASS       (bdw-nuci7)
        Subgroup read-crc-pipe-b-frame-sequence:
                pass       -> DMESG-WARN (bdw-ultra)
                skip       -> PASS       (bdw-nuci7)
                pass       -> DMESG-WARN (byt-nuc)
        Subgroup read-crc-pipe-c:
                skip       -> PASS       (bdw-nuci7)
Test kms_setmode:
        Subgroup basic-clone-single-crtc:
                dmesg-warn -> PASS       (snb-dellxps)
Test pm_rpm:
        Subgroup basic-pci-d3-state:
                skip       -> PASS       (bdw-nuci7)
        Subgroup basic-rte:
                skip       -> PASS       (bdw-nuci7)
                dmesg-warn -> PASS       (bdw-ultra)
bdw-nuci7        total:132  pass:122  dwarn:1   dfail:0   fail:0   skip:9  
bdw-ultra        total:132  pass:124  dwarn:2   dfail:0   fail:0   skip:6  
byt-nuc          total:135  pass:117  dwarn:5   dfail:0   fail:0   skip:13 
hsw-brixbox      total:135  pass:127  dwarn:1   dfail:0   fail:0   skip:7  
hsw-gt2          total:135  pass:130  dwarn:1   dfail:0   fail:0   skip:4  
hsw-xps12        total:132  pass:125  dwarn:3   dfail:0   fail:0   skip:4  
ilk-hp8440p      total:135  pass:99   dwarn:1   dfail:0   fail:0   skip:35 
ivb-t430s        total:135  pass:127  dwarn:2   dfail:0   fail:0   skip:6  
skl-i5k-2        total:135  pass:122  dwarn:5   dfail:0   fail:0   skip:8  
skl-i7k-2        total:135  pass:123  dwarn:4   dfail:0   fail:0   skip:8  
snb-dellxps      total:135  pass:121  dwarn:2   dfail:0   fail:0   skip:12 
snb-x220t        total:135  pass:121  dwarn:2   dfail:0   fail:1   skip:11 

Results at /archive/results/CI_IGT_test/Patchwork_781/

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

author
#2 lore raw
In reply to Matt Roper
Quoted 19 lines · Matt Roper

In commit

commit 024c9045221fe45482863c47c4b4c47d37f97cbf
Author: Matt Roper <[email protected]>
Date: Thu Sep 24 15:53:11 2015 -0700

drm/i915/skl: Eliminate usage of pipe_wm_parameters from SKL-style WM (v4)

I fumbled while converting the dimensions stored in the plane_parameters structure to the values stored in plane state and accidentally replaced the plane dimensions with the pipe dimensions in both the DDB allocation function and the WM calculation function. On the DDB side this is harmless since we effectively treat all of our non-cursor planes as full-screen which may not be optimal, but generally won't cause any problems either (and in 99% of the cases where there's no sprite plane usage or primary plane windowing, there's no effect at all). On the WM calculation side there's more potential for this fumble to cause actual problems since cursors also get miscalculated.

Quoted 4 lines
Cc Ville Syrjälä <[email protected]>
Cc "Kondapally, Kalyan" <[email protected]>
Cc Radhakrishna Sripada <[email protected]>

Bump; I think this patch got lost in the mix while most people were out over the holiday break.

Matt

Quoted 83 lines
---
 drivers/gpu/drm/i915/intel_pm.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +13 -11
index 8d0d6f5..f4d4cc7 100644
@@ -2845,25 +2845,22 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 			     const struct drm_plane_state *pstate,
 			     int y)
 {
-	struct intel_crtc *intel_crtc = to_intel_crtc(cstate->base.crtc);
+	struct intel_plane_state *intel_pstate = to_intel_plane_state(pstate);
 	struct drm_framebuffer *fb = pstate->fb;
+	unsigned w = drm_rect_width(&intel_pstate->dst);
+	unsigned h = drm_rect_height(&intel_pstate->dst);
 
 	/* for planar format */
 	if (fb->pixel_format == DRM_FORMAT_NV12) {
 		if (y)  /* y-plane data rate */
-			return intel_crtc->config->pipe_src_w *
-				intel_crtc->config->pipe_src_h *
-				drm_format_plane_cpp(fb->pixel_format, 0);
+			return w * h * drm_format_plane_cpp(fb->pixel_format, 0);
 		else    /* uv-plane data rate */
-			return (intel_crtc->config->pipe_src_w/2) *
-				(intel_crtc->config->pipe_src_h/2) *
+			return (w/2) * (h/2) *
 				drm_format_plane_cpp(fb->pixel_format, 1);
 	}
 
 	/* for packed formats */
-	return intel_crtc->config->pipe_src_w *
-		intel_crtc->config->pipe_src_h *
-		drm_format_plane_cpp(fb->pixel_format, 0);
+	return w * h * drm_format_plane_cpp(fb->pixel_format, 0);
 }
 
 /*
@@ -2960,6 +2957,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
 	 * FIXME: we may not allocate every single block here.
 	 */
 	total_data_rate = skl_get_total_relative_data_rate(cstate);
+	if (!total_data_rate)
+		return;
 
 	start = alloc->start;
 	for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
@@ -3093,12 +3092,15 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 {
 	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);
 	uint32_t latency = dev_priv->wm.skl_latency[level];
 	uint32_t method1, method2;
 	uint32_t plane_bytes_per_line, plane_blocks_per_line;
 	uint32_t res_blocks, res_lines;
 	uint32_t selected_result;
 	uint8_t bytes_per_pixel;
+	unsigned w = drm_rect_width(&intel_pstate->dst);
 
 	if (latency == 0 || !cstate->base.active || !fb)
 		return false;
@@ -3109,12 +3111,12 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 				 latency);
 	method2 = skl_wm_method2(skl_pipe_pixel_rate(cstate),
 				 cstate->base.adjusted_mode.crtc_htotal,
-				 cstate->pipe_src_w,
+				 w,
 				 bytes_per_pixel,
 				 fb->modifier[0],
 				 latency);
 
-	plane_bytes_per_line = cstate->pipe_src_w * bytes_per_pixel;
+	plane_bytes_per_line = w * bytes_per_pixel;
 	plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512);
 
 	if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
Signature · 1 line
2.1.4
Signature · 9 lines
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
In reply to Matt Roper
Quoted 32 lines · Matt Roper

In commit

commit 024c9045221fe45482863c47c4b4c47d37f97cbf
Author: Matt Roper <[email protected]>
Date: Thu Sep 24 15:53:11 2015 -0700

drm/i915/skl: Eliminate usage of pipe_wm_parameters from SKL-style WM (v4)

I fumbled while converting the dimensions stored in the plane_parameters structure to the values stored in plane state and accidentally replaced the plane dimensions with the pipe dimensions in both the DDB allocation function and the WM calculation function. On the DDB side this is harmless since we effectively treat all of our non-cursor planes as full-screen which may not be optimal, but generally won't cause any problems either (and in 99% of the cases where there's no sprite plane usage or primary plane windowing, there's no effect at all). On the WM calculation side there's more potential for this fumble to cause actual problems since cursors also get miscalculated.

Cc Ville Syrjälä <[email protected]>
Cc "Kondapally, Kalyan" <[email protected]>
Cc Radhakrishna Sripada <[email protected]>
---
 drivers/gpu/drm/i915/intel_pm.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_pm.c +0 -0
index 8d0d6f5..f4d4cc7 100644

drivers/gpu/drm/i915/intel_pm.c skl_plane_relative_data_rate(const struct intel_crtc_state *cstate, · line 2851

Quoted 8 lines
drivers/gpu/drm/i915/intel_pm.c +3 -1
@@ -2845,25 +2845,22 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 			     const struct drm_plane_state *pstate,
 			     int y)
 {
-	struct intel_crtc *intel_crtc = to_intel_crtc(cstate->base.crtc);
+	struct intel_plane_state *intel_pstate = to_intel_plane_state(pstate);
 	struct drm_framebuffer *fb = pstate->fb;
+	unsigned w = drm_rect_width(&intel_pstate->dst);
+	unsigned h = drm_rect_height(&intel_pstate->dst);

I think you're supposed to use the src dimensions in most places.

Quoted 70 lines
drivers/gpu/drm/i915/intel_pm.c +10 -10
 	/* for planar format */
 	if (fb->pixel_format == DRM_FORMAT_NV12) {
 		if (y)  /* y-plane data rate */
-			return intel_crtc->config->pipe_src_w *
-				intel_crtc->config->pipe_src_h *
-				drm_format_plane_cpp(fb->pixel_format, 0);
+			return w * h * drm_format_plane_cpp(fb->pixel_format, 0);
 		else    /* uv-plane data rate */
-			return (intel_crtc->config->pipe_src_w/2) *
-				(intel_crtc->config->pipe_src_h/2) *
+			return (w/2) * (h/2) *
 				drm_format_plane_cpp(fb->pixel_format, 1);
 	}
 
 	/* for packed formats */
-	return intel_crtc->config->pipe_src_w *
-		intel_crtc->config->pipe_src_h *
-		drm_format_plane_cpp(fb->pixel_format, 0);
+	return w * h * drm_format_plane_cpp(fb->pixel_format, 0);
 }
 
 /*
@@ -2960,6 +2957,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
 	 * FIXME: we may not allocate every single block here.
 	 */
 	total_data_rate = skl_get_total_relative_data_rate(cstate);
+	if (!total_data_rate)
+		return;
 
 	start = alloc->start;
 	for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
@@ -3093,12 +3092,15 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 {
 	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);
 	uint32_t latency = dev_priv->wm.skl_latency[level];
 	uint32_t method1, method2;
 	uint32_t plane_bytes_per_line, plane_blocks_per_line;
 	uint32_t res_blocks, res_lines;
 	uint32_t selected_result;
 	uint8_t bytes_per_pixel;
+	unsigned w = drm_rect_width(&intel_pstate->dst);
 
 	if (latency == 0 || !cstate->base.active || !fb)
 		return false;
@@ -3109,12 +3111,12 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 				 latency);
 	method2 = skl_wm_method2(skl_pipe_pixel_rate(cstate),
 				 cstate->base.adjusted_mode.crtc_htotal,
-				 cstate->pipe_src_w,
+				 w,
 				 bytes_per_pixel,
 				 fb->modifier[0],
 				 latency);
 
-	plane_bytes_per_line = cstate->pipe_src_w * bytes_per_pixel;
+	plane_bytes_per_line = w * bytes_per_pixel;
 	plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512);
 
 	if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
author
#4 lore raw
Quoted 28 lines · Ville Syrjälä
Quoted 27 lines · Matt Roper

In commit

commit 024c9045221fe45482863c47c4b4c47d37f97cbf
Author: Matt Roper <[email protected]>
Date: Thu Sep 24 15:53:11 2015 -0700

drm/i915/skl: Eliminate usage of pipe_wm_parameters from SKL-style WM (v4)

I fumbled while converting the dimensions stored in the plane_parameters structure to the values stored in plane state and accidentally replaced the plane dimensions with the pipe dimensions in both the DDB allocation function and the WM calculation function. On the DDB side this is harmless since we effectively treat all of our non-cursor planes as full-screen which may not be optimal, but generally won't cause any problems either (and in 99% of the cases where there's no sprite plane usage or primary plane windowing, there's no effect at all). On the WM calculation side there's more potential for this fumble to cause actual problems since cursors also get miscalculated.

Cc Ville Syrjälä <[email protected]>
Cc "Kondapally, Kalyan" <[email protected]>
Cc Radhakrishna Sripada <[email protected]>
---
 drivers/gpu/drm/i915/intel_pm.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
Quoted 15 lines

drivers/gpu/drm/i915/intel_pm.c skl_plane_relative_data_rate(const struct intel_crtc_state *cstate, · line 2851

Quoted 13 lines
drivers/gpu/drm/i915/intel_pm.c +3 -1
index 8d0d6f5..f4d4cc7 100644
@@ -2845,25 +2845,22 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 			     const struct drm_plane_state *pstate,
 			     int y)
 {
-	struct intel_crtc *intel_crtc = to_intel_crtc(cstate->base.crtc);
+	struct intel_plane_state *intel_pstate = to_intel_plane_state(pstate);
 	struct drm_framebuffer *fb = pstate->fb;
+	unsigned w = drm_rect_width(&intel_pstate->dst);
+	unsigned h = drm_rect_height(&intel_pstate->dst);

I think you're supposed to use the src dimensions in most places.

Hmm, just went back to double check the bpsec and if I'm interpreting it correctly, it looks like we actually need to use the larger of the two:
"Down scaling effectively increases the pixel rate. Up scaling does not reduce the pixel rate."

Thanks for pointing that out; I'll send an updated patch.

Matt

Quoted 75 lines
Quoted 71 lines
drivers/gpu/drm/i915/intel_pm.c +10 -10
 	/* for planar format */
 	if (fb->pixel_format == DRM_FORMAT_NV12) {
 		if (y)  /* y-plane data rate */
-			return intel_crtc->config->pipe_src_w *
-				intel_crtc->config->pipe_src_h *
-				drm_format_plane_cpp(fb->pixel_format, 0);
+			return w * h * drm_format_plane_cpp(fb->pixel_format, 0);
 		else    /* uv-plane data rate */
-			return (intel_crtc->config->pipe_src_w/2) *
-				(intel_crtc->config->pipe_src_h/2) *
+			return (w/2) * (h/2) *
 				drm_format_plane_cpp(fb->pixel_format, 1);
 	}
 
 	/* for packed formats */
-	return intel_crtc->config->pipe_src_w *
-		intel_crtc->config->pipe_src_h *
-		drm_format_plane_cpp(fb->pixel_format, 0);
+	return w * h * drm_format_plane_cpp(fb->pixel_format, 0);
 }
 
 /*
@@ -2960,6 +2957,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
 	 * FIXME: we may not allocate every single block here.
 	 */
 	total_data_rate = skl_get_total_relative_data_rate(cstate);
+	if (!total_data_rate)
+		return;
 
 	start = alloc->start;
 	for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
@@ -3093,12 +3092,15 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 {
 	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);
 	uint32_t latency = dev_priv->wm.skl_latency[level];
 	uint32_t method1, method2;
 	uint32_t plane_bytes_per_line, plane_blocks_per_line;
 	uint32_t res_blocks, res_lines;
 	uint32_t selected_result;
 	uint8_t bytes_per_pixel;
+	unsigned w = drm_rect_width(&intel_pstate->dst);
 
 	if (latency == 0 || !cstate->base.active || !fb)
 		return false;
@@ -3109,12 +3111,12 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 				 latency);
 	method2 = skl_wm_method2(skl_pipe_pixel_rate(cstate),
 				 cstate->base.adjusted_mode.crtc_htotal,
-				 cstate->pipe_src_w,
+				 w,
 				 bytes_per_pixel,
 				 fb->modifier[0],
 				 latency);
 
-	plane_bytes_per_line = cstate->pipe_src_w * bytes_per_pixel;
+	plane_bytes_per_line = w * bytes_per_pixel;
 	plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512);
 
 	if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC
Signature · 9 lines
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
Quoted 45 lines · Matt Roper
Quoted 28 lines · Ville Syrjälä
Quoted 27 lines · Matt Roper

In commit

commit 024c9045221fe45482863c47c4b4c47d37f97cbf
Author: Matt Roper <[email protected]>
Date: Thu Sep 24 15:53:11 2015 -0700

drm/i915/skl: Eliminate usage of pipe_wm_parameters from SKL-style WM (v4)

I fumbled while converting the dimensions stored in the plane_parameters structure to the values stored in plane state and accidentally replaced the plane dimensions with the pipe dimensions in both the DDB allocation function and the WM calculation function. On the DDB side this is harmless since we effectively treat all of our non-cursor planes as full-screen which may not be optimal, but generally won't cause any problems either (and in 99% of the cases where there's no sprite plane usage or primary plane windowing, there's no effect at all). On the WM calculation side there's more potential for this fumble to cause actual problems since cursors also get miscalculated.

Cc Ville Syrjälä <[email protected]>
Cc "Kondapally, Kalyan" <[email protected]>
Cc Radhakrishna Sripada <[email protected]>
---
 drivers/gpu/drm/i915/intel_pm.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)
Quoted 15 lines

drivers/gpu/drm/i915/intel_pm.c skl_plane_relative_data_rate(const struct intel_crtc_state *cstate, · line 2851

Quoted 13 lines
drivers/gpu/drm/i915/intel_pm.c +3 -1
index 8d0d6f5..f4d4cc7 100644
@@ -2845,25 +2845,22 @@ skl_plane_relative_data_rate(const struct intel_crtc_state *cstate,
 			     const struct drm_plane_state *pstate,
 			     int y)
 {
-	struct intel_crtc *intel_crtc = to_intel_crtc(cstate->base.crtc);
+	struct intel_plane_state *intel_pstate = to_intel_plane_state(pstate);
 	struct drm_framebuffer *fb = pstate->fb;
+	unsigned w = drm_rect_width(&intel_pstate->dst);
+	unsigned h = drm_rect_height(&intel_pstate->dst);

I think you're supposed to use the src dimensions in most places.

Quoted 4 lines

Hmm, just went back to double check the bpsec and if I'm interpreting it correctly, it looks like we actually need to use the larger of the two:
"Down scaling effectively increases the pixel rate. Up scaling does not reduce the pixel rate."

The pixel rate is "downscale factor * pixel clock"

Quoted 89 lines

Thanks for pointing that out; I'll send an updated patch.

Matt

Quoted 75 lines
Quoted 71 lines
drivers/gpu/drm/i915/intel_pm.c +10 -10
 	/* for planar format */
 	if (fb->pixel_format == DRM_FORMAT_NV12) {
 		if (y)  /* y-plane data rate */
-			return intel_crtc->config->pipe_src_w *
-				intel_crtc->config->pipe_src_h *
-				drm_format_plane_cpp(fb->pixel_format, 0);
+			return w * h * drm_format_plane_cpp(fb->pixel_format, 0);
 		else    /* uv-plane data rate */
-			return (intel_crtc->config->pipe_src_w/2) *
-				(intel_crtc->config->pipe_src_h/2) *
+			return (w/2) * (h/2) *
 				drm_format_plane_cpp(fb->pixel_format, 1);
 	}
 
 	/* for packed formats */
-	return intel_crtc->config->pipe_src_w *
-		intel_crtc->config->pipe_src_h *
-		drm_format_plane_cpp(fb->pixel_format, 0);
+	return w * h * drm_format_plane_cpp(fb->pixel_format, 0);
 }
 
 /*
@@ -2960,6 +2957,8 @@ skl_allocate_pipe_ddb(struct intel_crtc_state *cstate,
 	 * FIXME: we may not allocate every single block here.
 	 */
 	total_data_rate = skl_get_total_relative_data_rate(cstate);
+	if (!total_data_rate)
+		return;
 
 	start = alloc->start;
 	for_each_intel_plane_on_crtc(dev, intel_crtc, intel_plane) {
@@ -3093,12 +3092,15 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 {
 	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);
 	uint32_t latency = dev_priv->wm.skl_latency[level];
 	uint32_t method1, method2;
 	uint32_t plane_bytes_per_line, plane_blocks_per_line;
 	uint32_t res_blocks, res_lines;
 	uint32_t selected_result;
 	uint8_t bytes_per_pixel;
+	unsigned w = drm_rect_width(&intel_pstate->dst);
 
 	if (latency == 0 || !cstate->base.active || !fb)
 		return false;
@@ -3109,12 +3111,12 @@ static bool skl_compute_plane_wm(const struct drm_i915_private *dev_priv,
 				 latency);
 	method2 = skl_wm_method2(skl_pipe_pixel_rate(cstate),
 				 cstate->base.adjusted_mode.crtc_htotal,
-				 cstate->pipe_src_w,
+				 w,
 				 bytes_per_pixel,
 				 fb->modifier[0],
 				 latency);
 
-	plane_bytes_per_line = cstate->pipe_src_w * bytes_per_pixel;
+	plane_bytes_per_line = w * bytes_per_pixel;
 	plane_blocks_per_line = DIV_ROUND_UP(plane_bytes_per_line, 512);
 
 	if (fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
Signature · 6 lines
2.1.4

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 2 lines
Ville Syrjälä
Intel OTC
Signature · 5 lines
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx