Skip to contentSkip to conversation

drm/i915: Test plane mask for sprite watermark updates properly

PATCH In review Matt Roper 2 participants 4 messages May 7, 2015

Subsystems (2)
lore
Share & tools
lore

Matt Roper

author
#0 lore raw

PATCH 1/3 drm/i915: Test plane mask for sprite watermark updates properly

Our atomic transaction maintains a bitmask of planes that we need to update sprite watermarks for once vblank evasion is complete. When we actually go to make use of that bitmask, we've been comparing against the plane index rather than the plane mask; we need to update our comparison to check '(1 << index)' rather than 'index' directly.

This bug was introduced by

commit 32b7eeec4d1e861230b09d437e95d76c86ff4a68
Author: Matt Roper <[email protected]>
Date: Wed Dec 24 07:59:06 2014 -0800

drm/i915: Refactor work that can sleep out of commit (v7)

However we've been "lucky" and haven't actually run into problems caused by this yet due to another bug in the code...we forgot to actually remove the calls to intel_update_sprite_watermarks() from the low-level plane programming functions that run under evasion. We'll fix that problem in a subsequent patch.

---
 drivers/gpu/drm/i915/intel_display.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/intel_display.c +2 -1
index 5c2047b..2878924 100644
@@ -13460,7 +13460,8 @@ static void intel_finish_crtc_commit(struct drm_crtc *crtc)
 		intel_post_enable_primary(crtc);
 
 	drm_for_each_legacy_plane(p, &dev->mode_config.plane_list)
-		if (intel_crtc->atomic.update_sprite_watermarks & drm_plane_index(p))
+		if (intel_crtc->atomic.update_sprite_watermarks &
+		    (1 << drm_plane_index(p)))
 			intel_update_sprite_watermarks(p, crtc, 0, 0, 0,
 						       false, false);
 
Signature · 6 lines
1.8.5.1

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

PATCH 2/3 drm/i915: Drop parameters to intel_update_sprite_watermarks()

The values that ultimately get passed to intel_update_sprite_watermarks() are pulled out of the plane state (which has already been swapped into plane->state) as we update the plane programming. Drop the function parameters and just pull the relevant values out of the state structure inside the function.

This change will make it easier for us to extract the sprite WM programming out of the low-level foo_update_plane() functions (which are run under vblank evasion and shouldn't be calling potentially blocking watermark functions).

---
 drivers/gpu/drm/i915/intel_display.c |  3 +--
 drivers/gpu/drm/i915/intel_drv.h     |  6 +-----
 drivers/gpu/drm/i915/intel_pm.c      | 17 ++++++++++++-----
 drivers/gpu/drm/i915/intel_sprite.c  | 21 ++++++---------------
 4 files changed, 20 insertions(+), 27 deletions(-)
drivers/gpu/drm/i915/intel_display.c +1 -2
index 2878924..a6a11aa 100644
@@ -13462,8 +13462,7 @@ static void intel_finish_crtc_commit(struct drm_crtc *crtc)
 	drm_for_each_legacy_plane(p, &dev->mode_config.plane_list)
 		if (intel_crtc->atomic.update_sprite_watermarks &
 		    (1 << drm_plane_index(p)))
-			intel_update_sprite_watermarks(p, crtc, 0, 0, 0,
-						       false, false);
+			intel_update_sprite_watermarks(p, crtc);
 
 	memset(&intel_crtc->atomic, 0, sizeof(intel_crtc->atomic));
 }
drivers/gpu/drm/i915/intel_drv.h +1 -5
index cf701ed..c2cf17f 100644
@@ -1351,11 +1351,7 @@ void intel_suspend_hw(struct drm_device *dev);
 int ilk_wm_max_level(const struct drm_device *dev);
 void intel_update_watermarks(struct drm_crtc *crtc);
 void intel_update_sprite_watermarks(struct drm_plane *plane,
-				    struct drm_crtc *crtc,
-				    uint32_t sprite_width,
-				    uint32_t sprite_height,
-				    int pixel_size,
-				    bool enabled, bool scaled);
+				    struct drm_crtc *crtc);
 void intel_init_pm(struct drm_device *dev);
 void intel_pm_setup(struct drm_device *dev);
 void intel_gpu_ips_init(struct drm_i915_private *dev_priv);
