aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Skeggs <bskeggs@redhat.com>2011-06-08 20:24:59 -0400
committerDave Airlie <airlied@redhat.com>2011-06-20 22:32:33 -0400
commit304eda32920b5e23f6b9bc12eb40c7dc52a464ba (patch)
treec36e760a7ea45158999fe541134bff7841af94c5
parenta377e187df725fe7e62d2cec59ec290c5a605d93 (diff)
drm/gem: add hooks to notify driver when object handle is created/destroyed
Nouveau is going to use these hooks to map/unmap objects from a client's private GPU address space. Signed-off-by: Ben Skeggs <bskeggs@redhat.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/drm_gem.c21
-rw-r--r--include/drm/drmP.h2
2 files changed, 21 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 74e4ff578017..bad335966398 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -210,6 +210,8 @@ drm_gem_handle_delete(struct drm_file *filp, u32 handle)
210 idr_remove(&filp->object_idr, handle); 210 idr_remove(&filp->object_idr, handle);
211 spin_unlock(&filp->table_lock); 211 spin_unlock(&filp->table_lock);
212 212
213 if (dev->driver->gem_close_object)
214 dev->driver->gem_close_object(obj, filp);
213 drm_gem_object_handle_unreference_unlocked(obj); 215 drm_gem_object_handle_unreference_unlocked(obj);
214 216
215 return 0; 217 return 0;
@@ -226,7 +228,8 @@ drm_gem_handle_create(struct drm_file *file_priv,
226 struct drm_gem_object *obj, 228 struct drm_gem_object *obj,
227 u32 *handlep) 229 u32 *handlep)
228{ 230{
229 int ret; 231 struct drm_device *dev = obj->dev;
232 int ret;
230 233
231 /* 234 /*
232 * Get the user-visible handle using idr. 235 * Get the user-visible handle using idr.
@@ -247,6 +250,15 @@ again:
247 return ret; 250 return ret;
248 251
249 drm_gem_object_handle_reference(obj); 252 drm_gem_object_handle_reference(obj);
253
254 if (dev->driver->gem_open_object) {
255 ret = dev->driver->gem_open_object(obj, file_priv);
256 if (ret) {
257 drm_gem_handle_delete(file_priv, *handlep);
258 return ret;
259 }
260 }
261
250 return 0; 262 return 0;
251} 263}
252EXPORT_SYMBOL(drm_gem_handle_create); 264EXPORT_SYMBOL(drm_gem_handle_create);
@@ -401,7 +413,12 @@ drm_gem_open(struct drm_device *dev, struct drm_file *file_private)
401static int 413static int
402drm_gem_object_release_handle(int id, void *ptr, void *data) 414drm_gem_object_release_handle(int id, void *ptr, void *data)
403{ 415{
416 struct drm_file *file_priv = data;
404 struct drm_gem_object *obj = ptr; 417 struct drm_gem_object *obj = ptr;
418 struct drm_device *dev = obj->dev;
419
420 if (dev->driver->gem_close_object)
421 dev->driver->gem_close_object(obj, file_priv);
405 422
406 drm_gem_object_handle_unreference_unlocked(obj); 423 drm_gem_object_handle_unreference_unlocked(obj);
407 424
@@ -417,7 +434,7 @@ void
417drm_gem_release(struct drm_device *dev, struct drm_file *file_private) 434drm_gem_release(struct drm_device *dev, struct drm_file *file_private)
418{ 435{
419 idr_for_each(&file_private->object_idr, 436 idr_for_each(&file_private->object_idr,
420 &drm_gem_object_release_handle, NULL); 437 &drm_gem_object_release_handle, file_private);
421 438
422 idr_remove_all(&file_private->object_idr); 439 idr_remove_all(&file_private->object_idr);
423 idr_destroy(&file_private->object_idr); 440 idr_destroy(&file_private->object_idr);
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index 738b3a5faa12..4912cb75ae4c 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -886,6 +886,8 @@ struct drm_driver {
886 */ 886 */
887 int (*gem_init_object) (struct drm_gem_object *obj); 887 int (*gem_init_object) (struct drm_gem_object *obj);
888 void (*gem_free_object) (struct drm_gem_object *obj); 888 void (*gem_free_object) (struct drm_gem_object *obj);
889 int (*gem_open_object) (struct drm_gem_object *, struct drm_file *);
890 void (*gem_close_object) (struct drm_gem_object *, struct drm_file *);
889 891
890 /* vga arb irq handler */ 892 /* vga arb irq handler */
891 void (*vgaarb_irq)(struct drm_device *dev, bool state); 893 void (*vgaarb_irq)(struct drm_device *dev, bool state);