All of 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 02/12] drm/panthor: Further delay reset work enablement
Date: Tue, 04 Aug 2026 10:35:34 +0000	[thread overview]
Message-ID: <20260804103535.38CD51F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260804-panthor-unplug-fixes-v1-2-abbbd2d41b13@collabora.com>

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

New issues:
- [High] Calling disable_work_sync() on a work item from within the work item itself causes a deadlock.

Pre-existing issues:
- [High] A race condition during device resume can cause a hardware fault to be permanently ignored, leaving the reset.pending flag stuck at 1 and blocking all future resets.
- [High] A race condition at the end of the reset work can cause a new hardware fault to be lost because `reset.pending` is cleared after interrupts are re-enabled.
--

--- Patch [2]: [PATCH 02/12] drm/panthor: Further delay reset work enablement ---
commit 08177a6c8d92319bf18b6e18c4bb7d3f3023ca20
Author: Boris Brezillon <boris.brezillon@collabora.com>

drm/panthor: Further delay reset work enablement

There's no point re-enabling the reset work before the DRM device
registration succeeds, so move the enable_work() after the point where
nothing can fail anymore, and in the unlikely event where a reset was
pending, reschedule it.

> 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

[ ... ]

> @@ -300,6 +297,14 @@ int panthor_device_init(struct panthor_device *ptdev)
>  	if (ret)
>  		goto err_disable_autosuspend;
>  
> +	/* Now that everything is initialized, we can enable the reset work.
> +	 * If there was a reset pending, clear and reschedule, otherwise the
> +	 * reset.pending bit is stuck.
> +	 */
> +	enable_work(&ptdev->reset.work);
> +	if (atomic_cmpxchg(&ptdev->reset.pending, 1, 0))
> +		panthor_device_schedule_reset(ptdev);

[Severity: High]
Can this lead to a deadlock if the firmware boot fails?

If panthor_fw_post_reset() fails during panthor_device_reset_work() in
drivers/gpu/drm/panthor/panthor_device.c, it directly calls
panthor_device_unplug().

panthor_device_unplug() then unconditionally calls:
disable_work_sync(&ptdev->reset.work);

Since disable_work_sync() synchronously waits for the currently executing
work item to complete, would this deadlock on itself if called from within
the reset work?

[Severity: High]
This is a pre-existing issue, but is the same fix needed in
panthor_device_resume()?

In panthor_device_resume(), pm.state is set to ACTIVE without checking if a
fault occurred. When resuming, pm.state starts as RESUMING and interrupts
are re-enabled by panthor_device_resume_hw_components().

If a fault fires before pm.state becomes ACTIVE, the interrupt handler calls
panthor_device_schedule_reset(), which sets reset.pending to 1 but skips
queuing the work because pm.state is not ACTIVE.

When panthor_device_resume() later sets pm.state to ACTIVE without checking
if pending became 1 (unlike the fix applied here in panthor_device_init),
does this leave reset.pending stuck at 1 and block all future resets?

[Severity: High]
This is a pre-existing issue, but can a hardware fault be lost due to a race
condition at the end of the reset work?

In panthor_device_reset_work(), panthor_mmu_post_reset() and
panthor_fw_post_reset() are called, which re-enable hardware interrupts.

If a fault occurs immediately after, the interrupt handler calls
panthor_device_schedule_reset(). Since reset.pending is still 1,
the atomic_cmpxchg fails and no work is queued.

Then, panthor_device_reset_work() executes:
atomic_set(&ptdev->reset.pending, 0);

Are faults occurring in this window silently ignored?

> +
>  	pm_runtime_put_autosuspend(ptdev->base.dev);
>  	return 0;
>

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

  reply	other threads:[~2026-08-04 10:35 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 [this message]
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

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=20260804103535.38CD51F000E9@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 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.