* [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c
@ 2021-10-28 13:26 Christian König
2021-10-28 13:26 ` [PATCH 2/6] drm/amdgpu: stop getting excl fence separately Christian König
` (5 more replies)
0 siblings, 6 replies; 15+ messages in thread
From: Christian König @ 2021-10-28 13:26 UTC (permalink / raw)
To: dri-devel, linux-media, etnaviv, amd-gfx
The i915 driver implements a prune function which is called when it is very
likely that the fences inside the dma_resv object can be removed because they
are all signaled.
Move that function into the dma-resv.c code since the behavior of pruning
fences is something internal to the object.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/dma-buf/dma-resv.c | 18 ++++++++++++++++++
drivers/gpu/drm/i915/Makefile | 1 -
drivers/gpu/drm/i915/dma_resv_utils.c | 17 -----------------
drivers/gpu/drm/i915/dma_resv_utils.h | 13 -------------
drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 3 +--
drivers/gpu/drm/i915/gem/i915_gem_wait.c | 3 +--
include/linux/dma-resv.h | 1 +
7 files changed, 21 insertions(+), 35 deletions(-)
delete mode 100644 drivers/gpu/drm/i915/dma_resv_utils.c
delete mode 100644 drivers/gpu/drm/i915/dma_resv_utils.h
diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
index ff3c0558b3b8..64d4f95778c4 100644
--- a/drivers/dma-buf/dma-resv.c
+++ b/drivers/dma-buf/dma-resv.c
@@ -324,6 +324,24 @@ void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence)
}
EXPORT_SYMBOL(dma_resv_add_excl_fence);
+/**
+ * dma_resv_prune_unlocked - try to remove signaled fences
+ * @obj: The dma_resv object to prune
+ *
+ * Try to lock the object, test if it is signaled and if yes then remove all the
+ * signaled fences.
+ */
+void dma_resv_prune_unlocked(struct dma_resv *obj)
+{
+ if (!dma_resv_trylock(obj))
+ return;
+
+ if (dma_resv_test_signaled(obj, true))
+ dma_resv_add_excl_fence(obj, NULL);
+ dma_resv_unlock(obj);
+}
+EXPORT_SYMBOL(dma_resv_prune_unlocked);
+
/**
* dma_resv_iter_restart_unlocked - restart the unlocked iterator
* @cursor: The dma_resv_iter object to restart
diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
index 660bb03de6fc..5c1af130cb6d 100644
--- a/drivers/gpu/drm/i915/Makefile
+++ b/drivers/gpu/drm/i915/Makefile
@@ -60,7 +60,6 @@ i915-y += i915_drv.o \
# core library code
i915-y += \
- dma_resv_utils.o \
i915_memcpy.o \
i915_mm.o \
i915_sw_fence.o \
diff --git a/drivers/gpu/drm/i915/dma_resv_utils.c b/drivers/gpu/drm/i915/dma_resv_utils.c
deleted file mode 100644
index 7df91b7e4ca8..000000000000
--- a/drivers/gpu/drm/i915/dma_resv_utils.c
+++ /dev/null
@@ -1,17 +0,0 @@
-// SPDX-License-Identifier: MIT
-/*
- * Copyright © 2020 Intel Corporation
- */
-
-#include <linux/dma-resv.h>
-
-#include "dma_resv_utils.h"
-
-void dma_resv_prune(struct dma_resv *resv)
-{
- if (dma_resv_trylock(resv)) {
- if (dma_resv_test_signaled(resv, true))
- dma_resv_add_excl_fence(resv, NULL);
- dma_resv_unlock(resv);
- }
-}
diff --git a/drivers/gpu/drm/i915/dma_resv_utils.h b/drivers/gpu/drm/i915/dma_resv_utils.h
deleted file mode 100644
index b9d8fb5f8367..000000000000
--- a/drivers/gpu/drm/i915/dma_resv_utils.h
+++ /dev/null
@@ -1,13 +0,0 @@
-/* SPDX-License-Identifier: MIT */
-/*
- * Copyright © 2020 Intel Corporation
- */
-
-#ifndef DMA_RESV_UTILS_H
-#define DMA_RESV_UTILS_H
-
-struct dma_resv;
-
-void dma_resv_prune(struct dma_resv *resv);
-
-#endif /* DMA_RESV_UTILS_H */
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
index 5ab136ffdeb2..48029bbda682 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
@@ -15,7 +15,6 @@
#include "gt/intel_gt_requests.h"
-#include "dma_resv_utils.h"
#include "i915_trace.h"
static bool swap_available(void)
@@ -229,7 +228,7 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
i915_gem_object_unlock(obj);
}
- dma_resv_prune(obj->base.resv);
+ dma_resv_prune_unlocked(obj->base.resv);
scanned += obj->base.size >> PAGE_SHIFT;
skip:
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_wait.c b/drivers/gpu/drm/i915/gem/i915_gem_wait.c
index 569658c7859c..1915d203a72d 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c
@@ -10,7 +10,6 @@
#include "gt/intel_engine.h"
-#include "dma_resv_utils.h"
#include "i915_gem_ioctls.h"
#include "i915_gem_object.h"
@@ -53,7 +52,7 @@ i915_gem_object_wait_reservation(struct dma_resv *resv,
* signaled.
*/
if (timeout > 0)
- dma_resv_prune(resv);
+ dma_resv_prune_unlocked(resv);
return timeout;
}
diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
index eebf04325b34..e0558429a5ee 100644
--- a/include/linux/dma-resv.h
+++ b/include/linux/dma-resv.h
@@ -458,6 +458,7 @@ void dma_resv_fini(struct dma_resv *obj);
int dma_resv_reserve_shared(struct dma_resv *obj, unsigned int num_fences);
void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence);
void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence);
+void dma_resv_prune_unlocked(struct dma_resv *obj);
int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **pfence_excl,
unsigned *pshared_count, struct dma_fence ***pshared);
int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src);
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 2/6] drm/amdgpu: stop getting excl fence separately
2021-10-28 13:26 [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Christian König
@ 2021-10-28 13:26 ` Christian König
2021-11-11 8:58 ` Christian König
2021-10-28 13:26 ` [PATCH 3/6] drm/etnaviv: stop getting the excl fence separately here Christian König
` (4 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Christian König @ 2021-10-28 13:26 UTC (permalink / raw)
To: dri-devel, linux-media, etnaviv, amd-gfx
Just grab all fences for the display flip in one go.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 -
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 +-----
2 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
index d58e37fd01f4..4da7eb65e744 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
@@ -457,7 +457,6 @@ struct amdgpu_flip_work {
uint64_t base;
struct drm_pending_vblank_event *event;
struct amdgpu_bo *old_abo;
- struct dma_fence *excl;
unsigned shared_count;
struct dma_fence **shared;
struct dma_fence_cb cb;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index dc50c05f23fc..68108f151dad 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -83,9 +83,6 @@ static void amdgpu_display_flip_work_func(struct work_struct *__work)
unsigned i;
int vpos, hpos;
- if (amdgpu_display_flip_handle_fence(work, &work->excl))
- return;
-
for (i = 0; i < work->shared_count; ++i)
if (amdgpu_display_flip_handle_fence(work, &work->shared[i]))
return;
@@ -203,7 +200,7 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
goto unpin;
}
- r = dma_resv_get_fences(new_abo->tbo.base.resv, &work->excl,
+ r = dma_resv_get_fences(new_abo->tbo.base.resv, NULL,
&work->shared_count, &work->shared);
if (unlikely(r != 0)) {
DRM_ERROR("failed to get fences for buffer\n");
@@ -253,7 +250,6 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
cleanup:
amdgpu_bo_unref(&work->old_abo);
- dma_fence_put(work->excl);
for (i = 0; i < work->shared_count; ++i)
dma_fence_put(work->shared[i]);
kfree(work->shared);
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 3/6] drm/etnaviv: stop getting the excl fence separately here
2021-10-28 13:26 [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Christian König
2021-10-28 13:26 ` [PATCH 2/6] drm/amdgpu: stop getting excl fence separately Christian König
@ 2021-10-28 13:26 ` Christian König
2021-11-01 9:51 ` Lucas Stach
2021-10-28 13:26 ` [PATCH 4/6] dma-buf: drop excl_fence parameter from dma_resv_get_fences Christian König
` (3 subsequent siblings)
5 siblings, 1 reply; 15+ messages in thread
From: Christian König @ 2021-10-28 13:26 UTC (permalink / raw)
To: dri-devel, linux-media, etnaviv, amd-gfx
Just grab all fences in one go.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index 8dc93863bf96..b5e8ce86dbe7 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -189,7 +189,7 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit)
continue;
if (bo->flags & ETNA_SUBMIT_BO_WRITE) {
- ret = dma_resv_get_fences(robj, &bo->excl,
+ ret = dma_resv_get_fences(robj, NULL,
&bo->nr_shared,
&bo->shared);
if (ret)
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 4/6] dma-buf: drop excl_fence parameter from dma_resv_get_fences
2021-10-28 13:26 [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Christian König
2021-10-28 13:26 ` [PATCH 2/6] drm/amdgpu: stop getting excl fence separately Christian König
2021-10-28 13:26 ` [PATCH 3/6] drm/etnaviv: stop getting the excl fence separately here Christian König
@ 2021-10-28 13:26 ` Christian König
2021-10-28 13:26 ` [PATCH 5/6] RDMA: use dma_resv_wait() instead of extracting the fence Christian König
` (2 subsequent siblings)
5 siblings, 0 replies; 15+ messages in thread
From: Christian König @ 2021-10-28 13:26 UTC (permalink / raw)
To: dri-devel, linux-media, etnaviv, amd-gfx
Returning the exclusive fence separately is no longer used.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/dma-buf/dma-resv.c | 43 +++++++-------------
drivers/dma-buf/st-dma-resv.c | 26 +++---------
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 +-
drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c | 2 +-
drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 3 +-
include/linux/dma-resv.h | 4 +-
6 files changed, 26 insertions(+), 56 deletions(-)
diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
index 64d4f95778c4..fb02860312fc 100644
--- a/drivers/dma-buf/dma-resv.c
+++ b/drivers/dma-buf/dma-resv.c
@@ -561,26 +561,21 @@ EXPORT_SYMBOL(dma_resv_copy_fences);
* dma_resv_get_fences - Get an object's shared and exclusive
* fences without update side lock held
* @obj: the reservation object
- * @fence_excl: the returned exclusive fence (or NULL)
- * @shared_count: the number of shared fences returned
- * @shared: the array of shared fence ptrs returned (array is krealloc'd to
- * the required size, and must be freed by caller)
+ * @num_fences: the number of fences returned
+ * @fences: the array of fence ptrs returned (array is krealloc'd to the
+ * required size, and must be freed by caller)
*
- * Retrieve all fences from the reservation object. If the pointer for the
- * exclusive fence is not specified the fence is put into the array of the
- * shared fences as well. Returns either zero or -ENOMEM.
+ * Retrieve all fences from the reservation object.
+ * Returns either zero or -ENOMEM.
*/
-int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **fence_excl,
- unsigned int *shared_count, struct dma_fence ***shared)
+int dma_resv_get_fences(struct dma_resv *obj, unsigned int *num_fences,
+ struct dma_fence ***fences)
{
struct dma_resv_iter cursor;
struct dma_fence *fence;
- *shared_count = 0;
- *shared = NULL;
-
- if (fence_excl)
- *fence_excl = NULL;
+ *num_fences = 0;
+ *fences = NULL;
dma_resv_iter_begin(&cursor, obj, true);
dma_resv_for_each_fence_unlocked(&cursor, fence) {
@@ -588,30 +583,22 @@ int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **fence_excl,
if (dma_resv_iter_is_restarted(&cursor)) {
unsigned int count;
- while (*shared_count)
- dma_fence_put((*shared)[--(*shared_count)]);
-
- if (fence_excl)
- dma_fence_put(*fence_excl);
+ while (*num_fences)
+ dma_fence_put((*fences)[--(*num_fences)]);
- count = cursor.shared_count;
- count += fence_excl ? 0 : 1;
+ count = cursor.shared_count + 1;
/* Eventually re-allocate the array */
- *shared = krealloc_array(*shared, count,
+ *fences = krealloc_array(*fences, count,
sizeof(void *),
GFP_KERNEL);
- if (count && !*shared) {
+ if (count && !*fences) {
dma_resv_iter_end(&cursor);
return -ENOMEM;
}
}
- dma_fence_get(fence);
- if (dma_resv_iter_is_exclusive(&cursor) && fence_excl)
- *fence_excl = fence;
- else
- (*shared)[(*shared_count)++] = fence;
+ (*fences)[(*num_fences)++] = dma_fence_get(fence);
}
dma_resv_iter_end(&cursor);
diff --git a/drivers/dma-buf/st-dma-resv.c b/drivers/dma-buf/st-dma-resv.c
index bc32b3eedcb6..fd742a60f7e0 100644
--- a/drivers/dma-buf/st-dma-resv.c
+++ b/drivers/dma-buf/st-dma-resv.c
@@ -275,7 +275,7 @@ static int test_shared_for_each_unlocked(void *arg)
static int test_get_fences(void *arg, bool shared)
{
- struct dma_fence *f, *excl = NULL, **fences = NULL;
+ struct dma_fence *f, **fences = NULL;
struct dma_resv resv;
int r, i;
@@ -304,35 +304,19 @@ static int test_get_fences(void *arg, bool shared)
}
dma_resv_unlock(&resv);
- r = dma_resv_get_fences(&resv, &excl, &i, &fences);
+ r = dma_resv_get_fences(&resv, &i, &fences);
if (r) {
pr_err("get_fences failed\n");
goto err_free;
}
- if (shared) {
- if (excl != NULL) {
- pr_err("get_fences returned unexpected excl fence\n");
- goto err_free;
- }
- if (i != 1 || fences[0] != f) {
- pr_err("get_fences returned unexpected shared fence\n");
- goto err_free;
- }
- } else {
- if (excl != f) {
- pr_err("get_fences returned unexpected excl fence\n");
- goto err_free;
- }
- if (i != 0) {
- pr_err("get_fences returned unexpected shared fence\n");
- goto err_free;
- }
+ if (i != 1 || fences[0] != f) {
+ pr_err("get_fences returned unexpected fence\n");
+ goto err_free;
}
dma_fence_signal(f);
err_free:
- dma_fence_put(excl);
while (i--)
dma_fence_put(fences[i]);
kfree(fences);
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 68108f151dad..b8cf3740dd28 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -200,8 +200,8 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
goto unpin;
}
- r = dma_resv_get_fences(new_abo->tbo.base.resv, NULL,
- &work->shared_count, &work->shared);
+ r = dma_resv_get_fences(new_abo->tbo.base.resv, &work->shared_count,
+ &work->shared);
if (unlikely(r != 0)) {
DRM_ERROR("failed to get fences for buffer\n");
goto unpin;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
index b7fb72bff2c1..4500d6b4fcd3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ids.c
@@ -112,7 +112,7 @@ void amdgpu_pasid_free_delayed(struct dma_resv *resv,
unsigned count;
int r;
- r = dma_resv_get_fences(resv, NULL, &count, &fences);
+ r = dma_resv_get_fences(resv, &count, &fences);
if (r)
goto fallback;
diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
index b5e8ce86dbe7..982bd7135a66 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
@@ -189,8 +189,7 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit)
continue;
if (bo->flags & ETNA_SUBMIT_BO_WRITE) {
- ret = dma_resv_get_fences(robj, NULL,
- &bo->nr_shared,
+ ret = dma_resv_get_fences(robj, &bo->nr_shared,
&bo->shared);
if (ret)
return ret;
diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
index e0558429a5ee..cde0147e8830 100644
--- a/include/linux/dma-resv.h
+++ b/include/linux/dma-resv.h
@@ -459,8 +459,8 @@ int dma_resv_reserve_shared(struct dma_resv *obj, unsigned int num_fences);
void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence);
void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence);
void dma_resv_prune_unlocked(struct dma_resv *obj);
-int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **pfence_excl,
- unsigned *pshared_count, struct dma_fence ***pshared);
+int dma_resv_get_fences(struct dma_resv *obj, unsigned int *num_fences,
+ struct dma_fence ***fences);
int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src);
long dma_resv_wait_timeout(struct dma_resv *obj, bool wait_all, bool intr,
unsigned long timeout);
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 5/6] RDMA: use dma_resv_wait() instead of extracting the fence
2021-10-28 13:26 [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Christian König
` (2 preceding siblings ...)
2021-10-28 13:26 ` [PATCH 4/6] dma-buf: drop excl_fence parameter from dma_resv_get_fences Christian König
@ 2021-10-28 13:26 ` Christian König
2021-10-28 13:26 ` [PATCH 6/6] drm/radeon: use dma_resv_wait_timeout() instead of manually waiting Christian König
2021-11-25 9:31 ` [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Maarten Lankhorst
5 siblings, 0 replies; 15+ messages in thread
From: Christian König @ 2021-10-28 13:26 UTC (permalink / raw)
To: dri-devel, linux-media, etnaviv, amd-gfx
Use dma_resv_wait() instead of extracting the exclusive fence and
waiting on it manually.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/infiniband/core/umem_dmabuf.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/infiniband/core/umem_dmabuf.c b/drivers/infiniband/core/umem_dmabuf.c
index e824baf4640d..258ba9b8c17d 100644
--- a/drivers/infiniband/core/umem_dmabuf.c
+++ b/drivers/infiniband/core/umem_dmabuf.c
@@ -13,7 +13,6 @@ int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)
{
struct sg_table *sgt;
struct scatterlist *sg;
- struct dma_fence *fence;
unsigned long start, end, cur = 0;
unsigned int nmap = 0;
int i;
@@ -65,11 +64,8 @@ int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)
* may be not up-to-date. Wait for the exporter to finish
* the migration.
*/
- fence = dma_resv_excl_fence(umem_dmabuf->attach->dmabuf->resv);
- if (fence)
- return dma_fence_wait(fence, false);
-
- return 0;
+ return dma_resv_wait_timeout(umem_dmabuf->attach->dmabuf->resv, false,
+ false, MAX_SCHEDULE_TIMEOUT);
}
EXPORT_SYMBOL(ib_umem_dmabuf_map_pages);
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [PATCH 6/6] drm/radeon: use dma_resv_wait_timeout() instead of manually waiting
2021-10-28 13:26 [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Christian König
` (3 preceding siblings ...)
2021-10-28 13:26 ` [PATCH 5/6] RDMA: use dma_resv_wait() instead of extracting the fence Christian König
@ 2021-10-28 13:26 ` Christian König
2021-11-03 7:55 ` Christian König
2021-11-03 16:36 ` Das, Nirmoy
2021-11-25 9:31 ` [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Maarten Lankhorst
5 siblings, 2 replies; 15+ messages in thread
From: Christian König @ 2021-10-28 13:26 UTC (permalink / raw)
To: dri-devel, linux-media, etnaviv, amd-gfx
Don't touch the exclusive fence manually here, but rather use the
general dma_resv function. We did that for better hw reset handling but
this doesn't necessary work correctly.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/radeon/radeon_uvd.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
index 2ea86919d953..377f9cdb5b53 100644
--- a/drivers/gpu/drm/radeon/radeon_uvd.c
+++ b/drivers/gpu/drm/radeon/radeon_uvd.c
@@ -469,7 +469,6 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
{
int32_t *msg, msg_type, handle;
unsigned img_size = 0;
- struct dma_fence *f;
void *ptr;
int i, r;
@@ -479,13 +478,11 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
return -EINVAL;
}
- f = dma_resv_excl_fence(bo->tbo.base.resv);
- if (f) {
- r = radeon_fence_wait((struct radeon_fence *)f, false);
- if (r) {
- DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
- return r;
- }
+ r = dma_resv_wait_timeout(bo->tbo.base.resv, false, false,
+ MAX_SCHEDULE_TIMEOUT);
+ if (r <= 0) {
+ DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
+ return r ? r : -ETIME;
}
r = radeon_bo_kmap(bo, &ptr);
--
2.25.1
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [PATCH 3/6] drm/etnaviv: stop getting the excl fence separately here
2021-10-28 13:26 ` [PATCH 3/6] drm/etnaviv: stop getting the excl fence separately here Christian König
@ 2021-11-01 9:51 ` Lucas Stach
0 siblings, 0 replies; 15+ messages in thread
From: Lucas Stach @ 2021-11-01 9:51 UTC (permalink / raw)
To: Christian König, dri-devel, linux-media, etnaviv, amd-gfx
Am Donnerstag, dem 28.10.2021 um 15:26 +0200 schrieb Christian König:
> Just grab all fences in one go.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
Reviewed-by: Lucas Stach <l.stach@pengutronix.de>
> ---
> drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> index 8dc93863bf96..b5e8ce86dbe7 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gem_submit.c
> @@ -189,7 +189,7 @@ static int submit_fence_sync(struct etnaviv_gem_submit *submit)
> continue;
>
> if (bo->flags & ETNA_SUBMIT_BO_WRITE) {
> - ret = dma_resv_get_fences(robj, &bo->excl,
> + ret = dma_resv_get_fences(robj, NULL,
> &bo->nr_shared,
> &bo->shared);
> if (ret)
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 6/6] drm/radeon: use dma_resv_wait_timeout() instead of manually waiting
2021-10-28 13:26 ` [PATCH 6/6] drm/radeon: use dma_resv_wait_timeout() instead of manually waiting Christian König
@ 2021-11-03 7:55 ` Christian König
2021-11-03 16:36 ` Das, Nirmoy
1 sibling, 0 replies; 15+ messages in thread
From: Christian König @ 2021-11-03 7:55 UTC (permalink / raw)
To: Alex Deucher; +Cc: dri-devel, linux-media, etnaviv, amd-gfx
Ping, Alex do you have a moment for that one here?
Am 28.10.21 um 15:26 schrieb Christian König:
> Don't touch the exclusive fence manually here, but rather use the
> general dma_resv function. We did that for better hw reset handling but
> this doesn't necessary work correctly.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/radeon/radeon_uvd.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
> index 2ea86919d953..377f9cdb5b53 100644
> --- a/drivers/gpu/drm/radeon/radeon_uvd.c
> +++ b/drivers/gpu/drm/radeon/radeon_uvd.c
> @@ -469,7 +469,6 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
> {
> int32_t *msg, msg_type, handle;
> unsigned img_size = 0;
> - struct dma_fence *f;
> void *ptr;
>
> int i, r;
> @@ -479,13 +478,11 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
> return -EINVAL;
> }
>
> - f = dma_resv_excl_fence(bo->tbo.base.resv);
> - if (f) {
> - r = radeon_fence_wait((struct radeon_fence *)f, false);
> - if (r) {
> - DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
> - return r;
> - }
> + r = dma_resv_wait_timeout(bo->tbo.base.resv, false, false,
> + MAX_SCHEDULE_TIMEOUT);
> + if (r <= 0) {
> + DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
> + return r ? r : -ETIME;
> }
>
> r = radeon_bo_kmap(bo, &ptr);
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 6/6] drm/radeon: use dma_resv_wait_timeout() instead of manually waiting
@ 2021-11-03 7:55 ` Christian König
0 siblings, 0 replies; 15+ messages in thread
From: Christian König @ 2021-11-03 7:55 UTC (permalink / raw)
To: Alex Deucher; +Cc: amd-gfx, etnaviv, dri-devel, linux-media
Ping, Alex do you have a moment for that one here?
Am 28.10.21 um 15:26 schrieb Christian König:
> Don't touch the exclusive fence manually here, but rather use the
> general dma_resv function. We did that for better hw reset handling but
> this doesn't necessary work correctly.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/radeon/radeon_uvd.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
> index 2ea86919d953..377f9cdb5b53 100644
> --- a/drivers/gpu/drm/radeon/radeon_uvd.c
> +++ b/drivers/gpu/drm/radeon/radeon_uvd.c
> @@ -469,7 +469,6 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
> {
> int32_t *msg, msg_type, handle;
> unsigned img_size = 0;
> - struct dma_fence *f;
> void *ptr;
>
> int i, r;
> @@ -479,13 +478,11 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
> return -EINVAL;
> }
>
> - f = dma_resv_excl_fence(bo->tbo.base.resv);
> - if (f) {
> - r = radeon_fence_wait((struct radeon_fence *)f, false);
> - if (r) {
> - DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
> - return r;
> - }
> + r = dma_resv_wait_timeout(bo->tbo.base.resv, false, false,
> + MAX_SCHEDULE_TIMEOUT);
> + if (r <= 0) {
> + DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
> + return r ? r : -ETIME;
> }
>
> r = radeon_bo_kmap(bo, &ptr);
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 6/6] drm/radeon: use dma_resv_wait_timeout() instead of manually waiting
2021-10-28 13:26 ` [PATCH 6/6] drm/radeon: use dma_resv_wait_timeout() instead of manually waiting Christian König
2021-11-03 7:55 ` Christian König
@ 2021-11-03 16:36 ` Das, Nirmoy
1 sibling, 0 replies; 15+ messages in thread
From: Das, Nirmoy @ 2021-11-03 16:36 UTC (permalink / raw)
To: Christian König, dri-devel, linux-media, etnaviv, amd-gfx
Acked-by: Nirmoy Das <nirmoy.das@amd.com>
On 10/28/2021 3:26 PM, Christian König wrote:
> Don't touch the exclusive fence manually here, but rather use the
> general dma_resv function. We did that for better hw reset handling but
> this doesn't necessary work correctly.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/radeon/radeon_uvd.c | 13 +++++--------
> 1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_uvd.c b/drivers/gpu/drm/radeon/radeon_uvd.c
> index 2ea86919d953..377f9cdb5b53 100644
> --- a/drivers/gpu/drm/radeon/radeon_uvd.c
> +++ b/drivers/gpu/drm/radeon/radeon_uvd.c
> @@ -469,7 +469,6 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
> {
> int32_t *msg, msg_type, handle;
> unsigned img_size = 0;
> - struct dma_fence *f;
> void *ptr;
>
> int i, r;
> @@ -479,13 +478,11 @@ static int radeon_uvd_cs_msg(struct radeon_cs_parser *p, struct radeon_bo *bo,
> return -EINVAL;
> }
>
> - f = dma_resv_excl_fence(bo->tbo.base.resv);
> - if (f) {
> - r = radeon_fence_wait((struct radeon_fence *)f, false);
> - if (r) {
> - DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
> - return r;
> - }
> + r = dma_resv_wait_timeout(bo->tbo.base.resv, false, false,
> + MAX_SCHEDULE_TIMEOUT);
> + if (r <= 0) {
> + DRM_ERROR("Failed waiting for UVD message (%d)!\n", r);
> + return r ? r : -ETIME;
> }
>
> r = radeon_bo_kmap(bo, &ptr);
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/6] drm/amdgpu: stop getting excl fence separately
2021-10-28 13:26 ` [PATCH 2/6] drm/amdgpu: stop getting excl fence separately Christian König
@ 2021-11-11 8:58 ` Christian König
2021-11-16 10:43 ` Christian König
0 siblings, 1 reply; 15+ messages in thread
From: Christian König @ 2021-11-11 8:58 UTC (permalink / raw)
To: amd-gfx
Just a ping to the amd-gfx list.
Trivial cleanup, can anybody give me an rb for that?
Thanks,
Christian.
Am 28.10.21 um 15:26 schrieb Christian König:
> Just grab all fences for the display flip in one go.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 -
> drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 +-----
> 2 files changed, 1 insertion(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> index d58e37fd01f4..4da7eb65e744 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
> @@ -457,7 +457,6 @@ struct amdgpu_flip_work {
> uint64_t base;
> struct drm_pending_vblank_event *event;
> struct amdgpu_bo *old_abo;
> - struct dma_fence *excl;
> unsigned shared_count;
> struct dma_fence **shared;
> struct dma_fence_cb cb;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index dc50c05f23fc..68108f151dad 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -83,9 +83,6 @@ static void amdgpu_display_flip_work_func(struct work_struct *__work)
> unsigned i;
> int vpos, hpos;
>
> - if (amdgpu_display_flip_handle_fence(work, &work->excl))
> - return;
> -
> for (i = 0; i < work->shared_count; ++i)
> if (amdgpu_display_flip_handle_fence(work, &work->shared[i]))
> return;
> @@ -203,7 +200,7 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
> goto unpin;
> }
>
> - r = dma_resv_get_fences(new_abo->tbo.base.resv, &work->excl,
> + r = dma_resv_get_fences(new_abo->tbo.base.resv, NULL,
> &work->shared_count, &work->shared);
> if (unlikely(r != 0)) {
> DRM_ERROR("failed to get fences for buffer\n");
> @@ -253,7 +250,6 @@ int amdgpu_display_crtc_page_flip_target(struct drm_crtc *crtc,
>
> cleanup:
> amdgpu_bo_unref(&work->old_abo);
> - dma_fence_put(work->excl);
> for (i = 0; i < work->shared_count; ++i)
> dma_fence_put(work->shared[i]);
> kfree(work->shared);
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/6] drm/amdgpu: stop getting excl fence separately
2021-11-11 8:58 ` Christian König
@ 2021-11-16 10:43 ` Christian König
2021-11-16 14:54 ` Deucher, Alexander
0 siblings, 1 reply; 15+ messages in thread
From: Christian König @ 2021-11-16 10:43 UTC (permalink / raw)
To: amd-gfx, Alex Deucher
Adding Alex.
Once more a ping to the mailing list.
Thanks,
Christian.
Am 11.11.21 um 09:58 schrieb Christian König:
> Just a ping to the amd-gfx list.
>
> Trivial cleanup, can anybody give me an rb for that?
>
> Thanks,
> Christian.
>
> Am 28.10.21 um 15:26 schrieb Christian König:
>> Just grab all fences for the display flip in one go.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 -
>> drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 +-----
>> 2 files changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> index d58e37fd01f4..4da7eb65e744 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> @@ -457,7 +457,6 @@ struct amdgpu_flip_work {
>> uint64_t base;
>> struct drm_pending_vblank_event *event;
>> struct amdgpu_bo *old_abo;
>> - struct dma_fence *excl;
>> unsigned shared_count;
>> struct dma_fence **shared;
>> struct dma_fence_cb cb;
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> index dc50c05f23fc..68108f151dad 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> @@ -83,9 +83,6 @@ static void amdgpu_display_flip_work_func(struct
>> work_struct *__work)
>> unsigned i;
>> int vpos, hpos;
>> - if (amdgpu_display_flip_handle_fence(work, &work->excl))
>> - return;
>> -
>> for (i = 0; i < work->shared_count; ++i)
>> if (amdgpu_display_flip_handle_fence(work, &work->shared[i]))
>> return;
>> @@ -203,7 +200,7 @@ int amdgpu_display_crtc_page_flip_target(struct
>> drm_crtc *crtc,
>> goto unpin;
>> }
>> - r = dma_resv_get_fences(new_abo->tbo.base.resv, &work->excl,
>> + r = dma_resv_get_fences(new_abo->tbo.base.resv, NULL,
>> &work->shared_count, &work->shared);
>> if (unlikely(r != 0)) {
>> DRM_ERROR("failed to get fences for buffer\n");
>> @@ -253,7 +250,6 @@ int amdgpu_display_crtc_page_flip_target(struct
>> drm_crtc *crtc,
>> cleanup:
>> amdgpu_bo_unref(&work->old_abo);
>> - dma_fence_put(work->excl);
>> for (i = 0; i < work->shared_count; ++i)
>> dma_fence_put(work->shared[i]);
>> kfree(work->shared);
>
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 2/6] drm/amdgpu: stop getting excl fence separately
2021-11-16 10:43 ` Christian König
@ 2021-11-16 14:54 ` Deucher, Alexander
0 siblings, 0 replies; 15+ messages in thread
From: Deucher, Alexander @ 2021-11-16 14:54 UTC (permalink / raw)
To: Christian König, amd-gfx
[-- Attachment #1: Type: text/plain, Size: 2987 bytes --]
[AMD Official Use Only]
Acked-by: Alex Deucher <alexander.deucher@amd.com>
________________________________
From: Christian König <ckoenig.leichtzumerken@gmail.com>
Sent: Tuesday, November 16, 2021 5:43 AM
To: amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org>; Deucher, Alexander <Alexander.Deucher@amd.com>
Subject: Re: [PATCH 2/6] drm/amdgpu: stop getting excl fence separately
Adding Alex.
Once more a ping to the mailing list.
Thanks,
Christian.
Am 11.11.21 um 09:58 schrieb Christian König:
> Just a ping to the amd-gfx list.
>
> Trivial cleanup, can anybody give me an rb for that?
>
> Thanks,
> Christian.
>
> Am 28.10.21 um 15:26 schrieb Christian König:
>> Just grab all fences for the display flip in one go.
>>
>> Signed-off-by: Christian König <christian.koenig@amd.com>
>> ---
>> drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 -
>> drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 +-----
>> 2 files changed, 1 insertion(+), 6 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> index d58e37fd01f4..4da7eb65e744 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h
>> @@ -457,7 +457,6 @@ struct amdgpu_flip_work {
>> uint64_t base;
>> struct drm_pending_vblank_event *event;
>> struct amdgpu_bo *old_abo;
>> - struct dma_fence *excl;
>> unsigned shared_count;
>> struct dma_fence **shared;
>> struct dma_fence_cb cb;
>> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> index dc50c05f23fc..68108f151dad 100644
>> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
>> @@ -83,9 +83,6 @@ static void amdgpu_display_flip_work_func(struct
>> work_struct *__work)
>> unsigned i;
>> int vpos, hpos;
>> - if (amdgpu_display_flip_handle_fence(work, &work->excl))
>> - return;
>> -
>> for (i = 0; i < work->shared_count; ++i)
>> if (amdgpu_display_flip_handle_fence(work, &work->shared[i]))
>> return;
>> @@ -203,7 +200,7 @@ int amdgpu_display_crtc_page_flip_target(struct
>> drm_crtc *crtc,
>> goto unpin;
>> }
>> - r = dma_resv_get_fences(new_abo->tbo.base.resv, &work->excl,
>> + r = dma_resv_get_fences(new_abo->tbo.base.resv, NULL,
>> &work->shared_count, &work->shared);
>> if (unlikely(r != 0)) {
>> DRM_ERROR("failed to get fences for buffer\n");
>> @@ -253,7 +250,6 @@ int amdgpu_display_crtc_page_flip_target(struct
>> drm_crtc *crtc,
>> cleanup:
>> amdgpu_bo_unref(&work->old_abo);
>> - dma_fence_put(work->excl);
>> for (i = 0; i < work->shared_count; ++i)
>> dma_fence_put(work->shared[i]);
>> kfree(work->shared);
>
[-- Attachment #2: Type: text/html, Size: 5661 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c
2021-10-28 13:26 [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Christian König
` (4 preceding siblings ...)
2021-10-28 13:26 ` [PATCH 6/6] drm/radeon: use dma_resv_wait_timeout() instead of manually waiting Christian König
@ 2021-11-25 9:31 ` Maarten Lankhorst
2021-11-25 9:44 ` Christian König
5 siblings, 1 reply; 15+ messages in thread
From: Maarten Lankhorst @ 2021-11-25 9:31 UTC (permalink / raw)
To: Christian König, dri-devel, linux-media, etnaviv, amd-gfx
On 28-10-2021 15:26, Christian König wrote:
> The i915 driver implements a prune function which is called when it is very
> likely that the fences inside the dma_resv object can be removed because they
> are all signaled.
>
> Move that function into the dma-resv.c code since the behavior of pruning
> fences is something internal to the object.
>
> Signed-off-by: Christian König <christian.koenig@amd.com>
> ---
> drivers/dma-buf/dma-resv.c | 18 ++++++++++++++++++
> drivers/gpu/drm/i915/Makefile | 1 -
> drivers/gpu/drm/i915/dma_resv_utils.c | 17 -----------------
> drivers/gpu/drm/i915/dma_resv_utils.h | 13 -------------
> drivers/gpu/drm/i915/gem/i915_gem_shrinker.c | 3 +--
> drivers/gpu/drm/i915/gem/i915_gem_wait.c | 3 +--
> include/linux/dma-resv.h | 1 +
> 7 files changed, 21 insertions(+), 35 deletions(-)
> delete mode 100644 drivers/gpu/drm/i915/dma_resv_utils.c
> delete mode 100644 drivers/gpu/drm/i915/dma_resv_utils.h
>
> diff --git a/drivers/dma-buf/dma-resv.c b/drivers/dma-buf/dma-resv.c
> index ff3c0558b3b8..64d4f95778c4 100644
> --- a/drivers/dma-buf/dma-resv.c
> +++ b/drivers/dma-buf/dma-resv.c
> @@ -324,6 +324,24 @@ void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence)
> }
> EXPORT_SYMBOL(dma_resv_add_excl_fence);
>
> +/**
> + * dma_resv_prune_unlocked - try to remove signaled fences
> + * @obj: The dma_resv object to prune
> + *
> + * Try to lock the object, test if it is signaled and if yes then remove all the
> + * signaled fences.
> + */
> +void dma_resv_prune_unlocked(struct dma_resv *obj)
> +{
> + if (!dma_resv_trylock(obj))
> + return;
> +
> + if (dma_resv_test_signaled(obj, true))
> + dma_resv_add_excl_fence(obj, NULL);
> + dma_resv_unlock(obj);
> +}
> +EXPORT_SYMBOL(dma_resv_prune_unlocked);
> +
> /**
> * dma_resv_iter_restart_unlocked - restart the unlocked iterator
> * @cursor: The dma_resv_iter object to restart
> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefile
> index 660bb03de6fc..5c1af130cb6d 100644
> --- a/drivers/gpu/drm/i915/Makefile
> +++ b/drivers/gpu/drm/i915/Makefile
> @@ -60,7 +60,6 @@ i915-y += i915_drv.o \
>
> # core library code
> i915-y += \
> - dma_resv_utils.o \
> i915_memcpy.o \
> i915_mm.o \
> i915_sw_fence.o \
> diff --git a/drivers/gpu/drm/i915/dma_resv_utils.c b/drivers/gpu/drm/i915/dma_resv_utils.c
> deleted file mode 100644
> index 7df91b7e4ca8..000000000000
> --- a/drivers/gpu/drm/i915/dma_resv_utils.c
> +++ /dev/null
> @@ -1,17 +0,0 @@
> -// SPDX-License-Identifier: MIT
> -/*
> - * Copyright © 2020 Intel Corporation
> - */
> -
> -#include <linux/dma-resv.h>
> -
> -#include "dma_resv_utils.h"
> -
> -void dma_resv_prune(struct dma_resv *resv)
> -{
> - if (dma_resv_trylock(resv)) {
> - if (dma_resv_test_signaled(resv, true))
> - dma_resv_add_excl_fence(resv, NULL);
> - dma_resv_unlock(resv);
> - }
> -}
> diff --git a/drivers/gpu/drm/i915/dma_resv_utils.h b/drivers/gpu/drm/i915/dma_resv_utils.h
> deleted file mode 100644
> index b9d8fb5f8367..000000000000
> --- a/drivers/gpu/drm/i915/dma_resv_utils.h
> +++ /dev/null
> @@ -1,13 +0,0 @@
> -/* SPDX-License-Identifier: MIT */
> -/*
> - * Copyright © 2020 Intel Corporation
> - */
> -
> -#ifndef DMA_RESV_UTILS_H
> -#define DMA_RESV_UTILS_H
> -
> -struct dma_resv;
> -
> -void dma_resv_prune(struct dma_resv *resv);
> -
> -#endif /* DMA_RESV_UTILS_H */
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> index 5ab136ffdeb2..48029bbda682 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_shrinker.c
> @@ -15,7 +15,6 @@
>
> #include "gt/intel_gt_requests.h"
>
> -#include "dma_resv_utils.h"
> #include "i915_trace.h"
>
> static bool swap_available(void)
> @@ -229,7 +228,7 @@ i915_gem_shrink(struct i915_gem_ww_ctx *ww,
> i915_gem_object_unlock(obj);
> }
>
> - dma_resv_prune(obj->base.resv);
> + dma_resv_prune_unlocked(obj->base.resv);
>
> scanned += obj->base.size >> PAGE_SHIFT;
> skip:
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_wait.c b/drivers/gpu/drm/i915/gem/i915_gem_wait.c
> index 569658c7859c..1915d203a72d 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_wait.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_wait.c
> @@ -10,7 +10,6 @@
>
> #include "gt/intel_engine.h"
>
> -#include "dma_resv_utils.h"
> #include "i915_gem_ioctls.h"
> #include "i915_gem_object.h"
>
> @@ -53,7 +52,7 @@ i915_gem_object_wait_reservation(struct dma_resv *resv,
> * signaled.
> */
> if (timeout > 0)
> - dma_resv_prune(resv);
> + dma_resv_prune_unlocked(resv);
>
> return timeout;
> }
> diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
> index eebf04325b34..e0558429a5ee 100644
> --- a/include/linux/dma-resv.h
> +++ b/include/linux/dma-resv.h
> @@ -458,6 +458,7 @@ void dma_resv_fini(struct dma_resv *obj);
> int dma_resv_reserve_shared(struct dma_resv *obj, unsigned int num_fences);
> void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence);
> void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence);
> +void dma_resv_prune_unlocked(struct dma_resv *obj);
> int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **pfence_excl,
> unsigned *pshared_count, struct dma_fence ***pshared);
> int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src);
I don't mind adding a dma_resv_prune for locked case, but I don't think unlocked would have benefits.
Furthermore, I'm trying to remove the unlocked versions from i915. Could this be a prereq patch instead?
https://patchwork.freedesktop.org/patch/460722/?series=96115&rev=1
~Maarten
~Maarten
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c
2021-11-25 9:31 ` [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Maarten Lankhorst
@ 2021-11-25 9:44 ` Christian König
0 siblings, 0 replies; 15+ messages in thread
From: Christian König @ 2021-11-25 9:44 UTC (permalink / raw)
To: Maarten Lankhorst, dri-devel, linux-media, etnaviv, amd-gfx
Am 25.11.21 um 10:31 schrieb Maarten Lankhorst:
> [SNIP]
>> diff --git a/include/linux/dma-resv.h b/include/linux/dma-resv.h
>> index eebf04325b34..e0558429a5ee 100644
>> --- a/include/linux/dma-resv.h
>> +++ b/include/linux/dma-resv.h
>> @@ -458,6 +458,7 @@ void dma_resv_fini(struct dma_resv *obj);
>> int dma_resv_reserve_shared(struct dma_resv *obj, unsigned int num_fences);
>> void dma_resv_add_shared_fence(struct dma_resv *obj, struct dma_fence *fence);
>> void dma_resv_add_excl_fence(struct dma_resv *obj, struct dma_fence *fence);
>> +void dma_resv_prune_unlocked(struct dma_resv *obj);
>> int dma_resv_get_fences(struct dma_resv *obj, struct dma_fence **pfence_excl,
>> unsigned *pshared_count, struct dma_fence ***pshared);
>> int dma_resv_copy_fences(struct dma_resv *dst, struct dma_resv *src);
> I don't mind adding a dma_resv_prune for locked case, but I don't think unlocked would have benefits.
>
> Furthermore, I'm trying to remove the unlocked versions from i915. Could this be a prereq patch instead?
>
> https://patchwork.freedesktop.org/patch/460722/?series=96115&rev=1
Yeah, that works for me as well.
I was on the edge of dropping that from TTM as well since this is really
just abusing the interface to save a few bytes of memory.
Feel free to add an Acked-by: Christian König <christian.koenig@amd.com>
to the i915 patch if it helps to get that committed.
Regards,
Christian.
>
> ~Maarten
>
> ~Maarten
>
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2021-11-25 9:46 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-28 13:26 [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Christian König
2021-10-28 13:26 ` [PATCH 2/6] drm/amdgpu: stop getting excl fence separately Christian König
2021-11-11 8:58 ` Christian König
2021-11-16 10:43 ` Christian König
2021-11-16 14:54 ` Deucher, Alexander
2021-10-28 13:26 ` [PATCH 3/6] drm/etnaviv: stop getting the excl fence separately here Christian König
2021-11-01 9:51 ` Lucas Stach
2021-10-28 13:26 ` [PATCH 4/6] dma-buf: drop excl_fence parameter from dma_resv_get_fences Christian König
2021-10-28 13:26 ` [PATCH 5/6] RDMA: use dma_resv_wait() instead of extracting the fence Christian König
2021-10-28 13:26 ` [PATCH 6/6] drm/radeon: use dma_resv_wait_timeout() instead of manually waiting Christian König
2021-11-03 7:55 ` Christian König
2021-11-03 7:55 ` Christian König
2021-11-03 16:36 ` Das, Nirmoy
2021-11-25 9:31 ` [PATCH 1/6] dma-buf: move dma_resv_prune_unlocked into dma_resv.c Maarten Lankhorst
2021-11-25 9:44 ` Christian König
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.