aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_lock.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_lock.c')
-rw-r--r--drivers/gpu/drm/drm_lock.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/drivers/gpu/drm/drm_lock.c b/drivers/gpu/drm/drm_lock.c
index e26b59e385ff..f861361a635e 100644
--- a/drivers/gpu/drm/drm_lock.c
+++ b/drivers/gpu/drm/drm_lock.c
@@ -36,6 +36,7 @@
36#include <linux/export.h> 36#include <linux/export.h>
37#include <drm/drmP.h> 37#include <drm/drmP.h>
38#include "drm_legacy.h" 38#include "drm_legacy.h"
39#include "drm_internal.h"
39 40
40static int drm_notifier(void *priv); 41static int drm_notifier(void *priv);
41 42
@@ -52,7 +53,8 @@ static int drm_lock_take(struct drm_lock_data *lock_data, unsigned int context);
52 * 53 *
53 * Add the current task to the lock wait queue, and attempt to take to lock. 54 * Add the current task to the lock wait queue, and attempt to take to lock.
54 */ 55 */
55int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv) 56int drm_legacy_lock(struct drm_device *dev, void *data,
57 struct drm_file *file_priv)
56{ 58{
57 DECLARE_WAITQUEUE(entry, current); 59 DECLARE_WAITQUEUE(entry, current);
58 struct drm_lock *lock = data; 60 struct drm_lock *lock = data;
@@ -120,7 +122,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
120 sigaddset(&dev->sigmask, SIGTTOU); 122 sigaddset(&dev->sigmask, SIGTTOU);
121 dev->sigdata.context = lock->context; 123 dev->sigdata.context = lock->context;
122 dev->sigdata.lock = master->lock.hw_lock; 124 dev->sigdata.lock = master->lock.hw_lock;
123 block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); 125 block_all_signals(drm_notifier, dev, &dev->sigmask);
124 } 126 }
125 127
126 if (dev->driver->dma_quiescent && (lock->flags & _DRM_LOCK_QUIESCENT)) 128 if (dev->driver->dma_quiescent && (lock->flags & _DRM_LOCK_QUIESCENT))
@@ -146,7 +148,7 @@ int drm_lock(struct drm_device *dev, void *data, struct drm_file *file_priv)
146 * 148 *
147 * Transfer and free the lock. 149 * Transfer and free the lock.
148 */ 150 */
149int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv) 151int drm_legacy_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
150{ 152{
151 struct drm_lock *lock = data; 153 struct drm_lock *lock = data;
152 struct drm_master *master = file_priv->master; 154 struct drm_master *master = file_priv->master;
@@ -157,7 +159,7 @@ int drm_unlock(struct drm_device *dev, void *data, struct drm_file *file_priv)
157 return -EINVAL; 159 return -EINVAL;
158 } 160 }
159 161
160 if (drm_lock_free(&master->lock, lock->context)) { 162 if (drm_legacy_lock_free(&master->lock, lock->context)) {
161 /* FIXME: Should really bail out here. */ 163 /* FIXME: Should really bail out here. */
162 } 164 }
163 165
@@ -250,7 +252,7 @@ static int drm_lock_transfer(struct drm_lock_data *lock_data,
250 * Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task 252 * Marks the lock as not held, via the \p cmpxchg instruction. Wakes any task
251 * waiting on the lock queue. 253 * waiting on the lock queue.
252 */ 254 */
253int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context) 255int drm_legacy_lock_free(struct drm_lock_data *lock_data, unsigned int context)
254{ 256{
255 unsigned int old, new, prev; 257 unsigned int old, new, prev;
256 volatile unsigned int *lock = &lock_data->hw_lock->lock; 258 volatile unsigned int *lock = &lock_data->hw_lock->lock;
@@ -286,26 +288,27 @@ int drm_lock_free(struct drm_lock_data *lock_data, unsigned int context)
286 * If the lock is not held, then let the signal proceed as usual. If the lock 288 * If the lock is not held, then let the signal proceed as usual. If the lock
287 * is held, then set the contended flag and keep the signal blocked. 289 * is held, then set the contended flag and keep the signal blocked.
288 * 290 *
289 * \param priv pointer to a drm_sigdata structure. 291 * \param priv pointer to a drm_device structure.
290 * \return one if the signal should be delivered normally, or zero if the 292 * \return one if the signal should be delivered normally, or zero if the
291 * signal should be blocked. 293 * signal should be blocked.
292 */ 294 */
293static int drm_notifier(void *priv) 295static int drm_notifier(void *priv)
294{ 296{
295 struct drm_sigdata *s = (struct drm_sigdata *) priv; 297 struct drm_device *dev = priv;
298 struct drm_hw_lock *lock = dev->sigdata.lock;
296 unsigned int old, new, prev; 299 unsigned int old, new, prev;
297 300
298 /* Allow signal delivery if lock isn't held */ 301 /* Allow signal delivery if lock isn't held */
299 if (!s->lock || !_DRM_LOCK_IS_HELD(s->lock->lock) 302 if (!lock || !_DRM_LOCK_IS_HELD(lock->lock)
300 || _DRM_LOCKING_CONTEXT(s->lock->lock) != s->context) 303 || _DRM_LOCKING_CONTEXT(lock->lock) != dev->sigdata.context)
301 return 1; 304 return 1;
302 305
303 /* Otherwise, set flag to force call to 306 /* Otherwise, set flag to force call to
304 drmUnlock */ 307 drmUnlock */
305 do { 308 do {
306 old = s->lock->lock; 309 old = lock->lock;
307 new = old | _DRM_LOCK_CONT; 310 new = old | _DRM_LOCK_CONT;
308 prev = cmpxchg(&s->lock->lock, old, new); 311 prev = cmpxchg(&lock->lock, old, new);
309 } while (prev != old); 312 } while (prev != old);
310 return 0; 313 return 0;
311} 314}
@@ -323,7 +326,7 @@ static int drm_notifier(void *priv)
323 * having to worry about starvation. 326 * having to worry about starvation.
324 */ 327 */
325 328
326void drm_idlelock_take(struct drm_lock_data *lock_data) 329void drm_legacy_idlelock_take(struct drm_lock_data *lock_data)
327{ 330{
328 int ret; 331 int ret;
329 332
@@ -340,9 +343,9 @@ void drm_idlelock_take(struct drm_lock_data *lock_data)
340 } 343 }
341 spin_unlock_bh(&lock_data->spinlock); 344 spin_unlock_bh(&lock_data->spinlock);
342} 345}
343EXPORT_SYMBOL(drm_idlelock_take); 346EXPORT_SYMBOL(drm_legacy_idlelock_take);
344 347
345void drm_idlelock_release(struct drm_lock_data *lock_data) 348void drm_legacy_idlelock_release(struct drm_lock_data *lock_data)
346{ 349{
347 unsigned int old, prev; 350 unsigned int old, prev;
348 volatile unsigned int *lock = &lock_data->hw_lock->lock; 351 volatile unsigned int *lock = &lock_data->hw_lock->lock;
@@ -360,9 +363,10 @@ void drm_idlelock_release(struct drm_lock_data *lock_data)
360 } 363 }
361 spin_unlock_bh(&lock_data->spinlock); 364 spin_unlock_bh(&lock_data->spinlock);
362} 365}
363EXPORT_SYMBOL(drm_idlelock_release); 366EXPORT_SYMBOL(drm_legacy_idlelock_release);
364 367
365int drm_i_have_hw_lock(struct drm_device *dev, struct drm_file *file_priv) 368int drm_legacy_i_have_hw_lock(struct drm_device *dev,
369 struct drm_file *file_priv)
366{ 370{
367 struct drm_master *master = file_priv->master; 371 struct drm_master *master = file_priv->master;
368 return (file_priv->lock_count && master->lock.hw_lock && 372 return (file_priv->lock_count && master->lock.hw_lock &&