From: Kenneth Graunke Date: Wed, 29 Apr 2020 06:24:38 +0000 (-0700) Subject: iris: Rename iris_syncpt to iris_syncobj for clarity. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4a1ed75b85b91f6eb1a796bf7dceb195bcfc1bcf;p=mesa.git iris: Rename iris_syncpt to iris_syncobj for clarity. This is just a refcounted wrapper around a drm_syncobj. There is enough terminology going on in the area of synchronization (sync objects, sync files, ...) that I'd rather not invent our own. Part-of: --- diff --git a/src/gallium/drivers/iris/iris_batch.c b/src/gallium/drivers/iris/iris_batch.c index fd5cb26cfda..177ba3a848f 100644 --- a/src/gallium/drivers/iris/iris_batch.c +++ b/src/gallium/drivers/iris/iris_batch.c @@ -188,7 +188,7 @@ iris_init_batch(struct iris_batch *batch, iris_hw_context_set_priority(screen->bufmgr, batch->hw_ctx_id, priority); util_dynarray_init(&batch->exec_fences, ralloc_context(NULL)); - util_dynarray_init(&batch->syncpts, ralloc_context(NULL)); + util_dynarray_init(&batch->syncobjs, ralloc_context(NULL)); batch->exec_count = 0; batch->exec_array_size = 100; @@ -315,8 +315,8 @@ iris_use_pinned_bo(struct iris_batch *batch, if (other_entry && ((other_entry->flags & EXEC_OBJECT_WRITE) || writable)) { iris_batch_flush(batch->other_batches[b]); - iris_batch_add_syncpt(batch, batch->other_batches[b]->last_syncpt, - I915_EXEC_FENCE_WAIT); + iris_batch_add_syncobj(batch, batch->other_batches[b]->last_syncobj, + I915_EXEC_FENCE_WAIT); } } } @@ -387,9 +387,9 @@ iris_batch_reset(struct iris_batch *batch) create_batch(batch); assert(batch->bo->index == 0); - struct iris_syncpt *syncpt = iris_create_syncpt(screen); - iris_batch_add_syncpt(batch, syncpt, I915_EXEC_FENCE_SIGNAL); - iris_syncpt_reference(screen, &syncpt, NULL); + struct iris_syncobj *syncobj = iris_create_syncobj(screen); + iris_batch_add_syncobj(batch, syncobj, I915_EXEC_FENCE_SIGNAL); + iris_syncobj_reference(screen, &syncobj, NULL); iris_cache_sets_clear(batch); @@ -410,11 +410,11 @@ iris_batch_free(struct iris_batch *batch) ralloc_free(batch->exec_fences.mem_ctx); - util_dynarray_foreach(&batch->syncpts, struct iris_syncpt *, s) - iris_syncpt_reference(screen, s, NULL); - ralloc_free(batch->syncpts.mem_ctx); + util_dynarray_foreach(&batch->syncobjs, struct iris_syncobj *, s) + iris_syncobj_reference(screen, s, NULL); + ralloc_free(batch->syncobjs.mem_ctx); - iris_syncpt_reference(screen, &batch->last_syncpt, NULL); + iris_syncobj_reference(screen, &batch->last_syncobj, NULL); iris_bo_unreference(batch->bo); batch->bo = NULL; @@ -689,13 +689,13 @@ _iris_batch_flush(struct iris_batch *batch, const char *file, int line) batch->exec_count = 0; batch->aperture_space = 0; - struct iris_syncpt *syncpt = - ((struct iris_syncpt **) util_dynarray_begin(&batch->syncpts))[0]; - iris_syncpt_reference(screen, &batch->last_syncpt, syncpt); + struct iris_syncobj *syncobj = + ((struct iris_syncobj **) util_dynarray_begin(&batch->syncobjs))[0]; + iris_syncobj_reference(screen, &batch->last_syncobj, syncobj); - util_dynarray_foreach(&batch->syncpts, struct iris_syncpt *, s) - iris_syncpt_reference(screen, s, NULL); - util_dynarray_clear(&batch->syncpts); + util_dynarray_foreach(&batch->syncobjs, struct iris_syncobj *, s) + iris_syncobj_reference(screen, s, NULL); + util_dynarray_clear(&batch->syncobjs); util_dynarray_clear(&batch->exec_fences); diff --git a/src/gallium/drivers/iris/iris_batch.h b/src/gallium/drivers/iris/iris_batch.h index 19ad3959741..e285f1d6cfc 100644 --- a/src/gallium/drivers/iris/iris_batch.h +++ b/src/gallium/drivers/iris/iris_batch.h @@ -96,13 +96,13 @@ struct iris_batch { bool noop_enabled; /** - * A list of iris_syncpts associated with this batch. + * A list of iris_syncobjs associated with this batch. * * The first list entry will always be a signalling sync-point, indicating * that this batch has completed. The others are likely to be sync-points * to wait on before executing the batch. */ - struct util_dynarray syncpts; + struct util_dynarray syncobjs; /** A list of drm_i915_exec_fences to have execbuf signal or wait on */ struct util_dynarray exec_fences; @@ -110,8 +110,8 @@ struct iris_batch { /** The amount of aperture space (in bytes) used by all exec_bos */ int aperture_space; - /** A sync-point for the last batch that was submitted. */ - struct iris_syncpt *last_syncpt; + /** A drm_syncobj for the last batch that was submitted. */ + struct iris_syncobj *last_syncobj; /** List of other batches which we might need to flush to use a BO */ struct iris_batch *other_batches[IRIS_BATCH_COUNT - 1]; @@ -218,30 +218,30 @@ iris_batch_emit(struct iris_batch *batch, const void *data, unsigned size) } /** - * Get a pointer to the batch's signalling syncpt. Does not refcount. + * Get a pointer to the batch's signalling syncobj. Does not refcount. */ -static inline struct iris_syncpt * -iris_batch_get_signal_syncpt(struct iris_batch *batch) +static inline struct iris_syncobj * +iris_batch_get_signal_syncobj(struct iris_batch *batch) { - /* The signalling syncpt is the first one in the list. */ - struct iris_syncpt *syncpt = - ((struct iris_syncpt **) util_dynarray_begin(&batch->syncpts))[0]; - return syncpt; + /* The signalling syncobj is the first one in the list. */ + struct iris_syncobj *syncobj = + ((struct iris_syncobj **) util_dynarray_begin(&batch->syncobjs))[0]; + return syncobj; } /** - * Take a reference to the batch's signalling syncpt. + * Take a reference to the batch's signalling syncobj. * * Callers can use this to wait for the the current batch under construction * to complete (after flushing it). */ static inline void -iris_batch_reference_signal_syncpt(struct iris_batch *batch, - struct iris_syncpt **out_syncpt) +iris_batch_reference_signal_syncobj(struct iris_batch *batch, + struct iris_syncobj **out_syncobj) { - struct iris_syncpt *syncpt = iris_batch_get_signal_syncpt(batch); - iris_syncpt_reference(batch->screen, out_syncpt, syncpt); + struct iris_syncobj *syncobj = iris_batch_get_signal_syncobj(batch); + iris_syncobj_reference(batch->screen, out_syncobj, syncobj); } /** diff --git a/src/gallium/drivers/iris/iris_fence.c b/src/gallium/drivers/iris/iris_fence.c index 65982c41c7c..09c1b427ef8 100644 --- a/src/gallium/drivers/iris/iris_fence.c +++ b/src/gallium/drivers/iris/iris_fence.c @@ -62,27 +62,27 @@ gem_syncobj_destroy(int fd, uint32_t handle) /** * Make a new sync-point. */ -struct iris_syncpt * -iris_create_syncpt(struct iris_screen *screen) +struct iris_syncobj * +iris_create_syncobj(struct iris_screen *screen) { - struct iris_syncpt *syncpt = malloc(sizeof(*syncpt)); + struct iris_syncobj *syncobj = malloc(sizeof(*syncobj)); - if (!syncpt) + if (!syncobj) return NULL; - syncpt->handle = gem_syncobj_create(screen->fd, 0); - assert(syncpt->handle); + syncobj->handle = gem_syncobj_create(screen->fd, 0); + assert(syncobj->handle); - pipe_reference_init(&syncpt->ref, 1); + pipe_reference_init(&syncobj->ref, 1); - return syncpt; + return syncobj; } void -iris_syncpt_destroy(struct iris_screen *screen, struct iris_syncpt *syncpt) +iris_syncobj_destroy(struct iris_screen *screen, struct iris_syncobj *syncobj) { - gem_syncobj_destroy(screen->fd, syncpt->handle); - free(syncpt); + gem_syncobj_destroy(screen->fd, syncobj->handle); + free(syncobj); } /** @@ -91,30 +91,30 @@ iris_syncpt_destroy(struct iris_screen *screen, struct iris_syncpt *syncpt) * \p flags One of I915_EXEC_FENCE_WAIT or I915_EXEC_FENCE_SIGNAL. */ void -iris_batch_add_syncpt(struct iris_batch *batch, - struct iris_syncpt *syncpt, - unsigned flags) +iris_batch_add_syncobj(struct iris_batch *batch, + struct iris_syncobj *syncobj, + unsigned flags) { struct drm_i915_gem_exec_fence *fence = util_dynarray_grow(&batch->exec_fences, struct drm_i915_gem_exec_fence, 1); *fence = (struct drm_i915_gem_exec_fence) { - .handle = syncpt->handle, + .handle = syncobj->handle, .flags = flags, }; - struct iris_syncpt **store = - util_dynarray_grow(&batch->syncpts, struct iris_syncpt *, 1); + struct iris_syncobj **store = + util_dynarray_grow(&batch->syncobjs, struct iris_syncobj *, 1); *store = NULL; - iris_syncpt_reference(batch->screen, store, syncpt); + iris_syncobj_reference(batch->screen, store, syncobj); } /* ------------------------------------------------------------------- */ struct pipe_fence_handle { struct pipe_reference ref; - struct iris_syncpt *syncpt[IRIS_BATCH_COUNT]; + struct iris_syncobj *syncobj[IRIS_BATCH_COUNT]; unsigned count; }; @@ -125,7 +125,7 @@ iris_fence_destroy(struct pipe_screen *p_screen, struct iris_screen *screen = (struct iris_screen *)p_screen; for (unsigned i = 0; i < fence->count; i++) - iris_syncpt_reference(screen, &fence->syncpt[i], NULL); + iris_syncobj_reference(screen, &fence->syncobj[i], NULL); free(fence); } @@ -143,16 +143,16 @@ iris_fence_reference(struct pipe_screen *p_screen, } bool -iris_wait_syncpt(struct pipe_screen *p_screen, - struct iris_syncpt *syncpt, - int64_t timeout_nsec) +iris_wait_syncobj(struct pipe_screen *p_screen, + struct iris_syncobj *syncobj, + int64_t timeout_nsec) { - if (!syncpt) + if (!syncobj) return false; struct iris_screen *screen = (struct iris_screen *)p_screen; struct drm_syncobj_wait args = { - .handles = (uintptr_t)&syncpt->handle, + .handles = (uintptr_t)&syncobj->handle, .count_handles = 1, .timeout_nsec = timeout_nsec, }; @@ -196,11 +196,11 @@ iris_fence_flush(struct pipe_context *ctx, pipe_reference_init(&fence->ref, 1); for (unsigned b = 0; b < IRIS_BATCH_COUNT; b++) { - if (!iris_wait_syncpt(ctx->screen, ice->batches[b].last_syncpt, 0)) + if (!iris_wait_syncobj(ctx->screen, ice->batches[b].last_syncobj, 0)) continue; - iris_syncpt_reference(screen, &fence->syncpt[fence->count++], - ice->batches[b].last_syncpt); + iris_syncobj_reference(screen, &fence->syncobj[fence->count++], + ice->batches[b].last_syncobj); } iris_fence_reference(ctx->screen, out_fence, NULL); @@ -215,7 +215,7 @@ iris_fence_await(struct pipe_context *ctx, for (unsigned b = 0; b < IRIS_BATCH_COUNT; b++) { for (unsigned i = 0; i < fence->count; i++) { - iris_batch_add_syncpt(&ice->batches[b], fence->syncpt[i], + iris_batch_add_syncobj(&ice->batches[b], fence->syncobj[i], I915_EXEC_FENCE_WAIT); } } @@ -258,9 +258,9 @@ iris_fence_finish(struct pipe_screen *p_screen, if (!fence->count) return true; - uint32_t handles[ARRAY_SIZE(fence->syncpt)]; + uint32_t handles[ARRAY_SIZE(fence->syncobj)]; for (unsigned i = 0; i < fence->count; i++) - handles[i] = fence->syncpt[i]->handle; + handles[i] = fence->syncobj[i]->handle; struct drm_syncobj_wait args = { .handles = (uintptr_t)handles, @@ -318,7 +318,7 @@ iris_fence_get_fd(struct pipe_screen *p_screen, for (unsigned i = 0; i < fence->count; i++) { struct drm_syncobj_handle args = { - .handle = fence->syncpt[i]->handle, + .handle = fence->syncobj[i]->handle, .flags = DRM_SYNCOBJ_HANDLE_TO_FD_FLAGS_EXPORT_SYNC_FILE, .fd = -1, }; @@ -352,13 +352,13 @@ iris_fence_create_fd(struct pipe_context *ctx, return; } - struct iris_syncpt *syncpt = malloc(sizeof(*syncpt)); - syncpt->handle = args.handle; - pipe_reference_init(&syncpt->ref, 1); + struct iris_syncobj *syncobj = malloc(sizeof(*syncobj)); + syncobj->handle = args.handle; + pipe_reference_init(&syncobj->ref, 1); struct pipe_fence_handle *fence = malloc(sizeof(*fence)); pipe_reference_init(&fence->ref, 1); - fence->syncpt[0] = syncpt; + fence->syncobj[0] = syncobj; fence->count = 1; *out = fence; diff --git a/src/gallium/drivers/iris/iris_fence.h b/src/gallium/drivers/iris/iris_fence.h index 0ce5fa8ebfb..06966277966 100644 --- a/src/gallium/drivers/iris/iris_fence.h +++ b/src/gallium/drivers/iris/iris_fence.h @@ -30,32 +30,39 @@ struct pipe_screen; struct iris_screen; struct iris_batch; -struct iris_syncpt { +/** + * A refcounted DRM Sync Object (drm_syncobj). + */ +struct iris_syncobj { struct pipe_reference ref; uint32_t handle; }; -void iris_init_context_fence_functions(struct pipe_context *ctx); -void iris_init_screen_fence_functions(struct pipe_screen *screen); +struct iris_syncobj *iris_create_syncobj(struct iris_screen *screen); +void iris_syncobj_destroy(struct iris_screen *, struct iris_syncobj *); + +void iris_batch_add_syncobj(struct iris_batch *batch, + struct iris_syncobj *syncobj, + unsigned flags); +bool iris_wait_syncobj(struct pipe_screen *screen, + struct iris_syncobj *syncobj, + int64_t timeout_nsec); -struct iris_syncpt *iris_create_syncpt(struct iris_screen *screen); -void iris_syncpt_destroy(struct iris_screen *, struct iris_syncpt *); -void iris_batch_add_syncpt(struct iris_batch *batch, - struct iris_syncpt *syncpt, - unsigned flags); -bool iris_wait_syncpt(struct pipe_screen *screen, - struct iris_syncpt *syncpt, - int64_t timeout_nsec); static inline void -iris_syncpt_reference(struct iris_screen *screen, - struct iris_syncpt **dst, - struct iris_syncpt *src) +iris_syncobj_reference(struct iris_screen *screen, + struct iris_syncobj **dst, + struct iris_syncobj *src) { if (pipe_reference(*dst ? &(*dst)->ref : NULL, - src ? &src->ref: NULL)) - iris_syncpt_destroy(screen, *dst); + src ? &src->ref : NULL)) + iris_syncobj_destroy(screen, *dst); *dst = src; } +/* ------------------------------------------------------------------- */ + +void iris_init_context_fence_functions(struct pipe_context *ctx); +void iris_init_screen_fence_functions(struct pipe_screen *screen); + #endif diff --git a/src/gallium/drivers/iris/iris_query.c b/src/gallium/drivers/iris/iris_query.c index e626692881d..26d15a833b8 100644 --- a/src/gallium/drivers/iris/iris_query.c +++ b/src/gallium/drivers/iris/iris_query.c @@ -63,7 +63,7 @@ struct iris_query { struct iris_state_ref query_state_ref; struct iris_query_snapshots *map; - struct iris_syncpt *syncpt; + struct iris_syncobj *syncobj; int batch_idx; @@ -481,7 +481,7 @@ iris_destroy_query(struct pipe_context *ctx, struct pipe_query *p_query) iris_destroy_monitor_object(ctx, query->monitor); query->monitor = NULL; } else { - iris_syncpt_reference(screen, &query->syncpt, NULL); + iris_syncobj_reference(screen, &query->syncobj, NULL); screen->base.fence_reference(ctx->screen, &query->fence, NULL); } free(query); @@ -555,7 +555,7 @@ iris_end_query(struct pipe_context *ctx, struct pipe_query *query) if (q->type == PIPE_QUERY_TIMESTAMP) { iris_begin_query(ctx, query); - iris_batch_reference_signal_syncpt(batch, &q->syncpt); + iris_batch_reference_signal_syncobj(batch, &q->syncobj); mark_available(ice, q); return true; } @@ -573,7 +573,7 @@ iris_end_query(struct pipe_context *ctx, struct pipe_query *query) q->query_state_ref.offset + offsetof(struct iris_query_snapshots, end)); - iris_batch_reference_signal_syncpt(batch, &q->syncpt); + iris_batch_reference_signal_syncobj(batch, &q->syncobj); mark_available(ice, q); return true; @@ -624,12 +624,12 @@ iris_get_query_result(struct pipe_context *ctx, if (!q->ready) { struct iris_batch *batch = &ice->batches[q->batch_idx]; - if (q->syncpt == iris_batch_get_signal_syncpt(batch)) + if (q->syncobj == iris_batch_get_signal_syncobj(batch)) iris_batch_flush(batch); while (!READ_ONCE(q->map->snapshots_landed)) { if (wait) - iris_wait_syncpt(ctx->screen, q->syncpt, INT64_MAX); + iris_wait_syncobj(ctx->screen, q->syncobj, INT64_MAX); else return false; } @@ -672,7 +672,7 @@ iris_get_query_result_resource(struct pipe_context *ctx, * now so that progress happens. Either way, copy the snapshots * landed field to the destination resource. */ - if (q->syncpt == iris_batch_get_signal_syncpt(batch)) + if (q->syncobj == iris_batch_get_signal_syncobj(batch)) iris_batch_flush(batch); batch->screen->vtbl.copy_mem_mem(batch, dst_bo, offset,