Lines Matching refs:dev
145 static int mga_setup(drm_device_t *dev) in mga_setup() argument
149 atomic_set(&dev->ioctl_count, 0); in mga_setup()
150 atomic_set(&dev->vma_count, 0); in mga_setup()
151 dev->buf_use = 0; in mga_setup()
152 atomic_set(&dev->buf_alloc, 0); in mga_setup()
154 drm_dma_setup(dev); in mga_setup()
156 atomic_set(&dev->total_open, 0); in mga_setup()
157 atomic_set(&dev->total_close, 0); in mga_setup()
158 atomic_set(&dev->total_ioctl, 0); in mga_setup()
159 atomic_set(&dev->total_irq, 0); in mga_setup()
160 atomic_set(&dev->total_ctx, 0); in mga_setup()
161 atomic_set(&dev->total_locks, 0); in mga_setup()
162 atomic_set(&dev->total_unlocks, 0); in mga_setup()
163 atomic_set(&dev->total_contends, 0); in mga_setup()
164 atomic_set(&dev->total_sleeps, 0); in mga_setup()
167 dev->magiclist[i].head = NULL; in mga_setup()
168 dev->magiclist[i].tail = NULL; in mga_setup()
170 dev->maplist = NULL; in mga_setup()
171 dev->map_count = 0; in mga_setup()
172 dev->vmalist = NULL; in mga_setup()
173 dev->lock.hw_lock = NULL; in mga_setup()
174 init_waitqueue_head(&dev->lock.lock_queue); in mga_setup()
175 dev->queue_count = 0; in mga_setup()
176 dev->queue_reserved = 0; in mga_setup()
177 dev->queue_slots = 0; in mga_setup()
178 dev->queuelist = NULL; in mga_setup()
179 dev->irq = 0; in mga_setup()
180 dev->context_flag = 0; in mga_setup()
181 dev->interrupt_flag = 0; in mga_setup()
182 dev->dma_flag = 0; in mga_setup()
183 dev->last_context = 0; in mga_setup()
184 dev->last_switch = 0; in mga_setup()
185 dev->last_checked = 0; in mga_setup()
186 init_timer(&dev->timer); in mga_setup()
187 init_waitqueue_head(&dev->context_wait); in mga_setup()
189 dev->ctx_start = 0; in mga_setup()
190 dev->lck_start = 0; in mga_setup()
192 dev->buf_rp = dev->buf; in mga_setup()
193 dev->buf_wp = dev->buf; in mga_setup()
194 dev->buf_end = dev->buf + DRM_BSZ; in mga_setup()
195 dev->buf_async = NULL; in mga_setup()
196 init_waitqueue_head(&dev->buf_readers); in mga_setup()
197 init_waitqueue_head(&dev->buf_writers); in mga_setup()
211 static int mga_takedown(drm_device_t *dev) in mga_takedown() argument
220 if (dev->dev_private) mga_dma_cleanup(dev); in mga_takedown()
221 if (dev->irq) mga_irq_uninstall(dev); in mga_takedown()
223 down(&dev->struct_sem); in mga_takedown()
224 del_timer(&dev->timer); in mga_takedown()
226 if (dev->devname) { in mga_takedown()
227 drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); in mga_takedown()
228 dev->devname = NULL; in mga_takedown()
231 if (dev->unique) { in mga_takedown()
232 drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); in mga_takedown()
233 dev->unique = NULL; in mga_takedown()
234 dev->unique_len = 0; in mga_takedown()
238 for (pt = dev->magiclist[i].head; pt; pt = next) { in mga_takedown()
242 dev->magiclist[i].head = dev->magiclist[i].tail = NULL; in mga_takedown()
245 if (dev->agp) { in mga_takedown()
251 for (entry = dev->agp->memory; entry; entry = nexte) { in mga_takedown()
257 dev->agp->memory = NULL; in mga_takedown()
259 if (dev->agp->acquired) _drm_agp_release(); in mga_takedown()
261 dev->agp->acquired = 0; in mga_takedown()
262 dev->agp->enabled = 0; in mga_takedown()
265 if (dev->vmalist) { in mga_takedown()
266 for (vma = dev->vmalist; vma; vma = vma_next) { in mga_takedown()
270 dev->vmalist = NULL; in mga_takedown()
274 if (dev->maplist) { in mga_takedown()
275 for (i = 0; i < dev->map_count; i++) { in mga_takedown()
276 map = dev->maplist[i]; in mga_takedown()
289 drm_ioremapfree(map->handle, map->size, dev); in mga_takedown()
302 drm_free(dev->maplist, in mga_takedown()
303 dev->map_count * sizeof(*dev->maplist), in mga_takedown()
305 dev->maplist = NULL; in mga_takedown()
306 dev->map_count = 0; in mga_takedown()
309 if (dev->queuelist) { in mga_takedown()
310 for (i = 0; i < dev->queue_count; i++) { in mga_takedown()
311 drm_waitlist_destroy(&dev->queuelist[i]->waitlist); in mga_takedown()
312 if (dev->queuelist[i]) { in mga_takedown()
313 drm_free(dev->queuelist[i], in mga_takedown()
314 sizeof(*dev->queuelist[0]), in mga_takedown()
316 dev->queuelist[i] = NULL; in mga_takedown()
319 drm_free(dev->queuelist, in mga_takedown()
320 dev->queue_slots * sizeof(*dev->queuelist), in mga_takedown()
322 dev->queuelist = NULL; in mga_takedown()
325 drm_dma_takedown(dev); in mga_takedown()
327 dev->queue_count = 0; in mga_takedown()
328 if (dev->lock.hw_lock) { in mga_takedown()
329 dev->lock.hw_lock = NULL; /* SHM removed */ in mga_takedown()
330 dev->lock.pid = 0; in mga_takedown()
331 wake_up_interruptible(&dev->lock.lock_queue); in mga_takedown()
333 up(&dev->struct_sem); in mga_takedown()
344 drm_device_t *dev = &mga_device; in mga_init() local
348 memset((void *)dev, 0, sizeof(*dev)); in mga_init()
349 dev->count_lock = SPIN_LOCK_UNLOCKED; in mga_init()
350 sema_init(&dev->struct_sem, 1); in mga_init()
359 dev->device = MKDEV(MISC_MAJOR, mga_misc.minor); in mga_init()
360 dev->name = MGA_NAME; in mga_init()
363 drm_proc_init(dev); in mga_init()
364 dev->agp = drm_agp_init(); in mga_init()
365 if(dev->agp == NULL) { in mga_init()
371 mga_takedown(dev); in mga_init()
375 dev->agp->agp_mtrr = mtrr_add(dev->agp->agp_info.aper_base, in mga_init()
376 dev->agp->agp_info.aper_size * 1024 * 1024, in mga_init()
380 if((retcode = drm_ctxbitmap_init(dev))) { in mga_init()
384 mga_takedown(dev); in mga_init()
403 drm_device_t *dev = &mga_device; in mga_cleanup() local
413 drm_ctxbitmap_cleanup(dev); in mga_cleanup()
415 if(dev->agp && dev->agp->agp_mtrr) { in mga_cleanup()
417 retval = mtrr_del(dev->agp->agp_mtrr, in mga_cleanup()
418 dev->agp->agp_info.aper_base, in mga_cleanup()
419 dev->agp->agp_info.aper_size * 1024*1024); in mga_cleanup()
424 mga_takedown(dev); in mga_cleanup()
425 if (dev->agp) { in mga_cleanup()
427 drm_free(dev->agp, sizeof(*dev->agp), DRM_MEM_AGPLISTS); in mga_cleanup()
428 dev->agp = NULL; in mga_cleanup()
473 drm_device_t *dev = &mga_device; in mga_open() local
476 DRM_DEBUG("open_count = %d\n", dev->open_count); in mga_open()
477 if (!(retcode = drm_open_helper(inode, filp, dev))) { in mga_open()
481 atomic_inc(&dev->total_open); in mga_open()
482 spin_lock(&dev->count_lock); in mga_open()
483 if (!dev->open_count++) { in mga_open()
484 spin_unlock(&dev->count_lock); in mga_open()
485 return mga_setup(dev); in mga_open()
487 spin_unlock(&dev->count_lock); in mga_open()
495 drm_device_t *dev; in mga_release() local
499 dev = priv->dev; in mga_release()
501 current->pid, dev->device, dev->open_count); in mga_release()
503 if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) in mga_release()
504 && dev->lock.pid == current->pid) { in mga_release()
505 mga_reclaim_buffers(dev, priv->pid); in mga_release()
508 _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock), in mga_release()
509 dev->dev_private ? in mga_release()
510 ((drm_mga_private_t *)dev->dev_private) in mga_release()
514 if (dev->dev_private) in mga_release()
515 ((drm_mga_private_t *)dev->dev_private) in mga_release()
518 drm_lock_free(dev, in mga_release()
519 &dev->lock.hw_lock->lock, in mga_release()
520 _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); in mga_release()
521 } else if (dev->lock.hw_lock) { in mga_release()
524 add_wait_queue(&dev->lock.lock_queue, &entry); in mga_release()
527 if (!dev->lock.hw_lock) { in mga_release()
532 if (drm_lock_take(&dev->lock.hw_lock->lock, in mga_release()
534 dev->lock.pid = priv->pid; in mga_release()
535 dev->lock.lock_time = jiffies; in mga_release()
536 atomic_inc(&dev->total_locks); in mga_release()
540 atomic_inc(&dev->total_sleeps); in mga_release()
548 remove_wait_queue(&dev->lock.lock_queue, &entry); in mga_release()
550 mga_reclaim_buffers(dev, priv->pid); in mga_release()
551 if (dev->dev_private) in mga_release()
552 ((drm_mga_private_t *)dev->dev_private) in mga_release()
554 drm_lock_free(dev, &dev->lock.hw_lock->lock, in mga_release()
560 down(&dev->struct_sem); in mga_release()
562 drm_file_t *temp = dev->file_first; in mga_release()
569 else dev->file_first = priv->next; in mga_release()
571 else dev->file_last = priv->prev; in mga_release()
572 up(&dev->struct_sem); in mga_release()
578 atomic_inc(&dev->total_close); in mga_release()
579 spin_lock(&dev->count_lock); in mga_release()
580 if (!--dev->open_count) { in mga_release()
581 if (atomic_read(&dev->ioctl_count) || dev->blocked) { in mga_release()
583 atomic_read(&dev->ioctl_count), in mga_release()
584 dev->blocked); in mga_release()
585 spin_unlock(&dev->count_lock); in mga_release()
589 spin_unlock(&dev->count_lock); in mga_release()
591 return mga_takedown(dev); in mga_release()
593 spin_unlock(&dev->count_lock); in mga_release()
606 drm_device_t *dev = priv->dev; in mga_ioctl() local
611 atomic_inc(&dev->ioctl_count); in mga_ioctl()
612 atomic_inc(&dev->total_ioctl); in mga_ioctl()
624 current->pid, cmd, nr, dev->device, in mga_ioctl()
635 atomic_dec(&dev->ioctl_count); in mga_ioctl()
643 drm_device_t *dev = priv->dev; in mga_unlock() local
655 atomic_inc(&dev->total_unlocks); in mga_unlock()
656 if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock)) in mga_unlock()
657 atomic_inc(&dev->total_contends); in mga_unlock()
658 drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT); in mga_unlock()
659 mga_dma_schedule(dev, 1); in mga_unlock()
661 if (drm_lock_free(dev, &dev->lock.hw_lock->lock, in mga_unlock()