diff mbox series

[13/16] drm/msm: use new iterator in msm_gem_sync_object

Message ID 20210617111558.28486-14-christian.koenig@amd.com
State New
Headers show
Series [01/16] dma-buf: add dma_resv_for_each_fence_unlocked | expand

Commit Message

Christian König June 17, 2021, 11:15 a.m. UTC
Simplifying the code a bit.

Untested since I can't get the driver to compile on !ARM.

Signed-off-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/msm/msm_gem.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/msm_gem.c b/drivers/gpu/drm/msm/msm_gem.c
index 72a07e311de3..24f8c0603385 100644
--- a/drivers/gpu/drm/msm/msm_gem.c
+++ b/drivers/gpu/drm/msm/msm_gem.c
@@ -813,25 +813,11 @@  void msm_gem_vunmap(struct drm_gem_object *obj)
 int msm_gem_sync_object(struct drm_gem_object *obj,
 		struct msm_fence_context *fctx, bool exclusive)
 {
-	struct dma_resv_list *fobj;
+	struct dma_resv_cursor cursor;
 	struct dma_fence *fence;
-	int i, ret;
-
-	fence = dma_resv_excl_fence(obj->resv);
-	/* don't need to wait on our own fences, since ring is fifo */
-	if (fence && (fence->context != fctx->context)) {
-		ret = dma_fence_wait(fence, true);
-		if (ret)
-			return ret;
-	}
-
-	fobj = dma_resv_shared_list(obj->resv);
-	if (!exclusive || !fobj)
-		return 0;
+	int ret;
 
-	for (i = 0; i < fobj->shared_count; i++) {
-		fence = rcu_dereference_protected(fobj->shared[i],
-						dma_resv_held(obj->resv));
+	dma_resv_for_each_fence(obj->resv, &cursor, exclusive, fence) {
 		if (fence->context != fctx->context) {
 			ret = dma_fence_wait(fence, true);
 			if (ret)