Lines Matching refs:dev

135 static int gamma_setup(drm_device_t *dev)  in gamma_setup()  argument
139 atomic_set(&dev->ioctl_count, 0); in gamma_setup()
140 atomic_set(&dev->vma_count, 0); in gamma_setup()
141 dev->buf_use = 0; in gamma_setup()
142 atomic_set(&dev->buf_alloc, 0); in gamma_setup()
144 drm_dma_setup(dev); in gamma_setup()
146 atomic_set(&dev->total_open, 0); in gamma_setup()
147 atomic_set(&dev->total_close, 0); in gamma_setup()
148 atomic_set(&dev->total_ioctl, 0); in gamma_setup()
149 atomic_set(&dev->total_irq, 0); in gamma_setup()
150 atomic_set(&dev->total_ctx, 0); in gamma_setup()
151 atomic_set(&dev->total_locks, 0); in gamma_setup()
152 atomic_set(&dev->total_unlocks, 0); in gamma_setup()
153 atomic_set(&dev->total_contends, 0); in gamma_setup()
154 atomic_set(&dev->total_sleeps, 0); in gamma_setup()
157 dev->magiclist[i].head = NULL; in gamma_setup()
158 dev->magiclist[i].tail = NULL; in gamma_setup()
160 dev->maplist = NULL; in gamma_setup()
161 dev->map_count = 0; in gamma_setup()
162 dev->vmalist = NULL; in gamma_setup()
163 dev->lock.hw_lock = NULL; in gamma_setup()
164 init_waitqueue_head(&dev->lock.lock_queue); in gamma_setup()
165 dev->queue_count = 0; in gamma_setup()
166 dev->queue_reserved = 0; in gamma_setup()
167 dev->queue_slots = 0; in gamma_setup()
168 dev->queuelist = NULL; in gamma_setup()
169 dev->irq = 0; in gamma_setup()
170 dev->context_flag = 0; in gamma_setup()
171 dev->interrupt_flag = 0; in gamma_setup()
172 dev->dma_flag = 0; in gamma_setup()
173 dev->last_context = 0; in gamma_setup()
174 dev->last_switch = 0; in gamma_setup()
175 dev->last_checked = 0; in gamma_setup()
176 init_timer(&dev->timer); in gamma_setup()
177 init_waitqueue_head(&dev->context_wait); in gamma_setup()
179 memset(&dev->histo, 0, sizeof(dev->histo)); in gamma_setup()
181 dev->ctx_start = 0; in gamma_setup()
182 dev->lck_start = 0; in gamma_setup()
184 dev->buf_rp = dev->buf; in gamma_setup()
185 dev->buf_wp = dev->buf; in gamma_setup()
186 dev->buf_end = dev->buf + DRM_BSZ; in gamma_setup()
187 dev->buf_async = NULL; in gamma_setup()
188 init_waitqueue_head(&dev->buf_readers); in gamma_setup()
189 init_waitqueue_head(&dev->buf_writers); in gamma_setup()
203 static int gamma_takedown(drm_device_t *dev) in gamma_takedown() argument
212 if (dev->irq) gamma_irq_uninstall(dev); in gamma_takedown()
214 down(&dev->struct_sem); in gamma_takedown()
215 del_timer(&dev->timer); in gamma_takedown()
217 if (dev->devname) { in gamma_takedown()
218 drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); in gamma_takedown()
219 dev->devname = NULL; in gamma_takedown()
222 if (dev->unique) { in gamma_takedown()
223 drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); in gamma_takedown()
224 dev->unique = NULL; in gamma_takedown()
225 dev->unique_len = 0; in gamma_takedown()
229 for (pt = dev->magiclist[i].head; pt; pt = next) { in gamma_takedown()
233 dev->magiclist[i].head = dev->magiclist[i].tail = NULL; in gamma_takedown()
237 if (dev->vmalist) { in gamma_takedown()
238 for (vma = dev->vmalist; vma; vma = vma_next) { in gamma_takedown()
242 dev->vmalist = NULL; in gamma_takedown()
246 if (dev->maplist) { in gamma_takedown()
247 for (i = 0; i < dev->map_count; i++) { in gamma_takedown()
248 map = dev->maplist[i]; in gamma_takedown()
261 drm_ioremapfree(map->handle, map->size, dev); in gamma_takedown()
276 drm_free(dev->maplist, in gamma_takedown()
277 dev->map_count * sizeof(*dev->maplist), in gamma_takedown()
279 dev->maplist = NULL; in gamma_takedown()
280 dev->map_count = 0; in gamma_takedown()
283 if (dev->queuelist) { in gamma_takedown()
284 for (i = 0; i < dev->queue_count; i++) { in gamma_takedown()
285 drm_waitlist_destroy(&dev->queuelist[i]->waitlist); in gamma_takedown()
286 if (dev->queuelist[i]) { in gamma_takedown()
287 drm_free(dev->queuelist[i], in gamma_takedown()
288 sizeof(*dev->queuelist[0]), in gamma_takedown()
290 dev->queuelist[i] = NULL; in gamma_takedown()
293 drm_free(dev->queuelist, in gamma_takedown()
294 dev->queue_slots * sizeof(*dev->queuelist), in gamma_takedown()
296 dev->queuelist = NULL; in gamma_takedown()
299 drm_dma_takedown(dev); in gamma_takedown()
301 dev->queue_count = 0; in gamma_takedown()
302 if (dev->lock.hw_lock) { in gamma_takedown()
303 dev->lock.hw_lock = NULL; /* SHM removed */ in gamma_takedown()
304 dev->lock.pid = 0; in gamma_takedown()
305 wake_up_interruptible(&dev->lock.lock_queue); in gamma_takedown()
307 up(&dev->struct_sem); in gamma_takedown()
346 drm_device_t *dev = &gamma_device; in gamma_init() local
350 memset((void *)dev, 0, sizeof(*dev)); in gamma_init()
351 dev->count_lock = SPIN_LOCK_UNLOCKED; in gamma_init()
352 sema_init(&dev->struct_sem, 1); in gamma_init()
364 dev->device = MKDEV(MISC_MAJOR, gamma_misc.minor); in gamma_init()
365 dev->name = GAMMA_NAME; in gamma_init()
368 drm_proc_init(dev); in gamma_init()
386 drm_device_t *dev = &gamma_device; in gamma_cleanup() local
396 gamma_takedown(dev); in gamma_cleanup()
440 drm_device_t *dev = &gamma_device; in gamma_open() local
443 DRM_DEBUG("open_count = %d\n", dev->open_count); in gamma_open()
444 if (!(retcode = drm_open_helper(inode, filp, dev))) { in gamma_open()
448 atomic_inc(&dev->total_open); in gamma_open()
449 spin_lock(&dev->count_lock); in gamma_open()
450 if (!dev->open_count++) { in gamma_open()
451 spin_unlock(&dev->count_lock); in gamma_open()
452 return gamma_setup(dev); in gamma_open()
454 spin_unlock(&dev->count_lock); in gamma_open()
462 drm_device_t *dev; in gamma_release() local
466 dev = priv->dev; in gamma_release()
468 DRM_DEBUG("open_count = %d\n", dev->open_count); in gamma_release()
473 atomic_inc(&dev->total_close); in gamma_release()
474 spin_lock(&dev->count_lock); in gamma_release()
475 if (!--dev->open_count) { in gamma_release()
476 if (atomic_read(&dev->ioctl_count) || dev->blocked) { in gamma_release()
478 atomic_read(&dev->ioctl_count), in gamma_release()
479 dev->blocked); in gamma_release()
480 spin_unlock(&dev->count_lock); in gamma_release()
484 spin_unlock(&dev->count_lock); in gamma_release()
486 return gamma_takedown(dev); in gamma_release()
488 spin_unlock(&dev->count_lock); in gamma_release()
501 drm_device_t *dev = priv->dev; in gamma_ioctl() local
506 atomic_inc(&dev->ioctl_count); in gamma_ioctl()
507 atomic_inc(&dev->total_ioctl); in gamma_ioctl()
511 current->pid, cmd, nr, dev->device, priv->authenticated); in gamma_ioctl()
530 atomic_dec(&dev->ioctl_count); in gamma_ioctl()
539 drm_device_t *dev = priv->dev; in gamma_unlock() local
553 _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); in gamma_unlock()
554 atomic_inc(&dev->total_unlocks); in gamma_unlock()
555 if (_DRM_LOCK_IS_CONT(dev->lock.hw_lock->lock)) in gamma_unlock()
556 atomic_inc(&dev->total_contends); in gamma_unlock()
557 drm_lock_transfer(dev, &dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT); in gamma_unlock()
558 gamma_dma_schedule(dev, 1); in gamma_unlock()
559 if (!dev->context_flag) { in gamma_unlock()
560 if (drm_lock_free(dev, &dev->lock.hw_lock->lock, in gamma_unlock()
566 atomic_inc(&dev->histo.lhld[drm_histogram_slot(get_cycles() in gamma_unlock()
567 - dev->lck_start)]); in gamma_unlock()