Thomas Zimmermann
2025-Feb-18 14:23 UTC
[PATCH v3 06/25] drm/armada: Compute dumb-buffer sizes with drm_mode_size_dumb()
Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and
buffer size. No alignment required.
Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
Cc: Russell King <linux at armlinux.org.uk>
---
drivers/gpu/drm/armada/armada_gem.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git a/drivers/gpu/drm/armada/armada_gem.c
b/drivers/gpu/drm/armada/armada_gem.c
index 1a1680d71486..0f11ae06064a 100644
--- a/drivers/gpu/drm/armada/armada_gem.c
+++ b/drivers/gpu/drm/armada/armada_gem.c
@@ -9,6 +9,7 @@
#include <linux/shmem_fs.h>
#include <drm/armada_drm.h>
+#include <drm/drm_dumb_buffers.h>
#include <drm/drm_prime.h>
#include "armada_drm.h"
@@ -244,14 +245,13 @@ int armada_gem_dumb_create(struct drm_file *file, struct
drm_device *dev,
struct drm_mode_create_dumb *args)
{
struct armada_gem_object *dobj;
- u32 handle;
- size_t size;
int ret;
- args->pitch = armada_pitch(args->width, args->bpp);
- args->size = size = args->pitch * args->height;
+ ret = drm_mode_size_dumb(dev, args, 0, 0);
+ if (ret)
+ return ret;
- dobj = armada_gem_alloc_private_object(dev, size);
+ dobj = armada_gem_alloc_private_object(dev, args->size);
if (dobj == NULL)
return -ENOMEM;
@@ -259,14 +259,12 @@ int armada_gem_dumb_create(struct drm_file *file, struct
drm_device *dev,
if (ret)
goto err;
- ret = drm_gem_handle_create(file, &dobj->obj, &handle);
+ ret = drm_gem_handle_create(file, &dobj->obj, &args->handle);
if (ret)
goto err;
- args->handle = handle;
-
/* drop reference from allocate - handle holds it now */
- DRM_DEBUG_DRIVER("obj %p size %zu handle %#x\n", dobj, size,
handle);
+ DRM_DEBUG_DRIVER("obj %p size %llu handle %#x\n", dobj,
args->size, args->handle);
err:
drm_gem_object_put(&dobj->obj);
return ret;
--
2.48.1
Russell King (Oracle)
2025-Feb-18 15:57 UTC
[PATCH v3 06/25] drm/armada: Compute dumb-buffer sizes with drm_mode_size_dumb()
On Tue, Feb 18, 2025 at 03:23:29PM +0100, Thomas Zimmermann wrote:> Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and > buffer size. No alignment required. > > Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de> > Cc: Russell King <linux at armlinux.org.uk>armada_pitch() does have some special alignment (it aligns the pitch to 128 bytes). I've no idea what drm_mode_size_dumb() does. Can you check whether it does the same please? If it doesn't, then this patch is incorrect. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!