Use the pitch and size values stored in the args parameter for allocating a dumb buffer in drm_gem_vram_dumb_create(). Inline the relevant code from drm_gem_vram_fill_create_dumb(), but without the size computation. This value comes from drm_mode_create_dumb(). Align the pitch to a multiple of 8. Only hibmc and vboxvideo use gem-vram. Hibmc invokes the call to drm_gem_vram_fill_create_dumb() directly and is therefore not affected. Signed-off-by: Thomas Zimmermann <tzimmermann@xxxxxxx> --- drivers/gpu/drm/drm_gem_vram_helper.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index 22b1fe9c03b8..0d1a9cce47e7 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -6,6 +6,7 @@ #include <drm/drm_debugfs.h> #include <drm/drm_device.h> #include <drm/drm_drv.h> +#include <drm/drm_dumb_buffers.h> #include <drm/drm_file.h> #include <drm/drm_framebuffer.h> #include <drm/drm_gem_atomic_helper.h> @@ -582,10 +583,31 @@ int drm_gem_vram_driver_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args) { + struct drm_gem_vram_object *gbo; + int ret; + if (WARN_ONCE(!dev->vram_mm, "VRAM MM not initialized")) return -EINVAL; - return drm_gem_vram_fill_create_dumb(file, dev, 0, 0, args); + ret = drm_mode_align_dumb(args, 8, 0); + if (ret) + return ret; + + gbo = drm_gem_vram_create(dev, args->size, 0); + if (IS_ERR(gbo)) + return PTR_ERR(gbo); + + ret = drm_gem_handle_create(file, &gbo->bo.base, &args->handle); + if (ret) + goto err_drm_gem_object_put; + + drm_gem_object_put(&gbo->bo.base); + + return 0; + +err_drm_gem_object_put: + drm_gem_object_put(&gbo->bo.base); + return ret; } EXPORT_SYMBOL(drm_gem_vram_driver_dumb_create); -- 2.47.0