Lines Matching refs:dev
152 static int r128_setup(drm_device_t *dev) in r128_setup() argument
156 atomic_set(&dev->ioctl_count, 0); in r128_setup()
157 atomic_set(&dev->vma_count, 0); in r128_setup()
158 dev->buf_use = 0; in r128_setup()
159 atomic_set(&dev->buf_alloc, 0); in r128_setup()
161 drm_dma_setup(dev); in r128_setup()
163 atomic_set(&dev->total_open, 0); in r128_setup()
164 atomic_set(&dev->total_close, 0); in r128_setup()
165 atomic_set(&dev->total_ioctl, 0); in r128_setup()
166 atomic_set(&dev->total_irq, 0); in r128_setup()
167 atomic_set(&dev->total_ctx, 0); in r128_setup()
168 atomic_set(&dev->total_locks, 0); in r128_setup()
169 atomic_set(&dev->total_unlocks, 0); in r128_setup()
170 atomic_set(&dev->total_contends, 0); in r128_setup()
171 atomic_set(&dev->total_sleeps, 0); in r128_setup()
174 dev->magiclist[i].head = NULL; in r128_setup()
175 dev->magiclist[i].tail = NULL; in r128_setup()
177 dev->maplist = NULL; in r128_setup()
178 dev->map_count = 0; in r128_setup()
179 dev->vmalist = NULL; in r128_setup()
180 dev->lock.hw_lock = NULL; in r128_setup()
181 init_waitqueue_head(&dev->lock.lock_queue); in r128_setup()
182 dev->queue_count = 0; in r128_setup()
183 dev->queue_reserved = 0; in r128_setup()
184 dev->queue_slots = 0; in r128_setup()
185 dev->queuelist = NULL; in r128_setup()
186 dev->irq = 0; in r128_setup()
187 dev->context_flag = 0; in r128_setup()
188 dev->interrupt_flag = 0; in r128_setup()
189 dev->dma_flag = 0; in r128_setup()
190 dev->last_context = 0; in r128_setup()
191 dev->last_switch = 0; in r128_setup()
192 dev->last_checked = 0; in r128_setup()
193 init_timer(&dev->timer); in r128_setup()
194 init_waitqueue_head(&dev->context_wait); in r128_setup()
196 dev->ctx_start = 0; in r128_setup()
197 dev->lck_start = 0; in r128_setup()
199 dev->buf_rp = dev->buf; in r128_setup()
200 dev->buf_wp = dev->buf; in r128_setup()
201 dev->buf_end = dev->buf + DRM_BSZ; in r128_setup()
202 dev->buf_async = NULL; in r128_setup()
203 init_waitqueue_head(&dev->buf_readers); in r128_setup()
204 init_waitqueue_head(&dev->buf_writers); in r128_setup()
220 static int r128_takedown(drm_device_t *dev) in r128_takedown() argument
229 down(&dev->struct_sem); in r128_takedown()
230 del_timer(&dev->timer); in r128_takedown()
232 if (dev->devname) { in r128_takedown()
233 drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); in r128_takedown()
234 dev->devname = NULL; in r128_takedown()
237 if (dev->unique) { in r128_takedown()
238 drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); in r128_takedown()
239 dev->unique = NULL; in r128_takedown()
240 dev->unique_len = 0; in r128_takedown()
244 for (pt = dev->magiclist[i].head; pt; pt = next) { in r128_takedown()
248 dev->magiclist[i].head = dev->magiclist[i].tail = NULL; in r128_takedown()
253 if (dev->agp) { in r128_takedown()
259 for (entry = dev->agp->memory; entry; entry = nexte) { in r128_takedown()
265 dev->agp->memory = NULL; in r128_takedown()
267 if (dev->agp->acquired) _drm_agp_release(); in r128_takedown()
269 dev->agp->acquired = 0; in r128_takedown()
270 dev->agp->enabled = 0; in r128_takedown()
275 if (dev->vmalist) { in r128_takedown()
276 for (vma = dev->vmalist; vma; vma = vma_next) { in r128_takedown()
280 dev->vmalist = NULL; in r128_takedown()
284 if (dev->maplist) { in r128_takedown()
285 for (i = 0; i < dev->map_count; i++) { in r128_takedown()
286 map = dev->maplist[i]; in r128_takedown()
299 drm_ioremapfree(map->handle, map->size, dev); in r128_takedown()
314 drm_free(dev->maplist, in r128_takedown()
315 dev->map_count * sizeof(*dev->maplist), in r128_takedown()
317 dev->maplist = NULL; in r128_takedown()
318 dev->map_count = 0; in r128_takedown()
321 drm_dma_takedown(dev); in r128_takedown()
323 dev->queue_count = 0; in r128_takedown()
324 if (dev->lock.hw_lock) { in r128_takedown()
325 dev->lock.hw_lock = NULL; /* SHM removed */ in r128_takedown()
326 dev->lock.pid = 0; in r128_takedown()
327 wake_up_interruptible(&dev->lock.lock_queue); in r128_takedown()
329 up(&dev->struct_sem); in r128_takedown()
340 drm_device_t *dev = &r128_device; in r128_init() local
344 memset((void *)dev, 0, sizeof(*dev)); in r128_init()
345 dev->count_lock = SPIN_LOCK_UNLOCKED; in r128_init()
346 sema_init(&dev->struct_sem, 1); in r128_init()
356 dev->device = MKDEV(MISC_MAJOR, r128_misc.minor); in r128_init()
357 dev->name = R128_NAME; in r128_init()
360 drm_proc_init(dev); in r128_init()
363 dev->agp = drm_agp_init(); in r128_init()
364 if (dev->agp == NULL) { in r128_init()
368 r128_takedown(dev); in r128_init()
373 dev->agp->agp_mtrr = mtrr_add(dev->agp->agp_info.aper_base, in r128_init()
374 dev->agp->agp_info.aper_size*1024*1024, in r128_init()
380 if((retcode = drm_ctxbitmap_init(dev))) { in r128_init()
384 r128_takedown(dev); in r128_init()
403 drm_device_t *dev = &r128_device; in r128_cleanup() local
413 drm_ctxbitmap_cleanup(dev); in r128_cleanup()
414 r128_takedown(dev); in r128_cleanup()
416 if (dev->agp) { in r128_cleanup()
418 drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); in r128_cleanup()
419 dev->agp = NULL; in r128_cleanup()
465 drm_device_t *dev = &r128_device; in r128_open() local
468 DRM_DEBUG("open_count = %d\n", dev->open_count); in r128_open()
469 if (!(retcode = drm_open_helper(inode, filp, dev))) { in r128_open()
473 atomic_inc(&dev->total_open); in r128_open()
474 spin_lock(&dev->count_lock); in r128_open()
475 if (!dev->open_count++) { in r128_open()
476 spin_unlock(&dev->count_lock); in r128_open()
477 return r128_setup(dev); in r128_open()
479 spin_unlock(&dev->count_lock); in r128_open()
488 drm_device_t *dev; in r128_release() local
492 dev = priv->dev; in r128_release()
493 DRM_DEBUG("open_count = %d\n", dev->open_count); in r128_release()
498 atomic_inc(&dev->total_close); in r128_release()
499 spin_lock(&dev->count_lock); in r128_release()
500 if (!--dev->open_count) { in r128_release()
501 if (atomic_read(&dev->ioctl_count) || dev->blocked) { in r128_release()
503 atomic_read(&dev->ioctl_count), in r128_release()
504 dev->blocked); in r128_release()
505 spin_unlock(&dev->count_lock); in r128_release()
509 spin_unlock(&dev->count_lock); in r128_release()
511 return r128_takedown(dev); in r128_release()
513 spin_unlock(&dev->count_lock); in r128_release()
526 drm_device_t *dev = priv->dev; in r128_ioctl() local
531 atomic_inc(&dev->ioctl_count); in r128_ioctl()
532 atomic_inc(&dev->total_ioctl); in r128_ioctl()
536 current->pid, cmd, nr, dev->device, priv->authenticated); in r128_ioctl()
561 atomic_dec(&dev->ioctl_count); in r128_ioctl()
569 drm_device_t *dev = priv->dev; in r128_lock() local
576 dev->lck_start = start = get_cycles(); in r128_lock()
589 lock.context, current->pid, dev->lock.hw_lock->lock, in r128_lock()
596 add_wait_queue(&dev->lock.lock_queue, &entry); in r128_lock()
599 if (!dev->lock.hw_lock) { in r128_lock()
604 if (drm_lock_take(&dev->lock.hw_lock->lock, in r128_lock()
606 dev->lock.pid = current->pid; in r128_lock()
607 dev->lock.lock_time = jiffies; in r128_lock()
608 atomic_inc(&dev->total_locks); in r128_lock()
613 atomic_inc(&dev->total_sleeps); in r128_lock()
621 remove_wait_queue(&dev->lock.lock_queue, &entry); in r128_lock()
625 sigemptyset(&dev->sigmask); in r128_lock()
626 sigaddset(&dev->sigmask, SIGSTOP); in r128_lock()
627 sigaddset(&dev->sigmask, SIGTSTP); in r128_lock()
628 sigaddset(&dev->sigmask, SIGTTIN); in r128_lock()
629 sigaddset(&dev->sigmask, SIGTTOU); in r128_lock()
630 dev->sigdata.context = lock.context; in r128_lock()
631 dev->sigdata.lock = dev->lock.hw_lock; in r128_lock()
632 block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); in r128_lock()
640 r128_quiescent(dev); in r128_lock()
654 atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]); in r128_lock()
665 drm_device_t *dev = priv->dev; in r128_unlock() local
679 _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); in r128_unlock()
680 atomic_inc(&dev->total_unlocks); in r128_unlock()
681 if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock)) in r128_unlock()
682 atomic_inc(&dev->total_contends); in r128_unlock()
683 drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT); in r128_unlock()
685 if (!dev->context_flag) { in r128_unlock()
686 if (drm_lock_free(dev, &dev->lock.hw_lock->lock, in r128_unlock()