public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Mehdi Ben Hadj Khelifa <mehdi.benhadjkhelifa@gmail.com>,
	lanzano.alex@gmail.com, maarten.lankhorst@linux.intel.com,
	mripard@kernel.org, airlied@gmail.com, simona@ffwll.ch
Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	skhan@linuxfoundation.org, david.hunter.linux@gmail.com,
	khalid@kernel.org,
	linux-kernel-mentees@lists.linuxfoundation.org
Subject: Re: [PATCH] drm/tiny: Refactor framebuffer's size calculation
Date: Tue, 21 Oct 2025 08:57:07 +0200	[thread overview]
Message-ID: <a37d83c7-dc2d-4e1d-a8d4-5628e0ac52a2@suse.de> (raw)
In-Reply-To: <1de3112b-6349-46d8-b90b-69d0849c7659@suse.de>



Am 21.10.25 um 08:51 schrieb Thomas Zimmermann:
> Hi
>
> Am 20.10.25 um 13:57 schrieb 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;
>
> This is the wrong format. You're allocating the output buffer here, 
> but you're using the input format. IIUC the output format is 
> DRM_FORMAT_R1. The input is _XRGB8888.
>
> Best regards
> Thomas
>
>> +    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);

And TBH I'm not sure if we should really convert this call. It's not an 
array in the sense of that API.

Good candidates look like 'kmalloc(count * sizeof(<some type or variable>))'

>>       if (!buf) {
>>           ret = -ENOMEM;
>>           goto out_exit;
>

-- 
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)



  reply	other threads:[~2025-10-21  6:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a37d83c7-dc2d-4e1d-a8d4-5628e0ac52a2@suse.de \
    --to=tzimmermann@suse.de \
    --cc=airlied@gmail.com \
    --cc=david.hunter.linux@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=khalid@kernel.org \
    --cc=lanzano.alex@gmail.com \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mehdi.benhadjkhelifa@gmail.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=skhan@linuxfoundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox