Mesa passes shared bo, fence syncobj to userq_ioctl.
There can be duplicates here or some fences that are old.
This patch is remove duplicates fence and only keep the most
recent fence for each context.
v2: - Export this code from dma-fence-unwrap.c(by Christian).
v3: - To split this in a dma_buf patch and amd userq patch(by Sunil).
- No need to add a new function just re-use existing(by Christian).
Cc: Alex Deucher <[email protected]>
Cc: Christian Koenig <[email protected]>
Cc: Sunil Khatri <[email protected]>
Cc: Arunpravin Paneer Selvam <[email protected]>
Signed-off-by: Arvind Yadav <[email protected]>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
index 3288c2ff692e..0f4233b79a3b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_userq_fence.c
@@ -606,6 +606,7 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void
*data,
struct drm_gem_object **gobj_read;
struct dma_fence **fences = NULL;
u16 num_points, num_fences = 0;
+ unsigned int num_shrink_fences = 0;
int r, i, rentry, wentry, cnt;
struct drm_exec exec;
@@ -851,6 +852,13 @@ int amdgpu_userq_wait_ioctl(struct drm_device *dev, void
*data,
fences[num_fences++] = fence;
}
+ /*
+ * Remove duplicates fence and only keep the most recent fence
for
+ * each context.
+ */
+ dma_fence_unwrap_shrink_array(num_fences, fences,
num_shrink_fences);
+ num_fences = num_shrink_fences;
+
waitq = idr_find(&userq_mgr->userq_idr, wait_info->waitq_id);
if (!waitq)
goto free_fences;
--
2.34.1