various fixes from trying to get userspace started
authorDave Airlie <airlied@redhat.com>
Fri, 15 Feb 2008 06:15:04 +0000 (16:15 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 15 Feb 2008 06:15:04 +0000 (16:15 +1000)
linux-core/drm_bufs.c
linux-core/drm_crtc.c
linux-core/drm_fops.c
linux-core/drm_stub.c

index 3e1767c..031f8ba 100644 (file)
@@ -318,6 +318,7 @@ static int drm_addmap_core(struct drm_device *dev, unsigned int offset,
        list->user_token = list->hash.key << PAGE_SHIFT;
        mutex_unlock(&dev->struct_mutex);
 
+       list->master = dev->primary->master;
        *maplist = list;
        return 0;
 }
index 55390a8..3a0dd9c 100644 (file)
@@ -1094,7 +1094,7 @@ int drm_crtc_set_config(struct drm_crtc *crtc, struct drm_mode_crtc *crtc_info,
                crtc->fb = fb;
                crtc->enabled = (new_mode != NULL);
                if (new_mode != NULL) {
-                       DRM_DEBUG("attempting to set mode from userspace\n");
+                       DRM_DEBUG("attempting to set mode from userspace %p\n", crtc->fb);
                        drm_mode_debug_printmodeline(dev, new_mode);
                        if (!drm_crtc_set_mode(crtc, new_mode, crtc_info->x,
                                               crtc_info->y)) {
@@ -1577,7 +1577,13 @@ int drm_mode_setcrtc(struct drm_device *dev,
                                ret = -EINVAL;
                                goto out;
                        }
+                       DRM_DEBUG("found fb %p for id %d\n", fb, crtc_req->fb_id);
+               } else {
+                       DRM_DEBUG("Unknown FB ID %d\n", crtc_req->fb_id);
+                       ret = -EINVAL;
+                       goto out;
                }
+                       
 
                mode = drm_mode_create(dev);
                drm_crtc_convert_umode(mode, &crtc_req->mode);
index 6ac09fb..5a74f42 100644 (file)
@@ -268,9 +268,9 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
                        goto out_free;
        }
 
-       mutex_lock(&dev->struct_mutex);
 
        /* if there is no current master make this fd it */
+       mutex_lock(&dev->struct_mutex);
        if (!priv->minor->master) {
                priv->minor->master = drm_get_master(priv->minor);
                if (!priv->minor->master) {
@@ -281,17 +281,22 @@ static int drm_open_helper(struct inode *inode, struct file *filp,
                priv->is_master = 1;
                priv->master = priv->minor->master;
 
+               mutex_unlock(&dev->struct_mutex);
                if (dev->driver->master_create) {
                        ret = dev->driver->master_create(dev, priv->master);
                        if (ret) {
                                drm_put_master(priv->minor->master);
                                priv->minor->master = priv->master = NULL;
+                               mutex_unlock(&dev->struct_mutex);
                                goto out_free;
                        }
                }
-       }
-       else
+       } else {
                priv->master = priv->minor->master;
+               mutex_unlock(&dev->struct_mutex);
+       }
+
+       mutex_lock(&dev->struct_mutex);
        list_add(&priv->lhead, &dev->filelist);
        mutex_unlock(&dev->struct_mutex);
 
@@ -477,6 +482,14 @@ int drm_release(struct inode *inode, struct file *filp)
        mutex_unlock(&dev->ctxlist_mutex);
 
        drm_fb_release(filp);
+
+       file_priv->master = NULL;
+
+       if (file_priv->is_master) {
+              drm_put_master(file_priv->minor->master);
+              file_priv->minor->master = NULL;
+       }
+
        mutex_lock(&dev->struct_mutex);
        drm_object_release(filp);
        if (file_priv->remove_auth_on_close == 1) {
@@ -487,12 +500,6 @@ int drm_release(struct inode *inode, struct file *filp)
        }
        list_del(&file_priv->lhead);
 
-       if (file_priv->is_master) {
-              drm_put_master(file_priv->minor->master);
-              file_priv->minor->master = NULL;
-       }
-
-       file_priv->master = NULL;
 
        mutex_unlock(&dev->struct_mutex);
 
index 801dab0..334c8f0 100644 (file)
@@ -152,6 +152,7 @@ static int drm_fill_in_dev(struct drm_device * dev, struct pci_dev *pdev,
        INIT_LIST_HEAD(&dev->ctxlist);
        INIT_LIST_HEAD(&dev->vmalist);
        INIT_LIST_HEAD(&dev->maplist);
+       INIT_LIST_HEAD(&dev->filelist);
 
        spin_lock_init(&dev->count_lock);
        spin_lock_init(&dev->drw_lock);