2023-07-25 08:41:48

by Mikko Perttunen

[permalink] [raw]
Subject: [PATCH] dma_buf/sync_file: Enable signaling for fences when querying status

From: Mikko Perttunen <[email protected]>

dma_fence_get_status is not guaranteed to return valid information
on if the fence has been signaled or not if SW signaling has not
been enabled for the fence. To ensure valid information is reported,
enable SW signaling for fences before getting their status.

Signed-off-by: Mikko Perttunen <[email protected]>
---
drivers/dma-buf/sync_file.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
index af57799c86ce..57f194b8477f 100644
--- a/drivers/dma-buf/sync_file.c
+++ b/drivers/dma-buf/sync_file.c
@@ -267,6 +267,7 @@ static int sync_fill_fence_info(struct dma_fence *fence,
strscpy(info->driver_name, fence->ops->get_driver_name(fence),
sizeof(info->driver_name));

+ dma_fence_enable_sw_signaling(fence);
info->status = dma_fence_get_status(fence);
while (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags) &&
!test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags))
@@ -307,6 +308,7 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
* info->num_fences.
*/
if (!info.num_fences) {
+ dma_fence_enable_sw_signaling(sync_file->fence);
info.status = dma_fence_get_status(sync_file->fence);
goto no_fences;
} else {
--
2.40.1



2023-09-03 13:14:05

by Mikko Perttunen

[permalink] [raw]
Subject: Re: [PATCH] dma_buf/sync_file: Enable signaling for fences when querying status

On 7/25/23 10:46, Mikko Perttunen wrote:
> From: Mikko Perttunen <[email protected]>
>
> dma_fence_get_status is not guaranteed to return valid information
> on if the fence has been signaled or not if SW signaling has not
> been enabled for the fence. To ensure valid information is reported,
> enable SW signaling for fences before getting their status.
>
> Signed-off-by: Mikko Perttunen <[email protected]>
> ---
> drivers/dma-buf/sync_file.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/drivers/dma-buf/sync_file.c b/drivers/dma-buf/sync_file.c
> index af57799c86ce..57f194b8477f 100644
> --- a/drivers/dma-buf/sync_file.c
> +++ b/drivers/dma-buf/sync_file.c
> @@ -267,6 +267,7 @@ static int sync_fill_fence_info(struct dma_fence *fence,
> strscpy(info->driver_name, fence->ops->get_driver_name(fence),
> sizeof(info->driver_name));
>
> + dma_fence_enable_sw_signaling(fence);
> info->status = dma_fence_get_status(fence);
> while (test_bit(DMA_FENCE_FLAG_SIGNALED_BIT, &fence->flags) &&
> !test_bit(DMA_FENCE_FLAG_TIMESTAMP_BIT, &fence->flags))
> @@ -307,6 +308,7 @@ static long sync_file_ioctl_fence_info(struct sync_file *sync_file,
> * info->num_fences.
> */
> if (!info.num_fences) {
> + dma_fence_enable_sw_signaling(sync_file->fence);
> info.status = dma_fence_get_status(sync_file->fence);
> goto no_fences;
> } else {

Any thoughts?

Mikko