@@ -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);
}
@@ -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;
@@ -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,