Lines Matching +full:master +full:- +full:kernel
63 volatile unsigned int *lock = &lock_data->hw_lock->lock; in drm_lock_take()
65 spin_lock_bh(&lock_data->spinlock); in drm_lock_take()
72 ((lock_data->user_waiters + lock_data->kernel_waiters > 1) ? in drm_lock_take()
77 spin_unlock_bh(&lock_data->spinlock); in drm_lock_take()
98 * inside *_unlock to give lock to kernel before calling *_dma_schedule.
112 volatile unsigned int *lock = &lock_data->hw_lock->lock; in drm_lock_transfer()
114 lock_data->file_priv = NULL; in drm_lock_transfer()
127 volatile unsigned int *lock = &lock_data->hw_lock->lock; in drm_legacy_lock_free()
129 spin_lock_bh(&lock_data->spinlock); in drm_legacy_lock_free()
130 if (lock_data->kernel_waiters != 0) { in drm_legacy_lock_free()
132 lock_data->idle_has_lock = 1; in drm_legacy_lock_free()
133 spin_unlock_bh(&lock_data->spinlock); in drm_legacy_lock_free()
136 spin_unlock_bh(&lock_data->spinlock); in drm_legacy_lock_free()
149 wake_up_interruptible(&lock_data->lock_queue); in drm_legacy_lock_free()
169 struct drm_master *master = file_priv->master; in drm_legacy_lock() local
173 return -EOPNOTSUPP; in drm_legacy_lock()
175 ++file_priv->lock_count; in drm_legacy_lock()
177 if (lock->context == DRM_KERNEL_CONTEXT) { in drm_legacy_lock()
178 DRM_ERROR("Process %d using kernel context %d\n", in drm_legacy_lock()
179 task_pid_nr(current), lock->context); in drm_legacy_lock()
180 return -EINVAL; in drm_legacy_lock()
184 lock->context, task_pid_nr(current), in drm_legacy_lock()
185 master->lock.hw_lock ? master->lock.hw_lock->lock : -1, in drm_legacy_lock()
186 lock->flags); in drm_legacy_lock()
188 add_wait_queue(&master->lock.lock_queue, &entry); in drm_legacy_lock()
189 spin_lock_bh(&master->lock.spinlock); in drm_legacy_lock()
190 master->lock.user_waiters++; in drm_legacy_lock()
191 spin_unlock_bh(&master->lock.spinlock); in drm_legacy_lock()
195 if (!master->lock.hw_lock) { in drm_legacy_lock()
198 ret = -EINTR; in drm_legacy_lock()
201 if (drm_lock_take(&master->lock, lock->context)) { in drm_legacy_lock()
202 master->lock.file_priv = file_priv; in drm_legacy_lock()
203 master->lock.lock_time = jiffies; in drm_legacy_lock()
212 ret = -EINTR; in drm_legacy_lock()
216 spin_lock_bh(&master->lock.spinlock); in drm_legacy_lock()
217 master->lock.user_waiters--; in drm_legacy_lock()
218 spin_unlock_bh(&master->lock.spinlock); in drm_legacy_lock()
220 remove_wait_queue(&master->lock.lock_queue, &entry); in drm_legacy_lock()
222 DRM_DEBUG("%d %s\n", lock->context, in drm_legacy_lock()
226 /* don't set the block all signals on the master process for now in drm_legacy_lock()
230 dev->sigdata.context = lock->context; in drm_legacy_lock()
231 dev->sigdata.lock = master->lock.hw_lock; in drm_legacy_lock()
234 if (dev->driver->dma_quiescent && (lock->flags & _DRM_LOCK_QUIESCENT)) in drm_legacy_lock()
236 if (dev->driver->dma_quiescent(dev)) { in drm_legacy_lock()
238 lock->context); in drm_legacy_lock()
239 return -EBUSY; in drm_legacy_lock()
260 struct drm_master *master = file_priv->master; in drm_legacy_unlock() local
263 return -EOPNOTSUPP; in drm_legacy_unlock()
265 if (lock->context == DRM_KERNEL_CONTEXT) { in drm_legacy_unlock()
266 DRM_ERROR("Process %d using kernel context %d\n", in drm_legacy_unlock()
267 task_pid_nr(current), lock->context); in drm_legacy_unlock()
268 return -EINVAL; in drm_legacy_unlock()
271 if (drm_legacy_lock_free(&master->lock, lock->context)) { in drm_legacy_unlock()
280 * with the kernel context if it is free, otherwise it gets the highest priority when and if
283 * This guarantees that the kernel will _eventually_ have the lock _unless_ it is held
294 spin_lock_bh(&lock_data->spinlock); in drm_legacy_idlelock_take()
295 lock_data->kernel_waiters++; in drm_legacy_idlelock_take()
296 if (!lock_data->idle_has_lock) { in drm_legacy_idlelock_take()
298 spin_unlock_bh(&lock_data->spinlock); in drm_legacy_idlelock_take()
300 spin_lock_bh(&lock_data->spinlock); in drm_legacy_idlelock_take()
303 lock_data->idle_has_lock = 1; in drm_legacy_idlelock_take()
305 spin_unlock_bh(&lock_data->spinlock); in drm_legacy_idlelock_take()
312 volatile unsigned int *lock = &lock_data->hw_lock->lock; in drm_legacy_idlelock_release()
314 spin_lock_bh(&lock_data->spinlock); in drm_legacy_idlelock_release()
315 if (--lock_data->kernel_waiters == 0) { in drm_legacy_idlelock_release()
316 if (lock_data->idle_has_lock) { in drm_legacy_idlelock_release()
321 wake_up_interruptible(&lock_data->lock_queue); in drm_legacy_idlelock_release()
322 lock_data->idle_has_lock = 0; in drm_legacy_idlelock_release()
325 spin_unlock_bh(&lock_data->spinlock); in drm_legacy_idlelock_release()
332 struct drm_master *master = file_priv->master; in drm_legacy_i_have_hw_lock() local
334 return (file_priv->lock_count && master->lock.hw_lock && in drm_legacy_i_have_hw_lock()
335 _DRM_LOCK_IS_HELD(master->lock.hw_lock->lock) && in drm_legacy_i_have_hw_lock()
336 master->lock.file_priv == file_priv); in drm_legacy_i_have_hw_lock()
341 struct drm_file *file_priv = filp->private_data; in drm_legacy_lock_release()
343 /* if the master has gone away we can't do anything with the lock */ in drm_legacy_lock_release()
344 if (!dev->master) in drm_legacy_lock_release()
349 filp, _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); in drm_legacy_lock_release()
350 drm_legacy_lock_free(&file_priv->master->lock, in drm_legacy_lock_release()
351 _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); in drm_legacy_lock_release()
355 void drm_legacy_lock_master_cleanup(struct drm_device *dev, struct drm_master *master) in drm_legacy_lock_master_cleanup() argument
361 * Since the master is disappearing, so is the in drm_legacy_lock_master_cleanup()
364 mutex_lock(&dev->struct_mutex); in drm_legacy_lock_master_cleanup()
365 if (master->lock.hw_lock) { in drm_legacy_lock_master_cleanup()
366 if (dev->sigdata.lock == master->lock.hw_lock) in drm_legacy_lock_master_cleanup()
367 dev->sigdata.lock = NULL; in drm_legacy_lock_master_cleanup()
368 master->lock.hw_lock = NULL; in drm_legacy_lock_master_cleanup()
369 master->lock.file_priv = NULL; in drm_legacy_lock_master_cleanup()
370 wake_up_interruptible_all(&master->lock.lock_queue); in drm_legacy_lock_master_cleanup()
372 mutex_unlock(&dev->struct_mutex); in drm_legacy_lock_master_cleanup()