drivers/gpu/drm/i915/intel_pm.c +12 -5
index 7006f94..9e0ba53 100644
@@ -3703,13 +3703,20 @@ void intel_update_watermarks(struct drm_crtc *crtc)
 }
 
 void intel_update_sprite_watermarks(struct drm_plane *plane,
-				    struct drm_crtc *crtc,
-				    uint32_t sprite_width,
-				    uint32_t sprite_height,
-				    int pixel_size,
-				    bool enabled, bool scaled)
+				    struct drm_crtc *crtc)
 {
 	struct drm_i915_private *dev_priv = plane->dev->dev_private;
+	struct intel_plane_state *state = to_intel_plane_state(plane->state);
+	struct drm_framebuffer *fb = state->base.fb;
+	uint32_t sprite_width = drm_rect_width(&state->dst);
+	uint32_t sprite_height = drm_rect_height(&state->dst);
+	int pixel_size = fb ? drm_format_plane_cpp(fb->pixel_format, 0) : 0;
+	bool enabled = state->visible;
+	unsigned int src_w = drm_rect_width(&state->src) >> 16;
+	unsigned int src_h = drm_rect_height(&state->src) >> 16;
+	unsigned int dst_w = drm_rect_width(&state->dst);
+	unsigned int dst_h = drm_rect_height(&state->dst);
+	bool scaled = (src_w != dst_w || src_h != dst_h);
 
 	if (dev_priv->display.update_sprite_wm)
 		dev_priv->display.update_sprite_wm(plane, crtc,
drivers/gpu/drm/i915/intel_sprite.c +6 -15
index 856395b..6e27fbb 100644
@@ -192,7 +192,6 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 	const int pipe = intel_plane->pipe;
 	const int plane = intel_plane->plane + 1;
 	u32 plane_ctl, stride_div, stride;
-	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
 	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
 	unsigned long surf_addr;
 	u32 tile_height, plane_offset, plane_size;
@@ -210,9 +209,7 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 	rotation = drm_plane->state->rotation;
 	plane_ctl |= skl_plane_ctl_rotation(rotation);
 
-	intel_update_sprite_watermarks(drm_plane, crtc, src_w, src_h,
-				       pixel_size, true,
-				       src_w != crtc_w || src_h != crtc_h);
+	intel_update_sprite_watermarks(drm_plane, crtc);
 
 	stride_div = intel_fb_stride_alignment(dev, fb->modifier[0],
 					       fb->pixel_format);
@@ -297,7 +294,7 @@ skl_disable_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc)
 	I915_WRITE(PLANE_SURF(pipe, plane), 0);
 	POSTING_READ(PLANE_SURF(pipe, plane));
 
-	intel_update_sprite_watermarks(drm_plane, crtc, 0, 0, 0, false, false);
+	intel_update_sprite_watermarks(drm_plane, crtc);
 }
 
 static void
@@ -413,9 +410,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 	if (obj->tiling_mode != I915_TILING_NONE)
 		sprctl |= SP_TILED;
 
-	intel_update_sprite_watermarks(dplane, crtc, src_w, src_h,
-				       pixel_size, true,
-				       src_w != crtc_w || src_h != crtc_h);
+	intel_update_sprite_watermarks(dplane, crtc);
 
 	/* Sizes are 0 based */
 	src_w--;
@@ -489,7 +484,7 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)
 
 	intel_flush_primary_plane(dev_priv, intel_crtc->plane);
 
-	intel_update_sprite_watermarks(dplane, crtc, 0, 0, 0, false, false);
+	intel_update_sprite_watermarks(dplane, crtc);
 }
 
 
@@ -554,9 +549,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	if (IS_HASWELL(dev) || IS_BROADWELL(dev))
 		sprctl |= SPRITE_PIPE_CSC_ENABLE;
 
-	intel_update_sprite_watermarks(plane, crtc, src_w, src_h, pixel_size,
-				       true,
-				       src_w != crtc_w || src_h != crtc_h);
+	intel_update_sprite_watermarks(plane, crtc);
 
 	/* Sizes are 0 based */
 	src_w--;
@@ -697,9 +690,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	if (IS_GEN6(dev))
 		dvscntr |= DVS_TRICKLE_FEED_DISABLE; /* must disable */
 
-	intel_update_sprite_watermarks(plane, crtc, src_w, src_h,
-				       pixel_size, true,
-				       src_w != crtc_w || src_h != crtc_h);
+	intel_update_sprite_watermarks(plane, crtc);
 
 	/* Sizes are 0 based */
 	src_w--;
Signature · 6 lines
1.8.5.1

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

PATCH 3/3 drm/i915: Update sprite watermarks outside vblank evasion

In reply to Matt Roper

We never removed the sprite watermark updates from our low-level foo_update_plane() functions; since our hardware updates happen under vblank evasion, we're not supposed to be calling potentially sleeping functions there (since interrupts are disabled). Ensure that we properly set the atomic.update_sprite_watermarks flag so that these updates will happen outside vblank evasion and we can drop the direct calls from the plane programming code.

---
 drivers/gpu/drm/i915/intel_display.c | 11 +++++++++--
 drivers/gpu/drm/i915/intel_sprite.c  | 22 ++++------------------
 2 files changed, 13 insertions(+), 20 deletions(-)
