Merge branch 'for-linus' of git://git.infradead.org/users/vkoul/slave-dma
[deliverable/linux.git] / drivers / gpu / drm / drm_fops.c
index 10334999f2290362ac1e77ddd5db02cbd5def487..4be8e09a32ef730db4740f6f69e52f91ca829112 100644 (file)
@@ -48,43 +48,21 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
 
 static int drm_setup(struct drm_device * dev)
 {
-       int i;
        int ret;
 
-       if (dev->driver->firstopen) {
+       if (dev->driver->firstopen &&
+           !drm_core_check_feature(dev, DRIVER_MODESET)) {
                ret = dev->driver->firstopen(dev);
                if (ret != 0)
                        return ret;
        }
 
-       atomic_set(&dev->ioctl_count, 0);
-       atomic_set(&dev->vma_count, 0);
-
-       i = drm_legacy_dma_setup(dev);
-       if (i < 0)
-               return i;
-
-       for (i = 0; i < ARRAY_SIZE(dev->counts); i++)
-               atomic_set(&dev->counts[i], 0);
-
-       dev->sigdata.lock = NULL;
-
-       dev->context_flag = 0;
-       dev->last_context = 0;
-       dev->if_version = 0;
+       ret = drm_legacy_dma_setup(dev);
+       if (ret < 0)
+               return ret;
 
-       dev->buf_async = NULL;
 
        DRM_DEBUG("\n");
-
-       /*
-        * The kernel's context could be created here, but is now created
-        * in drm_dma_enqueue.  This is more resource-efficient for
-        * hardware that does not do DMA, but may mean that
-        * drm_select_queue fails between the time the interrupt is
-        * initialized and the time the queues are initialized.
-        */
-
        return 0;
 }
 
@@ -241,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);
@@ -284,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) {
@@ -325,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);
@@ -372,18 +349,6 @@ out_put_pid:
        return ret;
 }
 
-/** No-op. */
-int drm_fasync(int fd, struct file *filp, int on)
-{
-       struct drm_file *priv = filp->private_data;
-       struct drm_device *dev = priv->minor->dev;
-
-       DRM_DEBUG("fd = %d, device = 0x%lx\n", fd,
-                 (long)old_encode_dev(priv->minor->device));
-       return fasync_helper(fd, filp, on, &dev->buf_async);
-}
-EXPORT_SYMBOL(drm_fasync);
-
 static void drm_master_release(struct drm_device *dev, struct file *filp)
 {
        struct drm_file *file_priv = filp->private_data;
@@ -512,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);
@@ -520,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.025562 seconds and 5 git commands to generate.