All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Tvrtko Ursulin" <tvrtko.ursulin@igalia.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [RFC v3 2/2] drm/panthor: Create per queue priority workqueues
Date: Fri, 17 Jul 2026 09:24:47 +0000	[thread overview]
Message-ID: <20260717092447.AE4CB1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260717090209.26931-3-tvrtko.ursulin@igalia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Asynchronous teardown of `panthor_group` via `panthor_cleanup_wq` can race with device unplug and `drm_dev_release`, causing a Use-After-Free of the DRM device and workqueues.
--

--- Patch [2]: [RFC v3 2/2] drm/panthor: Create per queue priority workqueues ---
commit 55f41e3219b2c06b949efdf0212b58b264d95a7b
Author: Tvrtko Ursulin <tvrtko.ursulin@igalia.com>

drm/panthor: Create per queue priority workqueues

This commit splits the single workqueue used by the DRM scheduler into
multiple priority-based workqueues (low, medium, high, rt) to better serve
different GPU priority levels.

> diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
> index 5832dccfc0932..70e84ebb6c663 100644
> --- a/drivers/gpu/drm/panthor/panthor_sched.c
> +++ b/drivers/gpu/drm/panthor/panthor_sched.c

[ ... ]

> @@ -4084,6 +4096,15 @@ static void panthor_sched_fini(struct drm_device *ddev, void *res)
>  	if (!sched || !sched->csg_slot_count)
>  		return;
>  
> +	if (sched->submit_wq[PANTHOR_CSG_PRIORITY_MEDIUM])
> +		destroy_workqueue(sched->submit_wq[PANTHOR_CSG_PRIORITY_MEDIUM]);
> +
> +	if (sched->submit_wq[PANTHOR_CSG_PRIORITY_HIGH])
> +		destroy_workqueue(sched->submit_wq[PANTHOR_CSG_PRIORITY_HIGH]);
> +
> +	if (sched->submit_wq[PANTHOR_CSG_PRIORITY_RT])
> +		destroy_workqueue(sched->submit_wq[PANTHOR_CSG_PRIORITY_RT]);
> +

[Severity: High]
This is a pre-existing issue, but can this synchronous destruction race
with the asynchronous teardown of the queue?

When a user closes the device, the driver can schedule group_release on
the global panthor_cleanup_wq without holding a reference to the DRM
device:

group_release()
    ...
    queue_work(panthor_cleanup_wq, &group->release_work);

If this was the last reference, drm_dev_release can run immediately and
call panthor_sched_fini, which destroys these new submit_wq workqueues
and frees the ptdev allocation. 

Meanwhile, the asynchronous release work executing group_free_queue can
attempt to access the destroyed queue->scheduler.submit_wq, or access
the already-freed ptdev memory:

panthor_kernel_bo_destroy()
    ...
    ptdev = container_of(bo->obj->dev, struct panthor_device, base);

Could this lead to a use-after-free since the release work isn't flushed
before the device teardown?

>  	if (sched->wq)
>  		destroy_workqueue(sched->wq);
>

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260717090209.26931-1-tvrtko.ursulin@igalia.com?part=2

      reply	other threads:[~2026-07-17  9:24 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  9:02 [RFC v3 0/2] Realtime workqueues and panthor realtime submission Tvrtko Ursulin
2026-07-17  9:02 ` [RFC v3 1/2] workqueue: Add support for real-time workers Tvrtko Ursulin
2026-07-17  9:17   ` sashiko-bot
2026-07-17 10:06   ` Tvrtko Ursulin
2026-07-17  9:02 ` [RFC v3 2/2] drm/panthor: Create per queue priority workqueues Tvrtko Ursulin
2026-07-17  9:24   ` sashiko-bot [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=20260717092447.AE4CB1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=tvrtko.ursulin@igalia.com \
    /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.