Message ID | 20250218142542.438557-7-tzimmermann@suse.de (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | drm/dumb-buffers: Fix and improve buffer-size calculation | expand |
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@suse.de> > Cc: Russell King <linux@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.
Hi Am 18.02.25 um 16:57 schrieb Russell King (Oracle): > 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@suse.de> >> Cc: Russell King <linux@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. Indeed, I should have noticed. Will be fixed in the next iteration. Thanks for the review. Best regards Thomas >
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;
Call drm_mode_size_dumb() to compute dumb-buffer scanline pitch and buffer size. No alignment required. Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Cc: Russell King <linux@armlinux.org.uk> --- drivers/gpu/drm/armada/armada_gem.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)