All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lewis Lakerink" <lewis@retsim.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/imagination: guard fence release against device removal
Date: Thu, 26 Nov 2026 08:28:53 +0000	[thread overview]
Message-ID: <sashiko-outbox-235015@kernel.org> (raw)
In-Reply-To: <010101a211d07798-70c4219d-e457-43d8-835c-321a7c035057-000000@us-west-2.amazonses.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/imagination: pvr_queue_fence_release() leaks context when
  unplugged
--

commit 9773b5621e802ef35e9ac3c4db81027170ee1477
Author: Lewis Lakerink <lewis@retsim.com>

drm/imagination: guard fence release against device removal

This commit guards work queueing in pvr_queue_fence_release() with
drm_dev_enter(), freeing the fence directly and skipping
fence->release_work when the DRM device is marked unplugged.

> diff --git a/drivers/gpu/drm/imagination/pvr_queue.c b/drivers/gpu/drm/imagination/pvr_queue.c
> index 34b826381aa2b..2a6bfb090fadd 100644
> --- a/drivers/gpu/drm/imagination/pvr_queue.c
> +++ b/drivers/gpu/drm/imagination/pvr_queue.c
[ ... ]
> @@ -122,8 +123,19 @@ 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;
> +	int idx;
>  
> -	queue_work(pvr_dev->sched_wq, &fence->release_work);
> +	/*
> +	 * Fences held by drm_syncobj are released in drm_file_free() before
> +	 * postclose. After unplug, sched_wq and kernel_vm_ctx may already be
> +	 * torn down; free the fence directly and leak the context reference.
> +	 */
> +	if (drm_dev_enter(from_pvr_device(pvr_dev), &idx)) {
> +		queue_work(pvr_dev->sched_wq, &fence->release_work);
> +		drm_dev_exit(idx);
> +	} else {
> +		dma_fence_free(&fence->base);
> +	}
>  }

[Severity: High]
Does taking the else branch leak fence->queue->ctx on runtime device loss
as well as on driver unbind?

pvr_device_lost() calls drm_dev_unplug() at runtime when a GPU hard reset
or MMU flush fails, while the device is still bound and sched_wq is still
active.  Every pvr_queue_fence released after pvr_device_lost() (or after
drm_dev_unplug() in pvr_remove()) will skip pvr_context_put(), so
pvr_context_release() never runs.

That leaves the context's queues, firmware objects and ctx->vm_ctx
allocated, triggering WARN_ON(!list_empty(&pvr_dev->fw_dev.fw_objs.list))
in pvr_fw_fini() and WARN_ON(!xa_empty(&pvr_dev->ctx_ids)) in
pvr_context_device_fini() on unbind, and keeps ctx->vm_ctx->gpuvm_mgr's
drm_device reference alive so struct pvr_device is never freed.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/010101a211d07798-70c4219d-e457-43d8-835c-321a7c035057-000000@us-west-2.amazonses.com?part=1

  reply	other threads:[~2026-11-26  8:29 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261125082637.2839673-1-lewis@retsim.com>
2026-11-25  8:26 ` [PATCH 1/2] drm/imagination: guard fence release against device removal Lewis Lakerink
2026-11-26  8:28   ` sashiko-bot [this message]
2026-11-25  8:26 ` Lewis Lakerink
2026-11-25  8:42   ` sashiko-bot
2026-11-25  8:47     ` lewis
2026-11-25  8:26 ` [PATCH 2/2] drm/imagination: quiesce queues before device teardown Lewis Lakerink
2026-11-25  8:55   ` sashiko-bot
2026-11-25  8:26 ` Lewis Lakerink
2026-11-26  8:46   ` sashiko-bot

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=sashiko-outbox-235015@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lewis@retsim.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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 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.