Merge branch 'for-linus-4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/mason...
[deliverable/linux.git] / drivers / gpu / drm / drm_fops.c
index 50b3de990aee08a4094900db33a88f4dfe50f338..323c238fcac70426f947977649ccd38442693e03 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/module.h>
 #include "drm_legacy.h"
 #include "drm_internal.h"
+#include "drm_crtc_internal.h"
 
 /* from BKL pushdown */
 DEFINE_MUTEX(drm_global_mutex);
@@ -229,19 +230,11 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
                        goto out_prime_destroy;
        }
 
-       /* if there is no current master make this fd it, but do not create
-        * any master object for render clients */
-       mutex_lock(&dev->master_mutex);
-       if (drm_is_primary_client(priv) && !priv->minor->master) {
-               /* create a new master */
-               ret = drm_new_set_master(dev, priv);
+       if (drm_is_primary_client(priv)) {
+               ret = drm_master_open(priv);
                if (ret)
                        goto out_close;
-       } else if (drm_is_primary_client(priv)) {
-               /* get a reference to the master */
-               priv->master = drm_master_get(priv->minor->master);
        }
-       mutex_unlock(&dev->master_mutex);
 
        mutex_lock(&dev->filelist_mutex);
        list_add(&priv->lhead, &dev->filelist);
@@ -270,7 +263,6 @@ static int drm_open_helper(struct file *filp, struct drm_minor *minor)
        return 0;
 
 out_close:
-       mutex_unlock(&dev->master_mutex);
        if (dev->driver->postclose)
                dev->driver->postclose(dev, priv);
 out_prime_destroy:
@@ -385,11 +377,6 @@ int drm_release(struct inode *inode, struct file *filp)
        list_del(&file_priv->lhead);
        mutex_unlock(&dev->filelist_mutex);
 
-       mutex_lock(&dev->struct_mutex);
-       if (file_priv->magic)
-               idr_remove(&file_priv->master->magic_map, file_priv->magic);
-       mutex_unlock(&dev->struct_mutex);
-
        if (dev->driver->preclose)
                dev->driver->preclose(dev, file_priv);
 
@@ -420,43 +407,12 @@ int drm_release(struct inode *inode, struct file *filp)
 
        drm_legacy_ctxbitmap_flush(dev, file_priv);
 
-       mutex_lock(&dev->master_mutex);
-
-       if (file_priv->is_master) {
-               struct drm_master *master = file_priv->master;
-
-               /*
-                * Since the master is disappearing, so is the
-                * possibility to lock.
-                */
-               mutex_lock(&dev->struct_mutex);
-               if (master->lock.hw_lock) {
-                       if (dev->sigdata.lock == master->lock.hw_lock)
-                               dev->sigdata.lock = NULL;
-                       master->lock.hw_lock = NULL;
-                       master->lock.file_priv = NULL;
-                       wake_up_interruptible_all(&master->lock.lock_queue);
-               }
-               mutex_unlock(&dev->struct_mutex);
-
-               if (file_priv->minor->master == file_priv->master) {
-                       /* drop the reference held my the minor */
-                       if (dev->driver->master_drop)
-                               dev->driver->master_drop(dev, file_priv, true);
-                       drm_master_put(&file_priv->minor->master);
-               }
-       }
-
-       /* drop the master reference held by the file priv */
-       if (file_priv->master)
-               drm_master_put(&file_priv->master);
-       file_priv->is_master = 0;
-       mutex_unlock(&dev->master_mutex);
+       if (drm_is_primary_client(file_priv))
+               drm_master_release(file_priv);
 
        if (dev->driver->postclose)
                dev->driver->postclose(dev, file_priv);
 
-
        if (drm_core_check_feature(dev, DRIVER_PRIME))
                drm_prime_destroy_file_private(&file_priv->prime);
 
This page took 0.030827 seconds and 5 git commands to generate.