From: Oscar Mateo <oscar.mateo@xxxxxxxxx> Since context IDs are not globally unique anymore (they are only unique for a given file descriptor), we can use the new file_priv ID in combination with the context ID to unequivocally refer to a context. The ID 0 remains to be used internally by i915 (meaning no file_priv). Signed-off-by: Oscar Mateo <oscar.mateo@xxxxxxxxx> --- drivers/gpu/drm/i915/i915_dma.c | 14 +++++++++++--- drivers/gpu/drm/i915/i915_drv.h | 3 +++ drivers/gpu/drm/i915/i915_gem.c | 9 +++++++++ 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_dma.c b/drivers/gpu/drm/i915/i915_dma.c index ea5d965..7188403 100644 --- a/drivers/gpu/drm/i915/i915_dma.c +++ b/drivers/gpu/drm/i915/i915_dma.c @@ -1567,6 +1567,8 @@ int i915_driver_load(struct drm_device *dev, unsigned long flags) device_info = (struct intel_device_info *)&dev_priv->info; *device_info = *info; + idr_init(&dev_priv->filepriv_idr); + spin_lock_init(&dev_priv->irq_lock); spin_lock_init(&dev_priv->gpu_error.lock); spin_lock_init(&dev_priv->backlight_lock); @@ -1867,6 +1869,8 @@ int i915_driver_unload(struct drm_device *dev) if (dev_priv->slab) kmem_cache_destroy(dev_priv->slab); + idr_destroy(&dev_priv->filepriv_idr); + pci_dev_put(dev_priv->bridge_dev); kfree(dev->dev_private); @@ -1917,11 +1921,15 @@ void i915_driver_lastclose(struct drm_device * dev) i915_dma_cleanup(dev); } -void i915_driver_preclose(struct drm_device * dev, struct drm_file *file_priv) +void i915_driver_preclose(struct drm_device * dev, struct drm_file *file) { + drm_i915_private_t *dev_priv = dev->dev_private; + struct drm_i915_file_private *file_priv = file->driver_priv; + mutex_lock(&dev->struct_mutex); - i915_gem_context_close(dev, file_priv); - i915_gem_release(dev, file_priv); + idr_remove(&dev_priv->filepriv_idr, file_priv->id); + i915_gem_context_close(dev, file); + i915_gem_release(dev, file); mutex_unlock(&dev->struct_mutex); } diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index a9f807b..2f6e55d 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -1268,6 +1268,8 @@ typedef struct drm_i915_private { const struct intel_device_info info; + struct idr filepriv_idr; + int relative_constants_mode; void __iomem *regs; @@ -1676,6 +1678,7 @@ struct drm_i915_gem_request { struct drm_i915_file_private { struct drm_i915_private *dev_priv; struct drm_file *file; + int id; struct { spinlock_t lock; diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index e844c50..07d88847 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c @@ -4879,6 +4879,7 @@ i915_gem_file_idle_work_handler(struct work_struct *work) int i915_gem_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; int ret; @@ -4892,6 +4893,14 @@ int i915_gem_open(struct drm_device *dev, struct drm_file *file) file_priv->dev_priv = dev->dev_private; file_priv->file = file; + ret = idr_alloc(&dev_priv->filepriv_idr, file_priv, 0, 0, GFP_KERNEL); + if (ret < 0) { + kfree(file_priv); + return ret; + } + + file_priv->id = ret; + spin_lock_init(&file_priv->mm.lock); INIT_LIST_HEAD(&file_priv->mm.request_list); INIT_DELAYED_WORK(&file_priv->mm.idle_work, -- 1.9.0 _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx http://lists.freedesktop.org/mailman/listinfo/intel-gfx