From: Thomas Zimmermann <tzimmermann@suse.de>
To: jfalempe@redhat.com, javierm@redhat.com, rrameshbabu@nvidia.com,
maarten.lankhorst@linux.intel.com, mripard@kernel.org,
francesco@valla.it, airlied@gmail.com
Cc: dri-devel@lists.freedesktop.org, Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH v2 2/7] drm/client: Move dumb-buffer handling to drm_client_framebuffer_create()
Date: Mon, 27 Oct 2025 13:09:13 +0100 [thread overview]
Message-ID: <20251027121042.143588-3-tzimmermann@suse.de> (raw)
In-Reply-To: <20251027121042.143588-1-tzimmermann@suse.de>
Dumb-buffer creation within the client code is asymetrically balanced
across drm_client_buffer_create() and drm_client_framebuffer_create().
Put all dumb-buffer code into drm_client_framebuffer_create() and leave
client-buffer initialization to drm_client_buffer_create(). Clarifies
responsibility between these functions.
Apart form the architectural improvements, drm_client_buffer_create()
can now be exported if needed by clients. The client will be able to
initialize buffers that have been created from other interfaces than
dumb buffers.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com>
---
drivers/gpu/drm/drm_client.c | 56 +++++++++++++++++++-----------------
1 file changed, 29 insertions(+), 27 deletions(-)
diff --git a/drivers/gpu/drm/drm_client.c b/drivers/gpu/drm/drm_client.c
index 82b871d62313..5ad82ab8b15f 100644
--- a/drivers/gpu/drm/drm_client.c
+++ b/drivers/gpu/drm/drm_client.c
@@ -188,11 +188,8 @@ static void drm_client_buffer_delete(struct drm_client_buffer *buffer)
static struct drm_client_buffer *
drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height,
- u32 format, u32 *handle, u32 *pitch)
+ u32 format, u32 handle, u32 pitch)
{
- const struct drm_format_info *info = drm_format_info(format);
- struct drm_mode_create_dumb dumb_args = { };
- struct drm_device *dev = client->dev;
struct drm_client_buffer *buffer;
struct drm_gem_object *obj;
int ret;
@@ -203,28 +200,18 @@ drm_client_buffer_create(struct drm_client_dev *client, u32 width, u32 height,
buffer->client = client;
- dumb_args.width = width;
- dumb_args.height = height;
- dumb_args.bpp = drm_format_info_bpp(info, 0);
- ret = drm_mode_create_dumb(dev, &dumb_args, client->file);
- if (ret)
- goto err_delete;
-
- obj = drm_gem_object_lookup(client->file, dumb_args.handle);
+ obj = drm_gem_object_lookup(client->file, handle);
if (!obj) {
ret = -ENOENT;
goto err_delete;
}
buffer->gem = obj;
- *handle = dumb_args.handle;
- *pitch = dumb_args.pitch;
return buffer;
err_delete:
- drm_client_buffer_delete(buffer);
-
+ kfree(buffer);
return ERR_PTR(ret);
}
@@ -398,16 +385,30 @@ static int drm_client_buffer_addfb(struct drm_client_buffer *buffer,
struct drm_client_buffer *
drm_client_framebuffer_create(struct drm_client_dev *client, u32 width, u32 height, u32 format)
{
+ const struct drm_format_info *info = drm_format_info(format);
+ struct drm_device *dev = client->dev;
+ struct drm_mode_create_dumb dumb_args = { };
struct drm_client_buffer *buffer;
- u32 handle, pitch;
int ret;
+ dumb_args.width = width;
+ dumb_args.height = height;
+ dumb_args.bpp = drm_format_info_bpp(info, 0);
+ ret = drm_mode_create_dumb(dev, &dumb_args, client->file);
+ if (ret)
+ return ERR_PTR(ret);
+
buffer = drm_client_buffer_create(client, width, height, format,
- &handle, &pitch);
- if (IS_ERR(buffer))
- return buffer;
+ dumb_args.handle, dumb_args.pitch);
+ if (IS_ERR(buffer)) {
+ ret = PTR_ERR(buffer);
+ goto err_drm_mode_destroy_dumb;
+ }
- ret = drm_client_buffer_addfb(buffer, width, height, format, handle, pitch);
+ ret = drm_client_buffer_addfb(buffer, width, height, format,
+ dumb_args.handle, dumb_args.pitch);
+ if (ret)
+ goto err_drm_client_buffer_delete;
/*
* The handle is only needed for creating the framebuffer, destroy it
@@ -415,14 +416,15 @@ drm_client_framebuffer_create(struct drm_client_dev *client, u32 width, u32 heig
* object as DMA-buf. The framebuffer and our buffer structure are still
* holding references to the GEM object to prevent its destruction.
*/
- drm_mode_destroy_dumb(client->dev, handle, client->file);
-
- if (ret) {
- drm_client_buffer_delete(buffer);
- return ERR_PTR(ret);
- }
+ drm_mode_destroy_dumb(client->dev, dumb_args.handle, client->file);
return buffer;
+
+err_drm_client_buffer_delete:
+ drm_client_buffer_delete(buffer);
+err_drm_mode_destroy_dumb:
+ drm_mode_destroy_dumb(client->dev, dumb_args.handle, client->file);
+ return ERR_PTR(ret);
}
EXPORT_SYMBOL(drm_client_framebuffer_create);
--
2.51.1
next prev parent reply other threads:[~2025-10-27 12:11 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-27 12:09 [PATCH v2 0/7] drm/client: Simply client-buffer interface and implementation Thomas Zimmermann
2025-10-27 12:09 ` [PATCH v2 1/7] drm/client: Remove pitch from struct drm_client_buffer Thomas Zimmermann
2025-10-27 12:09 ` Thomas Zimmermann [this message]
2025-10-27 12:09 ` [PATCH v2 3/7] drm/client: Inline drm_client_buffer_addfb() and _rmfb() Thomas Zimmermann
2025-10-27 12:09 ` [PATCH v2 4/7] drm/client: Deprecate struct drm_client_buffer.gem Thomas Zimmermann
2025-10-31 15:49 ` [REGRESSION][ASAN] " Ian Forbes
2025-11-03 12:15 ` Thomas Zimmermann
2025-11-04 10:52 ` Thomas Zimmermann
2025-10-27 12:09 ` [PATCH v2 5/7] drm/client: Remove drm_client_framebuffer_delete() Thomas Zimmermann
2025-10-27 12:09 ` [PATCH v2 6/7] drm/client: Create client buffers with drm_client_buffer_create_dumb() Thomas Zimmermann
2025-10-27 12:09 ` [PATCH v2 7/7] drm/client: Flush client buffers with drm_client_buffer_sync() Thomas Zimmermann
2025-10-27 14:24 ` Jocelyn Falempe
2025-10-28 17:22 ` [PATCH v2 0/7] drm/client: Simply client-buffer interface and implementation Francesco Valla
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=20251027121042.143588-3-tzimmermann@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=francesco@valla.it \
--cc=javierm@redhat.com \
--cc=jfalempe@redhat.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=rrameshbabu@nvidia.com \
/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