drm/msm: fbdev: Use client buffers
cover drm/msm: fbdev: Use client buffers
A client buffer holds the DRM framebuffer for an in-kernel DRM client. Until now, msm created an internal ad-hoc framebuffer for its fbdev emulation, while by-passing the regular interfaces used by user-space compositors.
Convert msm's fbdev emulation to use client buffers. Replacing the existing code with a client buffer allows for stream-lining msm code and later also the fbdev helpers. The new framebuffer will be registered against the client's file and will support handles for GEM objects. It is then just another framebuffer within the DRM ecosystem.
Patches 1 and 6 change visibility of msm_framebuffer_init() during the refactoring. It is the easiest way to refactor the fbdev probe helper.
Patch 2 and 3 inline the fb allocation code into the fbdev-probe helper and fix it up a bit.
From there patches 4 and 5 convert fbdev buffer allocation to common DRM helpes and client buffers.
If all fbdev emulation helpers can be converted to client buffers, the emulation's whole framebuffer handling could possibly be moved into shared helpers.
Thomas Zimmermann (6):
drm/msm: Do not declare msm_framebuffer_init() as static drm/msm: fbdev: Inline msm_alloc_stolen_fb()
drm/msm: fbdev: Fix error reporting
drm/msm: fbdev: Calculate buffer geometry with format helpers drm/msm: fbdev: Use a DRM client buffer
drm/msm: Make msm_framebuffer_init() an internal interface again
drivers/gpu/drm/msm/msm_drv.h | 9 --- drivers/gpu/drm/msm/msm_fb.c | 98 +++++++++------------------------ drivers/gpu/drm/msm/msm_fbdev.c | 85 +++++++++++++++++++--------- 3 files changed, 85 insertions(+), 107 deletions(-)
Signature · 1 line
2.53.0
PATCH 1/6 drm/msm: Do not declare msm_framebuffer_init() as static
Declare msm_framebuffer_init() in msm_drv.h and remove the static qualifier. The function will be required in msm_fbdev.c after inlining msm_alloc_stolen_fb().
Also move msm_framebuffer_init() before msm_framebuffer_create(), so that it can later be made static again. Prepares msm's fbdev emulation for using client buffers.
--- drivers/gpu/drm/msm/msm_drv.h | 4 ++ drivers/gpu/drm/msm/msm_fb.c | 72 +++++++++++++++++------------------ 2 files changed, 39 insertions(+), 37 deletions(-)
drivers/gpu/drm/msm/msm_drv.h +4 -0
@@ -259,6 +259,10 @@ void msm_framebuffer_cleanup(struct drm_framebuffer *fb, bool needed_dirtyfb);uint32_t msm_framebuffer_iova (struct drm_framebuffer *fb,int plane);struct drm_gem_object *msm_framebuffer_bo (struct drm_framebuffer *fb,int plane);const struct msm_format *msm_framebuffer_format (struct drm_framebuffer *fb); +struct drm_framebuffer *msm_framebuffer_init (struct drm_device *dev, +const struct drm_format_info *info, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object **bos);struct drm_framebuffer *msm_framebuffer_create (struct drm_device *dev,struct drm_file *file,const struct drm_format_info *info,const struct drm_mode_fb_cmd2 *mode_cmd);
drivers/gpu/drm/msm/msm_fb.c +35 -37
90 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH 1/6] drm/msm: Do not declare msm_framebuffer_init() as static
Quoted 8 lines · Thomas Zimmermann
Declare
msm_framebuffer_init()inmsm_drv.hand remove the static qualifier. The function will be required inmsm_fbdev.cafter inliningmsm_alloc_stolen_fb().Also move
msm_framebuffer_init()beforemsm_framebuffer_create(), so that it can later be made static again. Prepares msm's fbdev emulation for using client buffers.
Quoted 6 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/msm/msm_drv.h | 4 ++ drivers/gpu/drm/msm/msm_fb.c | 72 +++++++++++++++++------------------ 2 files changed, 39 insertions(+), 37 deletions(-)
Signature · 2 lines
With best wishes Dmitry
PATCH 2/6 drm/msm: fbdev: Inline msm_alloc_stolen_fb()
In reply to Thomas ZimmermannInline msm_alloc_stolen_fb() into its only caller. This is necessary for converting fbdev emulation to use client buffers.
There are some minor changes:
- Handle errors for the non-stolen BO in the respective branch.
- Fill mode_cmd right before using it with msm_framebuffer_init(). Both will later be replaced with client-buffer interfaces.
- Set the modifier[0] to DRM_FORMAT_MOD_LINEAR. No functional change.
- Integrate the error handling with the existing clean-up.
--- drivers/gpu/drm/msm/msm_drv.h | 2 -- drivers/gpu/drm/msm/msm_fb.c | 46 --------------------------------- drivers/gpu/drm/msm/msm_fbdev.c | 44 +++++++++++++++++++++++++------ 3 files changed, 36 insertions(+), 56 deletions(-)
drivers/gpu/drm/msm/msm_drv.h +0 -2
@@ -266,8 +266,6 @@ struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,struct drm_framebuffer *msm_framebuffer_create (struct drm_device *dev,struct drm_file *file,const struct drm_format_info *info,const struct drm_mode_fb_cmd2 *mode_cmd); -struct drm_framebuffer *msm_alloc_stolen_fb (struct drm_device *dev, -int w,int h,int p,uint32_t format);#ifdef CONFIG_DRM_MSM_KMS_FBDEV int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
drivers/gpu/drm/msm/msm_fb.c +0 -46
55 lines not on this page · raw message
drivers/gpu/drm/msm/msm_fbdev.c +36 -8
90 lines not on this page · raw message
Signature · 1 line
2.53.0
Re: [PATCH 2/6] drm/msm: fbdev: Inline msm_alloc_stolen_fb()
Quoted 12 lines · Thomas Zimmermann
Inline
msm_alloc_stolen_fb()into its only caller. This is necessary for converting fbdev emulation to use client buffers.There are some minor changes:
- Handle errors for the non-stolen BO in the respective branch.
- Fill
mode_cmdright before using it withmsm_framebuffer_init(). Both will later be replaced with client-buffer interfaces.- Set the modifier[0] to
DRM_FORMAT_MOD_LINEAR. No functional change.
Quoted 9 lines
- Integrate the error handling with the existing clean-up.
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/msm/msm_drv.h | 2 -- drivers/gpu/drm/msm/msm_fb.c | 46 --------------------------------- drivers/gpu/drm/msm/msm_fbdev.c | 44 +++++++++++++++++++++++++------ 3 files changed, 36 insertions(+), 56 deletions(-)
Signature · 2 lines
With best wishes Dmitry
PATCH 3/6 drm/msm: fbdev: Fix error reporting
In reply to Thomas ZimmermannReplace deprecated error reporting in msm_fbdev_driver_fbdev_probe(). Use drm_warn() and drm_err() instead.
--- drivers/gpu/drm/msm/msm_fbdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/msm_fbdev.c +4 -4
@@ -114,11 +114,11 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,DBG ("allocating %d bytes for fb %d" , size, dev->primary->index); bo =msm_gem_new (dev, size,MSM_BO_SCANOUT |MSM_BO_WC |MSM_BO_STOLEN );if (IS_ERR (bo)) { -dev_warn (dev->dev,"could not allocate stolen bo\n" ); +drm_warn (dev,"could not allocate stolen bo\n" );/* try regular bo: */ bo =msm_gem_new (dev, size,MSM_BO_SCANOUT |MSM_BO_WC );if (IS_ERR (bo)) { -DRM_DEV_ERROR (dev->dev,"failed to allocate buffer object\n" ); +drm_err (dev,"failed to allocate buffer object\n" );return PTR_ERR (bo); } }
@@ -136,7 +136,7 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper, mode_cmd.modifier[0]), &mode_cmd, &bo);if (IS_ERR (fb)) { -DRM_DEV_ERROR (dev->dev,"failed to allocate fb\n" ); +drm_err (dev,"failed to allocate fb\n" ); ret =PTR_ERR (fb); goto err_drm_gem_object_put; }
@@ -148,7 +148,7 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,*/ ret =msm_gem_get_and_pin_iova (bo, priv->kms->vm, &paddr);if (ret) { -DRM_DEV_ERROR (dev->dev,"failed to get buffer obj iova: %d\n" , ret); +drm_err (dev,"failed to get buffer obj iova: %d\n" , ret); goto err_drm_framebuffer_remove; }
Signature · 1 line
2.53.0
Re: [PATCH 3/6] drm/msm: fbdev: Fix error reporting
Quoted 8 lines · Thomas Zimmermann
Replace deprecated error reporting in
msm_fbdev_driver_fbdev_probe(). Usedrm_warn()anddrm_err()instead.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/msm/msm_fbdev.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
Signature · 2 lines
With best wishes Dmitry
PATCH 4/6 drm/msm: fbdev: Calculate buffer geometry with format helpers
In reply to Thomas ZimmermannReplace 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.
--- drivers/gpu/drm/msm/msm_drv.h | 7 ------- drivers/gpu/drm/msm/msm_fbdev.c | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 21 deletions(-)
drivers/gpu/drm/msm/msm_drv.h +0 -7
@@ -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;})
drivers/gpu/drm/msm/msm_fbdev.c +12 -14
@@ -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 );/* allocate backing bo */ - size = pitch * sizes->surface_height; -DBG ("allocating %d bytes for fb %d" , size, dev->primary->index); +DBG ("allocating %llu bytes for fb %d" , size, dev->primary->index); bo =msm_gem_new (dev, size,MSM_BO_SCANOUT |MSM_BO_WC |MSM_BO_STOLEN );if (IS_ERR (bo)) {drm_warn (dev,"could not allocate stolen bo\n" );
@@ -125,16 +127,12 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,msm_gem_object_set_name (bo,"stolenfb" ); - mode_cmd.pixel_format = format; + mode_cmd.pixel_format = fourcc; mode_cmd.width = sizes->surface_width; mode_cmd.height = sizes->surface_height; mode_cmd.pitches[0 ] = pitch; - mode_cmd.modifier[0 ] =DRM_FORMAT_MOD_LINEAR ; - fb =msm_framebuffer_init (dev, -drm_get_format_info (dev, mode_cmd.pixel_format, - mode_cmd.modifier[0 ]), - &mode_cmd, &bo); + fb =msm_framebuffer_init (dev, format, &mode_cmd, &bo);if (IS_ERR (fb)) {drm_err (dev,"failed to allocate fb\n" ); ret =PTR_ERR (fb);
Signature · 1 line
2.53.0
Re: [PATCH 4/6] drm/msm: fbdev: Calculate buffer geometry with format helpers
Quoted 50 lines · Thomas Zimmermann
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 <[email protected]>--- drivers/gpu/drm/msm/msm_drv.h | 7 ------- drivers/gpu/drm/msm/msm_fbdev.c | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 21 deletions(-)drivers/gpu/drm/msm/msm_drv.h +0
-7@@ -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;})drivers/gpu/drm/msm/msm_fbdev.c +4
-5@@ -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;
drivers/gpu/drm/msm/msm_fbdev.c int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper, · line 113
Quoted 10 lines
drivers/gpu/drm/msm/msm_fbdev.c +5
-1DBG ("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.
Other than that, LGTM.
Signature · 2 lines
With best wishes Dmitry
Re: [PATCH 4/6] drm/msm: fbdev: Calculate buffer geometry with format helpers
Hi
Am 22.04.26 um 02:07 schrieb Dmitry Baryshkov:
Quoted 55 lines · Thomas Zimmermann
Quoted 54 lines
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 <[email protected]>--- drivers/gpu/drm/msm/msm_drv.h | 7 ------- drivers/gpu/drm/msm/msm_fbdev.c | 26 ++++++++++++-------------- 2 files changed, 12 insertions(+), 21 deletions(-)drivers/gpu/drm/msm/msm_drv.h +0
-7@@ -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;})drivers/gpu/drm/msm/msm_fbdev.c +4
-5@@ -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);
Quoted 9 lines
drivers/gpu/drm/msm/msm_fbdev.c int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper, · line 113
Quoted 6 lines
drivers/gpu/drm/msm/msm_fbdev.c +5
-1- 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
Quoted 3 lines
Other than that, LGTM.
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)
PATCH 5/6 drm/msm: fbdev: Use a DRM client buffer
In reply to Thomas ZimmermannReplace the internal DRM framebuffer with a DRM client buffer. The client buffer allocates the DRM framebuffer on a file and also uses GEM object handles via the regular ADDFB2 interfaces.
Using client-buffer interfaces unifies framebuffer allocation for DRM clients in user space and msm's internal fbdev emulation. It also simplifies the clean-up side of the fbdev emulation.
--- drivers/gpu/drm/msm/msm_fbdev.c | 55 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 23 deletions(-)
drivers/gpu/drm/msm/msm_fbdev.c +32 -23
@@ -41,17 +41,15 @@ static int msm_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma)static void msm_fbdev_fb_destroy (struct fb_info *info) {struct drm_fb_helper *helper = (struct drm_fb_helper *)info->par; -struct drm_framebuffer *fb = helper->fb; -struct drm_gem_object *bo =msm_framebuffer_bo (fb,0 ); +struct drm_gem_object *bo =msm_framebuffer_bo (helper->fb,0 );DBG ();drm_fb_helper_fini (helper); -/* this will free the backing object */ msm_gem_put_vaddr (bo); -drm_framebuffer_remove (fb); +drm_client_buffer_delete (helper->buffer);drm_client_release (&helper->client); }
@@ -90,15 +88,16 @@ static const struct drm_fb_helper_funcs msm_fbdev_helper_funcs = {int msm_fbdev_driver_fbdev_probe (struct drm_fb_helper *helper,struct drm_fb_helper_surface_size *sizes) { -struct drm_device *dev = helper->dev; +struct drm_client_dev *client = &helper->client; +struct drm_device *dev = client->dev; +struct drm_file *file = client->file;struct msm_drm_private *priv = dev->dev_private;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; +u32 fourcc, pitch, handle;u64 size;struct drm_gem_object *bo; +struct drm_client_buffer *buffer;uint64_t paddr;int ret;
@@ -127,16 +126,15 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,msm_gem_object_set_name (bo,"stolenfb" ); - mode_cmd.pixel_format = fourcc; - mode_cmd.width = sizes->surface_width; - mode_cmd.height = sizes->surface_height; - mode_cmd.pitches[0 ] = pitch; - - fb =msm_framebuffer_init (dev, format, &mode_cmd, &bo); -if (IS_ERR (fb)) { -drm_err (dev,"failed to allocate fb\n" ); - ret =PTR_ERR (fb); + ret =drm_gem_handle_create (file, bo, &handle); +if (ret) goto err_drm_gem_object_put; + + buffer =drm_client_buffer_create (client, sizes->surface_width, sizes->surface_height, + fourcc, handle, pitch); +if (IS_ERR (buffer)) { + ret =PTR_ERR (buffer); + goto err_drm_gem_handle_delete; }/*
@@ -147,13 +145,14 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper, ret =msm_gem_get_and_pin_iova (bo, priv->kms->vm, &paddr);if (ret) {drm_err (dev,"failed to get buffer obj iova: %d\n" , ret); - goto err_drm_framebuffer_remove; + goto err_drm_client_buffer_delete; }DBG ("fbi=%p, dev=%p" , fbi, dev); helper->funcs = &msm_fbdev_helper_funcs; - helper->fb = fb; + helper->buffer = buffer; + helper->fb = buffer->fb; fbi->fbops = &msm_fb_ops;
@@ -162,19 +161,29 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper, fbi->screen_buffer =msm_gem_get_vaddr (bo);if (IS_ERR (fbi->screen_buffer)) { ret =PTR_ERR (fbi->screen_buffer); - goto err_drm_framebuffer_remove; + goto err_msm_gem_put_vaddr; } fbi->screen_size = bo->size; fbi->fix.smem_start = paddr; fbi->fix.smem_len = bo->size;DBG ("par=%p, %dx%d" , fbi->par, fbi->var.xres, fbi->var.yres); -DBG ("allocated %dx%d fb" , fb->width, fb->height); +DBG ("allocated %dx%d fb" , buffer->fb->width, buffer->fb->height); + +/* The handle is only needed for creating the framebuffer. */ +drm_gem_handle_delete (file, handle); + +/* The framebuffer still holds a reference on the GEM object. */ +drm_gem_object_put (bo);return 0 ; -err_drm_framebuffer_remove: -drm_framebuffer_remove (fb); +err_msm_gem_put_vaddr: +msm_gem_put_vaddr (bo); +err_drm_client_buffer_delete: +drm_client_buffer_delete (buffer); +err_drm_gem_handle_delete: +drm_gem_handle_delete (file, handle); err_drm_gem_object_put:drm_gem_object_put (bo);return ret;
Signature · 1 line
2.53.0
Re: [PATCH 5/6] drm/msm: fbdev: Use a DRM client buffer
Quoted 4 lines · Thomas Zimmermann
Replace the internal DRM framebuffer with a DRM client buffer. The client buffer allocates the DRM framebuffer on a file and also uses GEM object handles via the regular ADDFB2 interfaces.
Quoted 9 lines
Using client-buffer interfaces unifies framebuffer allocation for DRM clients in user space and msm's internal fbdev emulation. It also simplifies the clean-up side of the fbdev emulation.
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/msm/msm_fbdev.c | 55 +++++++++++++++++++-------------- 1 file changed, 32 insertions(+), 23 deletions(-)
Signature · 2 lines
With best wishes Dmitry
PATCH 6/6 drm/msm: Make msm_framebuffer_init() an internal interface again
In reply to Thomas ZimmermannThe only caller of msm_framebuffer_init() is msm_framebuffer_create() from the same source file. Declare the former as static.
--- drivers/gpu/drm/msm/msm_drv.h | 4 ---- drivers/gpu/drm/msm/msm_fb.c | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/msm/msm_drv.h +0 -4
@@ -259,10 +259,6 @@ void msm_framebuffer_cleanup(struct drm_framebuffer *fb, bool needed_dirtyfb);uint32_t msm_framebuffer_iova (struct drm_framebuffer *fb,int plane);struct drm_gem_object *msm_framebuffer_bo (struct drm_framebuffer *fb,int plane);const struct msm_format *msm_framebuffer_format (struct drm_framebuffer *fb); -struct drm_framebuffer *msm_framebuffer_init (struct drm_device *dev, -const struct drm_format_info *info, -const struct drm_mode_fb_cmd2 *mode_cmd, -struct drm_gem_object **bos);struct drm_framebuffer *msm_framebuffer_create (struct drm_device *dev,struct drm_file *file,const struct drm_format_info *info,const struct drm_mode_fb_cmd2 *mode_cmd);
drivers/gpu/drm/msm/msm_fb.c +4 -4
@@ -134,10 +134,10 @@ const struct msm_format *msm_framebuffer_format(struct drm_framebuffer *fb)return msm_fb->format; } -struct drm_framebuffer *msm_framebuffer_init (struct drm_device *dev, -const struct drm_format_info *info, -const struct drm_mode_fb_cmd2 *mode_cmd, -struct drm_gem_object **bos) +static struct drm_framebuffer * +msm_framebuffer_init (struct drm_device *dev,const struct drm_format_info *info, +const struct drm_mode_fb_cmd2 *mode_cmd, +struct drm_gem_object **bos) {struct msm_drm_private *priv = dev->dev_private;struct msm_kms *kms = priv->kms;
Signature · 1 line
2.53.0
Re: [PATCH 6/6] drm/msm: Make msm_framebuffer_init() an internal interface again
Quoted 9 lines · Thomas Zimmermann
The only caller of
msm_framebuffer_init()ismsm_framebuffer_create()from the same source file. Declare the former as static.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/msm/msm_drv.h | 4 ---- drivers/gpu/drm/msm/msm_fb.c | 8 ++++---- 2 files changed, 4 insertions(+), 8 deletions(-)
Signature · 2 lines
With best wishes Dmitry
Quoted 4 lines · Thomas Zimmermann
A client buffer holds the DRM framebuffer for an in-kernel DRM client. Until now, msm created an internal ad-hoc framebuffer for its fbdev emulation, while by-passing the regular interfaces used by user-space compositors.
I assume this was somewhat because we supported using the stolen memory for FB. Support for it has been dropped when we moved to GPUVM.
Rob, would it be possible to get it back at some point?
Thomas, would the series prevent us from using the stolen memory for FB?
Quoted 36 lines
Convert msm's fbdev emulation to use client buffers. Replacing the existing code with a client buffer allows for stream-lining msm code and later also the fbdev helpers. The new framebuffer will be registered against the client's file and will support handles for GEM objects. It is then just another framebuffer within the DRM ecosystem.
Patches 1 and 6 change visibility of
msm_framebuffer_init()during the refactoring. It is the easiest way to refactor the fbdev probe helper.Patch 2 and 3 inline the fb allocation code into the fbdev-probe helper and fix it up a bit.
From there patches 4 and 5 convert fbdev buffer allocation to common DRM helpes and client buffers.
If all fbdev emulation helpers can be converted to client buffers, the emulation's whole framebuffer handling could possibly be moved into shared helpers.
Thomas Zimmermann (6):
drm/msm: Do not declaremsm_framebuffer_init()as static drm/msm: fbdev: Inlinemsm_alloc_stolen_fb()
drm/msm: fbdev: Fix error reporting
drm/msm: fbdev: Calculate buffer geometry with format helpers drm/msm: fbdev: Use a DRM client buffer
drm/msm: Makemsm_framebuffer_init()an internal interface againdrivers/gpu/drm/msm/msm_drv.h | 9 --- drivers/gpu/drm/msm/msm_fb.c | 98 +++++++++------------------------ drivers/gpu/drm/msm/msm_fbdev.c | 85 +++++++++++++++++++--------- 3 files changed, 85 insertions(+), 107 deletions(-)Signature · 1 line
2.53.0
Signature · 2 lines
With best wishes Dmitry
Quoted 6 lines · Dmitry Baryshkov
Quoted 4 lines · Thomas Zimmermann
A client buffer holds the DRM framebuffer for an in-kernel DRM client. Until now, msm created an internal ad-hoc framebuffer for its fbdev emulation, while by-passing the regular interfaces used by user-space compositors.
Quoted 6 lines
I assume this was somewhat because we supported using the stolen memory for FB. Support for it has been dropped when we moved to GPUVM.
Rob, would it be possible to get it back at some point?
Thomas, would the series prevent us from using the stolen memory for FB?
And answering my question, no, we still can continue using stolen memory for the FB.
Signature · 2 lines
With best wishes Dmitry
Hi
Am 22.04.26 um 02:14 schrieb Dmitry Baryshkov:
Quoted 6 lines · Dmitry Baryshkov
Quoted 5 lines · Thomas Zimmermann
Quoted 4 lines
A client buffer holds the DRM framebuffer for an in-kernel DRM client. Until now, msm created an internal ad-hoc framebuffer for its fbdev emulation, while by-passing the regular interfaces used by user-space compositors.
Quoted 8 lines
Quoted 6 lines
I assume this was somewhat because we supported using the stolen memory for FB. Support for it has been dropped when we moved to GPUVM.
Rob, would it be possible to get it back at some point?
Thomas, would the series prevent us from using the stolen memory for FB?
And answering my question, no, we still can continue using stolen memory for the FB.
Indeed. The idea here is to keep the GEM buffer allocation as it is; including stolen memory. Once all driver's fbdev emulation uses the client-buffer interfaces, we might be able to create the framebuffer in the shared fbdev helpers.
As I mentioned in my reply to patch 4, the GEM buffer object is something like fbdev framebuffer memory (i.e., video ram). In a later change, we could allocate all of the stolen memory unconditionally.
Best regards
Thomas
Quoted 1 line
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)