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()
79 void drm_exec_init(struct drm_exec *exec, u32 flags, unsigned nr) in drm_exec_init() argument
84 exec->flags = flags; in drm_exec_init()
85 exec->objects = kvmalloc_array(nr, sizeof(void *), GFP_KERNEL); in drm_exec_init()
88 exec->max_objects = exec->objects ? nr : 0; in drm_exec_init()
89 exec->num_objects = 0; in drm_exec_init()
90 exec->contended = DRM_EXEC_DUMMY; in drm_exec_init()
91 exec->prelocked = NULL; in drm_exec_init()
102 void drm_exec_fini(struct drm_exec *exec) in drm_exec_fini() argument
104 drm_exec_unlock_all(exec); in drm_exec_fini()
105 kvfree(exec->objects); in drm_exec_fini()
106 if (exec->contended != DRM_EXEC_DUMMY) { in drm_exec_fini()
107 drm_gem_object_put(exec->contended); in drm_exec_fini()
108 ww_acquire_fini(&exec->ticket); in drm_exec_fini()
121 bool drm_exec_cleanup(struct drm_exec *exec) in drm_exec_cleanup() argument
123 if (likely(!exec->contended)) { in drm_exec_cleanup()
124 ww_acquire_done(&exec->ticket); in drm_exec_cleanup()
128 if (likely(exec->contended == DRM_EXEC_DUMMY)) { in drm_exec_cleanup()
129 exec->contended = NULL; in drm_exec_cleanup()
130 ww_acquire_init(&exec->ticket, &reservation_ww_class); in drm_exec_cleanup()
134 drm_exec_unlock_all(exec); in drm_exec_cleanup()
135 exec->num_objects = 0; in drm_exec_cleanup()
141 static int drm_exec_obj_locked(struct drm_exec *exec, in drm_exec_obj_locked() argument
144 if (unlikely(exec->num_objects == exec->max_objects)) { in drm_exec_obj_locked()
145 size_t size = exec->max_objects * sizeof(void *); in drm_exec_obj_locked()
148 tmp = kvrealloc(exec->objects, size + PAGE_SIZE, GFP_KERNEL); in drm_exec_obj_locked()
152 exec->objects = tmp; in drm_exec_obj_locked()
153 exec->max_objects += PAGE_SIZE / sizeof(void *); in drm_exec_obj_locked()
156 exec->objects[exec->num_objects++] = obj; in drm_exec_obj_locked()
162 static int drm_exec_lock_contended(struct drm_exec *exec) in drm_exec_lock_contended() argument
164 struct drm_gem_object *obj = exec->contended; in drm_exec_lock_contended()
171 exec->contended = NULL; in drm_exec_lock_contended()
172 if (exec->flags & DRM_EXEC_INTERRUPTIBLE_WAIT) { in drm_exec_lock_contended()
174 &exec->ticket); in drm_exec_lock_contended()
178 dma_resv_lock_slow(obj->resv, &exec->ticket); in drm_exec_lock_contended()
181 ret = drm_exec_obj_locked(exec, obj); in drm_exec_lock_contended()
185 exec->prelocked = obj; in drm_exec_lock_contended()
207 int drm_exec_lock_obj(struct drm_exec *exec, struct drm_gem_object *obj) in drm_exec_lock_obj() argument
211 ret = drm_exec_lock_contended(exec); in drm_exec_lock_obj()
215 if (exec->prelocked == obj) { in drm_exec_lock_obj()
216 drm_gem_object_put(exec->prelocked); in drm_exec_lock_obj()
217 exec->prelocked = NULL; in drm_exec_lock_obj()
221 if (exec->flags & DRM_EXEC_INTERRUPTIBLE_WAIT) in drm_exec_lock_obj()
222 ret = dma_resv_lock_interruptible(obj->resv, &exec->ticket); in drm_exec_lock_obj()
224 ret = dma_resv_lock(obj->resv, &exec->ticket); in drm_exec_lock_obj()
228 exec->contended = obj; in drm_exec_lock_obj()
233 exec->flags & DRM_EXEC_IGNORE_DUPLICATES) in drm_exec_lock_obj()
239 ret = drm_exec_obj_locked(exec, obj); in drm_exec_lock_obj()
260 void drm_exec_unlock_obj(struct drm_exec *exec, struct drm_gem_object *obj) in drm_exec_unlock_obj() argument
264 for (i = exec->num_objects; i--;) { in drm_exec_unlock_obj()
265 if (exec->objects[i] == obj) { in drm_exec_unlock_obj()
267 for (++i; i < exec->num_objects; ++i) in drm_exec_unlock_obj()
268 exec->objects[i - 1] = exec->objects[i]; in drm_exec_unlock_obj()
269 --exec->num_objects; in drm_exec_unlock_obj()
289 int drm_exec_prepare_obj(struct drm_exec *exec, struct drm_gem_object *obj, in drm_exec_prepare_obj() argument
294 ret = drm_exec_lock_obj(exec, obj); in drm_exec_prepare_obj()
300 drm_exec_unlock_obj(exec, obj); in drm_exec_prepare_obj()
321 int drm_exec_prepare_array(struct drm_exec *exec, in drm_exec_prepare_array() argument
329 ret = drm_exec_prepare_obj(exec, objects[i], num_fences); in drm_exec_prepare_array()