Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma
[deliverable/linux.git] / drivers / gpu / drm / drm_fops.c
index 59f4592910937acc21306296735433891a83a202..4be8e09a32ef730db4740f6f69e52f91ca829112 100644 (file)
@@ -219,7 +219,7 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
                return -EBUSY;  /* No exclusive opens */
        if (!drm_cpu_valid())
                return -EINVAL;
-       if (dev->switch_power_state != DRM_SWITCH_POWER_ON)
+       if (dev->switch_power_state != DRM_SWITCH_POWER_ON && dev->switch_power_state != DRM_SWITCH_POWER_DYNAMIC_OFF)
                return -EINVAL;
 
        DRM_DEBUG("pid = %d, minor = %d\n", task_pid_nr(current), minor_id);
@@ -262,10 +262,10 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
                        goto out_prime_destroy;
        }
 
-
-       /* if there is no current master make this fd it */
+       /* if there is no current master make this fd it, but do not create
+        * any master object for render clients */
        mutex_lock(&dev->struct_mutex);
-       if (!priv->minor->master) {
+       if (!priv->minor->master && !drm_is_render_client(priv)) {
                /* create a new master */
                priv->minor->master = drm_master_create(priv->minor);
                if (!priv->minor->master) {
@@ -303,12 +303,11 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
                                goto out_close;
                        }
                }
-               mutex_unlock(&dev->struct_mutex);
-       } else {
+       } else if (!drm_is_render_client(priv)) {
                /* get a reference to the master */
                priv->master = drm_master_get(priv->minor->master);
-               mutex_unlock(&dev->struct_mutex);
        }
+       mutex_unlock(&dev->struct_mutex);
 
        mutex_lock(&dev->struct_mutex);
        list_add(&priv->lhead, &dev->filelist);
@@ -478,7 +477,8 @@ int drm_release(struct inode *inode, struct file *filp)
        iput(container_of(dev->dev_mapping, struct inode, i_data));
 
        /* drop the reference held my the file priv */
-       drm_master_put(&file_priv->master);
+       if (file_priv->master)
+               drm_master_put(&file_priv->master);
        file_priv->is_master = 0;
        list_del(&file_priv->lhead);
        mutex_unlock(&dev->struct_mutex);
@@ -486,6 +486,7 @@ int drm_release(struct inode *inode, struct file *filp)
        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.045623 seconds and 5 git commands to generate.