diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-06-19 10:52:30 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2012-06-20 05:15:37 -0400 |
commit | df12c6d5ec9b88fc45c672b77dac015327dd8497 (patch) | |
tree | af9c859549840b8c5fc8b8f9e9a2ca991040212e | |
parent | 55a6662837a5efe48c836bfc3570ace348f3db09 (diff) |
drm/i915: initialize the context idr unconditionally
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>
-rw-r--r-- | drivers/gpu/drm/i915/i915_dma.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_context.c | 15 |
3 files changed, 1 insertions, 17 deletions
diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index 9913a77478a..9563ab8390e 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c | |||
@@ -1759,7 +1759,7 @@ int i915_driver_open(struct drm_device *dev, struct drm_file *file) | |||
1759 | spin_lock_init(&file_priv->mm.lock); | 1759 | spin_lock_init(&file_priv->mm.lock); |
1760 | INIT_LIST_HEAD(&file_priv->mm.request_list); | 1760 | INIT_LIST_HEAD(&file_priv->mm.request_list); |
1761 | 1761 | ||
1762 | i915_gem_context_open(dev, file); | 1762 | idr_init(&file_priv->context_idr); |
1763 | 1763 | ||
1764 | return 0; | 1764 | return 0; |
1765 | } | 1765 | } |
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 6f29fd141ab..82e657eafd5 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
@@ -1383,7 +1383,6 @@ struct dma_buf *i915_gem_prime_export(struct drm_device *dev, | |||
1383 | /* i915_gem_context.c */ | 1383 | /* i915_gem_context.c */ |
1384 | void i915_gem_context_init(struct drm_device *dev); | 1384 | void i915_gem_context_init(struct drm_device *dev); |
1385 | void i915_gem_context_fini(struct drm_device *dev); | 1385 | void i915_gem_context_fini(struct drm_device *dev); |
1386 | void i915_gem_context_open(struct drm_device *dev, struct drm_file *file); | ||
1387 | void i915_gem_context_close(struct drm_device *dev, struct drm_file *file); | 1386 | void i915_gem_context_close(struct drm_device *dev, struct drm_file *file); |
1388 | int i915_switch_context(struct intel_ring_buffer *ring, | 1387 | int i915_switch_context(struct intel_ring_buffer *ring, |
1389 | struct drm_file *file, int to_id); | 1388 | struct drm_file *file, int to_id); |
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index 48e41df075b..047f81c206b 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c | |||
@@ -287,17 +287,6 @@ void i915_gem_context_fini(struct drm_device *dev) | |||
287 | do_destroy(dev_priv->ring[RCS].default_context); | 287 | do_destroy(dev_priv->ring[RCS].default_context); |
288 | } | 288 | } |
289 | 289 | ||
290 | void i915_gem_context_open(struct drm_device *dev, struct drm_file *file) | ||
291 | { | ||
292 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
293 | struct drm_i915_file_private *file_priv = file->driver_priv; | ||
294 | |||
295 | if (dev_priv->hw_contexts_disabled) | ||
296 | return; | ||
297 | |||
298 | idr_init(&file_priv->context_idr); | ||
299 | } | ||
300 | |||
301 | static int context_idr_cleanup(int id, void *p, void *data) | 290 | static int context_idr_cleanup(int id, void *p, void *data) |
302 | { | 291 | { |
303 | struct drm_file *file = (struct drm_file *)data; | 292 | struct drm_file *file = (struct drm_file *)data; |
@@ -316,12 +305,8 @@ static int context_idr_cleanup(int id, void *p, void *data) | |||
316 | 305 | ||
317 | void i915_gem_context_close(struct drm_device *dev, struct drm_file *file) | 306 | void i915_gem_context_close(struct drm_device *dev, struct drm_file *file) |
318 | { | 307 | { |
319 | struct drm_i915_private *dev_priv = dev->dev_private; | ||
320 | struct drm_i915_file_private *file_priv = file->driver_priv; | 308 | struct drm_i915_file_private *file_priv = file->driver_priv; |
321 | 309 | ||
322 | if (dev_priv->hw_contexts_disabled) | ||
323 | return; | ||
324 | |||
325 | mutex_lock(&dev->struct_mutex); | 310 | mutex_lock(&dev->struct_mutex); |
326 | idr_for_each(&file_priv->context_idr, context_idr_cleanup, file); | 311 | idr_for_each(&file_priv->context_idr, context_idr_cleanup, file); |
327 | idr_destroy(&file_priv->context_idr); | 312 | idr_destroy(&file_priv->context_idr); |