aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_lock.c
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2007-09-02 22:06:45 -0400
committerDave Airlie <airlied@optimus.(none)>2007-10-14 20:38:20 -0400
commitc153f45f9b7e30289157bba3ff5682291df16caa (patch)
tree33f21e1ebd83ec548751f3d490afe6230ab99972 /drivers/char/drm/drm_lock.c
parentb589ee5943a9610ebaea6e4e3433f2ae4d812b0b (diff)
drm: Replace DRM_IOCTL_ARGS with (dev, data, file_priv) and remove DRM_DEVICE.
The data is now in kernel space, copied in/out as appropriate according to t This results in DRM_COPY_{TO,FROM}_USER going away, and error paths to deal with those failures. This also means that XFree86 4.2.0 support for i810 DR is lost. Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/drm_lock.c')
-rw-r--r--drivers/char/drm/drm_lock.c57
1 files changed, 24 insertions, 33 deletions
diff --git a/drivers/char/drm/drm_lock.c b/drivers/char/drm/drm_lock.c
index 57c4306f4cb4..c6b73e744d67 100644
--- a/drivers/char/drm/drm_lock.c
+++ b/drivers/char/drm/drm_lock.c
@@ -48,31 +48,26 @@ static int drm_notifier(void *priv);
48 * 48 *
49 * Add the current task to the lock wait queue, and attempt to take to lock. 49 * Add the current task to the lock wait queue, and attempt to take to lock.
50 */ 50 */
51int drm_lock(struct inode *inode, struct drm_file *file_priv, 51int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
52 unsigned int cmd, unsigned long arg)
53{ 52{
54 struct drm_device *dev = file_priv->head->dev;
55 DECLARE_WAITQUEUE(entry, current); 53 DECLARE_WAITQUEUE(entry, current);
56 struct drm_lock lock; 54 struct drm_lock *lock = data;
57 int ret = 0; 55 int ret = 0;
58 56
59 ++file_priv->lock_count; 57 ++file_priv->lock_count;
60 58
61 if (copy_from_user(&lock, (struct drm_lock __user *) arg, sizeof(lock))) 59 if (lock->context == DRM_KERNEL_CONTEXT) {
62 return -EFAULT;
63
64 if (lock.context == DRM_KERNEL_CONTEXT) {
65 DRM_ERROR("Process %d using kernel context %d\n", 60 DRM_ERROR("Process %d using kernel context %d\n",
66 current->pid, lock.context); 61 current->pid, lock->context);
67 return -EINVAL; 62 return -EINVAL;
68 } 63 }
69 64
70 DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", 65 DRM_DEBUG("%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n",
71 lock.context, current->pid, 66 lock->context, current->pid,
72 dev->lock.hw_lock->lock, lock.flags); 67 dev->lock.hw_lock->lock, lock->flags);
73 68
74 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE)) 69 if (drm_core_check_feature(dev, DRIVER_DMA_QUEUE))
75 if (lock.context < 0) 70 if (lock->context < 0)
76 return -EINVAL; 71 return -EINVAL;
77 72
78 add_wait_queue(&dev->lock.lock_queue, &entry); 73 add_wait_queue(&dev->lock.lock_queue, &entry);
@@ -86,7 +81,7 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv,
86 ret = -EINTR; 81 ret = -EINTR;
87 break; 82 break;
88 } 83 }
89 if (drm_lock_take(&dev->lock, lock.context)) { 84 if (drm_lock_take(&dev->lock, lock->context)) {
90 dev->lock.file_priv = file_priv; 85 dev->lock.file_priv = file_priv;
91 dev->lock.lock_time = jiffies; 86 dev->lock.lock_time = jiffies;
92 atomic_inc(&dev->counts[_DRM_STAT_LOCKS]); 87 atomic_inc(&dev->counts[_DRM_STAT_LOCKS]);
@@ -106,7 +101,8 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv,
106 __set_current_state(TASK_RUNNING); 101 __set_current_state(TASK_RUNNING);
107 remove_wait_queue(&dev->lock.lock_queue, &entry); 102 remove_wait_queue(&dev->lock.lock_queue, &entry);
108 103
109 DRM_DEBUG( "%d %s\n", lock.context, ret ? "interrupted" : "has lock" ); 104 DRM_DEBUG("%d %s\n", lock->context,
105 ret ? "interrupted" : "has lock");
110 if (ret) return ret; 106 if (ret) return ret;
111 107
112 sigemptyset(&dev->sigmask); 108 sigemptyset(&dev->sigmask);
@@ -114,24 +110,26 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv,
114 sigaddset(&dev->sigmask, SIGTSTP); 110 sigaddset(&dev->sigmask, SIGTSTP);
115 sigaddset(&dev->sigmask, SIGTTIN); 111 sigaddset(&dev->sigmask, SIGTTIN);
116 sigaddset(&dev->sigmask, SIGTTOU); 112 sigaddset(&dev->sigmask, SIGTTOU);
117 dev->sigdata.context = lock.context; 113 dev->sigdata.context = lock->context;
118 dev->sigdata.lock = dev->lock.hw_lock; 114 dev->sigdata.lock = dev->lock.hw_lock;
119 block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); 115 block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask);
120 116
121 if (dev->driver->dma_ready && (lock.flags & _DRM_LOCK_READY)) 117 if (dev->driver->dma_ready && (lock->flags & _DRM_LOCK_READY))
122 dev->driver->dma_ready(dev); 118 dev->driver->dma_ready(dev);
123 119
124 if (dev->driver->dma_quiescent && (lock.flags & _DRM_LOCK_QUIESCENT)) { 120 if (dev->driver->dma_quiescent && (lock->flags & _DRM_LOCK_QUIESCENT))
121 {
125 if (dev->driver->dma_quiescent(dev)) { 122 if (dev->driver->dma_quiescent(dev)) {
126 DRM_DEBUG("%d waiting for DMA quiescent\n", lock.context); 123 DRM_DEBUG("%d waiting for DMA quiescent\n",
124 lock->context);
127 return -EBUSY; 125 return -EBUSY;
128 } 126 }
129 } 127 }
130 128
131 if (dev->driver->kernel_context_switch && 129 if (dev->driver->kernel_context_switch &&
132 dev->last_context != lock.context) { 130 dev->last_context != lock->context) {
133 dev->driver->kernel_context_switch(dev, dev->last_context, 131 dev->driver->kernel_context_switch(dev, dev->last_context,
134 lock.context); 132 lock->context);
135 } 133 }
136 134
137 return 0; 135 return 0;
@@ -148,19 +146,14 @@ int drm_lock(struct inode *inode, struct drm_file *file_priv,
148 * 146 *
149 * Transfer and free the lock. 147 * Transfer and free the lock.
150 */ 148 */
151int drm_unlock(struct inode *inode, struct drm_file *file_priv, 149int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
152 unsigned int cmd, unsigned long arg)
153{ 150{
154 struct drm_device *dev = file_priv->head->dev; 151 struct drm_lock *lock = data;
155 struct drm_lock lock;
156 unsigned long irqflags; 152 unsigned long irqflags;
157 153
158 if (copy_from_user(&lock, (struct drm_lock __user *) arg, sizeof(lock))) 154 if (lock->context == DRM_KERNEL_CONTEXT) {
159 return -EFAULT;
160
161 if (lock.context == DRM_KERNEL_CONTEXT) {
162 DRM_ERROR("Process %d using kernel context %d\n", 155 DRM_ERROR("Process %d using kernel context %d\n",
163 current->pid, lock.context); 156 current->pid, lock->context);
164 return -EINVAL; 157 return -EINVAL;
165 } 158 }
166 159
@@ -182,7 +175,7 @@ int drm_unlock(struct inode *inode, struct drm_file *file_priv,
182 if (dev->driver->kernel_context_switch_unlock) 175 if (dev->driver->kernel_context_switch_unlock)
183 dev->driver->kernel_context_switch_unlock(dev); 176 dev->driver->kernel_context_switch_unlock(dev);
184 else { 177 else {
185 if (drm_lock_free(&dev->lock,lock.context)) { 178 if (drm_lock_free(&dev->lock,lock->context)) {
186 /* FIXME: Should really bail out here. */ 179 /* FIXME: Should really bail out here. */
187 } 180 }
188 } 181 }
@@ -388,10 +381,8 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
388EXPORT_SYMBOL(drm_idlelock_release); 381EXPORT_SYMBOL(drm_idlelock_release);
389 382
390 383
391int drm_i_have_hw_lock(struct drm_file *file_priv) 384int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv)
392{ 385{
393 DRM_DEVICE;
394
395 return (file_priv->lock_count && dev->lock.hw_lock && 386 return (file_priv->lock_count && dev->lock.hw_lock &&
396 _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) && 387 _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) &&
397 dev->lock.file_priv == file_priv); 388 dev->lock.file_priv == file_priv);