From: Gabriel Gama <operatingsystemsdepression@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: patrik.r.jakobsson@gmail.com,
Gabriel Gama <operatingsystemsdepression@gmail.com>
Subject: [RFC PATCH 1/6] drm/gma500: use the common dumb-buffer size helper
Date: Mon, 9 Nov 2026 02:54:45 -0300 [thread overview]
Message-ID: <20261109055451.17458-2-operatingsystemsdepression@gmail.com> (raw)
In-Reply-To: <20261109055451.17458-1-operatingsystemsdepression@gmail.com>
Use drm_mode_size_dumb() instead of unchecked size_t arithmetic when
calculating dumb-buffer pitch and size. Preserve 64-byte pitch alignment
and page-aligned allocations through the common DRM helper.
Signed-off-by: Gabriel Gama <operatingsystemsdepression@gmail.com>
---
drivers/gpu/drm/gma500/gem.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/gpu/drm/gma500/gem.c b/drivers/gpu/drm/gma500/gem.c
index 2708e8c68..7250bf660 100644
--- a/drivers/gpu/drm/gma500/gem.c
+++ b/drivers/gpu/drm/gma500/gem.c
@@ -16,6 +16,7 @@
#include <asm/set_memory.h>
#include <drm/drm.h>
+#include <drm/drm_dumb_buffers.h>
#include <drm/drm_print.h>
#include <drm/drm_vma_manager.h>
@@ -200,21 +201,16 @@ psb_gem_create(struct drm_device *dev, u64 size, const char *name, bool stolen,
int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
struct drm_mode_create_dumb *args)
{
- size_t pitch, size;
struct psb_gem_object *pobj;
struct drm_gem_object *obj;
u32 handle;
int ret;
- pitch = args->width * DIV_ROUND_UP(args->bpp, 8);
- pitch = ALIGN(pitch, 64);
-
- size = pitch * args->height;
- size = roundup(size, PAGE_SIZE);
- if (!size)
- return -EINVAL;
+ ret = drm_mode_size_dumb(dev, args, 64, 0);
+ if (ret)
+ return ret;
- pobj = psb_gem_create(dev, size, "gem", false, PAGE_SIZE);
+ pobj = psb_gem_create(dev, args->size, "gem", false, PAGE_SIZE);
if (IS_ERR(pobj))
return PTR_ERR(pobj);
obj = &pobj->base;
@@ -225,8 +221,6 @@ int psb_gem_dumb_create(struct drm_file *file, struct drm_device *dev,
drm_gem_object_put(obj);
- args->pitch = pitch;
- args->size = size;
args->handle = handle;
return 0;
next prev parent reply other threads:[~2026-11-09 5:55 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-09 5:54 [RFC PATCH 0/6] drm/gma500: prepare GEM and MMU for 3D rendering and hybrid 2D Gabriel Gama
2026-11-09 5:54 ` Gabriel Gama [this message]
2026-11-09 5:54 ` [RFC PATCH 2/6] drm/gma500: do not underflow an unpinned GEM object Gabriel Gama
2026-11-09 5:54 ` [RFC PATCH 3/6] drm/gma500: Fix SGX page-table cache-flush mapping lifetime Gabriel Gama
2026-11-09 6:00 ` sashiko-bot
2026-11-09 5:54 ` [RFC PATCH 4/6] drm/gma500: Make SGX MMU insertion checked and transactional Gabriel Gama
2026-11-09 5:54 ` [RFC PATCH 5/6] drm/gma500: Propagate SGX MMU setup and GEM pin failures Gabriel Gama
2026-11-09 6:06 ` sashiko-bot
2026-11-09 5:54 ` [RFC PATCH 6/6] drm/gma500: Add software-only KUnit coverage for SGX page tables Gabriel Gama
2026-11-09 6:07 ` sashiko-bot
2026-11-09 6:26 ` Operating System's Depression
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=20261109055451.17458-2-operatingsystemsdepression@gmail.com \
--to=operatingsystemsdepression@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=patrik.r.jakobsson@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.