public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] drm/tiny: Refactor framebuffer's size calculation
@ 2025-10-20 11:57 Mehdi Ben Hadj Khelifa
  2025-10-21  6:51 ` Thomas Zimmermann
  0 siblings, 1 reply; 7+ messages in thread
From: Mehdi Ben Hadj Khelifa @ 2025-10-20 11:57 UTC (permalink / raw)
  To: lanzano.alex, maarten.lankhorst, mripard, tzimmermann, airlied,
	simona
  Cc: dri-devel, linux-kernel, skhan, david.hunter.linux, khalid,
	linux-kernel-mentees, Mehdi Ben Hadj Khelifa

Use drm_format_info_min_pitch() to calculate the framebuffer line pitch
instead of directly multiplying width and height. This aligns with DRM
helpers for determining per-line byte size and avoids manual assumptions
about bytes per pixel.

Suggested-by: Thomas Zimmermann <tzimmermann@suse.de>
Signed-off-by: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>
---
 drivers/gpu/drm/tiny/repaper.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tiny/repaper.c b/drivers/gpu/drm/tiny/repaper.c
index 4824f863fdba..aeff49bc6ba7 100644
--- a/drivers/gpu/drm/tiny/repaper.c
+++ b/drivers/gpu/drm/tiny/repaper.c
@@ -517,6 +517,8 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb, const struct iosys_map *
 	unsigned int dst_pitch = 0;
 	struct iosys_map dst;
 	struct drm_rect clip;
+	const struct drm_format_info *info = fb->format;
+	size_t pitch;
 	int idx, ret = 0;
 	u8 *buf = NULL;
 
@@ -534,7 +536,9 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb, const struct iosys_map *
 	DRM_DEBUG("Flushing [FB:%d] st=%ums\n", fb->base.id,
 		  epd->factored_stage_time);
 
-	buf = kmalloc(fb->width * fb->height / 8, GFP_KERNEL);
+	pitch = drm_format_info_min_pitch(info, 0, fb->width);
+
+	buf = kmalloc_array(fb->height, pitch, GFP_KERNEL);
 	if (!buf) {
 		ret = -ENOMEM;
 		goto out_exit;
-- 
2.51.1.dirty


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2025-10-21  8:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-20 11:57 [PATCH] drm/tiny: Refactor framebuffer's size calculation Mehdi Ben Hadj Khelifa
2025-10-21  6:51 ` Thomas Zimmermann
2025-10-21  6:57   ` Thomas Zimmermann
2025-10-21  8:42     ` Mehdi Ben Hadj Khelifa
2025-10-21  8:41   ` Mehdi Ben Hadj Khelifa
2025-10-21  8:32     ` Thomas Zimmermann
2025-10-21  9:44       ` Mehdi Ben Hadj Khelifa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox