From: Michal Wilczynski Date: Fri, 9 Aug 2024 12:38:40 +0000 (+0200) Subject: gpu: drm: img: Fix to use iterator instead of list X-Git-Tag: accepted/tizen/unified/x/20240818.074458~12 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=a512fd9e70ee622b1aa0e8045d240ca13435d0da;p=platform%2Fkernel%2Flinux-thead.git gpu: drm: img: Fix to use iterator instead of list This commit is cherry-picked from starfive repo [1] 1691514834f8 ("gpu: drm: img: Fix to use iterator instead of list"). [1] - git://git.tizen.org/platform/kernel/linux-starfive Change-Id: I4146b481a31c722785fce84d86b1c41788908afd Signed-off-by: Michal Wilczynski --- diff --git a/drivers/gpu/drm/img-rogue/pvr_buffer_sync.c b/drivers/gpu/drm/img-rogue/pvr_buffer_sync.c index e0e3cffce8a8..ab6a5b2dc093 100644 --- a/drivers/gpu/drm/img-rogue/pvr_buffer_sync.c +++ b/drivers/gpu/drm/img-rogue/pvr_buffer_sync.c @@ -177,7 +177,7 @@ pvr_buffer_sync_pmrs_fence_count(u32 nr_pmrs, struct _PMR_ **pmrs, u32 *pmr_flags) { struct dma_resv *resv; - struct dma_resv_list *resv_list; + struct dma_resv_iter cursor; struct dma_fence *fence; u32 fence_count = 0; bool exclusive; @@ -190,15 +190,9 @@ pvr_buffer_sync_pmrs_fence_count(u32 nr_pmrs, struct _PMR_ **pmrs, if (WARN_ON_ONCE(!resv)) continue; - resv_list = dma_resv_fences_list(resv); - fence = dma_resv_excl_fence(resv); - - if (fence && - (!exclusive || !resv_list || !resv_list->shared_count)) + dma_resv_for_each_fence(&cursor, resv, DMA_RESV_USAGE_BOOKKEEP, fence) { fence_count++; - - if (exclusive && resv_list) - fence_count += resv_list->shared_count; + } } return fence_count; @@ -213,11 +207,11 @@ pvr_buffer_sync_check_fences_create(struct pvr_fence_context *fence_ctx, { struct pvr_buffer_sync_check_data *data; struct dma_resv *resv; - struct dma_resv_list *resv_list; + struct dma_resv_iter cursor; struct dma_fence *fence; u32 fence_count; bool exclusive; - int i, j; + int i; int err; data = kzalloc(sizeof(*data), GFP_KERNEL); @@ -239,21 +233,14 @@ pvr_buffer_sync_check_fences_create(struct pvr_fence_context *fence_ctx, continue; exclusive = !!(pmr_flags[i] & PVR_BUFFER_FLAG_WRITE); - if (!exclusive) { - err = dma_resv_reserve_shared(resv -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 0, 0)) - , 1 -#endif - ); + + if (!resv->fences) { + err = dma_resv_reserve_fences(resv, 1); if (err) goto err_destroy_fences; } - resv_list = dma_resv_fences_list(resv); - fence = dma_resv_excl_fence(resv); - - if (fence && - (!exclusive || !resv_list || !resv_list->shared_count)) { + dma_resv_for_each_fence(&cursor, resv, DMA_RESV_USAGE_BOOKKEEP, fence) { data->fences[data->nr_fences++] = pvr_fence_create_from_fence(fence_ctx, sync_checkpoint_ctx, @@ -267,25 +254,6 @@ pvr_buffer_sync_check_fences_create(struct pvr_fence_context *fence_ctx, WARN_ON(dma_fence_wait(fence, true) <= 0); } } - - if (exclusive && resv_list) { - for (j = 0; j < resv_list->shared_count; j++) { - fence = rcu_dereference_protected(resv_list->shared[j], - dma_resv_held(resv)); - data->fences[data->nr_fences++] = - pvr_fence_create_from_fence(fence_ctx, - sync_checkpoint_ctx, - fence, - PVRSRV_NO_FENCE, - "check fence"); - if (!data->fences[data->nr_fences - 1]) { - data->nr_fences--; - PVR_FENCE_TRACE(fence, - "waiting on non-exclusive fence\n"); - WARN_ON(dma_fence_wait(fence, true) <= 0); - } - } - } } WARN_ON((i != nr_pmrs) || (data->nr_fences != fence_count)); @@ -531,14 +499,14 @@ pvr_buffer_sync_kick_succeeded(struct pvr_buffer_sync_append_data *data) PVR_FENCE_TRACE(&data->update_fence->base, "added exclusive fence (%s) to resv %p\n", data->update_fence->name, resv); - dma_resv_add_excl_fence(resv, - &data->update_fence->base); + dma_resv_add_fence(resv, + &data->update_fence->base, DMA_RESV_USAGE_WRITE); } else if (data->pmr_flags[i] & PVR_BUFFER_FLAG_READ) { PVR_FENCE_TRACE(&data->update_fence->base, "added non-exclusive fence (%s) to resv %p\n", data->update_fence->name, resv); - dma_resv_add_shared_fence(resv, - &data->update_fence->base); + dma_resv_add_fence(resv, + &data->update_fence->base, DMA_RESV_USAGE_READ); } }