drivers/gpu/drm/i915/intel_display.c +9 -2
index a6a11aa..3feb3d6 100644
@@ -13126,10 +13126,17 @@ static void intel_shared_dpll_init(struct drm_device *dev)
 bool intel_wm_need_update(struct drm_plane *plane,
 			  struct drm_plane_state *state)
 {
-	/* Update watermarks on tiling changes. */
+	struct intel_plane_state *new = to_intel_plane_state(state);
+	struct intel_plane_state *cur = to_intel_plane_state(plane->state);
+
+	/* Update watermarks on tiling changes or size changes. */
 	if (!plane->state->fb || !state->fb ||
 	    plane->state->fb->modifier[0] != state->fb->modifier[0] ||
-	    plane->state->rotation != state->rotation)
+	    plane->state->rotation != state->rotation ||
+	    drm_rect_width(&new->src) != drm_rect_width(&cur->src) ||
+	    drm_rect_height(&new->src) != drm_rect_height(&cur->src) ||
+	    drm_rect_width(&new->dst) != drm_rect_width(&cur->dst) ||
+	    drm_rect_height(&new->dst) != drm_rect_height(&cur->dst))
 		return true;
 
 	return false;
drivers/gpu/drm/i915/intel_sprite.c +4 -18
index 6e27fbb..51a9d00 100644
@@ -209,8 +209,6 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 	rotation = drm_plane->state->rotation;
 	plane_ctl |= skl_plane_ctl_rotation(rotation);
 
-	intel_update_sprite_watermarks(drm_plane, crtc);
-
 	stride_div = intel_fb_stride_alignment(dev, fb->modifier[0],
 					       fb->pixel_format);
 
@@ -293,8 +291,6 @@ skl_disable_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc)
 	/* Activate double buffered register update */
 	I915_WRITE(PLANE_SURF(pipe, plane), 0);
 	POSTING_READ(PLANE_SURF(pipe, plane));
-
-	intel_update_sprite_watermarks(drm_plane, crtc);
 }
 
 static void
@@ -410,8 +406,6 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 	if (obj->tiling_mode != I915_TILING_NONE)
 		sprctl |= SP_TILED;
 
-	intel_update_sprite_watermarks(dplane, crtc);
-
 	/* Sizes are 0 based */
 	src_w--;
 	src_h--;
@@ -483,8 +477,6 @@ vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)
 	I915_WRITE(SPSURF(pipe, plane), 0);
 
 	intel_flush_primary_plane(dev_priv, intel_crtc->plane);
-
-	intel_update_sprite_watermarks(dplane, crtc);
 }
 
 
@@ -549,8 +541,6 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	if (IS_HASWELL(dev) || IS_BROADWELL(dev))
 		sprctl |= SPRITE_PIPE_CSC_ENABLE;
 
-	intel_update_sprite_watermarks(plane, crtc);
-
 	/* Sizes are 0 based */
 	src_w--;
 	src_h--;
@@ -690,8 +680,6 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	if (IS_GEN6(dev))
 		dvscntr |= DVS_TRICKLE_FEED_DISABLE; /* must disable */
 
-	intel_update_sprite_watermarks(plane, crtc);
-
 	/* Sizes are 0 based */
 	src_w--;
 	src_h--;
@@ -1030,18 +1018,16 @@ finish:
 		if (!intel_crtc->primary_enabled && !state->hides_primary)
 			intel_crtc->atomic.post_enable_primary = true;
 
-		if (intel_wm_need_update(plane, &state->base))
-			intel_crtc->atomic.update_wm = true;
+		if (intel_wm_need_update(plane, &state->base) || !state->visible)
+			intel_crtc->atomic.update_sprite_watermarks |=
+				(1 << drm_plane_index(plane));
 
-		if (!state->visible) {
+		if (!state->visible)
 			/*
 			 * Avoid underruns when disabling the sprite.
 			 * FIXME remove once watermark updates are done properly.
 			 */
 			intel_crtc->atomic.wait_vblank = true;
-			intel_crtc->atomic.update_sprite_watermarks |=
-				(1 << drm_plane_index(plane));
-		}
 	}
 
 	if (INTEL_INFO(dev)->gen >= 9) {
Signature · 6 lines
1.8.5.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Tested-by on v1 3/3
#3 lore raw

Re: [PATCH 3/3] drm/i915: Update sprite watermarks outside vblank evasion

Task id: 6337 -------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied

PNV                                  276/276              276/276
ILK                                  302/302              302/302
SNB                                  316/316              316/316
IVB                                  342/342              342/342
BYT                                  286/286              286/286
BDW                                  321/321              321/321

-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx