From: Raag Jadav <raag.jadav@intel.com>
To: Riana Tauro <riana.tauro@intel.com>
Cc: intel-xe@lists.freedesktop.org, anshuman.gupta@intel.com,
aravind.iddamsetty@linux.intel.com, badal.nilawar@intel.com,
ravi.kishore.koppuravuri@intel.com, mallesh.koujalagi@intel.com,
soham.purkait@intel.com, tejas.upadhyay@intel.com
Subject: Re: [PATCH v5 4/4] drm/xe/ras: Serialize RAS workers on an ordered workqueue
Date: Tue, 1 Dec 2026 14:23:29 +0100 [thread overview]
Message-ID: <aw7KUTyv4oByYYuS@black.igk.intel.com> (raw)
In-Reply-To: <20261201094549.3158286-10-riana.tauro@intel.com>
On Tue, Dec 01, 2026 at 03:15:54PM +0530, Riana Tauro wrote:
> The sysctrl event worker and the per-tile hw error workers are scheduled
> on the system workqueue and can run concurrently.
>
> The page offline flow is not atomic. The soft-offlining in
> xe_ttm_vram_handle_addr_fault() and firmware action are separate steps.
> Two workers handling the same address can both see the page as not yet
> offlined and send a duplicate or out-of-order firmware command.
>
> Teardown had a similar problem. devres runs ras_fini() before
> sysctrl_fini() disables the sysctrl worker, so a worker queued before
> the IRQ was uninstalled can store into offlined_pages after
> xa_destroy(), leaking XArray nodes.
>
> Add an ordered RAS workqueue and queue both workers on it, so that RAS
> workers do not run concurrently. Destroy the workqueue in ras_fini()
> before destroying offlined_pages. By then the IRQ is uninstalled,
> so draining the queue guarantees no worker touches RAS state afterwards.
>
> Also flush the RAS workqueue on suspend, after interrupts are disabled,
> so no RAS worker runs across suspend or FLR.
>
> Suggested-by: Raag Jadav <raag.jadav@intel.com>
> Signed-off-by: Riana Tauro <riana.tauro@intel.com>
> ---
> drivers/gpu/drm/xe/xe_device.c | 1 +
> drivers/gpu/drm/xe/xe_hw_error.c | 7 ++++---
> drivers/gpu/drm/xe/xe_ras.c | 28 +++++++++++++++++++++++-----
> drivers/gpu/drm/xe/xe_ras.h | 1 +
> drivers/gpu/drm/xe/xe_ras_types.h | 2 ++
> drivers/gpu/drm/xe/xe_sysctrl.c | 2 +-
> 6 files changed, 32 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index 36693df65594..b7e0d89e1b04 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);
>
> if (flr) {
> unmap_mapping_range(xe->drm.anon_inode->i_mapping, 0, 0, 1);
> diff --git a/drivers/gpu/drm/xe/xe_hw_error.c b/drivers/gpu/drm/xe/xe_hw_error.c
> index 86b29f282837..7bf3f5688825 100644
> --- a/drivers/gpu/drm/xe/xe_hw_error.c
> +++ b/drivers/gpu/drm/xe/xe_hw_error.c
> @@ -227,7 +227,7 @@ static void csc_hw_error_handler(struct xe_tile *tile, const enum hardware_error
> hec_uncorrected_fw_errors[err_bit], severity_str,
> err_bit);
>
> - schedule_work(&tile->hw_error_work);
> + queue_work(xe->ras.state.ras_wq, &tile->hw_error_work);
> }
> }
>
> @@ -461,7 +461,7 @@ static void hw_error_source_handler(struct xe_tile *tile, const enum hardware_er
> */
> if (xe->info.has_sysctrl) {
> drm_err_ratelimited(&xe->drm, HW_ERR "Non-fatal %s reported\n", severity_str);
> - schedule_work(&tile->hw_error_work);
> + queue_work(xe->ras.state.ras_wq, &tile->hw_error_work);
> return;
> }
>
> @@ -533,10 +533,11 @@ static void hw_error_source_handler(struct xe_tile *tile, const enum hardware_er
> */
> void xe_hw_error_irq_handler(struct xe_tile *tile, const u32 master_ctl)
> {
> + struct xe_device *xe = tile_to_xe(tile);
> enum hardware_error hw_err;
>
> if (xe_fault_csc_hw_error())
> - schedule_work(&tile->hw_error_work);
> + queue_work(xe->ras.state.ras_wq, &tile->hw_error_work);
>
> for (hw_err = 0; hw_err < HARDWARE_ERROR_MAX; hw_err++) {
> if (master_ctl & ERROR_IRQ(hw_err))
> diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c
> index febd151c92f0..4730b0abdbb9 100644
> --- a/drivers/gpu/drm/xe/xe_ras.c
> +++ b/drivers/gpu/drm/xe/xe_ras.c
> @@ -1448,8 +1448,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);
Don't complicate things. Split all the page offline stuff into its own init
and have its own devm action.
> }
>
> /**
> @@ -1494,6 +1497,17 @@ void xe_ras_set_aer_internal_error(struct xe_device *xe)
> xe->ras.state.aer_internal_error = true;
> }
>
> +/**
> + * xe_ras_suspend() - Flush workqueue
> + * @xe: xe device instance
> + *
> + * Flush the RAS workqueue.
> + */
> +void xe_ras_suspend(struct xe_device *xe)
> +{
> + flush_workqueue(xe->ras.state.ras_wq);
> +}
> +
> /**
> * xe_ras_init - Initialize Xe RAS
> * @xe: xe device instance
> @@ -1509,6 +1523,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;
>
> @@ -1524,10 +1546,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;
> -
> /* Fetch the offline list before queue to avoid duplication */
> ret = get_offline_list(xe);
> if (ret == -ENOTRECOVERABLE)
> diff --git a/drivers/gpu/drm/xe/xe_ras.h b/drivers/gpu/drm/xe/xe_ras.h
> index 18531f172695..5ec8eb692efe 100644
> --- a/drivers/gpu/drm/xe/xe_ras.h
> +++ b/drivers/gpu/drm/xe/xe_ras.h
> @@ -33,4 +33,5 @@ u32 xe_ras_drain_info_queue(struct xe_device *xe,
> u8 *dest_buf, u32 dest_size);
> bool xe_ras_is_aer_internal_error(struct xe_device *xe);
> void xe_ras_set_aer_internal_error(struct xe_device *xe);
> +void xe_ras_suspend(struct xe_device *xe);
> #endif
> diff --git a/drivers/gpu/drm/xe/xe_ras_types.h b/drivers/gpu/drm/xe/xe_ras_types.h
> index 80f5d46d2dc2..1e327c9270f8 100644
> --- a/drivers/gpu/drm/xe/xe_ras_types.h
> +++ b/drivers/gpu/drm/xe/xe_ras_types.h
> @@ -536,5 +536,7 @@ struct xe_ras_state {
> u32 max_pages;
> /** @offlined_pages: XArray of pages offlined by firmware */
> struct xarray offlined_pages;
> + /** @ras_wq: Workqueue for serializing RAS workers */
> + struct workqueue_struct *ras_wq;
Nit: It's already part of ras state, just make it 'wq'.
Raag
> };
> #endif
> diff --git a/drivers/gpu/drm/xe/xe_sysctrl.c b/drivers/gpu/drm/xe/xe_sysctrl.c
> index d362e8156fca..e1c057a50e7d 100644
> --- a/drivers/gpu/drm/xe/xe_sysctrl.c
> +++ b/drivers/gpu/drm/xe/xe_sysctrl.c
> @@ -122,7 +122,7 @@ void xe_sysctrl_irq_handler(struct xe_device *xe, u32 master_ctl)
> return;
>
> if (master_ctl & SYSCTRL_IRQ)
> - schedule_work(&sc->work);
> + queue_work(xe->ras.state.ras_wq, &sc->work);
> }
>
> /**
> --
> 2.47.1
>
next prev parent reply other threads:[~2026-12-01 13:23 UTC|newest]
Thread overview: 11+ 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
2026-12-01 13:23 ` Raag Jadav [this message]
2026-12-01 14:03 ` Tauro, Riana
2026-12-01 10:11 ` ✓ CI.KUnit: success for Handle sysctrl event for page offline full (rev2) Patchwork
2026-12-01 10:49 ` ✓ Xe.CI.BAT: " 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=aw7KUTyv4oByYYuS@black.igk.intel.com \
--to=raag.jadav@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=aravind.iddamsetty@linux.intel.com \
--cc=badal.nilawar@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=mallesh.koujalagi@intel.com \
--cc=ravi.kishore.koppuravuri@intel.com \
--cc=riana.tauro@intel.com \
--cc=soham.purkait@intel.com \
--cc=tejas.upadhyay@intel.com \
/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