diff options
author | Thomas Hellstrom <thellstrom@vmware.com> | 2009-03-02 05:10:56 -0500 |
---|---|---|
committer | Dave Airlie <airlied@linux.ie> | 2009-03-02 18:50:20 -0500 |
commit | fda714c29cdf360464059044b221450decb4b913 (patch) | |
tree | dc985f3c861d9490a1b5ffe82583497b6fe64236 | |
parent | 171901d15deeef61aa8e1b0d0772404f39691b73 (diff) |
drm: Avoid client deadlocks when the master disappears.
This is done by
1) Wake up lock waiters when we close the master file descriptor.
Not when the master structure is removed, since the latter
requires the waiters themselves to release the refcount on the
master structure -> Deadlock.
2) Send a SIGTERM to all clients waiting for the lock.
Normally these clients will get a SIGPIPE when the X server dies,
but clients may also spin trying to grab the DRM lock, without
getting any sort of notification.
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
Signed-off-by: Dave Airlie <airlied@linux.ie>
-rw-r--r-- | drivers/gpu/drm/drm_fops.c | 14 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_lock.c | 1 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_stub.c | 8 |
3 files changed, 15 insertions, 8 deletions
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c index 6c020fe5431c..f52663ebe016 100644 --- a/drivers/gpu/drm/drm_fops.c +++ b/drivers/gpu/drm/drm_fops.c | |||
@@ -484,6 +484,7 @@ int drm_release(struct inode *inode, struct file *filp) | |||
484 | mutex_lock(&dev->struct_mutex); | 484 | mutex_lock(&dev->struct_mutex); |
485 | 485 | ||
486 | if (file_priv->is_master) { | 486 | if (file_priv->is_master) { |
487 | struct drm_master *master = file_priv->master; | ||
487 | struct drm_file *temp; | 488 | struct drm_file *temp; |
488 | list_for_each_entry(temp, &dev->filelist, lhead) { | 489 | list_for_each_entry(temp, &dev->filelist, lhead) { |
489 | if ((temp->master == file_priv->master) && | 490 | if ((temp->master == file_priv->master) && |
@@ -491,6 +492,19 @@ int drm_release(struct inode *inode, struct file *filp) | |||
491 | temp->authenticated = 0; | 492 | temp->authenticated = 0; |
492 | } | 493 | } |
493 | 494 | ||
495 | /** | ||
496 | * Since the master is disappearing, so is the | ||
497 | * possibility to lock. | ||
498 | */ | ||
499 | |||
500 | if (master->lock.hw_lock) { | ||
501 | if (dev->sigdata.lock == master->lock.hw_lock) | ||
502 | dev->sigdata.lock = NULL; | ||
503 | master->lock.hw_lock = NULL; | ||
504 | master->lock.file_priv = NULL; | ||
505 | wake_up_interruptible_all(&master->lock.lock_queue); | ||
506 | } | ||
507 | |||
494 | if (file_priv->minor->master == file_priv->master) { | 508 | if (file_priv->minor->master == file_priv->master) { |
495 | /* drop the reference held my the minor */ | 509 | /* drop the reference held my the minor */ |
496 | drm_master_put(&file_priv->minor->master); | 510 | drm_master_put(&file_priv->minor->master); |
diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c index b03586fdabbd..e2f70a516c34 100644 --- a/drivers/gpu/drm/drm_lock.c +++ b/drivers/gpu/drm/drm_lock.c | |||
@@ -80,6 +80,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv) | |||
80 | __set_current_state(TASK_INTERRUPTIBLE); | 80 | __set_current_state(TASK_INTERRUPTIBLE); |
81 | if (!master->lock.hw_lock) { | 81 | if (!master->lock.hw_lock) { |
82 | /* Device has been unregistered */ | 82 | /* Device has been unregistered */ |
83 | send_sig(SIGTERM, current, 0); | ||
83 | ret = -EINTR; | 84 | ret = -EINTR; |
84 | break; | 85 | break; |
85 | } | 86 | } |
diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index 7b251dd70811..096e2a37446d 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c | |||
@@ -146,14 +146,6 @@ static void drm_master_destroy(struct kref *kref) | |||
146 | 146 | ||
147 | drm_ht_remove(&master->magiclist); | 147 | drm_ht_remove(&master->magiclist); |
148 | 148 | ||
149 | if (master->lock.hw_lock) { | ||
150 | if (dev->sigdata.lock == master->lock.hw_lock) | ||
151 | dev->sigdata.lock = NULL; | ||
152 | master->lock.hw_lock = NULL; | ||
153 | master->lock.file_priv = NULL; | ||
154 | wake_up_interruptible_all(&master->lock.lock_queue); | ||
155 | } | ||
156 | |||
157 | drm_free(master, sizeof(*master), DRM_MEM_DRIVER); | 149 | drm_free(master, sizeof(*master), DRM_MEM_DRIVER); |
158 | } | 150 | } |
159 | 151 | ||