diff options
author | Thomas Zimmermann <tzimmermann@suse.de> | 2019-11-07 10:43:05 +0100 |
---|---|---|
committer | Thomas Zimmermann <tzimmermann@suse.de> | 2019-11-08 12:29:56 +0100 |
commit | 1d48b9e988a8874225e38fc1ac9967666e7eafd7 (patch) | |
tree | c92c57405183818ee8bfbda2450442d9d5db7c45 /drivers/gpu/drm | |
parent | 92c4eeb0c9d2e7cc2d9ebd734bdd78cb69f72f88 (diff) | |
download | linux-1d48b9e988a8874225e38fc1ac9967666e7eafd7.tar.bz2 |
drm/udl: Allocate GEM object via struct drm_driver.gem_create_object
In preparation of a switch to SHMEM, udl now allocates its GEM
objects via struct drm_driver.gem_create_object. No functional
changes are made.
For SHMEM GEM objects, udl will require the use of a special mmap
function, which we set though the create-object function.
Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191107094307.19870-3-tzimmermann@suse.de
Diffstat (limited to 'drivers/gpu/drm')
-rw-r--r-- | drivers/gpu/drm/udl/udl_drv.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/udl/udl_drv.h | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/udl/udl_gem.c | 25 |
3 files changed, 24 insertions, 4 deletions
diff --git a/drivers/gpu/drm/udl/udl_drv.c b/drivers/gpu/drm/udl/udl_drv.c index 8426669433e4..778a0b652f64 100644 --- a/drivers/gpu/drm/udl/udl_drv.c +++ b/drivers/gpu/drm/udl/udl_drv.c @@ -64,6 +64,7 @@ static struct drm_driver driver = { /* gem hooks */ .gem_free_object_unlocked = udl_gem_free_object, + .gem_create_object = udl_driver_gem_create_object, .gem_vm_ops = &udl_gem_vm_ops, .dumb_create = udl_dumb_create, diff --git a/drivers/gpu/drm/udl/udl_drv.h b/drivers/gpu/drm/udl/udl_drv.h index e1306a51903c..fc312e791d18 100644 --- a/drivers/gpu/drm/udl/udl_drv.h +++ b/drivers/gpu/drm/udl/udl_drv.h @@ -125,6 +125,8 @@ int udl_dumb_create(struct drm_file *file_priv, int udl_gem_mmap(struct drm_file *file_priv, struct drm_device *dev, uint32_t handle, uint64_t *offset); +struct drm_gem_object *udl_driver_gem_create_object(struct drm_device *dev, + size_t size); void udl_gem_free_object(struct drm_gem_object *gem_obj); struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev, size_t size); diff --git a/drivers/gpu/drm/udl/udl_gem.c b/drivers/gpu/drm/udl/udl_gem.c index 7d3c1b73ea02..628749cc1143 100644 --- a/drivers/gpu/drm/udl/udl_gem.c +++ b/drivers/gpu/drm/udl/udl_gem.c @@ -6,26 +6,43 @@ #include <linux/dma-buf.h> #include <linux/vmalloc.h> +#include <drm/drm_drv.h> #include <drm/drm_mode.h> #include <drm/drm_prime.h> #include "udl_drv.h" -struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev, - size_t size) +/* + * Helpers for struct drm_driver + */ + +struct drm_gem_object *udl_driver_gem_create_object(struct drm_device *dev, + size_t size) { struct udl_gem_object *obj; obj = kzalloc(sizeof(*obj), GFP_KERNEL); + if (!obj) + return NULL; + + return &obj->base; +} + +struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev, + size_t size) +{ + struct drm_gem_object *obj; + + obj = dev->driver->gem_create_object(dev, size); if (obj == NULL) return NULL; - if (drm_gem_object_init(dev, &obj->base, size) != 0) { + if (drm_gem_object_init(dev, obj, size) != 0) { kfree(obj); return NULL; } - return obj; + return to_udl_bo(obj); } static int |