Lines Matching refs:dev
37 __FBSDID("$FreeBSD: releng/11.0/sys/dev/drm2/drm_context.c 280183 2015-03-17 18:50:33Z dumbbell $");
46 #include <dev/drm2/drmP.h>
55 * \param dev DRM device.
62 void drm_ctxbitmap_free(struct drm_device * dev, int ctx_handle)
65 dev->ctx_bitmap == NULL) {
71 DRM_LOCK(dev);
72 clear_bit(ctx_handle, dev->ctx_bitmap);
73 dev->context_sareas[ctx_handle] = NULL;
74 DRM_UNLOCK(dev);
80 * \param dev DRM device.
86 static int drm_ctxbitmap_next(struct drm_device * dev)
90 if (dev->ctx_bitmap == NULL)
93 DRM_LOCK(dev);
94 bit = find_first_zero_bit(dev->ctx_bitmap, DRM_MAX_CTXBITMAP);
96 DRM_UNLOCK(dev);
100 set_bit(bit, dev->ctx_bitmap);
102 if ((bit+1) > dev->max_context) {
106 ctx_sareas = realloc(dev->context_sareas,
107 max_ctx * sizeof(*dev->context_sareas),
110 clear_bit(bit, dev->ctx_bitmap);
112 DRM_UNLOCK(dev);
115 dev->max_context = max_ctx;
116 dev->context_sareas = ctx_sareas;
117 dev->context_sareas[bit] = NULL;
119 DRM_UNLOCK(dev);
126 * \param dev DRM device.
130 int drm_ctxbitmap_init(struct drm_device * dev)
135 DRM_LOCK(dev);
136 dev->ctx_bitmap = malloc(PAGE_SIZE, DRM_MEM_CTXBITMAP,
138 if (dev->ctx_bitmap == NULL) {
139 DRM_UNLOCK(dev);
142 dev->context_sareas = NULL;
143 dev->max_context = -1;
144 DRM_UNLOCK(dev);
147 temp = drm_ctxbitmap_next(dev);
157 * \param dev DRM device.
162 void drm_ctxbitmap_cleanup(struct drm_device * dev)
164 DRM_LOCK(dev);
165 if (dev->context_sareas != NULL)
166 free(dev->context_sareas, DRM_MEM_SAREA);
167 free(dev->ctx_bitmap, DRM_MEM_CTXBITMAP);
168 DRM_UNLOCK(dev);
189 int drm_getsareactx(struct drm_device *dev, void *data,
195 DRM_LOCK(dev);
196 if (dev->max_context < 0 ||
197 request->ctx_id >= (unsigned) dev->max_context) {
198 DRM_UNLOCK(dev);
202 map = dev->context_sareas[request->ctx_id];
203 DRM_UNLOCK(dev);
222 int drm_setsareactx(struct drm_device *dev, void *data,
229 DRM_LOCK(dev);
230 list_for_each_entry(r_list, &dev->maplist, head) {
233 if (dev->max_context < 0)
235 if (request->ctx_id >= (unsigned) dev->max_context)
237 dev->context_sareas[request->ctx_id] = map;
238 DRM_UNLOCK(dev);
244 DRM_UNLOCK(dev);
257 * \param dev DRM device.
264 static int drm_context_switch(struct drm_device * dev, int old, int new)
266 if (test_and_set_bit(0, &dev->context_flag)) {
273 if (new == dev->last_context) {
274 clear_bit(0, &dev->context_flag);
284 * \param dev DRM device.
292 static int drm_context_switch_complete(struct drm_device *dev,
295 dev->last_context = new; /* PRE/POST: This is the _only_ writer. */
296 dev->last_switch = jiffies;
305 clear_bit(0, &dev->context_flag);
306 wakeup(&dev->context_wait);
320 int drm_resctx(struct drm_device *dev, void *data,
351 int drm_addctx(struct drm_device *dev, void *data,
357 ctx->handle = drm_ctxbitmap_next(dev);
360 ctx->handle = drm_ctxbitmap_next(dev);
379 DRM_LOCK(dev);
380 list_add(&ctx_entry->head, &dev->ctxlist);
381 ++dev->ctx_count;
382 DRM_UNLOCK(dev);
387 int drm_modctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
402 int drm_getctx(struct drm_device *dev, void *data, struct drm_file *file_priv)
423 int drm_switchctx(struct drm_device *dev, void *data,
429 return drm_context_switch(dev, dev->last_context, ctx->handle);
443 int drm_newctx(struct drm_device *dev, void *data,
449 drm_context_switch_complete(dev, file_priv, ctx->handle);
465 int drm_rmctx(struct drm_device *dev, void *data,
472 if (dev->driver->context_dtor)
473 dev->driver->context_dtor(dev, ctx->handle);
474 drm_ctxbitmap_free(dev, ctx->handle);
477 DRM_LOCK(dev);
478 if (!list_empty(&dev->ctxlist)) {
481 list_for_each_entry_safe(pos, n, &dev->ctxlist, head) {
485 --dev->ctx_count;
489 DRM_UNLOCK(dev);