dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Christian Gmeiner" <christian.gmeiner@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 2/2] drm/etnaviv: Add GPU reset counters
Date: Fri, 10 Jul 2026 09:27:42 +0000	[thread overview]
Message-ID: <20260710092742.B17D21F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260710-etnaviv-reset-notification-v2-2-90cfebcf22a2@igalia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] Concurrent modification and unannotated lockless reads of `gpu->reset_counter` and `ctx->reset_counter` lead to data races and lost increments.
--

--- Patch [2]: [PATCH v2 2/2] drm/etnaviv: Add GPU reset counters ---
commit 0f536ab6e10b2d00764a49473b750d556dcda8ee
Author: Christian Gmeiner <cgmeiner@igalia.com>

drm/etnaviv: Add GPU reset counters

This commit adds per-GPU and per-context reset counters to etnaviv to allow
userspace to detect GPU resets and determine if their context was guilty.

> --- a/drivers/gpu/drm/etnaviv/etnaviv_drv.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_drv.c
[ ... ]
> +static int etnaviv_ioctl_reset_query(struct drm_device *dev, void *data,
> +		struct drm_file *file)
> +{
> +	struct etnaviv_drm_private *priv = dev->dev_private;
> +	struct etnaviv_file_private *ctx = file->driver_priv;
> +	struct drm_etnaviv_reset_query *args = data;
> +	struct etnaviv_gpu *gpu;
> +
> +	if (args->flags)
> +		return -EINVAL;
> +
> +	if (args->pipe >= ETNA_MAX_PIPES)
> +		return -EINVAL;
> +
> +	gpu = priv->gpu[args->pipe];
> +	if (!gpu)
> +		return -ENXIO;
> +
> +	args->global_reset_counter = gpu->reset_counter;
> +	args->context_reset_counter = ctx->reset_counter;

[Severity: Medium]
Is it possible for these counters to be updated concurrently while being
read here? 

Since etnaviv_sched_timedout_job() can increment the counters on another CPU,
it seems this lockless read might need READ_ONCE() to prevent load tearing and
ensure the compiler doesn't optimize the read incorrectly.

> +
> +	return 0;
> +}
[ ... ]
> --- a/drivers/gpu/drm/etnaviv/etnaviv_sched.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_sched.c
[ ... ]
> @@ -79,6 +79,9 @@ static enum drm_gpu_sched_stat etnaviv_sched_timedout_job(struct drm_sched_job
>  	if(sched_job)
>  		drm_sched_increase_karma(sched_job);
>  
> +	gpu->reset_counter++;
> +	submit->ctx->reset_counter++;

[Severity: Medium]
Can a single userspace context submit jobs to multiple GPU pipes that
might hang at the same time? 

If so, could multiple per-GPU scheduler timeout workers execute
etnaviv_sched_timedout_job() simultaneously? If they do, both workers would
evaluate submit->ctx->reset_counter++ concurrently, which could lead to a
multi-writer data race and lost increments. 

Would it make sense to use atomic_t for the context reset counter, or at
least WRITE_ONCE() if exact counts are less critical than preventing data
races?

>  	/* get the GPU back into the init state */
>  	etnaviv_core_dump(submit);

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260710-etnaviv-reset-notification-v2-0-90cfebcf22a2@igalia.com?part=2

  reply	other threads:[~2026-07-10  9:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10  9:00 [PATCH v2 0/2] drm/etnaviv: Add GPU reset counters for robustness Christian Gmeiner
2026-07-10  9:00 ` [PATCH v2 1/2] drm/etnaviv: Reference count struct etnaviv_file_private Christian Gmeiner
2026-07-10  9:20   ` sashiko-bot
2026-07-10  9:00 ` [PATCH v2 2/2] drm/etnaviv: Add GPU reset counters Christian Gmeiner
2026-07-10  9:27   ` sashiko-bot [this message]
2026-07-10 11:47   ` Lucas Stach
2026-07-10 12:01     ` Christian Gmeiner

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=20260710092742.B17D21F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=christian.gmeiner@gmail.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