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 v3 2/7] drm/xe/hw_error: Initialize hw_error_work per tile
Date: Tue, 03 Nov 2026 06:23:30 +0000	[thread overview]
Message-ID: <sashiko-outbox-194620@kernel.org> (raw)
In-Reply-To: <20261103060929.1586783-11-riana.tauro@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/xe/hw_error: missing xe_hw_error_work_disable() on probe error unwind
--

commit 07d05aa9e22e61afa48de05e4142a663fa2508dd
Author: Riana Tauro <riana.tauro@intel.com>

drm/xe/hw_error: Initialize hw_error_work per tile

This commit initializes tile->hw_error_work across all tiles in
xe_hw_error_init() and adds xe_hw_error_work_disable() in
xe_device_remove() to stop the hardware error work items on device
removal.

> diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> index 07a7ab6ac0832..8f498e3e3e586 100644
> --- a/drivers/gpu/drm/xe/xe_device.c
> +++ b/drivers/gpu/drm/xe/xe_device.c
[ ... ]
> @@ -1118,6 +1119,8 @@ int xe_device_probe(struct xe_device *xe)
>  
>  void xe_device_remove(struct xe_device *xe)
>  {
> +	xe_hw_error_work_disable(xe);
> +
>  	xe_display_unregister(xe);
>  
>  	drm_dev_unplug(&xe->drm);

[Severity: High]
As reported by Sashiko on v2 [1], what happens if xe_device_probe() fails
after xe_hw_error_init() has already run?

During probe, xe_device_probe() calls xe_irq_install(), which invokes
xe_hw_error_init(xe) before allocating or requesting IRQs:

drivers/gpu/drm/xe/xe_irq.c:xe_irq_install() {
	xe_hw_error_init(xe);

	xe_irq_reset(xe);
	...
	err = pci_alloc_irq_vectors(pdev, nvec, nvec, irq_flags);
	if (err < 0) {
		drm_err(&xe->drm, "Failed to allocate IRQ vectors: %d\n", err);
		return err;
	}
}

Inside xe_hw_error_init(), process_hw_errors() -> xe_hw_error_irq_handler()
can immediately schedule tile->hw_error_work, and once xe_irq_install()
enables interrupts, dg1_irq_handler() can also schedule tile->hw_error_work
while the rest of xe_device_probe() is executing.

However, in __xe_pci_probe(), xe_pci_remove() -> xe_device_remove() is
only called if xe_pm_init() fails after xe_device_probe() has already
succeeded:

drivers/gpu/drm/xe/xe_pci.c:__xe_pci_probe() {
	err = xe_device_probe(xe);
	if (err)
		return err;

	err = xe_pm_init(xe);
	if (err)
		goto err_driver_cleanup;

	return 0;

err_driver_cleanup:
	xe_pci_remove(pdev);
	return err;
}

If xe_irq_install() fails after xe_hw_error_init(), or if any subsequent
step in xe_device_probe() fails (such as xe_gt_init(), xe_vram_memtest(),
or xe_heci_gsc_init()), xe_device_remove() is never called. Can
tile->hw_error_work remain pending or running while devres_release_all()
unmaps MMIO and frees struct xe_device, causing a use-after-free on probe
error unwind?

[1] https://lore.kernel.org/r/20261026060459.771448-13-riana.tauro@intel.com

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261103060929.1586783-9-riana.tauro@intel.com?part=2

  reply	other threads:[~2026-11-03  6:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-03  6:09 [PATCH v3 0/7] Handle non-fatal errors routed via IRQ Riana Tauro
2026-11-03  6:09 ` [PATCH v3 1/7] drm/xe/hw_error: Reuse CSC worker for generic error handling Riana Tauro
2026-11-03  6:27   ` Mallesh, Koujalagi
2026-11-03  6:09 ` [PATCH v3 2/7] drm/xe/hw_error: Initialize hw_error_work per tile Riana Tauro
2026-11-03  6:23   ` sashiko-bot [this message]
2026-11-03  6:42     ` Tauro, Riana
2026-11-04  9:31   ` Mallesh, Koujalagi
2026-11-04 12:58     ` Tauro, Riana
2026-11-03  6:09 ` [PATCH v3 3/7] drm/xe/ras: Treat non-fatal PCIe errors as recovered Riana Tauro
2026-11-03  6:19   ` Mallesh, Koujalagi
2026-11-03  6:09 ` [PATCH v3 4/7] drm/xe/pci: Add upstream switch port lookup helper Riana Tauro
2026-11-03  6:09 ` [PATCH v3 5/7] drm/xe/xe_ras: Add a flag for uncorrectable internal error Riana Tauro
2026-11-03  8:19   ` Mallesh, Koujalagi
2026-11-03  6:09 ` [PATCH v3 6/7] drm/xe: Add support for wa_14028434957 Riana Tauro
2026-11-03  6:33   ` sashiko-bot
2026-11-03  6:45     ` Tauro, Riana
2026-11-04 10:38   ` Mallesh, Koujalagi
2026-11-04 10:44     ` Tauro, Riana
2026-11-03  6:09 ` [PATCH v3 7/7] drm/xe/xe_ras: Skip double-bit ECC page offlining on AER path Riana Tauro
2026-11-03  6:23   ` sashiko-bot
2026-11-03  7:32 ` ✓ CI.KUnit: success for Handle non-fatal errors routed via IRQ (rev3) Patchwork
2026-11-03  8:05 ` ✓ Xe.CI.BAT: " Patchwork
2026-11-03 13:34 ` ✓ 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-194620@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