Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Sebastian Brzezinka" <sebastian.brzezinka@intel.com>,
	intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v5 2/2] drm/i915/selftests: take error_mutex in stolen reset test
Date: Thu, 12 Nov 2026 12:26:48 +0000	[thread overview]
Message-ID: <sashiko-outbox-211085@kernel.org> (raw)
In-Reply-To: <20261112115907.16263-3-sebastian.brzezinka@intel.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] drm/i915/selftests: lock inversion holding error_mutex in
  __igt_reset_stolen()
- [Medium] drm/i915/selftests: lockdep inversion in __igt_reset_stolen()
  insert_page()
--

commit c33d0f8d797f0fad1f041bc0438964e9aab4e35c
Author: Sebastian Brzezinka <sebastian.brzezinka@intel.com>

drm/i915/selftests: take error_mutex in stolen reset test

This commit acquires ggtt->error_mutex around the stolen memory page
sampling and GPU reset in __igt_reset_stolen() to serialize access to the
ggtt->error_capture slot.

> diff --git a/drivers/gpu/drm/i915/gt/selftest_reset.c b/drivers/gpu/drm/i915/gt/selftest_reset.c
> index a419dfe9a34fb..386741637e45d 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_reset.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_reset.c
> @@ -98,6 +98,7 @@ __igt_reset_stolen(struct intel_gt *gt,
>  	}
>  
>  	mutex_lock(&gt->i915->mm.stolen_lock);
> +	mutex_lock(&ggtt->error_mutex);
>  
>  	for (page = 0; page < num_pages; page++) {
>  		dma_addr_t dma = (dma_addr_t)dsm->start + (page << PAGE_SHIFT);

[Severity: Medium]
Does calling ggtt->vm.insert_page() in the two sampling loops while
holding ggtt->error_mutex introduce a lockdep circular dependency on
Cherryview and Broxton with VT-d?

On platforms where intel_vm_no_concurrent_access_wa() is true,
gen8_gmch_probe() sets ggtt->vm.insert_page to
bxt_vtd_ggtt_insert_page__BKL(), which calls stop_machine() and acquires
cpu_hotplug_lock.  Because i915_vma_coredump_create() acquires
ggtt->error_mutex inside a dma_fence_begin_signalling() section (after
i915_vma_resource_hold()), lockdep already tracks cpu_hotplug_lock ->
dma_fence_map -> ggtt->error_mutex.  Calling ggtt->vm.insert_page() under
ggtt->error_mutex inverts that order.

Using ggtt->vm.raw_insert_page when non-NULL, the same way
i915_vma_coredump_create() does under ggtt->error_mutex, avoids
stop_machine().

> @@ -182,6 +183,7 @@ __igt_reset_stolen(struct intel_gt *gt,
>  	mb();
>  	ggtt->vm.clear_range(&ggtt->vm, ggtt->error_capture.start, PAGE_SIZE);
>  
> +	mutex_unlock(&ggtt->error_mutex);
>  	mutex_unlock(&gt->i915->mm.stolen_lock);
>  
>  	if (count > 0) {

[Severity: Medium]
Can keeping ggtt->error_mutex held across intel_gt_reset() cause an ABBA
deadlock with GuC error capture?

CPU0                                  kworker (guc->ct.requests.worker)
----                                  ---------------------------------
__igt_reset_stolen()
  mutex_lock(&ggtt->error_mutex)
  intel_gt_reset()
    mutex_lock(&gt->reset.mutex)
    ...
    flush_work(&guc->ct.requests.worker)
                                      ct_incoming_request_worker_func()
                                        ...
                                        i915_vma_coredump_create()
                                          mutex_lock(&ggtt->error_mutex)

 *** DEADLOCK ***

Holding ggtt->error_mutex across intel_gt_reset() also inverts the lock
order against i_mmap_rwsem (acquired in gt_revoke() ->
unmap_mapping_range()) and dma_fence_map, since i915_vma_coredump_create()
takes ggtt->error_mutex inside a dma_fence_begin_signalling() section.

Since ggtt->error_capture is cleared before the reset and
gt->i915->mm.stolen_lock stays held across it, ggtt->error_mutex could be
unlocked before the reset and re-locked for the post-reset loop.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261112115907.16263-1-sebastian.brzezinka@intel.com?part=2

  reply	other threads:[~2026-11-12 12:27 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-12 11:59 [PATCH v5 0/2] drm/i915/selftests: fix stolen reset test races Sebastian Brzezinka
2026-11-12 11:59 ` [PATCH v5 1/2] drm/i915/selftests: Fix unlocked mm.stolen in reset selftest Sebastian Brzezinka
2026-11-12 12:22   ` sashiko-bot
2026-11-12 11:59 ` [PATCH v5 2/2] drm/i915/selftests: take error_mutex in stolen reset test Sebastian Brzezinka
2026-11-12 12:26   ` sashiko-bot [this message]
2026-11-12 16:22 ` ✓ i915.CI.BAT: success for drm/i915/selftests: fix stolen reset test races Patchwork
2026-11-13 14:04 ` ✓ i915.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-211085@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sebastian.brzezinka@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