Lines Matching refs:ctx

37  * of extra utility/tracking out of our acquire-ctx.  This is provided
44 * drm_modeset_acquire_init(ctx, DRM_MODESET_ACQUIRE_INTERRUPTIBLE)
47 * ret = drm_modeset_lock(lock, ctx)
49 * ret = drm_modeset_backoff(ctx);
58 * drm_modeset_drop_locks(ctx);
59 * drm_modeset_acquire_fini(ctx);
67 * by passing a NULL instead of ctx in the drm_modeset_lock() call or
146 struct drm_modeset_acquire_ctx *ctx;
149 ctx = kzalloc(sizeof(*ctx), GFP_KERNEL | __GFP_NOFAIL);
150 if (WARN_ON(!ctx))
155 drm_modeset_acquire_init(ctx, 0);
158 ret = drm_modeset_lock_all_ctx(dev, ctx);
161 drm_modeset_backoff(ctx);
165 drm_modeset_acquire_fini(ctx);
166 kfree(ctx);
169 ww_acquire_done(&ctx->ww_ctx);
177 config->acquire_ctx = ctx;
200 struct drm_modeset_acquire_ctx *ctx = config->acquire_ctx;
202 if (WARN_ON(!ctx))
206 drm_modeset_drop_locks(ctx);
207 drm_modeset_acquire_fini(ctx);
209 kfree(ctx);
239 * @ctx: the acquire context
246 void drm_modeset_acquire_init(struct drm_modeset_acquire_ctx *ctx,
249 memset(ctx, 0, sizeof(*ctx));
250 ww_acquire_init(&ctx->ww_ctx, &crtc_ww_class);
251 INIT_LIST_HEAD(&ctx->locked);
254 ctx->interruptible = true;
260 * @ctx: the acquire context
262 void drm_modeset_acquire_fini(struct drm_modeset_acquire_ctx *ctx)
264 ww_acquire_fini(&ctx->ww_ctx);
270 * @ctx: the acquire context
274 void drm_modeset_drop_locks(struct drm_modeset_acquire_ctx *ctx)
276 if (WARN_ON(ctx->contended))
277 __drm_stack_depot_print(ctx->stack_depot);
279 while (!list_empty(&ctx->locked)) {
282 lock = list_first_entry(&ctx->locked,
291 struct drm_modeset_acquire_ctx *ctx,
296 if (WARN_ON(ctx->contended))
297 __drm_stack_depot_print(ctx->stack_depot);
299 if (ctx->trylock_only) {
300 lockdep_assert_held(&ctx->ww_ctx);
307 ret = ww_mutex_lock_slow_interruptible(&lock->mutex, &ctx->ww_ctx);
309 ret = ww_mutex_lock_interruptible(&lock->mutex, &ctx->ww_ctx);
311 ww_mutex_lock_slow(&lock->mutex, &ctx->ww_ctx);
314 ret = ww_mutex_lock(&lock->mutex, &ctx->ww_ctx);
318 list_add(&lock->head, &ctx->locked);
327 ctx->contended = lock;
328 ctx->stack_depot = __drm_stack_depot_save();
336 * @ctx: the acquire context
346 int drm_modeset_backoff(struct drm_modeset_acquire_ctx *ctx)
348 struct drm_modeset_lock *contended = ctx->contended;
350 ctx->contended = NULL;
351 ctx->stack_depot = 0;
356 drm_modeset_drop_locks(ctx);
358 return modeset_lock(contended, ctx, ctx->interruptible, true);
377 * @ctx: acquire ctx
379 * If @ctx is not NULL, then its ww acquire context is used and the
385 * If the @ctx is not NULL and initialized with
389 * If @ctx is NULL then the function call behaves like a normal,
393 struct drm_modeset_acquire_ctx *ctx)
395 if (ctx)
396 return modeset_lock(lock, ctx, ctx->interruptible, false);
432 * @ctx: lock acquisition context
440 * @ctx.
443 * drm_modeset_drop_locks() function on @ctx.
450 struct drm_modeset_acquire_ctx *ctx)
457 ret = drm_modeset_lock(&dev->mode_config.connection_mutex, ctx);
462 ret = drm_modeset_lock(&crtc->mutex, ctx);
468 ret = drm_modeset_lock(&plane->mutex, ctx);
474 ret = drm_modeset_lock(&privobj->lock, ctx);