Lines Matching refs:dev
129 static int tdfx_setup(drm_device_t *dev) in tdfx_setup() argument
133 atomic_set(&dev->ioctl_count, 0); in tdfx_setup()
134 atomic_set(&dev->vma_count, 0); in tdfx_setup()
135 dev->buf_use = 0; in tdfx_setup()
136 atomic_set(&dev->buf_alloc, 0); in tdfx_setup()
138 atomic_set(&dev->total_open, 0); in tdfx_setup()
139 atomic_set(&dev->total_close, 0); in tdfx_setup()
140 atomic_set(&dev->total_ioctl, 0); in tdfx_setup()
141 atomic_set(&dev->total_irq, 0); in tdfx_setup()
142 atomic_set(&dev->total_ctx, 0); in tdfx_setup()
143 atomic_set(&dev->total_locks, 0); in tdfx_setup()
144 atomic_set(&dev->total_unlocks, 0); in tdfx_setup()
145 atomic_set(&dev->total_contends, 0); in tdfx_setup()
146 atomic_set(&dev->total_sleeps, 0); in tdfx_setup()
149 dev->magiclist[i].head = NULL; in tdfx_setup()
150 dev->magiclist[i].tail = NULL; in tdfx_setup()
152 dev->maplist = NULL; in tdfx_setup()
153 dev->map_count = 0; in tdfx_setup()
154 dev->vmalist = NULL; in tdfx_setup()
155 dev->lock.hw_lock = NULL; in tdfx_setup()
156 init_waitqueue_head(&dev->lock.lock_queue); in tdfx_setup()
157 dev->queue_count = 0; in tdfx_setup()
158 dev->queue_reserved = 0; in tdfx_setup()
159 dev->queue_slots = 0; in tdfx_setup()
160 dev->queuelist = NULL; in tdfx_setup()
161 dev->irq = 0; in tdfx_setup()
162 dev->context_flag = 0; in tdfx_setup()
163 dev->interrupt_flag = 0; in tdfx_setup()
164 dev->dma = 0; in tdfx_setup()
165 dev->dma_flag = 0; in tdfx_setup()
166 dev->last_context = 0; in tdfx_setup()
167 dev->last_switch = 0; in tdfx_setup()
168 dev->last_checked = 0; in tdfx_setup()
169 init_timer(&dev->timer); in tdfx_setup()
170 init_waitqueue_head(&dev->context_wait); in tdfx_setup()
172 dev->ctx_start = 0; in tdfx_setup()
173 dev->lck_start = 0; in tdfx_setup()
175 dev->buf_rp = dev->buf; in tdfx_setup()
176 dev->buf_wp = dev->buf; in tdfx_setup()
177 dev->buf_end = dev->buf + DRM_BSZ; in tdfx_setup()
178 dev->buf_async = NULL; in tdfx_setup()
179 init_waitqueue_head(&dev->buf_readers); in tdfx_setup()
180 init_waitqueue_head(&dev->buf_writers); in tdfx_setup()
196 static int tdfx_takedown(drm_device_t *dev) in tdfx_takedown() argument
205 down(&dev->struct_sem); in tdfx_takedown()
206 del_timer(&dev->timer); in tdfx_takedown()
208 if (dev->devname) { in tdfx_takedown()
209 drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); in tdfx_takedown()
210 dev->devname = NULL; in tdfx_takedown()
213 if (dev->unique) { in tdfx_takedown()
214 drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); in tdfx_takedown()
215 dev->unique = NULL; in tdfx_takedown()
216 dev->unique_len = 0; in tdfx_takedown()
220 for (pt = dev->magiclist[i].head; pt; pt = next) { in tdfx_takedown()
224 dev->magiclist[i].head = dev->magiclist[i].tail = NULL; in tdfx_takedown()
228 if (dev->agp) { in tdfx_takedown()
232 temp = dev->agp->memory; in tdfx_takedown()
239 if (dev->agp->acquired) _drm_agp_release(); in tdfx_takedown()
243 if (dev->vmalist) { in tdfx_takedown()
244 for (vma = dev->vmalist; vma; vma = vma_next) { in tdfx_takedown()
248 dev->vmalist = NULL; in tdfx_takedown()
252 if (dev->maplist) { in tdfx_takedown()
253 for (i = 0; i < dev->map_count; i++) { in tdfx_takedown()
254 map = dev->maplist[i]; in tdfx_takedown()
267 drm_ioremapfree(map->handle, map->size, dev); in tdfx_takedown()
282 drm_free(dev->maplist, in tdfx_takedown()
283 dev->map_count * sizeof(*dev->maplist), in tdfx_takedown()
285 dev->maplist = NULL; in tdfx_takedown()
286 dev->map_count = 0; in tdfx_takedown()
289 if (dev->lock.hw_lock) { in tdfx_takedown()
290 dev->lock.hw_lock = NULL; /* SHM removed */ in tdfx_takedown()
291 dev->lock.pid = 0; in tdfx_takedown()
292 wake_up_interruptible(&dev->lock.lock_queue); in tdfx_takedown()
294 up(&dev->struct_sem); in tdfx_takedown()
305 drm_device_t *dev = &tdfx_device; in tdfx_init() local
309 memset((void *)dev, 0, sizeof(*dev)); in tdfx_init()
310 dev->count_lock = SPIN_LOCK_UNLOCKED; in tdfx_init()
311 sema_init(&dev->struct_sem, 1); in tdfx_init()
321 dev->device = MKDEV(MISC_MAJOR, tdfx_misc.minor); in tdfx_init()
322 dev->name = TDFX_NAME; in tdfx_init()
325 drm_proc_init(dev); in tdfx_init()
327 dev->agp = drm_agp_init(); in tdfx_init()
329 if((retcode = drm_ctxbitmap_init(dev))) { in tdfx_init()
333 tdfx_takedown(dev); in tdfx_init()
352 drm_device_t *dev = &tdfx_device; in tdfx_cleanup() local
362 drm_ctxbitmap_cleanup(dev); in tdfx_cleanup()
363 tdfx_takedown(dev); in tdfx_cleanup()
365 if (dev->agp) { in tdfx_cleanup()
367 drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); in tdfx_cleanup()
368 dev->agp = NULL; in tdfx_cleanup()
414 drm_device_t *dev = &tdfx_device; in tdfx_open() local
417 DRM_DEBUG("open_count = %d\n", dev->open_count); in tdfx_open()
418 if (!(retcode = drm_open_helper(inode, filp, dev))) { in tdfx_open()
422 atomic_inc(&dev->total_open); in tdfx_open()
423 spin_lock(&dev->count_lock); in tdfx_open()
424 if (!dev->open_count++) { in tdfx_open()
425 spin_unlock(&dev->count_lock); in tdfx_open()
426 return tdfx_setup(dev); in tdfx_open()
428 spin_unlock(&dev->count_lock); in tdfx_open()
436 drm_device_t *dev; in tdfx_release() local
440 dev = priv->dev; in tdfx_release()
442 DRM_DEBUG("open_count = %d\n", dev->open_count); in tdfx_release()
447 atomic_inc(&dev->total_close); in tdfx_release()
448 spin_lock(&dev->count_lock); in tdfx_release()
449 if (!--dev->open_count) { in tdfx_release()
450 if (atomic_read(&dev->ioctl_count) || dev->blocked) { in tdfx_release()
452 atomic_read(&dev->ioctl_count), in tdfx_release()
453 dev->blocked); in tdfx_release()
454 spin_unlock(&dev->count_lock); in tdfx_release()
458 spin_unlock(&dev->count_lock); in tdfx_release()
460 return tdfx_takedown(dev); in tdfx_release()
462 spin_unlock(&dev->count_lock); in tdfx_release()
476 drm_device_t *dev = priv->dev; in tdfx_ioctl() local
481 atomic_inc(&dev->ioctl_count); in tdfx_ioctl()
482 atomic_inc(&dev->total_ioctl); in tdfx_ioctl()
486 current->pid, cmd, nr, dev->device, priv->authenticated); in tdfx_ioctl()
505 atomic_dec(&dev->ioctl_count); in tdfx_ioctl()
513 drm_device_t *dev = priv->dev; in tdfx_lock() local
520 dev->lck_start = start = get_cycles(); in tdfx_lock()
533 lock.context, current->pid, dev->lock.hw_lock->lock, in tdfx_lock()
539 if (lock.context < 0 || lock.context >= dev->queue_count) in tdfx_lock()
545 if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) in tdfx_lock()
547 long j = jiffies - dev->lock.lock_time; in tdfx_lock()
555 dev->lock.lock_time, jiffies); in tdfx_lock()
563 add_wait_queue(&dev->lock.lock_queue, &entry); in tdfx_lock()
566 if (!dev->lock.hw_lock) { in tdfx_lock()
571 if (drm_lock_take(&dev->lock.hw_lock->lock, in tdfx_lock()
573 dev->lock.pid = current->pid; in tdfx_lock()
574 dev->lock.lock_time = jiffies; in tdfx_lock()
575 atomic_inc(&dev->total_locks); in tdfx_lock()
580 atomic_inc(&dev->total_sleeps); in tdfx_lock()
588 remove_wait_queue(&dev->lock.lock_queue, &entry); in tdfx_lock()
592 if (!ret && dev->last_context != lock.context && in tdfx_lock()
594 dev->last_context != tdfx_res_ctx.handle) { in tdfx_lock()
595 add_wait_queue(&dev->context_wait, &entry); in tdfx_lock()
598 tdfx_context_switch(dev, dev->last_context, lock.context); in tdfx_lock()
606 remove_wait_queue(&dev->context_wait, &entry); in tdfx_lock()
609 } else if (dev->last_context != lock.context) { in tdfx_lock()
611 dev->last_context, lock.context); in tdfx_lock()
617 sigemptyset(&dev->sigmask); in tdfx_lock()
618 sigaddset(&dev->sigmask, SIGSTOP); in tdfx_lock()
619 sigaddset(&dev->sigmask, SIGTSTP); in tdfx_lock()
620 sigaddset(&dev->sigmask, SIGTTIN); in tdfx_lock()
621 sigaddset(&dev->sigmask, SIGTTOU); in tdfx_lock()
622 dev->sigdata.context = lock.context; in tdfx_lock()
623 dev->sigdata.lock = dev->lock.hw_lock; in tdfx_lock()
624 block_all_signals(drm_notifier, &dev->sigdata, &dev->sigmask); in tdfx_lock()
632 tdfx_quiescent(dev); in tdfx_lock()
646 atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]); in tdfx_lock()
657 drm_device_t *dev = priv->dev; in tdfx_unlock() local
671 _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); in tdfx_unlock()
672 atomic_inc(&dev->total_unlocks); in tdfx_unlock()
673 if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock)) in tdfx_unlock()
674 atomic_inc(&dev->total_contends); in tdfx_unlock()
675 drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT); in tdfx_unlock()
677 if (!dev->context_flag) { in tdfx_unlock()
678 if (drm_lock_free(dev, &dev->lock.hw_lock->lock, in tdfx_unlock()