summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2013-11-27 20:41:20 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2013-11-27 20:41:20 +0000
commitb179af997c19328f308520ec8342ea71f362bc6e (patch)
treeb73636505c82b98df2a218e8df3c889a93f844cf
parent791aa4b8eef5b21ba07f7b8c6ad2437f942ecc08 (diff)
Hook up gem_open/close_object methods.
ok jsg@
-rw-r--r--sys/dev/pci/drm/drmP.h17
-rw-r--r--sys/dev/pci/drm/drm_drv.c20
-rw-r--r--sys/dev/pci/drm/radeon/radeon_kms.c4
3 files changed, 29 insertions, 12 deletions
diff --git a/sys/dev/pci/drm/drmP.h b/sys/dev/pci/drm/drmP.h
index 8720bd43df2..081682538f2 100644
--- a/sys/dev/pci/drm/drmP.h
+++ b/sys/dev/pci/drm/drmP.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: drmP.h,v 1.153 2013/11/19 19:14:09 kettenis Exp $ */
+/* $OpenBSD: drmP.h,v 1.154 2013/11/27 20:41:19 kettenis Exp $ */
/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
* Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
*/
@@ -638,12 +638,17 @@ struct drm_driver_info {
int (*get_vblank_timestamp)(struct drm_device *, int, int *,
struct timeval *, unsigned);;
- /*
- * driver-specific constructor for gem objects to set up private data.
- * returns 0 on success.
+ /**
+ * Driver-specific constructor for drm_gem_objects, to set up
+ * obj->driver_private.
+ *
+ * Returns 0 on success.
*/
- int (*gem_init_object)(struct drm_obj *);
- void (*gem_free_object)(struct drm_obj *);
+ int (*gem_init_object) (struct drm_obj *obj);
+ void (*gem_free_object) (struct drm_obj *obj);
+ int (*gem_open_object) (struct drm_obj *, struct drm_file *);
+ void (*gem_close_object) (struct drm_obj *, struct drm_file *);
+
int (*gem_fault)(struct drm_obj *, struct uvm_faultinfo *, off_t,
vaddr_t, vm_page_t *, int, int, vm_prot_t, int);
diff --git a/sys/dev/pci/drm/drm_drv.c b/sys/dev/pci/drm/drm_drv.c
index e78771ec7b9..dbd34b98360 100644
--- a/sys/dev/pci/drm/drm_drv.c
+++ b/sys/dev/pci/drm/drm_drv.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: drm_drv.c,v 1.116 2013/11/02 22:58:10 kettenis Exp $ */
+/* $OpenBSD: drm_drv.c,v 1.117 2013/11/27 20:41:19 kettenis Exp $ */
/*-
* Copyright 2007-2009 Owain G. Ainsworth <oga@openbsd.org>
* Copyright © 2008 Intel Corporation
@@ -1536,7 +1536,9 @@ drm_gem_handle_create(struct drm_file *file_priv,
struct drm_obj *obj,
u32 *handlep)
{
- struct drm_handle *han;
+ struct drm_device *dev = obj->dev;
+ struct drm_handle *han;
+ int ret;
if ((han = drm_calloc(1, sizeof(*han))) == NULL)
return -ENOMEM;
@@ -1556,6 +1558,14 @@ again:
drm_gem_object_handle_reference(obj);
+ if (dev->driver->gem_open_object) {
+ ret = dev->driver->gem_open_object(obj, file_priv);
+ if (ret) {
+ drm_gem_handle_delete(file_priv, *handlep);
+ return ret;
+ }
+ }
+
return 0;
}
@@ -1565,6 +1575,7 @@ again:
int
drm_gem_handle_delete(struct drm_file *filp, u32 handle)
{
+ struct drm_device *dev;
struct drm_obj *obj;
struct drm_handle *han, find;
@@ -1575,13 +1586,16 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
mtx_leave(&filp->table_lock);
return -EINVAL;
}
-
obj = han->obj;
+ dev = obj->dev;
+
SPLAY_REMOVE(drm_obj_tree, &filp->obj_tree, han);
mtx_leave(&filp->table_lock);
drm_free(han);
+ if (dev->driver->gem_close_object)
+ dev->driver->gem_close_object(obj, filp);
drm_gem_object_handle_unreference_unlocked(obj);
return 0;
diff --git a/sys/dev/pci/drm/radeon/radeon_kms.c b/sys/dev/pci/drm/radeon/radeon_kms.c
index 1d26c3ad6e8..dff41e59a0b 100644
--- a/sys/dev/pci/drm/radeon/radeon_kms.c
+++ b/sys/dev/pci/drm/radeon/radeon_kms.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: radeon_kms.c,v 1.11 2013/11/17 13:41:26 kettenis Exp $ */
+/* $OpenBSD: radeon_kms.c,v 1.12 2013/11/27 20:41:19 kettenis Exp $ */
/*
* Copyright 2008 Advanced Micro Devices, Inc.
* Copyright 2008 Red Hat Inc.
@@ -217,10 +217,8 @@ static struct drm_driver_info kms_driver = {
.irq_handler = radeon_driver_irq_handler_kms,
.gem_init_object = radeon_gem_object_init,
.gem_free_object = radeon_gem_object_free,
-#ifdef notyet
.gem_open_object = radeon_gem_object_open,
.gem_close_object = radeon_gem_object_close,
-#endif
.gem_size = sizeof(struct radeon_bo),
.dma_ioctl = radeon_dma_ioctl_kms,
.dumb_create = radeon_mode_dumb_create,