Re: [PATCH] drm/radeon: restore hardware polling in fence_is_signaled to fix performance regression

Christian König <[email protected]>
Newsgroups org.freedesktop.lists.dri-devel,org.freedesktop.lists.amd-gfx,org.kernel.vger.linux-kernel
Message-ID <[email protected]>
On 7/29/26 12:26, [email protected] wrote:
> From: Wang Jiang <[email protected]>
> 
> Commit 9eb00b5f5697b ("drm/radeon: delete radeon_fence_process in
> is_signaled, no deadlock") removed the hardware polling from
> radeon_fence_is_signaled() to fix a self-deadlock caused by
> wake_up_all(&rdev->fence_queue) being called with the fence queue
> lock held.
> 
> However, removing the polling entirely causes significant performance
> regression (e.g. glxgears FPS drop) because the fence signaled check
> becomes purely passive — it only reads the cached last_seq without
> probing the GPU, so completed GPU work is not detected in time,
> causing unnecessary CPU stalls in sync-heavy workloads.
> 
> Fix this by calling radeon_fence_activity() directly instead of
> radeon_fence_process(). radeon_fence_activity() reads the hardware
> fence counter and updates last_seq via atomic ops without calling
> wake_up_all(), thus avoiding the deadlock while restoring timely
> fence detection.

Yeah I already feared that removing this in commit 9eb00b5f5697b could cause issues.

Adding Philip and Danilo since we recently had a discussion about the necessity of this.
> Fixes: 9eb00b5f5697b ("drm/radeon: delete radeon_fence_process in is_signaled, no deadlock")
> Signed-off-by: Wang Jiang <[email protected]>

As far as I remember the radeon code the solution should work, but I don't have time to double check.

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

Thanks,
Christian.

> ---
>  drivers/gpu/drm/radeon/radeon_fence.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/radeon/radeon_fence.c b/drivers/gpu/drm/radeon/radeon_fence.c
> index 02a40e4750c7..299865569252 100644
> --- a/drivers/gpu/drm/radeon/radeon_fence.c
> +++ b/drivers/gpu/drm/radeon/radeon_fence.c
> @@ -360,6 +360,13 @@ static bool radeon_fence_is_signaled(struct dma_fence *f)
>         if (atomic64_read(&rdev->fence_drv[ring].last_seq) >= seq)
>                 return true;
> 
> +       if (down_read_trylock(&rdev->exclusive_lock)) {
> +               radeon_fence_activity(rdev, ring);
> +               up_read(&rdev->exclusive_lock);
> +
> +               if (atomic64_read(&rdev->fence_drv[ring].last_seq) >= seq)
> +                       return true;
> +       }
>         return false;
>  }
> 
> --
> 2.25.1
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.