dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Boris Brezillon" <boris.brezillon@collabora.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 12/12] drm/panthor: Fix unplug in the reset path
Date: Tue, 04 Aug 2026 16:01:24 +0000	[thread overview]
Message-ID: <20260804160125.5B8021F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804-panthor-unplug-fixes-v1-12-abbbd2d41b13@collabora.com>

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

Pre-existing issues:
- [High] Concurrent execution of device removal and a failing reset work causes an unrecoverable AB-BA cross-thread deadlock.
--

--- Patch [12]: [PATCH 12/12] drm/panthor: Fix unplug in the reset path ---
commit cac1a79672cc7dc4544f4f69a02f107969842cb8
Author: Boris Brezillon <boris.brezillon@collabora.com>

drm/panthor: Fix unplug in the reset path

We can't use disable_work_sync() if panthor_device_unplug() is called
from the reset work or we'll deadlock. Pass a from_reset_work bool to
the panthor_device_unplug() function and lower the disable_work_sync()
to a disable_work() in that case.

> diff --git a/drivers/gpu/drm/panthor/panthor_device.c b/drivers/gpu/drm/panthor/panthor_device.c
> --- a/drivers/gpu/drm/panthor/panthor_device.c
> +++ b/drivers/gpu/drm/panthor/panthor_device.c
> @@ -189,13 +192,16 @@ static void panthor_device_reset_work(struct work_struct *work)
>  	panthor_hw_soft_reset(ptdev);
>  	panthor_hw_l2_power_on(ptdev);
>  	panthor_mmu_post_reset(ptdev);
> -	ret = panthor_fw_post_reset(ptdev);
> +	if (ptdev->reset.fake_failure)
> +		ret = -EIO;
> +	else
> +		ret = panthor_fw_post_reset(ptdev);
>  	atomic_set(&ptdev->reset.pending, 0);
>  	panthor_sched_post_reset(ptdev, ret != 0);
>  	drm_dev_exit(cookie);
>  
>  	if (ret) {
> -		panthor_device_unplug(ptdev);
> +		panthor_device_unplug(ptdev, true);

[Severity: High]
This is a pre-existing issue, but does this sequence still leave an AB-BA
deadlock if driver removal runs concurrently with a failing reset work?

If CPU1 is running driver removal via panthor_remove(), it calls
panthor_device_unplug(..., false). This acquires ptdev->unplug.lock
earlier in the function.

If CPU2 is running panthor_device_reset_work(), it holds the SRCU
read lock via drm_dev_enter().

CPU1 then blocks in drm_dev_unplug() waiting for active SRCU readers.

CPU2 encounters a reset error, calls drm_dev_exit() (releasing SRCU),
and unblocks CPU1.

CPU1 continues in panthor_device_unplug() and blocks in
disable_work_sync() waiting for the reset work to finish (since it
holds ptdev->unplug.lock and from_reset_work is false):

CPU1:
panthor_remove()
  panthor_device_unplug(ptdev, false)
    mutex_lock(&ptdev->unplug.lock);
    ...
    drm_dev_unplug(&ptdev->base);
    ...
    disable_work_sync(&ptdev->reset.work);

Meanwhile, CPU2 proceeds to the error handling path and calls
panthor_device_unplug(ptdev, true). This attempts to acquire
ptdev->unplug.lock, but CPU1 already holds it:

CPU2:
panthor_device_reset_work()
  ...
  if (ret)
    panthor_device_unplug(ptdev, true)
      mutex_lock(&ptdev->unplug.lock);

Could this cause both threads to hang indefinitely?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260804-panthor-unplug-fixes-v1-0-abbbd2d41b13@collabora.com?part=12

      reply	other threads:[~2026-08-04 16:01 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-04 10:09 [PATCH 00/12] drm/panthor: Fix the unplug logic Boris Brezillon
2026-08-04 10:09 ` [PATCH 01/12] drm/panthor: Disable reset work before unplug Boris Brezillon
2026-08-04 10:21   ` sashiko-bot
2026-08-04 10:46   ` Boris Brezillon
2026-08-04 10:09 ` [PATCH 02/12] drm/panthor: Further delay reset work enablement Boris Brezillon
2026-08-04 10:35   ` sashiko-bot
2026-08-04 10:09 ` [PATCH 03/12] drm/panthor: Move the debugfs initialization to panthor_device.c Boris Brezillon
2026-08-04 12:50   ` Liviu Dudau
2026-08-04 10:09 ` [PATCH 04/12] drm/panthor: Flush the cleanup_wq before destroying the drm_device Boris Brezillon
2026-08-04 10:55   ` sashiko-bot
2026-08-04 10:09 ` [PATCH 05/12] drm/panthor: Drop unused vm argument passed to panthor_vm_prepare_sync_only_op_ctx() Boris Brezillon
2026-08-04 10:09 ` [PATCH 06/12] drm/panthor: Split panthor_vm Boris Brezillon
2026-08-04 10:09 ` [PATCH 07/12] drm/panthor: Add fine-grained restrictions on VMs Boris Brezillon
2026-08-04 13:27   ` sashiko-bot
2026-08-04 10:09 ` [PATCH 08/12] drm/panthor: Check AS state before disabling Boris Brezillon
2026-08-04 10:09 ` [PATCH 09/12] drm/panthor: Don't pre-allocate VMAs or page tables when preparing a full VM unmap Boris Brezillon
2026-08-04 10:09 ` [PATCH 10/12] drm/panthor: Make the VM cleanup path more robust against UAF Boris Brezillon
2026-08-04 15:23   ` sashiko-bot
2026-08-04 10:09 ` [PATCH 11/12] drm/panthor: Make the unplug logic more robust Boris Brezillon
2026-08-04 15:53   ` sashiko-bot
2026-08-04 10:09 ` [PATCH 12/12] drm/panthor: Fix unplug in the reset path Boris Brezillon
2026-08-04 16:01   ` 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=20260804160125.5B8021F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=boris.brezillon@collabora.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox