Lines Matching refs:exec

54 static void drm_exec_unlock_all(struct drm_exec *exec)  in drm_exec_unlock_all()  argument
59 drm_exec_for_each_locked_object_reverse(exec, index, obj) { in drm_exec_unlock_all()
64 drm_gem_object_put(exec->prelocked); in drm_exec_unlock_all()
65 exec->prelocked = NULL; in drm_exec_unlock_all()
75 void drm_exec_init(struct drm_exec *exec, uint32_t flags) in drm_exec_init() argument
77 exec->flags = flags; in drm_exec_init()
78 exec->objects = kmalloc(PAGE_SIZE, GFP_KERNEL); in drm_exec_init()
81 exec->max_objects = exec->objects ? PAGE_SIZE / sizeof(void *) : 0; in drm_exec_init()
82 exec->num_objects = 0; in drm_exec_init()
83 exec->contended = DRM_EXEC_DUMMY; in drm_exec_init()
84 exec->prelocked = NULL; in drm_exec_init()
95 void drm_exec_fini(struct drm_exec *exec) in drm_exec_fini() argument
97 drm_exec_unlock_all(exec); in drm_exec_fini()
98 kvfree(exec->objects); in drm_exec_fini()
99 if (exec->contended != DRM_EXEC_DUMMY) { in drm_exec_fini()
100 drm_gem_object_put(exec->contended); in drm_exec_fini()
101 ww_acquire_fini(&exec->ticket); in drm_exec_fini()
114 bool drm_exec_cleanup(struct drm_exec *exec) in drm_exec_cleanup() argument
116 if (likely(!exec->contended)) { in drm_exec_cleanup()
117 ww_acquire_done(&exec->ticket); in drm_exec_cleanup()
121 if (likely(exec->contended == DRM_EXEC_DUMMY)) { in drm_exec_cleanup()
122 exec->contended = NULL; in drm_exec_cleanup()
123 ww_acquire_init(&exec->ticket, &reservation_ww_class); in drm_exec_cleanup()
127 drm_exec_unlock_all(exec); in drm_exec_cleanup()
128 exec->num_objects = 0; in drm_exec_cleanup()
134 static int drm_exec_obj_locked(struct drm_exec *exec, in drm_exec_obj_locked() argument
137 if (unlikely(exec->num_objects == exec->max_objects)) { in drm_exec_obj_locked()
138 size_t size = exec->max_objects * sizeof(void *); in drm_exec_obj_locked()
141 tmp = kvrealloc(exec->objects, size, size + PAGE_SIZE, in drm_exec_obj_locked()
146 exec->objects = tmp; in drm_exec_obj_locked()
147 exec->max_objects += PAGE_SIZE / sizeof(void *); in drm_exec_obj_locked()
150 exec->objects[exec->num_objects++] = obj; in drm_exec_obj_locked()
156 static int drm_exec_lock_contended(struct drm_exec *exec) in drm_exec_lock_contended() argument
158 struct drm_gem_object *obj = exec->contended; in drm_exec_lock_contended()
165 exec->contended = NULL; in drm_exec_lock_contended()
166 if (exec->flags & DRM_EXEC_INTERRUPTIBLE_WAIT) { in drm_exec_lock_contended()
168 &exec->ticket); in drm_exec_lock_contended()
172 dma_resv_lock_slow(obj->resv, &exec->ticket); in drm_exec_lock_contended()
175 ret = drm_exec_obj_locked(exec, obj); in drm_exec_lock_contended()
179 exec->prelocked = obj; in drm_exec_lock_contended()
201 int drm_exec_lock_obj(struct drm_exec *exec, struct drm_gem_object *obj) in drm_exec_lock_obj() argument
205 ret = drm_exec_lock_contended(exec); in drm_exec_lock_obj()
209 if (exec->prelocked == obj) { in drm_exec_lock_obj()
210 drm_gem_object_put(exec->prelocked); in drm_exec_lock_obj()
211 exec->prelocked = NULL; in drm_exec_lock_obj()
215 if (exec->flags & DRM_EXEC_INTERRUPTIBLE_WAIT) in drm_exec_lock_obj()
216 ret = dma_resv_lock_interruptible(obj->resv, &exec->ticket); in drm_exec_lock_obj()
218 ret = dma_resv_lock(obj->resv, &exec->ticket); in drm_exec_lock_obj()
222 exec->contended = obj; in drm_exec_lock_obj()
227 exec->flags & DRM_EXEC_IGNORE_DUPLICATES) in drm_exec_lock_obj()
233 ret = drm_exec_obj_locked(exec, obj); in drm_exec_lock_obj()
254 void drm_exec_unlock_obj(struct drm_exec *exec, struct drm_gem_object *obj) in drm_exec_unlock_obj() argument
258 for (i = exec->num_objects; i--;) { in drm_exec_unlock_obj()
259 if (exec->objects[i] == obj) { in drm_exec_unlock_obj()
261 for (++i; i < exec->num_objects; ++i) in drm_exec_unlock_obj()
262 exec->objects[i - 1] = exec->objects[i]; in drm_exec_unlock_obj()
263 --exec->num_objects; in drm_exec_unlock_obj()
283 int drm_exec_prepare_obj(struct drm_exec *exec, struct drm_gem_object *obj, in drm_exec_prepare_obj() argument
288 ret = drm_exec_lock_obj(exec, obj); in drm_exec_prepare_obj()
294 drm_exec_unlock_obj(exec, obj); in drm_exec_prepare_obj()
315 int drm_exec_prepare_array(struct drm_exec *exec, in drm_exec_prepare_array() argument
323 ret = drm_exec_prepare_obj(exec, objects[i], num_fences); in drm_exec_prepare_array()