dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Arvind Yadav" <arvind.yadav@intel.com>
Cc: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 04/15] drm/xe: Protect device I/O with DRM device SRCU
Date: Tue, 22 Sep 2026 10:28:02 +0000	[thread overview]
Message-ID: <20260922102803.000E41F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260922101721.1583542-5-arvind.yadav@intel.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/xe: hardware forcewake drop outside IO protection in send_tlb_inval_ggtt()
--

commit e9f023cf84d9700d7a5ded726d95cff381241557
Author: Arvind Yadav <arvind.yadav@intel.com>

drm/xe: Protect device I/O with DRM device SRCU

This commit introduces wrappers around DRM device SRCU to protect device
I/O operations. It blocks new access during PCI recovery or when the
device is wedged, and drains existing hardware users to safely isolate
the device.

> diff --git a/drivers/gpu/drm/xe/xe_guc_tlb_inval.c b/drivers/gpu/drm/xe/xe_guc_tlb_inval.c
> --- a/drivers/gpu/drm/xe/xe_guc_tlb_inval.c
> +++ b/drivers/gpu/drm/xe/xe_guc_tlb_inval.c

[ ... ]

> @@ -86,8 +84,13 @@ static int send_tlb_inval_ggtt(struct xe_tlb_inval *tlb_inval, u32 seqno)
>  	} else if (xe_device_uc_enabled(xe)) {
>  		struct xe_mmio *mmio = &gt->mmio;
>  
> -		if (IS_SRIOV_VF(xe))
> +		if (xe_device_io_get(xe, &io_idx))
> +			return -ECANCELED;
> +
> +		if (IS_SRIOV_VF(xe)) {
> +			xe_device_io_put(io_idx);
>  			return -ECANCELED;
> +		}
>  
>  		CLASS(xe_force_wake, fw_ref)(gt_to_fw(gt), XE_FW_GT);
>  		if (xe->info.platform == XE_PVC || GRAPHICS_VER(xe) >= 20) {
> @@ -99,6 +102,8 @@ static int send_tlb_inval_ggtt(struct xe_tlb_inval *tlb_inval, u32 seqno)
>  			xe_mmio_write32(mmio, GUC_TLB_INV_CR,
>  					GUC_TLB_INV_CR_INVALIDATE);
>  		}
> +
> +		xe_device_io_put(io_idx);

[Severity: High]
Does this code drop the I/O protection before the scoped forcewake destructor
runs?

The CLASS(xe_force_wake, fw_ref) macro creates a scoped guard whose destructor
executes when leaving the block. Because xe_device_io_put(io_idx) is called
explicitly right before the closing brace, the I/O protection is released
before the forcewake destructor runs.

If PCI error recovery or wedge isolation disables the device immediately after
xe_device_io_put() returns, the automatically executing fw_ref destructor will
perform MMIO writes on a disabled device. This could trigger a PCI Advanced
Error Reporting (AER) fault and crash the system.

>  	}
>  
>  	return -ECANCELED;

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260922101721.1583542-1-arvind.yadav@intel.com?part=4

  reply	other threads:[~2026-09-22 10:28 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-22 10:16 [PATCH v2 00/15] drm/xe: Isolate wedged devices from hardware access Arvind Yadav
2026-09-22 10:16 ` [PATCH v2 01/15] drm/xe/irq: Always free requested IRQs on uninstall Arvind Yadav
2026-09-22 10:16 ` [PATCH v2 02/15] drm/drv: Export drm_dev_srcu_synchronize() Arvind Yadav
2026-09-22 10:16 ` [PATCH v2 03/15] drm/xe: Separate AER reset state from device wedging Arvind Yadav
2026-09-22 10:16 ` [PATCH v2 04/15] drm/xe: Protect device I/O with DRM device SRCU Arvind Yadav
2026-09-22 10:28   ` sashiko-bot [this message]
2026-09-22 10:16 ` [PATCH v2 05/15] drm/xe: Drop queued page faults when device I/O is blocked Arvind Yadav
2026-09-22 10:16 ` [PATCH v2 06/15] drm/xe: Stop VM work " Arvind Yadav
2026-09-22 10:16 ` [PATCH v2 07/15] drm/xe: Send wedged notification from a worker Arvind Yadav
2026-09-22 10:27   ` sashiko-bot
2026-09-22 10:16 ` [PATCH v2 08/15] drm/xe: Reuse one dummy page per BO after wedge Arvind Yadav
2026-09-22 10:16 ` [PATCH v2 09/15] drm/xe: Invalidate existing VRAM mappings on wedge Arvind Yadav
2026-09-22 10:30   ` sashiko-bot
2026-09-22 10:16 ` [PATCH v2 10/15] drm/xe/irq: Protect IRQ state during wedge isolation Arvind Yadav
2026-09-22 10:16 ` [PATCH v2 11/15] drm/xe: Isolate a wedged device before notifying userspace Arvind Yadav
2026-09-22 10:31   ` sashiko-bot
2026-09-22 10:16 ` [PATCH v2 12/15] drm/xe/ttm: Reject VRAM allocations on wedged devices Arvind Yadav
2026-09-22 10:16 ` [PATCH v2 13/15] drm/xe/guc: Skip timeout recovery on a wedged device Arvind Yadav
2026-09-22 10:16 ` [PATCH v2 14/15] drm/xe: Skip PM notifier preparation when device I/O is blocked Arvind Yadav
2026-09-22 10:17 ` [PATCH v2 15/15] drm/xe: Block BO VM access when device I/O is unavailable Arvind Yadav

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=20260922102803.000E41F000FF@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=arvind.yadav@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    --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