drm/i915: initialize the context idr unconditionally
authorDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 19 Jun 2012 14:52:30 +0000 (16:52 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Wed, 20 Jun 2012 09:15:37 +0000 (11:15 +0200)
It doesn't hurt and it at least prevents us from OOPSing left and
right at quite a few places. This also allows us to simplify the code
a bit by folding the only line of context_open into the callsite.

We obviuosly also need to run the cleanup code unconditionally, too.

Reviewed-by: Ben Widawsky <ben@bwidawsk.net>
Signed-Off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
drivers/gpu/drm/i915/i915_dma.c
drivers/gpu/drm/i915/i915_drv.h
drivers/gpu/drm/i915/i915_gem_context.c

index 9913a77478a314adc5005f83c3fc00407eb5abf0..9563ab8390e7cc92a2d67f9da23554492c1c4f33 100644 (file)
@@ -1759,7 +1759,7 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file)
        spin_lock_init(&file_priv->mm.lock);
        INIT_LIST_HEAD(&file_priv->mm.request_list);
 
-       i915_gem_context_open(dev, file);
+       idr_init(&file_priv->context_idr);
 
        return 0;
 }
index 6f29fd141ab0b24f4781a35738d338617d1c6b2b..82e657eafd5524a6b1c5e406e07214548825a00c 100644 (file)
@@ -1383,7 +1383,6 @@ struct dma_buf *i915_gem_prime_export(struct drm_device *dev,
 /* i915_gem_context.c */
 void i915_gem_context_init(struct drm_device *dev);
 void i915_gem_context_fini(struct drm_device *dev);
-void i915_gem_context_open(struct drm_device *dev, struct drm_file *file);
 void i915_gem_context_close(struct drm_device *dev, struct drm_file *file);
 int i915_switch_context(struct intel_ring_buffer *ring,
                        struct drm_file *file, int to_id);
index 48e41df075b902451a196c76b14fd31e0ccad879..047f81c206b3a86103a52f598aba01fe51236adb 100644 (file)
@@ -287,17 +287,6 @@ void i915_gem_context_fini(struct drm_device *dev)
        do_destroy(dev_priv->ring[RCS].default_context);
 }
 
-void i915_gem_context_open(struct drm_device *dev, struct drm_file *file)
-{
-       struct drm_i915_private *dev_priv = dev->dev_private;
-       struct drm_i915_file_private *file_priv = file->driver_priv;
-
-       if (dev_priv->hw_contexts_disabled)
-               return;
-
-       idr_init(&file_priv->context_idr);
-}
-
 static int context_idr_cleanup(int id, void *p, void *data)
 {
        struct drm_file *file = (struct drm_file *)data;
@@ -316,12 +305,8 @@ static int context_idr_cleanup(int id, void *p, void *data)
 
 void i915_gem_context_close(struct drm_device *dev, struct drm_file *file)
 {
-       struct drm_i915_private *dev_priv = dev->dev_private;
        struct drm_i915_file_private *file_priv = file->driver_priv;
 
-       if (dev_priv->hw_contexts_disabled)
-               return;
-
        mutex_lock(&dev->struct_mutex);
        idr_for_each(&file_priv->context_idr, context_idr_cleanup, file);
        idr_destroy(&file_priv->context_idr);