[Intel-gfx] [PATCH 20/26] drm: use new iterator in drm_gem_fence_array_add_implicit
Christian König
ckoenig.leichtzumerken at gmail.com
Mon Sep 13 13:17:01 UTC 2021
Simplifying the code a bit.
Signed-off-by: Christian König <christian.koenig at amd.com>
---
drivers/gpu/drm/drm_gem.c | 30 ++++++++----------------------
1 file changed, 8 insertions(+), 22 deletions(-)
diff --git a/drivers/gpu/drm/drm_gem.c b/drivers/gpu/drm/drm_gem.c
index 09c820045859..6e3b8491be68 100644
--- a/drivers/gpu/drm/drm_gem.c
+++ b/drivers/gpu/drm/drm_gem.c
@@ -1340,31 +1340,17 @@ int drm_gem_fence_array_add_implicit(struct xarray *fence_array,
struct drm_gem_object *obj,
bool write)
{
- int ret;
- struct dma_fence **fences;
- unsigned int i, fence_count;
-
- if (!write) {
- struct dma_fence *fence =
- dma_resv_get_excl_unlocked(obj->resv);
-
- return drm_gem_fence_array_add(fence_array, fence);
- }
-
- ret = dma_resv_get_fences(obj->resv, NULL,
- &fence_count, &fences);
- if (ret || !fence_count)
- return ret;
+ struct dma_resv_cursor cursor;
+ struct dma_fence *fence;
+ int ret = 0;
- for (i = 0; i < fence_count; i++) {
- ret = drm_gem_fence_array_add(fence_array, fences[i]);
- if (ret)
+ dma_resv_for_each_fence_unlocked(obj->resv, &cursor, write, fence) {
+ ret = drm_gem_fence_array_add(fence_array, fence);
+ if (ret) {
+ dma_fence_put(fence);
break;
+ }
}
-
- for (; i < fence_count; i++)
- dma_fence_put(fences[i]);
- kfree(fences);
return ret;
}
EXPORT_SYMBOL(drm_gem_fence_array_add_implicit);
--
2.25.1
More information about the Intel-gfx
mailing list