Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Cc: robin.clark@oss.qualcomm.com, lumag@kernel.org,
	abhinav.kumar@linux.dev, jesszhan0024@gmail.com, sean@poorly.run,
	marijn.suijten@somainline.org, airlied@gmail.com,
	simona@ffwll.ch, linux-arm-msm@vger.kernel.org,
	dri-devel@lists.freedesktop.org, freedreno@lists.freedesktop.org
Subject: Re: [PATCH 4/6] drm/msm: fbdev: Calculate buffer geometry with format helpers
Date: Thu, 23 Apr 2026 09:58:45 +0200	[thread overview]
Message-ID: <837457c1-2a4b-417d-80a6-a7ca43642838@suse.de> (raw)
In-Reply-To: <kywf5seogl4dmh6msqcmfyxdxyg7i5y2jyr2z6fcbu7qrpemhy@nemrwv3lyg7i>

Hi

Am 22.04.26 um 02:07 schrieb Dmitry Baryshkov:
> On Tue, Apr 21, 2026 at 02:51:17PM +0200, Thomas Zimmermann wrote:
>> Replace the geometry and size calculation in msm's fbdev emulation
>> with DRM format helpers. This consists of a 4CC lookup from the fbdev
>> parameters, format lookup, pitch calculation and size calculation.
>> Then allocate the GEM buffer object for the framebuffer memory from
>> the calculated size.
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
>> ---
>>   drivers/gpu/drm/msm/msm_drv.h   |  7 -------
>>   drivers/gpu/drm/msm/msm_fbdev.c | 26 ++++++++++++--------------
>>   2 files changed, 12 insertions(+), 21 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h
>> index b3173fa4d222..00c50d7437d6 100644
>> --- a/drivers/gpu/drm/msm/msm_drv.h
>> +++ b/drivers/gpu/drm/msm/msm_drv.h
>> @@ -509,13 +509,6 @@ void msm_hrtimer_work_init(struct msm_hrtimer_work *work,
>>   #define DBG(fmt, ...) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__)
>>   #define VERB(fmt, ...) if (0) DRM_DEBUG_DRIVER(fmt"\n", ##__VA_ARGS__)
>>   
>> -static inline int align_pitch(int width, int bpp)
>> -{
>> -	int bytespp = (bpp + 7) / 8;
>> -	/* adreno needs pitch aligned to 32 pixels: */
>> -	return bytespp * ALIGN(width, 32);
>> -}
>> -
>>   /* for the generated headers: */
>>   #define INVALID_IDX(idx) ({BUG(); 0;})
>>   #define fui(x)                ({BUG(); 0;})
>> diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
>> index 1eb0368a6d07..5532c5779f17 100644
>> --- a/drivers/gpu/drm/msm/msm_fbdev.c
>> +++ b/drivers/gpu/drm/msm/msm_fbdev.c
>> @@ -95,23 +95,25 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
>>   	struct fb_info *fbi = helper->info;
>>   	struct drm_mode_fb_cmd2 mode_cmd = { };
>>   	struct drm_framebuffer *fb = NULL;
>> +	const struct drm_format_info *format;
>> +	u32 fourcc, pitch;
>> +	u64 size;
>>   	struct drm_gem_object *bo;
>>   	uint64_t paddr;
>> -	uint32_t format;
>> -	int ret, pitch;
>> -	int size;
>> -
>> -	format = drm_mode_legacy_fb_format(sizes->surface_bpp, sizes->surface_depth);
>> +	int ret;
>>   
>>   	DBG("create fbdev: %dx%d@%d (%dx%d)", sizes->surface_width,
>>   			sizes->surface_height, sizes->surface_bpp,
>>   			sizes->fb_width, sizes->fb_height);
>>   
>> -	pitch = align_pitch(sizes->surface_width, sizes->surface_bpp);
>> +	fourcc = drm_mode_legacy_fb_format(sizes->surface_bpp, sizes->surface_depth);
>> +	format = drm_get_format_info(dev, fourcc, DRM_FORMAT_MOD_LINEAR);
>> +	/* adreno needs pitch aligned to 32 pixels: */
>> +	pitch = drm_format_info_min_pitch(format, 0, ALIGN(sizes->surface_width, 32));
>> +	size = ALIGN(pitch * sizes->surface_height, PAGE_SIZE);
> Hmm, why do we need to align the size to the PAGE_SIZE? I might be
> missing a point, but it would be nice to mention it in the commit
> message.

This buffer will be mmap'ed to user space and fbdev's mmap of course 
requires page-aligned sizes.  Hence the alignment here. Msm's memory 
manager should take care of this, but it doesn't hurt to request it 
specifically.

On a more general note: while we use this GEM buffer object for backing 
the DRM framebuffer, it is better to think of it as fbdev framebuffer 
memory.

I'll update the commit description accordingly.

Best regards
Thomas


>
> Other than that, LGTM.
>

-- 
--
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)



  reply	other threads:[~2026-04-23  7:58 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-04-21 12:51 [PATCH 0/6] drm/msm: fbdev: Use client buffers Thomas Zimmermann
2026-04-21 12:51 ` [PATCH 1/6] drm/msm: Do not declare msm_framebuffer_init() as static Thomas Zimmermann
2026-04-21 16:09   ` Dmitry Baryshkov
2026-04-21 12:51 ` [PATCH 2/6] drm/msm: fbdev: Inline msm_alloc_stolen_fb() Thomas Zimmermann
2026-04-21 16:22   ` Dmitry Baryshkov
2026-04-21 12:51 ` [PATCH 3/6] drm/msm: fbdev: Fix error reporting Thomas Zimmermann
2026-04-21 16:22   ` Dmitry Baryshkov
2026-04-21 12:51 ` [PATCH 4/6] drm/msm: fbdev: Calculate buffer geometry with format helpers Thomas Zimmermann
2026-04-22  0:07   ` Dmitry Baryshkov
2026-04-23  7:58     ` Thomas Zimmermann [this message]
2026-04-21 12:51 ` [PATCH 5/6] drm/msm: fbdev: Use a DRM client buffer Thomas Zimmermann
2026-04-22  0:13   ` Dmitry Baryshkov
2026-04-21 12:51 ` [PATCH 6/6] drm/msm: Make msm_framebuffer_init() an internal interface again Thomas Zimmermann
2026-04-22  0:13   ` Dmitry Baryshkov
2026-04-21 16:08 ` [PATCH 0/6] drm/msm: fbdev: Use client buffers Dmitry Baryshkov
2026-04-22  0:14   ` Dmitry Baryshkov
2026-04-23  8:04     ` Thomas Zimmermann

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=837457c1-2a4b-417d-80a6-a7ca43642838@suse.de \
    --to=tzimmermann@suse.de \
    --cc=abhinav.kumar@linux.dev \
    --cc=airlied@gmail.com \
    --cc=dmitry.baryshkov@oss.qualcomm.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jesszhan0024@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=marijn.suijten@somainline.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    /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