mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matt Coster <Matt.Coster@imgtec.com>
To: Brendan King <Brendan.King@imgtec.com>
Cc: Frank Binns <Frank.Binns@imgtec.com>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] drm/imagination: avoid deadlock on fence release
Date: Wed, 19 Feb 2025 12:47:21 +0000	[thread overview]
Message-ID: <fd658c0a-78b0-4a30-bfe4-99107675700a@imgtec.com> (raw)
In-Reply-To: <20250203-fence-release-deadlock-v1-1-6e1de1260b38@imgtec.com>


[-- Attachment #1.1: Type: text/plain, Size: 3939 bytes --]

On 03/02/2025 15:32, Brendan King via B4 Relay wrote:
> From: Brendan King <Brendan.King@imgtec.com>
> 
> Do scheduler queue fence release processing on a workqueue, rather
> than in the release function itself.
> 
> Fixes deadlock issues such as the following:
> 
> [  607.400437] ============================================
> [  607.405755] WARNING: possible recursive locking detected
> [  607.415500] --------------------------------------------
> [  607.420817] weston:zfq0/24149 is trying to acquire lock:
> [  607.426131] ffff000017d041a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: pvr_gem_object_vunmap+0x40/0xc0 [powervr]
> [  607.436728]
>                but task is already holding lock:
> [  607.442554] ffff000017d105a0 (reservation_ww_class_mutex){+.+.}-{3:3}, at: dma_buf_ioctl+0x250/0x554
> [  607.451727]
>                other info that might help us debug this:
> [  607.458245]  Possible unsafe locking scenario:
> 
> [  607.464155]        CPU0
> [  607.466601]        ----
> [  607.469044]   lock(reservation_ww_class_mutex);
> [  607.473584]   lock(reservation_ww_class_mutex);
> [  607.478114]
>                 *** DEADLOCK ***
> 
> Signed-off-by: Brendan King <brendan.king@imgtec.com>

Hi Brendan,

Reviewed-by: Matt Coster <matt.coster@imgtec.com>

Would you mind sending a V2 with "Cc: stable@vger.kernel.org" so this
fix will get picked up for stable backporting?

Cheers,
Matt

> ---
>  drivers/gpu/drm/imagination/pvr_queue.c | 13 +++++++++++--
>  drivers/gpu/drm/imagination/pvr_queue.h |  4 ++++
>  2 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/imagination/pvr_queue.c b/drivers/gpu/drm/imagination/pvr_queue.c
> index c4f08432882b12f5cdfeb7fc991fd941f0946676..f3f1c5212df7432161919ddc510cececacbbe143 100644
> --- a/drivers/gpu/drm/imagination/pvr_queue.c
> +++ b/drivers/gpu/drm/imagination/pvr_queue.c
> @@ -109,12 +109,20 @@ pvr_queue_fence_get_driver_name(struct dma_fence *f)
>  	return PVR_DRIVER_NAME;
>  }
>  
> +static void pvr_queue_fence_release_work(struct work_struct *w)
> +{
> +	struct pvr_queue_fence *fence = container_of(w, struct pvr_queue_fence, release_work);
> +
> +	pvr_context_put(fence->queue->ctx);
> +	dma_fence_free(&fence->base);
> +}
> +
>  static void pvr_queue_fence_release(struct dma_fence *f)
>  {
>  	struct pvr_queue_fence *fence = container_of(f, struct pvr_queue_fence, base);
> +	struct pvr_device *pvr_dev = fence->queue->ctx->pvr_dev;
>  
> -	pvr_context_put(fence->queue->ctx);
> -	dma_fence_free(f);
> +	queue_work(pvr_dev->sched_wq, &fence->release_work);
>  }
>  
>  static const char *
> @@ -268,6 +276,7 @@ pvr_queue_fence_init(struct dma_fence *f,
>  
>  	pvr_context_get(queue->ctx);
>  	fence->queue = queue;
> +	INIT_WORK(&fence->release_work, pvr_queue_fence_release_work);
>  	dma_fence_init(&fence->base, fence_ops,
>  		       &fence_ctx->lock, fence_ctx->id,
>  		       atomic_inc_return(&fence_ctx->seqno));
> diff --git a/drivers/gpu/drm/imagination/pvr_queue.h b/drivers/gpu/drm/imagination/pvr_queue.h
> index e06ced69302fca47fc26451dfb09ebbb24b57f52..93fe9ac9f58ccc020615485e86be438548dcee43 100644
> --- a/drivers/gpu/drm/imagination/pvr_queue.h
> +++ b/drivers/gpu/drm/imagination/pvr_queue.h
> @@ -5,6 +5,7 @@
>  #define PVR_QUEUE_H
>  
>  #include <drm/gpu_scheduler.h>
> +#include <linux/workqueue.h>
>  
>  #include "pvr_cccb.h"
>  #include "pvr_device.h"
> @@ -63,6 +64,9 @@ struct pvr_queue_fence {
>  
>  	/** @queue: Queue that created this fence. */
>  	struct pvr_queue *queue;
> +
> +	/** @release_work: Fence release work structure. */
> +	struct work_struct release_work;
>  };
>  
>  /**
> 
> ---
> base-commit: 3ab334814dc7dff39075e055e12847d51878916e
> change-id: 20250203-fence-release-deadlock-a0753c07bfdd
> 
> Best regards,

-- 
Matt Coster
E: matt.coster@imgtec.com

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]

      reply	other threads:[~2025-02-19 12:47 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-03 15:32 Brendan King via B4 Relay
2025-02-19 12:47 ` Matt Coster [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=fd658c0a-78b0-4a30-bfe4-99107675700a@imgtec.com \
    --to=matt.coster@imgtec.com \
    --cc=Brendan.King@imgtec.com \
    --cc=Frank.Binns@imgtec.com \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®