From: Hoegeun Kwon Date: Tue, 9 Jan 2024 08:45:52 +0000 (+0900) Subject: gpu: drm: img: Fix to use iterator instead of list X-Git-Tag: accepted/tizen/unified/toolchain/20240311.065846~53 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1691514834f8953601cc9398eb95986da1c172af;p=platform%2Fkernel%2Flinux-starfive.git gpu: drm: img: Fix to use iterator instead of list Change the dma fence management method from list to iterator method. Also the fences have to added individually on each other driver. So dma_resv_add_fence does not add a fence, but dma_resv_reserve_fences is used to add it. Change-Id: I4c87608b9878e218fe0ae5cc5acb564c1f9d5db9 Signed-off-by: Hoegeun Kwon Signed-off-by: Seung-Woo Kim --- diff --git a/drivers/gpu/drm/img/img-rogue/services/server/env/linux/pvr_buffer_sync.c b/drivers/gpu/drm/img/img-rogue/services/server/env/linux/pvr_buffer_sync.c index b5426d4..ab99301 100644 --- a/drivers/gpu/drm/img/img-rogue/services/server/env/linux/pvr_buffer_sync.c +++ b/drivers/gpu/drm/img/img-rogue/services/server/env/linux/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_shared_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 (!fence_count) { + err = dma_resv_reserve_fences(resv, 1); if (err) goto err_destroy_fences; } - resv_list = dma_resv_shared_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); } }