drm: make minors independent of global lock

We used to protect minor-lookup and setup by the global drm lock. To
continue our attempts of dropping drm_global_mutex, this patch makes the
minor management independent of it. Furthermore, we make it all atomic and
switch to spin-locks instead of a mutex.

Now that minor-lookup is independent, we also move the
"drm_is_unplugged()" test into the minor-lookup path. There is no reason
to ever return a minor for unplugged objects, so keep that logic internal.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 4ce5318..8f46fe2 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -39,7 +39,7 @@
 #include <linux/slab.h>
 #include <linux/module.h>
 
-/* from BKL pushdown: note that nothing else serializes idr_find() */
+/* from BKL pushdown */
 DEFINE_MUTEX(drm_global_mutex);
 EXPORT_SYMBOL(drm_global_mutex);
 
@@ -91,11 +91,6 @@
 		return PTR_ERR(minor);
 
 	dev = minor->dev;
-	if (drm_device_is_unplugged(dev)) {
-		retcode = -ENODEV;
-		goto err_release;
-	}
-
 	if (!dev->open_count++)
 		need_setup = 1;
 	mutex_lock(&dev->struct_mutex);
@@ -127,7 +122,6 @@
 	dev->dev_mapping = old_mapping;
 	mutex_unlock(&dev->struct_mutex);
 	dev->open_count--;
-err_release:
 	drm_minor_release(minor);
 	return retcode;
 }
@@ -157,9 +151,6 @@
 		goto out_unlock;
 
 	dev = minor->dev;
-	if (drm_device_is_unplugged(dev))
-		goto out_release;
-
 	new_fops = fops_get(dev->driver->fops);
 	if (!new_fops)
 		goto out_release;