Lines Matching +full:master +full:- +full:kernel

48 	if (dev->driver->firstopen) {  in drm_setup()
49 ret = dev->driver->firstopen(dev); in drm_setup()
54 atomic_set(&dev->ioctl_count, 0); in drm_setup()
55 atomic_set(&dev->vma_count, 0); in drm_setup()
59 dev->buf_use = 0; in drm_setup()
60 atomic_set(&dev->buf_alloc, 0); in drm_setup()
68 * FIXME Linux<->FreeBSD: counter incremented in drm_open() and in drm_setup()
72 for (i = 0; i < ARRAY_SIZE(dev->counts); i++) in drm_setup()
73 atomic_set(&dev->counts[i], 0); in drm_setup()
76 dev->sigdata.lock = NULL; in drm_setup()
78 dev->context_flag = 0; in drm_setup()
79 dev->interrupt_flag = 0; in drm_setup()
80 dev->dma_flag = 0; in drm_setup()
81 dev->last_context = 0; in drm_setup()
82 dev->last_switch = 0; in drm_setup()
83 dev->last_checked = 0; in drm_setup()
84 DRM_INIT_WAITQUEUE(&dev->context_wait); in drm_setup()
85 dev->if_version = 0; in drm_setup()
88 dev->ctx_start = 0; in drm_setup()
89 dev->lck_start = 0; in drm_setup()
91 dev->buf_async = NULL; in drm_setup()
92 DRM_INIT_WAITQUEUE(&dev->buf_readers); in drm_setup()
93 DRM_INIT_WAITQUEUE(&dev->buf_writers); in drm_setup()
99 * The kernel's context could be created here, but is now created in drm_setup()
100 * in drm_dma_enqueue. This is more resource-efficient for in drm_setup()
127 minor = kdev->si_drv1; in drm_open()
131 if (!(dev = minor->dev)) in drm_open()
137 * FIXME Linux<->FreeBSD: On Linux, counter updated outside in drm_open()
140 if (!dev->open_count++) in drm_open()
146 return (-retcode); in drm_open()
148 atomic_inc(&dev->counts[_DRM_STAT_OPENS]); in drm_open()
158 device_unbusy(dev->dev); in drm_open()
159 dev->open_count--; in drm_open()
161 return -retcode; in drm_open()
183 return -EBUSY; /* No exclusive opens */ in drm_open_helper()
184 if (dev->switch_power_state != DRM_SWITCH_POWER_ON) in drm_open_helper()
185 return -EINVAL; in drm_open_helper()
191 return -ENOMEM; in drm_open_helper()
193 priv->uid = p->td_ucred->cr_svuid; in drm_open_helper()
194 priv->pid = p->td_proc->p_pid; in drm_open_helper()
195 priv->minor = kdev->si_drv1; in drm_open_helper()
196 priv->ioctl_count = 0; in drm_open_helper()
198 priv->authenticated = DRM_SUSER(p); in drm_open_helper()
199 priv->lock_count = 0; in drm_open_helper()
201 INIT_LIST_HEAD(&priv->lhead); in drm_open_helper()
202 INIT_LIST_HEAD(&priv->fbs); in drm_open_helper()
203 INIT_LIST_HEAD(&priv->event_list); in drm_open_helper()
204 priv->event_space = 4096; /* set aside 4k for event buffer */ in drm_open_helper()
206 if (dev->driver->driver_features & DRIVER_GEM) in drm_open_helper()
211 drm_prime_init_file_private(&priv->prime); in drm_open_helper()
214 if (dev->driver->open) { in drm_open_helper()
215 ret = dev->driver->open(dev, priv); in drm_open_helper()
221 /* if there is no current master make this fd it */ in drm_open_helper()
223 if (!priv->minor->master) { in drm_open_helper()
224 /* create a new master */ in drm_open_helper()
225 priv->minor->master = drm_master_create(priv->minor); in drm_open_helper()
226 if (!priv->minor->master) { in drm_open_helper()
228 ret = -ENOMEM; in drm_open_helper()
232 priv->is_master = 1; in drm_open_helper()
234 priv->master = drm_master_get(priv->minor->master); in drm_open_helper()
236 priv->authenticated = 1; in drm_open_helper()
239 if (dev->driver->master_create) { in drm_open_helper()
240 ret = dev->driver->master_create(dev, priv->master); in drm_open_helper()
244 drm_master_put(&priv->minor->master); in drm_open_helper()
245 drm_master_put(&priv->master); in drm_open_helper()
251 if (dev->driver->master_set) { in drm_open_helper()
252 ret = dev->driver->master_set(dev, priv, true); in drm_open_helper()
255 drm_master_put(&priv->minor->master); in drm_open_helper()
256 drm_master_put(&priv->master); in drm_open_helper()
263 /* get a reference to the master */ in drm_open_helper()
264 priv->master = drm_master_get(priv->minor->master); in drm_open_helper()
269 list_add(&priv->lhead, &dev->filelist); in drm_open_helper()
272 device_busy(dev->dev); in drm_open_helper()
289 file_priv, _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); in drm_master_release()
290 drm_lock_free(&file_priv->master->lock, in drm_master_release()
291 _DRM_LOCKING_CONTEXT(file_priv->master->lock.hw_lock->lock)); in drm_master_release()
297 struct drm_device *dev = file_priv->minor->dev; in drm_events_release()
302 DRM_SPINLOCK_IRQSAVE(&dev->event_lock, flags); in drm_events_release()
305 list_for_each_entry_safe(v, vt, &dev->vblank_event_list, base.link) in drm_events_release()
306 if (v->base.file_priv == file_priv) { in drm_events_release()
307 list_del(&v->base.link); in drm_events_release()
308 drm_vblank_put(dev, v->pipe); in drm_events_release()
309 v->base.destroy(&v->base); in drm_events_release()
313 list_for_each_entry_safe(e, et, &file_priv->event_list, link) in drm_events_release()
314 e->destroy(e); in drm_events_release()
316 DRM_SPINUNLOCK_IRQRESTORE(&dev->event_lock, flags); in drm_events_release()
326 * If the hardware lock is held then free it, and take it again for the kernel
334 struct drm_device *dev = file_priv->minor->dev; in drm_release()
338 DRM_DEBUG("open_count = %d\n", dev->open_count); in drm_release()
340 if (dev->driver->preclose) in drm_release()
341 dev->driver->preclose(dev, file_priv); in drm_release()
349 (long)file_priv->minor->device, in drm_release()
350 dev->open_count); in drm_release()
354 if (file_priv->magic) in drm_release()
355 (void) drm_remove_magic(file_priv->master, file_priv->magic); in drm_release()
357 /* if the master has gone away we can't do anything with the lock */ in drm_release()
358 if (file_priv->minor->master) in drm_release()
366 seldrain(&file_priv->event_poll); in drm_release()
368 if (dev->driver->driver_features & DRIVER_MODESET) in drm_release()
371 if (dev->driver->driver_features & DRIVER_GEM) in drm_release()
375 mutex_lock(&dev->ctxlist_mutex); in drm_release()
376 if (!list_empty(&dev->ctxlist)) { in drm_release()
379 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { in drm_release()
380 if (pos->tag == file_priv && in drm_release()
381 pos->handle != DRM_KERNEL_CONTEXT) { in drm_release()
382 if (dev->driver->context_dtor) in drm_release()
383 dev->driver->context_dtor(dev, in drm_release()
384 pos->handle); in drm_release()
386 drm_ctxbitmap_free(dev, pos->handle); in drm_release()
388 list_del(&pos->head); in drm_release()
390 --dev->ctx_count; in drm_release()
394 mutex_unlock(&dev->ctxlist_mutex); in drm_release()
399 if (file_priv->is_master) { in drm_release()
400 struct drm_master *master = file_priv->master; in drm_release() local
402 list_for_each_entry(temp, &dev->filelist, lhead) { in drm_release()
403 if ((temp->master == file_priv->master) && in drm_release()
405 temp->authenticated = 0; in drm_release()
409 * Since the master is disappearing, so is the in drm_release()
413 if (master->lock.hw_lock) { in drm_release()
414 if (dev->sigdata.lock == master->lock.hw_lock) in drm_release()
415 dev->sigdata.lock = NULL; in drm_release()
416 master->lock.hw_lock = NULL; in drm_release()
417 master->lock.file_priv = NULL; in drm_release()
418 DRM_WAKEUP_INT(&master->lock.lock_queue); in drm_release()
421 if (file_priv->minor->master == file_priv->master) { in drm_release()
423 if (dev->driver->master_drop) in drm_release()
424 dev->driver->master_drop(dev, file_priv, true); in drm_release()
425 drm_master_put(&file_priv->minor->master); in drm_release()
430 drm_master_put(&file_priv->master); in drm_release()
431 file_priv->is_master = 0; in drm_release()
432 list_del(&file_priv->lhead); in drm_release()
435 if (dev->driver->postclose) in drm_release()
436 dev->driver->postclose(dev, file_priv); in drm_release()
440 drm_prime_destroy_file_private(&file_priv->prime); in drm_release()
449 atomic_inc(&dev->counts[_DRM_STAT_CLOSES]); in drm_release()
450 device_unbusy(dev->dev); in drm_release()
451 if (!--dev->open_count) { in drm_release()
452 if (atomic_read(&dev->ioctl_count)) { in drm_release()
454 atomic_read(&dev->ioctl_count)); in drm_release()
470 /* DRM_SPINLOCK_IRQSAVE(&dev->event_lock, flags); */ in drm_dequeue_event()
473 if (list_empty(&file_priv->event_list)) in drm_dequeue_event()
475 e = list_first_entry(&file_priv->event_list, in drm_dequeue_event()
477 if (e->event->length > uio->uio_resid) in drm_dequeue_event()
480 file_priv->event_space += e->event->length; in drm_dequeue_event()
481 list_del(&e->link); in drm_dequeue_event()
486 /* DRM_SPINUNLOCK_IRQRESTORE(&dev->event_lock, flags); */ in drm_dequeue_event()
505 mtx_lock(&dev->event_lock); in drm_read()
506 while (list_empty(&file_priv->event_list)) { in drm_read()
511 error = msleep(&file_priv->event_space, &dev->event_lock, in drm_read()
518 mtx_unlock(&dev->event_lock); in drm_read()
519 error = uiomove(e->event, e->event->length, uio); in drm_read()
520 CTR3(KTR_DRM, "drm_event_dequeued %d %d %d", curproc->p_pid, in drm_read()
521 e->event->type, e->event->length); in drm_read()
523 e->destroy(e); in drm_read()
526 mtx_lock(&dev->event_lock); in drm_read()
530 mtx_unlock(&dev->event_lock); in drm_read()
541 file_priv = e->file_priv; in drm_event_wakeup()
542 dev = file_priv->minor->dev; in drm_event_wakeup()
543 mtx_assert(&dev->event_lock, MA_OWNED); in drm_event_wakeup()
545 wakeup(&file_priv->event_space); in drm_event_wakeup()
546 selwakeup(&file_priv->event_poll); in drm_event_wakeup()
565 mtx_lock(&dev->event_lock); in drm_poll()
567 if (list_empty(&file_priv->event_list)) { in drm_poll()
569 selrecord(td, &file_priv->event_poll); in drm_poll()
575 mtx_unlock(&dev->event_lock); in drm_poll()
587 if (dev->drm_ttm_bdev != NULL) { in drm_mmap_single()
588 return (-ttm_bo_mmap_single(dev->drm_ttm_bdev, offset, size, in drm_mmap_single()
590 } else if ((dev->driver->driver_features & DRIVER_GEM) != 0) { in drm_mmap_single()
591 return (-drm_gem_mmap_single(dev, offset, size, obj_res, nprot)); in drm_mmap_single()