Lines Matching +full:device +full:- +full:handle
42 drm_context_t handle; member
51 * Free a handle from the context bitmap.
53 * \param dev DRM device.
54 * \param ctx_handle context handle.
66 mutex_lock(&dev->struct_mutex); in drm_legacy_ctxbitmap_free()
67 idr_remove(&dev->ctx_idr, ctx_handle); in drm_legacy_ctxbitmap_free()
68 mutex_unlock(&dev->struct_mutex); in drm_legacy_ctxbitmap_free()
74 * \param dev DRM device.
75 * \return (non-negative) context handle on success or a negative number on failure.
84 mutex_lock(&dev->struct_mutex); in drm_legacy_ctxbitmap_next()
85 ret = idr_alloc(&dev->ctx_idr, NULL, DRM_RESERVED_CONTEXTS, 0, in drm_legacy_ctxbitmap_next()
87 mutex_unlock(&dev->struct_mutex); in drm_legacy_ctxbitmap_next()
94 * \param dev DRM device.
104 idr_init(&dev->ctx_idr); in drm_legacy_ctxbitmap_init()
110 * \param dev DRM device.
121 mutex_lock(&dev->struct_mutex); in drm_legacy_ctxbitmap_cleanup()
122 idr_destroy(&dev->ctx_idr); in drm_legacy_ctxbitmap_cleanup()
123 mutex_unlock(&dev->struct_mutex); in drm_legacy_ctxbitmap_cleanup()
127 * drm_legacy_ctxbitmap_flush() - Flush all contexts owned by a file
128 * @dev: DRM device to operate on
143 mutex_lock(&dev->ctxlist_mutex); in drm_legacy_ctxbitmap_flush()
145 list_for_each_entry_safe(pos, tmp, &dev->ctxlist, head) { in drm_legacy_ctxbitmap_flush()
146 if (pos->tag == file && in drm_legacy_ctxbitmap_flush()
147 pos->handle != DRM_KERNEL_CONTEXT) { in drm_legacy_ctxbitmap_flush()
148 if (dev->driver->context_dtor) in drm_legacy_ctxbitmap_flush()
149 dev->driver->context_dtor(dev, pos->handle); in drm_legacy_ctxbitmap_flush()
151 drm_legacy_ctxbitmap_free(dev, pos->handle); in drm_legacy_ctxbitmap_flush()
152 list_del(&pos->head); in drm_legacy_ctxbitmap_flush()
157 mutex_unlock(&dev->ctxlist_mutex); in drm_legacy_ctxbitmap_flush()
167 * Get per-context SAREA.
169 * \param inode device inode.
175 * Gets the map from drm_device::ctx_idr with the handle specified and
176 * returns its handle.
187 return -EOPNOTSUPP; in drm_legacy_getsareactx()
189 mutex_lock(&dev->struct_mutex); in drm_legacy_getsareactx()
191 map = idr_find(&dev->ctx_idr, request->ctx_id); in drm_legacy_getsareactx()
193 mutex_unlock(&dev->struct_mutex); in drm_legacy_getsareactx()
194 return -EINVAL; in drm_legacy_getsareactx()
197 request->handle = NULL; in drm_legacy_getsareactx()
198 list_for_each_entry(_entry, &dev->maplist, head) { in drm_legacy_getsareactx()
199 if (_entry->map == map) { in drm_legacy_getsareactx()
200 request->handle = in drm_legacy_getsareactx()
201 (void *)(unsigned long)_entry->user_token; in drm_legacy_getsareactx()
206 mutex_unlock(&dev->struct_mutex); in drm_legacy_getsareactx()
208 if (request->handle == NULL) in drm_legacy_getsareactx()
209 return -EINVAL; in drm_legacy_getsareactx()
215 * Set per-context SAREA.
217 * \param inode device inode.
235 return -EOPNOTSUPP; in drm_legacy_setsareactx()
237 mutex_lock(&dev->struct_mutex); in drm_legacy_setsareactx()
238 list_for_each_entry(r_list, &dev->maplist, head) { in drm_legacy_setsareactx()
239 if (r_list->map in drm_legacy_setsareactx()
240 && r_list->user_token == (unsigned long) request->handle) in drm_legacy_setsareactx()
244 mutex_unlock(&dev->struct_mutex); in drm_legacy_setsareactx()
245 return -EINVAL; in drm_legacy_setsareactx()
248 map = r_list->map; in drm_legacy_setsareactx()
252 if (IS_ERR(idr_replace(&dev->ctx_idr, map, request->ctx_id))) in drm_legacy_setsareactx()
255 mutex_unlock(&dev->struct_mutex); in drm_legacy_setsareactx()
269 * \param dev DRM device.
270 * \param old old context handle.
271 * \param new new context handle.
278 if (test_and_set_bit(0, &dev->context_flag)) { in drm_context_switch()
279 DRM_ERROR("Reentering -- FIXME\n"); in drm_context_switch()
280 return -EBUSY; in drm_context_switch()
285 if (new == dev->last_context) { in drm_context_switch()
286 clear_bit(0, &dev->context_flag); in drm_context_switch()
296 * \param dev DRM device.
297 * \param new new context handle.
307 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ in drm_context_switch_complete()
309 if (!_DRM_LOCK_IS_HELD(file_priv->master->lock.hw_lock->lock)) { in drm_context_switch_complete()
317 clear_bit(0, &dev->context_flag); in drm_context_switch_complete()
325 * \param inode device inode.
340 return -EOPNOTSUPP; in drm_legacy_resctx()
342 if (res->count >= DRM_RESERVED_CONTEXTS) { in drm_legacy_resctx()
345 ctx.handle = i; in drm_legacy_resctx()
346 if (copy_to_user(&res->contexts[i], &ctx, sizeof(ctx))) in drm_legacy_resctx()
347 return -EFAULT; in drm_legacy_resctx()
350 res->count = DRM_RESERVED_CONTEXTS; in drm_legacy_resctx()
358 * \param inode device inode.
364 * Get a new handle for the context and copy to userspace.
375 return -EOPNOTSUPP; in drm_legacy_addctx()
385 /* Should this return -EBUSY instead? */ in drm_legacy_addctx()
389 ctx->handle = tmp_handle; in drm_legacy_addctx()
394 return -ENOMEM; in drm_legacy_addctx()
397 INIT_LIST_HEAD(&ctx_entry->head); in drm_legacy_addctx()
398 ctx_entry->handle = ctx->handle; in drm_legacy_addctx()
399 ctx_entry->tag = file_priv; in drm_legacy_addctx()
401 mutex_lock(&dev->ctxlist_mutex); in drm_legacy_addctx()
402 list_add(&ctx_entry->head, &dev->ctxlist); in drm_legacy_addctx()
403 mutex_unlock(&dev->ctxlist_mutex); in drm_legacy_addctx()
411 * \param inode device inode.
424 return -EOPNOTSUPP; in drm_legacy_getctx()
426 /* This is 0, because we don't handle any context flags */ in drm_legacy_getctx()
427 ctx->flags = 0; in drm_legacy_getctx()
435 * \param inode device inode.
450 return -EOPNOTSUPP; in drm_legacy_switchctx()
452 DRM_DEBUG("%d\n", ctx->handle); in drm_legacy_switchctx()
453 return drm_context_switch(dev, dev->last_context, ctx->handle); in drm_legacy_switchctx()
459 * \param inode device inode.
474 return -EOPNOTSUPP; in drm_legacy_newctx()
476 DRM_DEBUG("%d\n", ctx->handle); in drm_legacy_newctx()
477 drm_context_switch_complete(dev, file_priv, ctx->handle); in drm_legacy_newctx()
485 * \param inode device inode.
500 return -EOPNOTSUPP; in drm_legacy_rmctx()
502 DRM_DEBUG("%d\n", ctx->handle); in drm_legacy_rmctx()
503 if (ctx->handle != DRM_KERNEL_CONTEXT) { in drm_legacy_rmctx()
504 if (dev->driver->context_dtor) in drm_legacy_rmctx()
505 dev->driver->context_dtor(dev, ctx->handle); in drm_legacy_rmctx()
506 drm_legacy_ctxbitmap_free(dev, ctx->handle); in drm_legacy_rmctx()
509 mutex_lock(&dev->ctxlist_mutex); in drm_legacy_rmctx()
510 if (!list_empty(&dev->ctxlist)) { in drm_legacy_rmctx()
513 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) { in drm_legacy_rmctx()
514 if (pos->handle == ctx->handle) { in drm_legacy_rmctx()
515 list_del(&pos->head); in drm_legacy_rmctx()
520 mutex_unlock(&dev->ctxlist_mutex); in drm_legacy_rmctx()