From: Thomas Zimmermann Date: Mon, 6 Jan 2020 12:57:45 +0000 (+0100) Subject: drm/vram-helper: Support struct drm_driver.gem_create_object X-Git-Tag: v5.15~303^2~28^2~3722 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0fb5f69e19643569b6d42ce437a830e95555f1e5;p=platform%2Fkernel%2Flinux-starfive.git drm/vram-helper: Support struct drm_driver.gem_create_object Drivers that what to allocate VRAM GEM objects with additional fields can now do this by implementing struct drm_driver.gem_create_object. v3: * separately check allocation failure in if/else branches before upcast to gbo v2: * only cast to gbo within if branch; set gbo directly in else branch Signed-off-by: Thomas Zimmermann Reviewed-by: Daniel Vetter Acked-by: Sam Ravnborg Link: https://patchwork.freedesktop.org/patch/msgid/20200106125745.13797-9-tzimmermann@suse.de --- diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c index 942af7ed..a486332 100644 --- a/drivers/gpu/drm/drm_gem_vram_helper.c +++ b/drivers/gpu/drm/drm_gem_vram_helper.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -145,9 +146,17 @@ struct drm_gem_vram_object *drm_gem_vram_create(struct drm_device *dev, struct drm_gem_vram_object *gbo; int ret; - gbo = kzalloc(sizeof(*gbo), GFP_KERNEL); - if (!gbo) - return ERR_PTR(-ENOMEM); + if (dev->driver->gem_create_object) { + struct drm_gem_object *gem = + dev->driver->gem_create_object(dev, size); + if (!gem) + return ERR_PTR(-ENOMEM); + gbo = drm_gem_vram_of_gem(gem); + } else { + gbo = kzalloc(sizeof(*gbo), GFP_KERNEL); + if (!gbo) + return ERR_PTR(-ENOMEM); + } ret = drm_gem_vram_init(dev, gbo, size, pg_align); if (ret < 0)