Skip to contentSkip to conversation

drm/fb-helper: Fix clipping when damage area spans a single scanline

PATCH In review Francesco Lavra 2 participants 4 messages Feb 10 – May 4

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

PATCH 1/1 drm/fb-helper: Fix clipping when damage area spans a single scanline

When the damage area resulting from a dirty memory range spans a single scanline, the width of the rectangle is calculated dynamically because it may not coincide with the framebuffer width.
If the dirty range ends exactly at the end of the scanline, the bit_end variable is incorrectly assigned a 0 value, which results in a bogus clip rectangle where the x2 coordinate is 0. This prevents the dirty scanline from being flushed to the hardware.
Change the calculation of the bit_end value to fix the x2 coordinate value in the above edge case.

Fixes ded74cafeea9 ("drm/fb-helper: Clip damage area horizontally")
---
 drivers/gpu/drm/drm_fb_helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +1 -1
index 4b47aa0dab35..d545342d24b3 100644
@@ -608,7 +608,7 @@ static void drm_fb_helper_memory_range_to_clip(struct fb_info *info, off_t off,
 		 * the number of horizontal pixels that need an update.
 		 */
 		off_t bit_off = (off % line_length) * 8;
-		off_t bit_end = (end % line_length) * 8;
+		off_t bit_end = bit_off + len * 8;
 
 		x1 = bit_off / info->var.bits_per_pixel;
 		x2 = DIV_ROUND_UP(bit_end, info->var.bits_per_pixel);
Signature · 1 line
2.39.5
maintainer Reviewed-by on v1 1/1
#1 lore raw

Hi

Am 10.02.26 um 18:35 schrieb Francesco Lavra:

Quoted 10 lines

When the damage area resulting from a dirty memory range spans a single scanline, the width of the rectangle is calculated dynamically because it may not coincide with the framebuffer width.
If the dirty range ends exactly at the end of the scanline, the bit_end variable is incorrectly assigned a 0 value, which results in a bogus clip rectangle where the x2 coordinate is 0. This prevents the dirty scanline from being flushed to the hardware.
Change the calculation of the bit_end value to fix the x2 coordinate value in the above edge case.

Quoted 2 lines
Fixes ded74cafeea9 ("drm/fb-helper: Clip damage area horizontally")

The whole logic in that helper would need an update. But for now

Best regards
Thomas

Quoted 17 lines
---
  drivers/gpu/drm/drm_fb_helper.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +1 -1
index 4b47aa0dab35..d545342d24b3 100644
@@ -608,7 +608,7 @@ static void drm_fb_helper_memory_range_to_clip(struct fb_info *info, off_t off,
  		 * the number of horizontal pixels that need an update.
  		 */
  		off_t bit_off = (off % line_length) * 8;
-		off_t bit_end = (end % line_length) * 8;
+		off_t bit_end = bit_off + len * 8;
 
  		x1 = bit_off / info->var.bits_per_pixel;
  		x2 = DIV_ROUND_UP(bit_end, info->var.bits_per_pixel);
Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)
#2 lore raw
In reply to Francesco Lavra

Friendly ping

Quoted 31 lines · Francesco Lavra

When the damage area resulting from a dirty memory range spans a single scanline, the width of the rectangle is calculated dynamically because it may not coincide with the framebuffer width.
If the dirty range ends exactly at the end of the scanline, the bit_end variable is incorrectly assigned a 0 value, which results in a bogus clip rectangle where the x2 coordinate is 0. This prevents the dirty scanline from being flushed to the hardware.
Change the calculation of the bit_end value to fix the x2 coordinate value in the above edge case.

Fixes ded74cafeea9 ("drm/fb-helper: Clip damage area horizontally")

---
 drivers/gpu/drm/drm_fb_helper.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +1 -1
index 4b47aa0dab35..d545342d24b3 100644
@@ -608,7 +608,7 @@ static void drm_fb_helper_memory_range_to_clip(struct
 fb_info *info, off_t off,
                  * the number of horizontal pixels that need an update.
                  */
                 off_t bit_off = (off % line_length) * 8;
-               off_t bit_end = (end % line_length) * 8;
+               off_t bit_end = bit_off + len * 8;


                x1 = bit_off / info->var.bits_per_pixel; x2 = DIV_ROUND_UP(bit_end, info->var.bits_per_pixel);

#3 lore raw

Hi

Am 30.04.26 um 17:35 schrieb Francesco Lavra:

Quoted 1 line

Friendly ping

Sorry, forgot this patch. It's merged now. Thanks a lot.

Best regards
Thomas

Quoted 33 lines · Francesco Lavra
Quoted 31 lines

When the damage area resulting from a dirty memory range spans a single scanline, the width of the rectangle is calculated dynamically because it may not coincide with the framebuffer width.
If the dirty range ends exactly at the end of the scanline, the bit_end variable is incorrectly assigned a 0 value, which results in a bogus clip rectangle where the x2 coordinate is 0. This prevents the dirty scanline from being flushed to the hardware.
Change the calculation of the bit_end value to fix the x2 coordinate value in the above edge case.

Fixes ded74cafeea9 ("drm/fb-helper: Clip damage area horizontally")
---
  drivers/gpu/drm/drm_fb_helper.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/drm_fb_helper.c +1 -1
index 4b47aa0dab35..d545342d24b3 100644
@@ -608,7 +608,7 @@ static void drm_fb_helper_memory_range_to_clip(struct
 fb_info *info, off_t off,
                  * the number of horizontal pixels that need an update.
                  */
                 off_t bit_off = (off % line_length) * 8;
-               off_t bit_end = (end % line_length) * 8;
+               off_t bit_end = bit_off + len * 8;
 
                 x1 = bit_off / info->var.bits_per_pixel;

                x2 = DIV_ROUND_UP(bit_end, info->var.bits_per_pixel);

Signature · 6 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Jochen Jaser, Andrew McDonald, Werner Knoblich, (HRB 36809, AG Nürnberg)