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 v5 09/11] drm/panfrost: Introduce a reset lock
Date: Tue, 11 Aug 2026 21:55:20 +0000	[thread overview]
Message-ID: <20260811215520.ADBC91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260811-claude-fixes-v5-9-3d692c9e98c2@collabora.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The GPU reset path acquires the read/write semaphore in shared (read) mode instead of exclusive (write) mode, failing to provide mutual exclusion against driver entry points.
--

--- Patch [9]: [PATCH v5 09/11] drm/panfrost: Introduce a reset lock ---
commit 4a244ba91270b92c6bb1ef0025f7f540dbdc5eff
Author: Adrián Larumbe <adrian.larumbe@collabora.com>

drm/panfrost: envelope GPU reset sequence with rw_semaphore

This commit introduces a read/write semaphore to prevent driver entry
points from accessing hardware registers while a GPU reset is ongoing.
The query timestamp ioctl is updated to hold this semaphore during
execution.

> diff --git a/drivers/gpu/drm/panfrost/panfrost_device.c b/drivers/gpu/drm/panfrost/panfrost_device.c
> index 5b66173c75b9..e0390b6c0d22 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_device.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_device.c
> @@ -602,6 +602,8 @@ bool panfrost_exception_needs_reset(const struct panfrost_device *pfdev,
>  
>  void panfrost_device_reset(struct panfrost_device *pfdev, bool enable_job_int)
>  {
> +	guard(rwsem_read)(&pfdev->reset.lock);

[Severity: High]
Does acquiring this lock as a shared reader (rwsem_read) instead of an
exclusive writer (rwsem_write) fail to provide mutual exclusion?

Since the protected ioctl path in panfrost_ioctl_query_timestamp() also
acquires the lock in read mode, won't both paths execute concurrently?

This could allow an unprivileged userspace program calling the timestamp
ioctl to access hardware registers while the GPU reset is ongoing, which
defeats the intended mutual exclusion.

> +
>  	panfrost_gpu_soft_reset(pfdev);
>  	panfrost_gpu_power_on(pfdev);
>  	panfrost_mmu_reset(pfdev);

[ ... ]

> diff --git a/drivers/gpu/drm/panfrost/panfrost_drv.c b/drivers/gpu/drm/panfrost/panfrost_drv.c
> index 958f1d36ab10..ff23b1a979bb 100644
> --- a/drivers/gpu/drm/panfrost/panfrost_drv.c
> +++ b/drivers/gpu/drm/panfrost/panfrost_drv.c
> @@ -41,9 +41,12 @@ static int panfrost_ioctl_query_timestamp(struct panfrost_device *pfdev,
>  	if (ret)
>  		return ret;
>  
> -	panfrost_cycle_counter_get(pfdev);
> -	*arg = panfrost_timestamp_read(pfdev);
> -	panfrost_cycle_counter_put(pfdev);
> +	/* We should not read timestamp register while the GPU  is being reset */
> +	scoped_guard(rwsem_read, &pfdev->reset.lock) {

[Severity: High]
As noted above, since both the reset path and this ioctl path acquire the
lock in read mode, will this scoped_guard fail to wait for an ongoing reset
to complete?

> +		panfrost_cycle_counter_get(pfdev);
> +		*arg = panfrost_timestamp_read(pfdev);
> +		panfrost_cycle_counter_put(pfdev);
> +	}
>  
>  	pm_runtime_put(pfdev->base.dev);
>  	return 0;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260811-claude-fixes-v5-0-3d692c9e98c2@collabora.com?part=9

  reply	other threads:[~2026-08-11 21:55 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-11 21:42 [PATCH v5 00/11] RPM, perfcnt and other minor fixes for Panfrost Adrián Larumbe
2026-08-11 21:42 ` [PATCH v5 01/11] drm/panfrost: Check another bo field for cache option query Adrián Larumbe
2026-08-11 21:42 ` [PATCH v5 02/11] drm/panfrost: Prevent division by 0 Adrián Larumbe
2026-08-11 21:57   ` sashiko-bot
2026-08-12  7:59   ` Boris Brezillon
2026-08-11 21:42 ` [PATCH v5 03/11] drm/panfrost: Remove unnecessary header file include Adrián Larumbe
2026-08-12  8:00   ` Boris Brezillon
2026-08-11 21:42 ` [PATCH v5 04/11] drm/panfrost: Move shrinker initialization and unplug one level down Adrián Larumbe
2026-08-11 21:55   ` sashiko-bot
2026-08-12  8:07   ` Boris Brezillon
2026-08-11 21:42 ` [PATCH v5 05/11] drm/panfrost: Move all device power up and down into RPM callbacks Adrián Larumbe
2026-08-11 21:54   ` sashiko-bot
2026-08-12  9:07   ` Boris Brezillon
2026-08-11 21:42 ` [PATCH v5 06/11] drm/panfrost: Explicitly enable MMU interrupts at device init Adrián Larumbe
2026-08-11 21:54   ` sashiko-bot
2026-08-12  9:14   ` Boris Brezillon
2026-08-11 21:42 ` [PATCH v5 07/11] drm/panfrost: Add debugfs knob for manually triggering a GPU reset Adrián Larumbe
2026-08-11 21:54   ` sashiko-bot
2026-08-12  9:17   ` Boris Brezillon
2026-08-11 21:42 ` [PATCH v5 08/11] drm/panfrost: Move perfcnt GPU disable sequence into a helper Adrián Larumbe
2026-08-12  9:48   ` Boris Brezillon
2026-08-11 21:42 ` [PATCH v5 09/11] drm/panfrost: Introduce a reset lock Adrián Larumbe
2026-08-11 21:55   ` sashiko-bot [this message]
2026-08-12  9:44   ` Boris Brezillon
2026-08-12  9:45   ` Boris Brezillon
2026-08-11 21:42 ` [PATCH v5 10/11] drm/panfrost: Fix races between perfcnt and reset sequence Adrián Larumbe
2026-08-11 21:58   ` sashiko-bot
2026-08-12 10:06   ` Boris Brezillon
2026-08-11 21:42 ` [PATCH v5 11/11] drm/panfrost: Bump driver minor to reflect new DUMP IOCTL req field Adrián Larumbe
2026-08-11 21:55   ` 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=20260811215520.ADBC91F000E9@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.