Commit 1d48b9e9 authored by Thomas Zimmermann's avatar Thomas Zimmermann

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: default avatarThomas Zimmermann <tzimmermann@suse.de>
Acked-by: default avatarGerd Hoffmann <kraxel@redhat.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191107094307.19870-3-tzimmermann@suse.de
parent 92c4eeb0
...@@ -64,6 +64,7 @@ static struct drm_driver driver = { ...@@ -64,6 +64,7 @@ static struct drm_driver driver = {
/* gem hooks */ /* gem hooks */
.gem_free_object_unlocked = udl_gem_free_object, .gem_free_object_unlocked = udl_gem_free_object,
.gem_create_object = udl_driver_gem_create_object,
.gem_vm_ops = &udl_gem_vm_ops, .gem_vm_ops = &udl_gem_vm_ops,
.dumb_create = udl_dumb_create, .dumb_create = udl_dumb_create,
......
...@@ -125,6 +125,8 @@ int udl_dumb_create(struct drm_file *file_priv, ...@@ -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, int udl_gem_mmap(struct drm_file *file_priv, struct drm_device *dev,
uint32_t handle, uint64_t *offset); 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); void udl_gem_free_object(struct drm_gem_object *gem_obj);
struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev, struct udl_gem_object *udl_gem_alloc_object(struct drm_device *dev,
size_t size); size_t size);
......
...@@ -6,26 +6,43 @@ ...@@ -6,26 +6,43 @@
#include <linux/dma-buf.h> #include <linux/dma-buf.h>
#include <linux/vmalloc.h> #include <linux/vmalloc.h>
#include <drm/drm_drv.h>
#include <drm/drm_mode.h> #include <drm/drm_mode.h>
#include <drm/drm_prime.h> #include <drm/drm_prime.h>
#include "udl_drv.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; struct udl_gem_object *obj;
obj = kzalloc(sizeof(*obj), GFP_KERNEL); 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) if (obj == NULL)
return NULL; return NULL;
if (drm_gem_object_init(dev, &obj->base, size) != 0) { if (drm_gem_object_init(dev, obj, size) != 0) {
kfree(obj); kfree(obj);
return NULL; return NULL;
} }
return obj; return to_udl_bo(obj);
} }
static int static int
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment