Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Soham Purkait" <soham.purkait@intel.com>,
	intel-xe@lists.freedesktop.org
Subject: Re: [PATCH v3 2/2] drm/xe/ras: Wedge device if page offline list is full at probe
Date: Thu, 03 Dec 2026 13:38:32 +0000	[thread overview]
Message-ID: <sashiko-outbox-247868@kernel.org> (raw)
In-Reply-To: <20261203131610.1375755-6-soham.purkait@intel.com>

Thank you for your contribution! Sashiko AI review found 6 potential
issues to consider:
- [High] drm/xe/ras: wedging in xe_ras_init() races wedge_work() and
  breaks uevent
- [High] drm/xe/ras: xe_wedged() check in xe_ras_init() breaks
  survivability mode
- [High] drm/xe/ras: xe_ras_init() drains fw queues after
  get_offline_list() wedges
- [Medium] drm/xe/ras: process_offline_pages() wedges when page
  offlining is disabled
- [Medium] drm/xe/ras: full-list check in process_offline_pages()
  bypassed on errors
- [Low] drm/xe/ras: gpu_health sysfs exposed in xe_ras_init() before
  xe_wedged() check
--

commit ded7ea6d0d1b2641c02d725a1cf8b2ad9008e692
Author: Soham Purkait <soham.purkait@intel.com>

drm/xe/ras: Wedge device if page offline list is full at probe

This commit declares the device wedged during probe when the firmware's
page offline list has reached its maximum capacity, and fails xe_ras_init()
with -ECANCELED if the device is wedged.

> diff --git a/drivers/gpu/drm/xe/xe_ras.c b/drivers/gpu/drm/xe/xe_ras.c
> index b65c4ef42e459..ac4cfb1d1c7cd 100644
> --- a/drivers/gpu/drm/xe/xe_ras.c
> +++ b/drivers/gpu/drm/xe/xe_ras.c
> @@ -467,6 +467,11 @@ static void process_offline_pages(struct xe_device *xe, u32 cmd, void *req, size
>  			return;
>  		}
>  	} while (common->additional_data);
> +
> +	if (!xe_wedged(xe) && list_req && state->max_pages && total_pages >= state->max_pages) {
> +		xe_err(xe, "[RAS]: page offline list is full\n");
> +		xe_wedge_declare(xe, 0);
> +	}
>  }

[Severity: High]
Does wedging here and then failing probe with -ECANCELED in xe_ras_init()
race wedge_work() with probe-failure teardown and break the wedged uevent?

xe_device_probe() calls xe_ras_init() before drm_dev_register().  When
process_offline_pages() schedules xe->wedged.work and xe_ras_init() returns
-ECANCELED, devres teardown runs xe_wedge_fini() in parallel with
wedge_work():

CPU0 (probe)                      kworker
xe_ras_init()
  process_offline_pages()
    xe_wedge_declare(xe, 0)
      schedule_work(&wedged.work)
  return -ECANCELED
devres_release_all()
  ...
  xe_wedge_fini()                 wedge_work()
    disable_work_sync(...)          drm_dev_wedged_event()
                                      kobject_uevent_env(...)
                                        <-- KOBJ_CHANGE before device_add()

If xe_wedge_fini() runs first, disable_work_sync() cancels wedge_work() and
userspace gets no uevent.  If wedge_work() runs first, drm_dev_wedged_event()
emits KOBJ_CHANGE on an unregistered primary kdev whose parent is still NULL,
producing a malformed DEVPATH=/cardN for a minor that is immediately freed.

More broadly, wedging expects the driver to stay bound so userspace receives
the uevent and sees -ECANCELED on IOCTLs, whereas failing probe unbinds the
driver and tears down the DRM device.

[Severity: Medium]
Should this check !xe_ras_get_disable_vram_page_offline(xe) before wedging
the device?

When VRAM page offlining is disabled via configfs, handle_page_offline()
runs in logging-only mode and never asks firmware to add new offline entries.
Wedging here prevents an administrator from probing a device with a full
offline list even when page offlining is explicitly disabled.

[Severity: Medium]
Can an error on a later chunk or a zero pages_returned response bypass this
full-list check?

state->max_pages and common->total_pages are known on the first response, yet
an early return from xe_sysctrl_send_command() on a later chunk skips this
check.  If the first chunk has pages_returned == 0, the loop also breaks
before assigning total_pages = common->total_pages, leaving total_pages at 0.

Checking on the first response would avoid both bypasses and skip fetching
and soft-offlining the remaining chunks when the list is already full.

[ ... ]

> @@ -1523,5 +1528,8 @@ int xe_ras_init(struct xe_device *xe)
>  	if (ret)
>  		return ret;
>  
> +	if (xe_wedged(xe))
> +		return -ECANCELED;

[Severity: High]
Will checking xe_wedged(xe) after xe_ras_process_errors() break runtime
survivability mode?

On a CSC firmware error in xe_ras_process_errors(),
xe_survivability_mode_runtime_enable() sets up survivability sysfs and calls
xe_wedge_declare() while expecting probe to stay bound for xe_nvm_init() and
xe_heci_gsc_init().  Returning -ECANCELED aborts probe and removes that sysfs.

Separately, booting with xe.wedged_mode=0 (XE_WEDGED_MODE_NEVER) makes
xe_wedge_declare() return early without setting xe->wedged.ref, so
xe_wedged(xe) stays false and probe succeeds despite a full offline list.

[Severity: High]
Does waiting until the end of xe_ras_init() to abort let get_offline_queue()
and xe_ras_process_errors() drain firmware queues before probe fails?

get_offline_queue() passes notify_fw = true, so handle_page_offline() sends
XE_RAS_PAGE_ACTION_REMOVE to drop queued poison pages from firmware SRAM
before probe failure discards the volatile TTM reservations.
xe_ras_process_errors() then drains pending SoC error records as well.

[Severity: Low]
Why is gpu_health_group registered before the xe_wedged(xe) check?

Exposing gpu_health right before returning -ECANCELED opens a window where
concurrent reads or writes in gpu_health_show() / gpu_health_store() can
issue sysctrl mailbox commands to the wedged device before devres removes the
attribute, since neither handler checks xe_wedged(xe).

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261203131610.1375755-4-soham.purkait@intel.com?part=2

  reply	other threads:[~2026-12-03 13:38 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03 13:16 [PATCH v3 0/2] Wedge device if page offline list is full Soham Purkait
2026-12-03 13:16 ` [PATCH v3 1/2] drm/xe/ras: Wedge device if page offline list is full during offlining Soham Purkait
2026-12-03 13:42   ` sashiko-bot
2026-12-03 13:16 ` [PATCH v3 2/2] drm/xe/ras: Wedge device if page offline list is full at probe Soham Purkait
2026-12-03 13:38   ` sashiko-bot [this message]
2026-12-03 13:25 ` ✓ CI.KUnit: success for Wedge device if page offline list is full (rev3) Patchwork
2026-12-03 13:59 ` ✓ 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=sashiko-outbox-247868@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=soham.purkait@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