2022-09-27 18:16:19

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH 0/3] dma-buf: Check status of enable-signaling bit on debug

Fence signaling must be enabled to make sure that
the dma_fence_is_signaled() and dma_fence_is_signaled_locked()
function ever returns true. Since drivers and implementations
sometimes mess this up, this ensures correct behaviour when
DEBUG_WW_MUTEX_SLOWPATH is used during debugging.
This should make any implementation bugs resulting in not
signaled fences much more obvious.


Arvind Yadav (3):
[PATCH 1/3] dma-buf: Remove the signaled bit status check
[PATCH 2/3] dma-buf: Enable signaling on fence for sw_sync
[PATCH 3/3] dma-buf: Check status of enable-signaling bit on debug

drivers/dma-buf/dma-fence.c | 5 -----
drivers/dma-buf/sw_sync.c | 2 ++
include/linux/dma-fence.h | 5 +++++
3 files changed, 7 insertions(+), 5 deletions(-)

--
2.25.1


2022-09-27 18:44:45

by Arvind Yadav

[permalink] [raw]
Subject: [PATCH 1/3] dma-buf: Remove the signaled bit status check

Remove the extra signaled bit status check because
it is returning early when the fence is already signaled and
__dma_fence_enable_signaling is checking the status of signaled
bit again.

Signed-off-by: Arvind Yadav <[email protected]>
---
drivers/dma-buf/dma-fence.c | 5 -----
1 file changed, 5 deletions(-)

diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
index 406b4e26f538..11ef20f70ee0 100644
--- a/drivers/dma-buf/dma-fence.c
+++ b/drivers/dma-buf/dma-fence.c
@@ -648,11 +648,6 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb,
if (WARN_ON(!fence || !func))
return -EINVAL;

- if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) {
- INIT_LIST_HEAD(&cb->node);
- return -ENOENT;
- }
-
spin_lock_irqsave(fence->lock, flags);

if (__dma_fence_enable_signaling(fence)) {
--
2.25.1

2022-09-29 18:38:22

by Christian König

[permalink] [raw]
Subject: Re: [PATCH 1/3] dma-buf: Remove the signaled bit status check

Am 27.09.22 um 19:24 schrieb Arvind Yadav:
> Remove the extra signaled bit status check because
> it is returning early when the fence is already signaled and
> __dma_fence_enable_signaling is checking the status of signaled
> bit again.
>
> Signed-off-by: Arvind Yadav <[email protected]>

Reviewed-by: Christian König <[email protected]>

> ---
> drivers/dma-buf/dma-fence.c | 5 -----
> 1 file changed, 5 deletions(-)
>
> diff --git a/drivers/dma-buf/dma-fence.c b/drivers/dma-buf/dma-fence.c
> index 406b4e26f538..11ef20f70ee0 100644
> --- a/drivers/dma-buf/dma-fence.c
> +++ b/drivers/dma-buf/dma-fence.c
> @@ -648,11 +648,6 @@ int dma_fence_add_callback(struct dma_fence *fence, struct dma_fence_cb *cb,
> if (WARN_ON(!fence || !func))
> return -EINVAL;
>
> - if (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags)) {
> - INIT_LIST_HEAD(&cb->node);
> - return -ENOENT;
> - }
> -
> spin_lock_irqsave(fence->lock, flags);
>
> if (__dma_fence_enable_signaling(fence)) {