All of 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 v4 3/3] drm/xe/ras: Skip offline queue processing after device unplug
Date: Thu, 26 Nov 2026 08:46:56 +0000	[thread overview]
Message-ID: <sashiko-outbox-235054@kernel.org> (raw)
In-Reply-To: <20261126083516.1932195-8-riana.tauro@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/xe/ras: race with ras_fini() in
  xe_ras_get_offline_queue() on probe error
--

commit 34b9c8950fa648b356e8d2444006f4d6fdb7ac18
Author: Riana Tauro <riana.tauro@intel.com>

drm/xe/ras: Skip offline queue processing after device unplug

This commit wraps xe_ras_get_offline_queue() in drm_dev_enter() and
drm_dev_exit() to prevent the system controller worker from accessing the
offlined pages XArray after ras_fini() runs on device unplug.

> diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c
> index e080cbebbdbeb..89c2385eabf7c 100644
> --- a/drivers/gpu/drm/xe/xe_ras.c
> +++ b/drivers/gpu/drm/xe/xe_ras.c
[ ... ]
> @@ -486,9 +488,16 @@ static void process_offline_pages(struct xe_device *xe, u32 cmd, void *req, size
>  void xe_ras_get_offline_queue(struct xe_device *xe)
>  {
>  	struct xe_ras_offline_common response = {0};
> +	int idx;
> +
> +	/* Unplug waits for this section, so nothing runs after ras_fini() */
> +	if (!drm_dev_enter(&xe->drm, &idx))
> +		return;
>  
>  	process_offline_pages(xe, XE_SYSCTRL_CMD_GET_OFFLINE_QUEUE, NULL, 0, &response,
>  			      sizeof(response), &response, true);
> +
> +	drm_dev_exit(idx);
>  }

[Severity: Medium]
Can xe_ras_get_offline_queue() still race with ras_fini() and use
xe->ras.state.lock and xe->ras.state.offlined_pages after they are
destroyed when xe_device_probe() fails?

In xe_device_probe(), xe_sysctrl_init() and xe_ras_init() register their
devm teardown actions in that order, and then xe_irq_install() enables
interrupts (including SYSCTRL_IRQ, which schedules xe->sc.work) before the
remaining fallible probe steps such as xe_gt_init().  If any of those
later steps fails, xe_device_probe() unwinds without calling
drm_dev_unplug() (even the err_unregister_display path only calls
drm_dev_unregister()), so xe->drm.unplugged remains false when devres
releases resources in reverse order:

CPU0 (probe error unwind)         CPU1 (kworker)
devres_release_all()
  ras_fini()
    xa_destroy(&state->offlined_pages)
  devm_mutex_release(&state->lock)
                                  xe_sysctrl_work()
                                    ...
                                      xe_ras_get_offline_queue()
                                        drm_dev_enter() -> true
                                        process_offline_pages()
                                          handle_page_offline()
                                            mutex_lock(&state->lock)
                                            xa_store(&state->offlined_pages)
                                              <-- use-after-destroy
  sysctrl_fini()
    disable_work_sync(&sc->work)

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126083516.1932195-5-riana.tauro@intel.com?part=3

  reply	other threads:[~2026-11-26  8:47 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26  8:35 [PATCH v4 0/3] Handle sysctrl event for page offline full Riana Tauro
2026-11-26  8:35 ` [PATCH v4 1/3] drm/xe/ras: Wedge the device on page offline failure in all callers Riana Tauro
2026-11-26  9:02   ` sashiko-bot
2026-11-26  8:35 ` [PATCH v4 2/3] drm/xe/sysctrl: Drain page offline queue on queue-full event Riana Tauro
2026-11-26  8:52   ` sashiko-bot
2026-11-26  8:35 ` [PATCH v4 3/3] drm/xe/ras: Skip offline queue processing after device unplug Riana Tauro
2026-11-26  8:46   ` sashiko-bot [this message]
2026-11-26  8:49     ` Tauro, Riana
2026-11-26  9:25   ` Raag Jadav
2026-11-26  9:40     ` Tauro, Riana
2026-11-26  8:43 ` ✗ CI.checkpatch: warning for Handle sysctrl event for page offline full Patchwork
2026-11-26  8:45 ` ✓ CI.KUnit: success " Patchwork
2026-11-26  9:27 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-26 14:29 ` ✓ Xe.CI.FULL: " Patchwork

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-235054@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 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.