[RFC] drm/i915/fb: Fix aligning y coordinates for linear surface

Jouni Högander jouni.hogander at intel.com
Fri Jan 7 10:02:58 UTC 2022


Current y coordinate calculation in intel_compute_aligned_offset
is broken. It is adjusting y coordinate so that only added
alignment is included in calculated y value and original y value
is discarded.

Fix this by adding needed alignment into original y value.

Fixes: 7361bdb26c2c (drm/i915: Add support for non-power-of-2 FB plane alignment)
Signed-off-by: Jouni Högander <jouni.hogander at intel.com>
---
 drivers/gpu/drm/i915/display/intel_fb.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c
index 23cfe2e5ce2a..a526cbdc96c4 100644
--- a/drivers/gpu/drm/i915/display/intel_fb.c
+++ b/drivers/gpu/drm/i915/display/intel_fb.c
@@ -920,6 +920,7 @@ static u32 intel_compute_aligned_offset(struct drm_i915_private *i915,
 {
 	unsigned int cpp = fb->format->cpp[color_plane];
 	u32 offset, offset_aligned;
+	int y_alignment;
 
 	if (!is_surface_linear(fb, color_plane)) {
 		unsigned int tile_size, tile_width, tile_height;
@@ -955,8 +956,9 @@ static u32 intel_compute_aligned_offset(struct drm_i915_private *i915,
 		offset_aligned = offset;
 		if (alignment) {
 			offset_aligned = rounddown(offset_aligned, alignment);
-			*y = (offset % alignment) / pitch;
-			*x = ((offset % alignment) - *y * pitch) / cpp;
+			offset_y_alignement = offset % alignment;
+			*y += offset_alignement  / pitch;
+			*x = ((offset % alignment) - y_alignement * pitch) / cpp;
 		} else {
 			*y = *x = 0;
 		}
-- 
2.25.1



More information about the Intel-gfx-trybot mailing list