All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Adrián Larumbe" <adrian.larumbe@collabora.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 08/13] drm/panfrost: Rewire reset sequence to avoid concurrent attempts
Date: Fri, 24 Jul 2026 00:09:00 +0000	[thread overview]
Message-ID: <20260724000900.AD3071F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260724-claude-fixes-v3-8-542af61abd0f@collabora.com>

Thank you for your contribution! Sashiko AI review found 4 potential issue(s) to consider:
- [High] Workqueue deadlock in `panfrost_job_timedout()` due to waiting on an ordered workqueue from a task executing on the same workqueue.
- [High] The timed-out job is permanently leaked and bypasses karma accounting because the asynchronous reset work executes with a NULL 'bad' job reference.
- [Medium] Unrealistically short wait timeout (60 milliseconds) for the GPU reset sequence.
- [Medium] Premature clearing of the `reset.pending` flag creates a data race with the TDR worker.
--

--- Patch [8]: [PATCH v3 08/13] drm/panfrost: Rewire reset sequence to avoid concurrent attempts ---
commit 2c4929474201c3a58918917376876f5a96009f31
Author: Adrián Larumbe <adrian.larumbe@collabora.com>
Subject: drm/panfrost: Rewire reset sequence to avoid concurrent attempts

This commit introduces a dedicated reset worker to serialize GPU resets.
It uses an ordered workqueue and wait_event_timeout to block concurrent
reset attempts while the ongoing reset thread completes.

Link: None provided

> diff --git a/drivers/gpu/drm/panfrost/panfrost_job.c b/drivers/gpu/drm/panfrost/panfrost_job.c
> --- a/drivers/gpu/drm/panfrost/panfrost_job.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_job.c
> @@ -797,10 +798,12 @@ static enum drm_gpu_sched_stat panfrost_job_timedout(struct drm_sched_job
>  
>  	panfrost_core_dump(job);
>  
> -	atomic_set(&pfdev->reset.pending, 1);
> -	panfrost_reset(pfdev, sched_job);
> +	panfrost_device_schedule_reset(pfdev);

[Severity: High]
By removing the synchronous panfrost_reset() call and relying on
panfrost_reset_work(), we seem to lose the reference to the timed-out job.

Looking at the new worker function:

static void panfrost_reset_work(struct work_struct *work)
{
	struct panfrost_device *pfdev;

	pfdev = container_of(work, struct panfrost_device, reset.work);
	panfrost_reset(pfdev, NULL);
}

Since the guilty job is passed as NULL, it bypasses karma accounting and
drm_sched_stop() will fail to reinsert it into the pending list. Will this
cause the bad job to permanently leak and hang userspace?

> +	ret = wait_event_timeout(pfdev->reset.wait,
> +				 !atomic_read(&pfdev->reset.pending),
> +				 msecs_to_jiffies(60));

[Severity: High]
Could this wait trigger a workqueue deadlock?

In panfrost_jm_init(), args.timeout_wq is assigned to pfdev->reset.wq.
This means the timeout handler runs on the ordered reset workqueue.

By queuing pfdev->reset.work onto this exact same workqueue and synchronously
waiting for it to complete here, it seems the reset work can never execute
because the single-threaded queue is blocked waiting for it.

[Severity: Medium]
Is this timeout duration sufficient?

A 60 millisecond wait seems extremely short for a full GPU reset, which
involves soft-stopping jobs and polling the hardware. If it expires
prematurely, it will return ENODEV and abandon recovery. Could this have
been intended to be 60 seconds (60000 msecs)?

[Severity: Medium]
Is it safe to rely on the pending flag to synchronize scheduler restart?

In panfrost_reset(), atomic_set(&pfdev->reset.pending, 0) is called
immediately after the hardware reset, but before drm_sched_resubmit_jobs()
and drm_sched_start() have finished.

If this wait_event_timeout() wakes up early or spuriously, it will unblock
the DRM scheduler while the reset worker is still actively modifying
scheduler lists. Should the flag be cleared only after the full reset
sequence completes?

> -	return DRM_GPU_SCHED_STAT_RESET;
> +	return (ret) ? DRM_GPU_SCHED_STAT_RESET : DRM_GPU_SCHED_STAT_ENODEV;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260724-claude-fixes-v3-0-542af61abd0f@collabora.com?part=8

  reply	other threads:[~2026-07-24  0:09 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23 23:58 [PATCH v3 00/13] RPM, perfcnt and other minor fixes for Panfrost Adrián Larumbe
2026-07-23 23:58 ` [PATCH v3 01/13] drm/panfrost: Check another bo field for cache option query Adrián Larumbe
2026-07-23 23:58 ` [PATCH v3 02/13] drm/panfrost: Prevent division by 0 Adrián Larumbe
2026-07-24  0:08   ` sashiko-bot
2026-07-23 23:58 ` [PATCH v3 03/13] drm/panfrost: Remove unnecessary header file include Adrián Larumbe
2026-07-23 23:58 ` [PATCH v3 04/13] drm/panfrost: Move shrinker initialization and unplug one level down Adrián Larumbe
2026-07-24  0:06   ` sashiko-bot
2026-07-23 23:58 ` [PATCH v3 05/13] drm/panfrost: Move all device power up and down into RPM callbacks Adrián Larumbe
2026-07-24  0:11   ` sashiko-bot
2026-07-23 23:58 ` [PATCH v3 06/13] drm/panfrost: Explicitly enable MMU interrupts at device init Adrián Larumbe
2026-07-24  0:13   ` sashiko-bot
2026-07-23 23:59 ` [PATCH v3 07/13] drm/panfrost: Sync with IRQ before MMU disable and reset Adrián Larumbe
2026-07-24  0:17   ` sashiko-bot
2026-07-23 23:59 ` [PATCH v3 08/13] drm/panfrost: Rewire reset sequence to avoid concurrent attempts Adrián Larumbe
2026-07-24  0:09   ` sashiko-bot [this message]
2026-07-23 23:59 ` [PATCH v3 09/13] drm/panfrost: Add debugfs knob for manually triggering a GPU reset Adrián Larumbe
2026-07-24  0:14   ` sashiko-bot
2026-07-23 23:59 ` [PATCH v3 10/13] drm/panfrost: Move perfcnt GPU disable sequence into a helper Adrián Larumbe
2026-07-23 23:59 ` [PATCH v3 11/13] drm/panfrost: Introduce a reset lock Adrián Larumbe
2026-07-24  0:16   ` sashiko-bot
2026-07-23 23:59 ` [PATCH v3 12/13] drm/panfrost: Fix races between perfcnt and reset sequence Adrián Larumbe
2026-07-24  0:12   ` sashiko-bot
2026-07-23 23:59 ` [PATCH v3 13/13] drm/panfrost: Bump driver minor to reflect new DUMP IOCTL req field Adrián Larumbe
2026-07-24  0:16   ` 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=20260724000900.AD3071F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=adrian.larumbe@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.