Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Riana Tauro" <riana.tauro@intel.com>, intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v5 4/4] drm/xe/ras: Serialize RAS workers on an ordered workqueue
Date: Tue, 01 Dec 2026 10:01:12 +0000	[thread overview]
Message-ID: <sashiko-outbox-243028@kernel.org> (raw)
In-Reply-To: <20261201094549.3158286-10-riana.tauro@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/xe/ras: uninitialized XArray spinlock in ras_fini() on
  probe error
- [Medium] drm/xe/ras: circular lock dependency in xe_ras_suspend()
  flushing ras_wq
--

commit 190e744799c17ac8b742cdb2e90b6eebab8fb92c
Author: Riana Tauro <riana.tauro@intel.com>

drm/xe/ras: Serialize RAS workers on an ordered workqueue

This commit introduces an ordered RAS workqueue to serialize the sysctrl
event worker and per-tile hw error workers, drains it in ras_fini() before
destroying offlined_pages, and flushes it during xe_device_suspend().

> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index 36693df655941..b7e0d89e1b043 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
> @@ -1452,6 +1452,7 @@ int xe_device_suspend(struct xe_device *xe, bool hibernate, bool flr)
>  	}
>  
>  	xe_irq_suspend(xe);
> +	xe_ras_suspend(xe);

[Severity: Medium]
Does flushing ras_wq in xe_device_suspend() create a circular lock
dependency between vm->lock, xe_pm_block_lockdep_map, and
ras_wq->lockdep_map?

CPU0                        CPU1                        CPU2
----                        ----                        ----
lock(&vm->lock)
                            lock(xe_pm_block_lockdep_map)
                                                        lock(ras_wq)
                                                        lock(&vm->lock)
                            flush_workqueue(ras_wq)
lock(xe_pm_block_lockdep_map)

 *** DEADLOCK ***

CPU0: xe_exec_ioctl() -> xe_pm_block_on_suspend()
CPU1: xe_pm_suspend() -> xe_device_suspend() -> xe_ras_suspend()
CPU2: hw_error_work() / xe_sysctrl_work() -> ... ->
      xe_ttm_vram_purge_page()

xe_pm_suspend() holds xe_pm_block_lockdep_map across xe_device_suspend(),
while xe_exec_ioctl() calls xe_pm_block_on_suspend() under vm->lock, and
the RAS workers queued on ras_wq acquire vm->lock in
xe_ttm_vram_purge_page().

> diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c
> index 71585bc8bfe01..207c2706ec8d5 100644
> --- a/drivers/gpu/drm/xe/xe_ras.c
> +++ b/drivers/gpu/drm/xe/xe_ras.c
> @@ -1437,8 +1437,11 @@ static const struct attribute_group gpu_health_group = {
>  static void ras_fini(void *arg)
>  {
>  	struct xe_device *xe = arg;
> +	struct xe_ras_state *state = &xe->ras.state;
>  
> -	xa_destroy(&xe->ras.state.offlined_pages);
> +	destroy_workqueue(state->ras_wq);
> +	if (xe->info.has_sysctrl)
> +		xa_destroy(&state->offlined_pages);
>  }

[ ... ]

> @@ -1498,6 +1512,14 @@ int xe_ras_init(struct xe_device *xe)
>  
>  	xe_drm_ras_init(xe);
>  
> +	state->ras_wq = alloc_ordered_workqueue("xe-ras-wq", 0);
> +	if (!state->ras_wq)
> +		return -ENOMEM;
> +
> +	ret = devm_add_action_or_reset(xe->drm.dev, ras_fini, xe);
> +	if (ret)
> +		return ret;
> +
>  	if (!xe->info.has_sysctrl)
>  		return 0;
>  
> @@ -1513,10 +1535,6 @@ int xe_ras_init(struct xe_device *xe)
>  
>  	xa_init(&state->offlined_pages);
>  
> -	ret = devm_add_action_or_reset(xe->drm.dev, ras_fini, xe);
> -	if (ret)
> -		return ret;

[Severity: Medium]
Can devm_add_action_or_reset() invoke ras_fini() before
xa_init(&state->offlined_pages) has initialized offlined_pages.xa_lock?

On platforms with xe->info.has_sysctrl set, an allocation failure inside
devm_add_action_or_reset() calls ras_fini() ->
xa_destroy(&state->offlined_pages) right away, locking an uninitialized
spinlock because xa_init(&state->offlined_pages) only runs later in
xe_ras_init().

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201094549.3158286-6-riana.tauro@intel.com?part=4

      reply	other threads:[~2026-12-01 10:01 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01  9:45 [PATCH v5 0/4] Handle sysctrl event for page offline full Riana Tauro
2026-12-01  9:45 ` [PATCH v5 1/4] drm/xe/ras: Fail probe if the device is wedged Riana Tauro
2026-12-01 10:06   ` sashiko-bot
2026-12-01  9:45 ` [PATCH v5 2/4] drm/xe/ras: Wedge for Critical BO page offline failures Riana Tauro
2026-12-01  9:45 ` [PATCH v5 3/4] drm/xe/sysctrl: Drain page offline queue on queue-full event Riana Tauro
2026-12-01  9:45 ` [PATCH v5 4/4] drm/xe/ras: Serialize RAS workers on an ordered workqueue Riana Tauro
2026-12-01 10: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=sashiko-outbox-243028@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=riana.tauro@intel.com \
    --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