Skip to contentSkip to conversation

drm/i915/skl: Consider plane rotation when calculating stride in skl_do_mmio_flip

PATCH Superseded Tvrtko Ursulin 3 participants 6 messages Oct 20, 2015 – Oct 21, 2015

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 drm/i915/skl: Consider plane rotation when calculating stride in skl_do_mmio_flip

From: Tvrtko Ursulin <[email protected]>

Previously rotation was ignored and wrong stride programmed into the plane registers resulting in a corrupt image on screen.

v2: Do not access potentialy old plane state at flip time,
but store the rotation value at the time of queing the flip. (Ville)

Testcase: igt/kms_rotation_crc/primary-rotation-90-flip-stress (SKL)
Cc: Sonika Jindal <[email protected]>
Cc: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/i915/intel_display.c | 30 +++++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 2 files changed, 20 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_display.c +19 -11
index 1fc1d240d3c1..9cb29086971a 100644
@@ -11091,13 +11091,14 @@ static bool use_mmio_flip(struct intel_engine_cs *ring,
 }
 
 static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
+			     unsigned int rotation,
 			     struct intel_unpin_work *work)
 {
 	struct drm_device *dev = intel_crtc->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_framebuffer *fb = intel_crtc->base.primary->fb;
 	const enum pipe pipe = intel_crtc->pipe;
-	u32 ctl, stride;
+	u32 ctl, stride, tile_height;
 
 	ctl = I915_READ(PLANE_CTL(pipe, 0));
 	ctl &= ~PLANE_CTL_TILED_MASK;
@@ -11121,9 +11122,16 @@ static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
 	 * The stride is either expressed as a multiple of 64 bytes chunks for
 	 * linear buffers or in number of tiles for tiled buffers.
 	 */
-	stride = fb->pitches[0] /
-		 intel_fb_stride_alignment(dev, fb->modifier[0],
-					   fb->pixel_format);
+	if (intel_rotation_90_or_270(rotation)) {
+		/* stride = Surface height in tiles */
+		tile_height = intel_tile_height(dev, fb->pixel_format,
+						fb->modifier[0], 0);
+		stride = DIV_ROUND_UP(fb->height, tile_height);
+	} else {
+		stride = fb->pitches[0] /
+				intel_fb_stride_alignment(dev, fb->modifier[0],
+							  fb->pixel_format);
+	}
 
 	/*
 	 * Both PLANE_CTL and PLANE_STRIDE are not updated on vblank but on
@@ -11181,7 +11189,7 @@ static void intel_do_mmio_flip(struct intel_mmio_flip *mmio_flip)
 	intel_pipe_update_start(crtc);
 
 	if (INTEL_INFO(mmio_flip->i915)->gen >= 9)
-		skl_do_mmio_flip(crtc, work);
+		skl_do_mmio_flip(crtc, mmio_flip->rotation, work);
 	else
 		/* use_mmio_flip() retricts MMIO flips to ilk+ */
 		ilk_do_mmio_flip(crtc, work);
@@ -11208,10 +11216,8 @@ static void intel_mmio_flip_work_func(struct work_struct *work)
 
 static int intel_queue_mmio_flip(struct drm_device *dev,
 				 struct drm_crtc *crtc,
-				 struct drm_framebuffer *fb,
-				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
-				 uint32_t flags)
+				 unsigned int rotation,
+				 struct drm_i915_gem_object *obj)
 {
 	struct intel_mmio_flip *mmio_flip;
 
@@ -11222,6 +11228,7 @@ static int intel_queue_mmio_flip(struct drm_device *dev,
 	mmio_flip->i915 = to_i915(dev);
 	mmio_flip->req = i915_gem_request_reference(obj->last_write_req);
 	mmio_flip->crtc = to_intel_crtc(crtc);
+	mmio_flip->rotation = rotation;
 
 	INIT_WORK(&mmio_flip->work, intel_mmio_flip_work_func);
 	schedule_work(&mmio_flip->work);
@@ -11438,8 +11445,9 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 	work->gtt_offset += intel_crtc->dspaddr_offset;
 
 	if (mmio_flip) {
-		ret = intel_queue_mmio_flip(dev, crtc, fb, obj, ring,
-					    page_flip_flags);
+		ret = intel_queue_mmio_flip(dev, crtc,
+					    crtc->primary->state->rotation,
+					    obj);
 		if (ret)
 			goto cleanup_unpin;
 
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 27dccf35f9bc..140f949302c7 100644
@@ -493,6 +493,7 @@ struct intel_mmio_flip {
 	struct drm_i915_private *i915;
 	struct drm_i915_gem_request *req;
 	struct intel_crtc *crtc;
+	unsigned int rotation;
 };
 
 struct skl_pipe_wm {
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Reviewed-by on v2 1/1
#1 lore raw
Quoted 81 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Previously rotation was ignored and wrong stride programmed into the plane registers resulting in a corrupt image on screen.

v2: Do not access potentialy old plane state at flip time,
but store the rotation value at the time of queing the flip. (Ville)

Testcase: igt/kms_rotation_crc/primary-rotation-90-flip-stress (SKL)
Cc: Sonika Jindal <[email protected]>
Cc: Ville Syrjälä <[email protected]>

---
 drivers/gpu/drm/i915/intel_display.c | 30 +++++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 2 files changed, 20 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_display.c +15 -9
index 1fc1d240d3c1..9cb29086971a 100644
@@ -11091,13 +11091,14 @@ static bool use_mmio_flip(struct intel_engine_cs *ring,
 }
 
 static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
+			     unsigned int rotation,
 			     struct intel_unpin_work *work)
 {
 	struct drm_device *dev = intel_crtc->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_framebuffer *fb = intel_crtc->base.primary->fb;
 	const enum pipe pipe = intel_crtc->pipe;
-	u32 ctl, stride;
+	u32 ctl, stride, tile_height;
 
 	ctl = I915_READ(PLANE_CTL(pipe, 0));
 	ctl &= ~PLANE_CTL_TILED_MASK;
@@ -11121,9 +11122,16 @@ static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
 	 * The stride is either expressed as a multiple of 64 bytes chunks for
 	 * linear buffers or in number of tiles for tiled buffers.
 	 */
-	stride = fb->pitches[0] /
-		 intel_fb_stride_alignment(dev, fb->modifier[0],
-					   fb->pixel_format);
+	if (intel_rotation_90_or_270(rotation)) {
+		/* stride = Surface height in tiles */
+		tile_height = intel_tile_height(dev, fb->pixel_format,
+						fb->modifier[0], 0);
+		stride = DIV_ROUND_UP(fb->height, tile_height);
+	} else {
+		stride = fb->pitches[0] /
+				intel_fb_stride_alignment(dev, fb->modifier[0],
+							  fb->pixel_format);
+	}
 
 	/*
 	 * Both PLANE_CTL and PLANE_STRIDE are not updated on vblank but on
@@ -11181,7 +11189,7 @@ static void intel_do_mmio_flip(struct intel_mmio_flip *mmio_flip)
 	intel_pipe_update_start(crtc);
 
 	if (INTEL_INFO(mmio_flip->i915)->gen >= 9)
-		skl_do_mmio_flip(crtc, work);
+		skl_do_mmio_flip(crtc, mmio_flip->rotation, work);
 	else
 		/* use_mmio_flip() retricts MMIO flips to ilk+ */
 		ilk_do_mmio_flip(crtc, work);
@@ -11208,10 +11216,8 @@ static void intel_mmio_flip_work_func(struct work_struct *work)
 
 static int intel_queue_mmio_flip(struct drm_device *dev,
 				 struct drm_crtc *crtc,
-				 struct drm_framebuffer *fb,
-				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
-				 uint32_t flags)
+				 unsigned int rotation,
+				 struct drm_i915_gem_object *obj)
 {
 	struct intel_mmio_flip *mmio_flip;
 

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 11231

Quoted 4 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
@@ -11222,6 +11228,7 @@ static int intel_queue_mmio_flip(struct drm_device *dev,
 	mmio_flip->i915 = to_i915(dev);
 	mmio_flip->req = i915_gem_request_reference(obj->last_write_req);
 	mmio_flip->crtc = to_intel_crtc(crtc);
+	mmio_flip->rotation = rotation;

Could just do the crtc->primary->state->rotation thing here and avoid having to pass the rotation from the caller.

But the patch looks OK anyway:

Quoted 29 lines
drivers/gpu/drm/i915/intel_display.c +3 -2
 	INIT_WORK(&mmio_flip->work, intel_mmio_flip_work_func);
 	schedule_work(&mmio_flip->work);
@@ -11438,8 +11445,9 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 	work->gtt_offset += intel_crtc->dspaddr_offset;
 
 	if (mmio_flip) {
-		ret = intel_queue_mmio_flip(dev, crtc, fb, obj, ring,
-					    page_flip_flags);
+		ret = intel_queue_mmio_flip(dev, crtc,
+					    crtc->primary->state->rotation,
+					    obj);
 		if (ret)
 			goto cleanup_unpin;
 
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 27dccf35f9bc..140f949302c7 100644
@@ -493,6 +493,7 @@ struct intel_mmio_flip {
 	struct drm_i915_private *i915;
 	struct drm_i915_gem_request *req;
 	struct intel_crtc *crtc;
+	unsigned int rotation;
 };
 
 struct skl_pipe_wm {
Signature · 1 line
1.9.1
Signature · 6 lines
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw
Quoted 81 lines · Ville Syrjälä
Quoted 80 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Previously rotation was ignored and wrong stride programmed into the plane registers resulting in a corrupt image on screen.

v2: Do not access potentialy old plane state at flip time,
but store the rotation value at the time of queing the flip. (Ville)

Testcase: igt/kms_rotation_crc/primary-rotation-90-flip-stress (SKL)
Cc: Sonika Jindal <[email protected]>
Cc: Ville Syrjälä <[email protected]>

---
  drivers/gpu/drm/i915/intel_display.c | 30 +++++++++++++++++++-----------
  drivers/gpu/drm/i915/intel_drv.h     |  1 +
  2 files changed, 20 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_display.c +15 -9
index 1fc1d240d3c1..9cb29086971a 100644
@@ -11091,13 +11091,14 @@ static bool use_mmio_flip(struct intel_engine_cs *ring,
  }
 
  static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
+			     unsigned int rotation,
  			     struct intel_unpin_work *work)
  {
  	struct drm_device *dev = intel_crtc->base.dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct drm_framebuffer *fb = intel_crtc->base.primary->fb;
  	const enum pipe pipe = intel_crtc->pipe;
-	u32 ctl, stride;
+	u32 ctl, stride, tile_height;
 
  	ctl = I915_READ(PLANE_CTL(pipe, 0));
  	ctl &= ~PLANE_CTL_TILED_MASK;
@@ -11121,9 +11122,16 @@ static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
  	 * The stride is either expressed as a multiple of 64 bytes chunks for
  	 * linear buffers or in number of tiles for tiled buffers.
  	 */
-	stride = fb->pitches[0] /
-		 intel_fb_stride_alignment(dev, fb->modifier[0],
-					   fb->pixel_format);
+	if (intel_rotation_90_or_270(rotation)) {
+		/* stride = Surface height in tiles */
+		tile_height = intel_tile_height(dev, fb->pixel_format,
+						fb->modifier[0], 0);
+		stride = DIV_ROUND_UP(fb->height, tile_height);
+	} else {
+		stride = fb->pitches[0] /
+				intel_fb_stride_alignment(dev, fb->modifier[0],
+							  fb->pixel_format);
+	}
 
  	/*
  	 * Both PLANE_CTL and PLANE_STRIDE are not updated on vblank but on
@@ -11181,7 +11189,7 @@ static void intel_do_mmio_flip(struct intel_mmio_flip *mmio_flip)
  	intel_pipe_update_start(crtc);
 
  	if (INTEL_INFO(mmio_flip->i915)->gen >= 9)
-		skl_do_mmio_flip(crtc, work);
+		skl_do_mmio_flip(crtc, mmio_flip->rotation, work);
  	else
  		/* use_mmio_flip() retricts MMIO flips to ilk+ */
  		ilk_do_mmio_flip(crtc, work);
@@ -11208,10 +11216,8 @@ static void intel_mmio_flip_work_func(struct work_struct *work)
 
  static int intel_queue_mmio_flip(struct drm_device *dev,
  				 struct drm_crtc *crtc,
-				 struct drm_framebuffer *fb,
-				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
-				 uint32_t flags)
+				 unsigned int rotation,
+				 struct drm_i915_gem_object *obj)
  {
  	struct intel_mmio_flip *mmio_flip;
 
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 11231

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
@@ -11222,6 +11228,7 @@ static int intel_queue_mmio_flip(struct drm_device *dev,
  	mmio_flip->i915 = to_i915(dev);
  	mmio_flip->req = i915_gem_request_reference(obj->last_write_req);
  	mmio_flip->crtc = to_intel_crtc(crtc);
+	mmio_flip->rotation = rotation;

Could just do the crtc->primary->state->rotation thing here and avoid having to pass the rotation from the caller.

Oh that would indeed be nicer. I'll do a v3.

Quoted 2 lines

But the patch looks OK anyway:

Can I carry over the r-b to v3?

Regards,

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

#3 lore raw
Quoted 92 lines · Tvrtko Ursulin
Quoted 81 lines · Ville Syrjälä
Quoted 80 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Previously rotation was ignored and wrong stride programmed into the plane registers resulting in a corrupt image on screen.

v2: Do not access potentialy old plane state at flip time,
but store the rotation value at the time of queing the flip. (Ville)

Testcase: igt/kms_rotation_crc/primary-rotation-90-flip-stress (SKL)
Cc: Sonika Jindal <[email protected]>
Cc: Ville Syrjälä <[email protected]>

---
  drivers/gpu/drm/i915/intel_display.c | 30 +++++++++++++++++++-----------
  drivers/gpu/drm/i915/intel_drv.h     |  1 +
  2 files changed, 20 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_display.c +15 -9
index 1fc1d240d3c1..9cb29086971a 100644
@@ -11091,13 +11091,14 @@ static bool use_mmio_flip(struct intel_engine_cs *ring,
  }
 
  static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
+			     unsigned int rotation,
  			     struct intel_unpin_work *work)
  {
  	struct drm_device *dev = intel_crtc->base.dev;
  	struct drm_i915_private *dev_priv = dev->dev_private;
  	struct drm_framebuffer *fb = intel_crtc->base.primary->fb;
  	const enum pipe pipe = intel_crtc->pipe;
-	u32 ctl, stride;
+	u32 ctl, stride, tile_height;
 
  	ctl = I915_READ(PLANE_CTL(pipe, 0));
  	ctl &= ~PLANE_CTL_TILED_MASK;
@@ -11121,9 +11122,16 @@ static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
  	 * The stride is either expressed as a multiple of 64 bytes chunks for
  	 * linear buffers or in number of tiles for tiled buffers.
  	 */
-	stride = fb->pitches[0] /
-		 intel_fb_stride_alignment(dev, fb->modifier[0],
-					   fb->pixel_format);
+	if (intel_rotation_90_or_270(rotation)) {
+		/* stride = Surface height in tiles */
+		tile_height = intel_tile_height(dev, fb->pixel_format,
+						fb->modifier[0], 0);
+		stride = DIV_ROUND_UP(fb->height, tile_height);
+	} else {
+		stride = fb->pitches[0] /
+				intel_fb_stride_alignment(dev, fb->modifier[0],
+							  fb->pixel_format);
+	}
 
  	/*
  	 * Both PLANE_CTL and PLANE_STRIDE are not updated on vblank but on
@@ -11181,7 +11189,7 @@ static void intel_do_mmio_flip(struct intel_mmio_flip *mmio_flip)
  	intel_pipe_update_start(crtc);
 
  	if (INTEL_INFO(mmio_flip->i915)->gen >= 9)
-		skl_do_mmio_flip(crtc, work);
+		skl_do_mmio_flip(crtc, mmio_flip->rotation, work);
  	else
  		/* use_mmio_flip() retricts MMIO flips to ilk+ */
  		ilk_do_mmio_flip(crtc, work);
@@ -11208,10 +11216,8 @@ static void intel_mmio_flip_work_func(struct work_struct *work)
 
  static int intel_queue_mmio_flip(struct drm_device *dev,
  				 struct drm_crtc *crtc,
-				 struct drm_framebuffer *fb,
-				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
-				 uint32_t flags)
+				 unsigned int rotation,
+				 struct drm_i915_gem_object *obj)
  {
  	struct intel_mmio_flip *mmio_flip;
 
Quoted 8 lines

drivers/gpu/drm/i915/intel_display.c static int intel_queue_mmio_flip(struct drm_device *dev, · line 11231

Quoted 5 lines
drivers/gpu/drm/i915/intel_display.c +1 -0
@@ -11222,6 +11228,7 @@ static int intel_queue_mmio_flip(struct drm_device *dev,
  	mmio_flip->i915 = to_i915(dev);
  	mmio_flip->req = i915_gem_request_reference(obj->last_write_req);
  	mmio_flip->crtc = to_intel_crtc(crtc);
+	mmio_flip->rotation = rotation;

Could just do the crtc->primary->state->rotation thing here and avoid having to pass the rotation from the caller.

Quoted 6 lines

Oh that would indeed be nicer. I'll do a v3.

Quoted 2 lines

But the patch looks OK anyway:

Can I carry over the r-b to v3?

Yes.

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

PATCH v3 1/1 drm/i915/skl: Consider plane rotation when calculating stride in skl_do_mmio_flip

From: Tvrtko Ursulin <[email protected]>

Previously rotation was ignored and wrong stride programmed into the plane registers resulting in a corrupt image on screen.

v2: Do not access potentialy old plane state at flip time,
but store the rotation value at the time of queing the flip. (Ville)

v3: No need to pass rotation to intel_queue_mmio_flip since it
is available in the crtc. (Ville)

Testcase: igt/kms_rotation_crc/primary-rotation-90-flip-stress (SKL)

Cc Sonika Jindal <[email protected]>
Cc Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/intel_display.c | 27 ++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 2 files changed, 17 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_display.c +16 -11
index 1fc1d240d3c1..2981d09d5e4e 100644
@@ -11091,13 +11091,14 @@ static bool use_mmio_flip(struct intel_engine_cs *ring,
 }
 
 static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
+			     unsigned int rotation,
 			     struct intel_unpin_work *work)
 {
 	struct drm_device *dev = intel_crtc->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_framebuffer *fb = intel_crtc->base.primary->fb;
 	const enum pipe pipe = intel_crtc->pipe;
-	u32 ctl, stride;
+	u32 ctl, stride, tile_height;
 
 	ctl = I915_READ(PLANE_CTL(pipe, 0));
 	ctl &= ~PLANE_CTL_TILED_MASK;
@@ -11121,9 +11122,16 @@ static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
 	 * The stride is either expressed as a multiple of 64 bytes chunks for
 	 * linear buffers or in number of tiles for tiled buffers.
 	 */
-	stride = fb->pitches[0] /
-		 intel_fb_stride_alignment(dev, fb->modifier[0],
-					   fb->pixel_format);
+	if (intel_rotation_90_or_270(rotation)) {
+		/* stride = Surface height in tiles */
+		tile_height = intel_tile_height(dev, fb->pixel_format,
+						fb->modifier[0], 0);
+		stride = DIV_ROUND_UP(fb->height, tile_height);
+	} else {
+		stride = fb->pitches[0] /
+				intel_fb_stride_alignment(dev, fb->modifier[0],
+							  fb->pixel_format);
+	}
 
 	/*
 	 * Both PLANE_CTL and PLANE_STRIDE are not updated on vblank but on
@@ -11181,7 +11189,7 @@ static void intel_do_mmio_flip(struct intel_mmio_flip *mmio_flip)
 	intel_pipe_update_start(crtc);
 
 	if (INTEL_INFO(mmio_flip->i915)->gen >= 9)
-		skl_do_mmio_flip(crtc, work);
+		skl_do_mmio_flip(crtc, mmio_flip->rotation, work);
 	else
 		/* use_mmio_flip() retricts MMIO flips to ilk+ */
 		ilk_do_mmio_flip(crtc, work);
@@ -11208,10 +11216,7 @@ static void intel_mmio_flip_work_func(struct work_struct *work)
 
 static int intel_queue_mmio_flip(struct drm_device *dev,
 				 struct drm_crtc *crtc,
-				 struct drm_framebuffer *fb,
-				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
-				 uint32_t flags)
+				 struct drm_i915_gem_object *obj)
 {
 	struct intel_mmio_flip *mmio_flip;
 
@@ -11222,6 +11227,7 @@ static int intel_queue_mmio_flip(struct drm_device *dev,
 	mmio_flip->i915 = to_i915(dev);
 	mmio_flip->req = i915_gem_request_reference(obj->last_write_req);
 	mmio_flip->crtc = to_intel_crtc(crtc);
+	mmio_flip->rotation = crtc->primary->state->rotation;
 
 	INIT_WORK(&mmio_flip->work, intel_mmio_flip_work_func);
 	schedule_work(&mmio_flip->work);
@@ -11438,8 +11444,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 	work->gtt_offset += intel_crtc->dspaddr_offset;
 
 	if (mmio_flip) {
-		ret = intel_queue_mmio_flip(dev, crtc, fb, obj, ring,
-					    page_flip_flags);
+		ret = intel_queue_mmio_flip(dev, crtc, obj);
 		if (ret)
 			goto cleanup_unpin;
 
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 27dccf35f9bc..140f949302c7 100644
@@ -493,6 +493,7 @@ struct intel_mmio_flip {
 	struct drm_i915_private *i915;
 	struct drm_i915_gem_request *req;
 	struct intel_crtc *crtc;
+	unsigned int rotation;
 };
 
 struct skl_pipe_wm {
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
Quoted 9 lines · Tvrtko Ursulin

From: Tvrtko Ursulin <[email protected]>

Previously rotation was ignored and wrong stride programmed into the plane registers resulting in a corrupt image on screen.

v2: Do not access potentialy old plane state at flip time,
but store the rotation value at the time of queing the flip. (Ville)

Quoted 8 lines

v3: No need to pass rotation to intel_queue_mmio_flip since it
is available in the crtc. (Ville)

Testcase: igt/kms_rotation_crc/primary-rotation-90-flip-stress (SKL)

Cc Sonika Jindal <[email protected]>
Cc Ville Syrjälä <[email protected]>

Queued for -next, thanks for the patch.
-Daniel

Quoted 103 lines
---
 drivers/gpu/drm/i915/intel_display.c | 27 ++++++++++++++++-----------
 drivers/gpu/drm/i915/intel_drv.h     |  1 +
 2 files changed, 17 insertions(+), 11 deletions(-)
drivers/gpu/drm/i915/intel_display.c +16 -11
index 1fc1d240d3c1..2981d09d5e4e 100644
@@ -11091,13 +11091,14 @@ static bool use_mmio_flip(struct intel_engine_cs *ring,
 }
 
 static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
+			     unsigned int rotation,
 			     struct intel_unpin_work *work)
 {
 	struct drm_device *dev = intel_crtc->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_framebuffer *fb = intel_crtc->base.primary->fb;
 	const enum pipe pipe = intel_crtc->pipe;
-	u32 ctl, stride;
+	u32 ctl, stride, tile_height;
 
 	ctl = I915_READ(PLANE_CTL(pipe, 0));
 	ctl &= ~PLANE_CTL_TILED_MASK;
@@ -11121,9 +11122,16 @@ static void skl_do_mmio_flip(struct intel_crtc *intel_crtc,
 	 * The stride is either expressed as a multiple of 64 bytes chunks for
 	 * linear buffers or in number of tiles for tiled buffers.
 	 */
-	stride = fb->pitches[0] /
-		 intel_fb_stride_alignment(dev, fb->modifier[0],
-					   fb->pixel_format);
+	if (intel_rotation_90_or_270(rotation)) {
+		/* stride = Surface height in tiles */
+		tile_height = intel_tile_height(dev, fb->pixel_format,
+						fb->modifier[0], 0);
+		stride = DIV_ROUND_UP(fb->height, tile_height);
+	} else {
+		stride = fb->pitches[0] /
+				intel_fb_stride_alignment(dev, fb->modifier[0],
+							  fb->pixel_format);
+	}
 
 	/*
 	 * Both PLANE_CTL and PLANE_STRIDE are not updated on vblank but on
@@ -11181,7 +11189,7 @@ static void intel_do_mmio_flip(struct intel_mmio_flip *mmio_flip)
 	intel_pipe_update_start(crtc);
 
 	if (INTEL_INFO(mmio_flip->i915)->gen >= 9)
-		skl_do_mmio_flip(crtc, work);
+		skl_do_mmio_flip(crtc, mmio_flip->rotation, work);
 	else
 		/* use_mmio_flip() retricts MMIO flips to ilk+ */
 		ilk_do_mmio_flip(crtc, work);
@@ -11208,10 +11216,7 @@ static void intel_mmio_flip_work_func(struct work_struct *work)
 
 static int intel_queue_mmio_flip(struct drm_device *dev,
 				 struct drm_crtc *crtc,
-				 struct drm_framebuffer *fb,
-				 struct drm_i915_gem_object *obj,
-				 struct intel_engine_cs *ring,
-				 uint32_t flags)
+				 struct drm_i915_gem_object *obj)
 {
 	struct intel_mmio_flip *mmio_flip;
 
@@ -11222,6 +11227,7 @@ static int intel_queue_mmio_flip(struct drm_device *dev,
 	mmio_flip->i915 = to_i915(dev);
 	mmio_flip->req = i915_gem_request_reference(obj->last_write_req);
 	mmio_flip->crtc = to_intel_crtc(crtc);
+	mmio_flip->rotation = crtc->primary->state->rotation;
 
 	INIT_WORK(&mmio_flip->work, intel_mmio_flip_work_func);
 	schedule_work(&mmio_flip->work);
@@ -11438,8 +11444,7 @@ static int intel_crtc_page_flip(struct drm_crtc *crtc,
 	work->gtt_offset += intel_crtc->dspaddr_offset;
 
 	if (mmio_flip) {
-		ret = intel_queue_mmio_flip(dev, crtc, fb, obj, ring,
-					    page_flip_flags);
+		ret = intel_queue_mmio_flip(dev, crtc, obj);
 		if (ret)
 			goto cleanup_unpin;
 
drivers/gpu/drm/i915/intel_drv.h +1 -0
index 27dccf35f9bc..140f949302c7 100644
@@ -493,6 +493,7 @@ struct intel_mmio_flip {
 	struct drm_i915_private *i915;
 	struct drm_i915_gem_request *req;
 	struct intel_crtc *crtc;
+	unsigned int rotation;
 };
 
 struct skl_pipe_wm {
Signature · 6 lines
1.9.1

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx