public inbox for intel-xe@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Raag Jadav <raag.jadav@intel.com>
To: Matthew Auld <matthew.auld@intel.com>
Cc: intel-xe@lists.freedesktop.org, matthew.brost@intel.com,
	thomas.hellstrom@linux.intel.com,
	himal.prasad.ghimiray@intel.com, matthew.d.roper@intel.com
Subject: Re: [PATCH v1] drm/xe: Drop dma mappings for wedged device
Date: Wed, 25 Mar 2026 20:37:07 +0100	[thread overview]
Message-ID: <acQ5Y8UklS9EG-u9@black.igk.intel.com> (raw)
In-Reply-To: <8f2a95b6-2a5b-4920-952f-63871fd087bf@intel.com>

On Tue, Mar 24, 2026 at 03:37:21PM +0000, Matthew Auld wrote:
> On 24/03/2026 15:14, Raag Jadav wrote:
> > On Tue, Mar 24, 2026 at 12:52:30PM +0000, Matthew Auld wrote:
> > > On 24/03/2026 07:13, Raag Jadav wrote:
> > > > As per uapi documentation[1], the prerequisite for wedged device is to
> > > > drop all dma mappings. Reuse xe_bo_pci_dev_remove_pinned() for this,
> > > > which iterates over external bo list and removes all dma mappings.
> > > > 
> > > > [1] Documentation/gpu/drm-uapi.rst
> > > 
> > > Can you point to where it says that? Do you just mean the: "disabling DMA to
> > > system memory" ?
> > > 
> > > One other thing that maybe jumps out is:
> > > 
> > > "All existing mmaps should be invalidated and
> > > page faults should be redirected to a dummy page"
> > > 
> > > Are we also missing that? We have the dummy page flow, but do we actually
> > > force everything to be refaulted?
> > 
> > I tried this with commit c020fff70d75 but it clearly doesn't cover
> > everything.
> 
> Ah right. Yeah, in theory if you do something like:
> 
> addr = mmap(bo);
> addr[0] = 0xdeadbeaf;
> igt_assert_eq(addr[0], 0xdeadbeaf);
> wedge();
> igt_assert_eq(addr[0], 0);
> 
> It should fail the second assert, I think. With the below fix in theory the
> access after the wedge will now trigger a new fault which will then map your
> dummy page (which is hopefully all zeroes), which I think is what the doc
> wants.

Weirdly, I remember testing something like above with commit c020fff70d75
and it worked even without below fix. Or perhaps I missed some obvious
detail in my testing :/

Let me revisit this.

Raag

> > > Something like:
> > > 
> > >   /* Clear all CPU mappings pointing to this device */
> > >   unmap_mapping_range(dev->anon_inode->i_mapping, 0, 0, 1);
> > 
> > Sure.
> > 
> > > > Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> > > > ---
> > > > PS: This is pretty much uncharted territory for me, so please consider
> > > > this an RFC.
> > > > 
> > > >    drivers/gpu/drm/xe/xe_bo_evict.c | 8 +++++++-
> > > >    drivers/gpu/drm/xe/xe_bo_evict.h | 1 +
> > > >    drivers/gpu/drm/xe/xe_device.c   | 2 ++
> > > >    3 files changed, 10 insertions(+), 1 deletion(-)
> > > > 
> > > > diff --git a/drivers/gpu/drm/xe/xe_bo_evict.c b/drivers/gpu/drm/xe/xe_bo_evict.c
> > > > index 7661fca7f278..f741cda50b2d 100644
> > > > --- a/drivers/gpu/drm/xe/xe_bo_evict.c
> > > > +++ b/drivers/gpu/drm/xe/xe_bo_evict.c
> > > > @@ -270,7 +270,13 @@ int xe_bo_restore_late(struct xe_device *xe)
> > > >    	return ret;
> > > >    }
> > > > -static void xe_bo_pci_dev_remove_pinned(struct xe_device *xe)
> > > > +/**
> > > > + * xe_bo_pci_dev_remove_pinned() - Unmap external bos
> > > > + * @xe: xe device
> > > > + *
> > > > + * Drop dma mappings of all external pinned bos.
> > > > + */
> > > > +void xe_bo_pci_dev_remove_pinned(struct xe_device *xe)
> > > >    {
> > > >    	struct xe_tile *tile;
> > > >    	unsigned int id;
> > > > diff --git a/drivers/gpu/drm/xe/xe_bo_evict.h b/drivers/gpu/drm/xe/xe_bo_evict.h
> > > > index e8385cb7f5e9..6ce27e272780 100644
> > > > --- a/drivers/gpu/drm/xe/xe_bo_evict.h
> > > > +++ b/drivers/gpu/drm/xe/xe_bo_evict.h
> > > > @@ -15,6 +15,7 @@ void xe_bo_notifier_unprepare_all_pinned(struct xe_device *xe);
> > > >    int xe_bo_restore_early(struct xe_device *xe);
> > > >    int xe_bo_restore_late(struct xe_device *xe);
> > > > +void xe_bo_pci_dev_remove_pinned(struct xe_device *xe);
> > > >    void xe_bo_pci_dev_remove_all(struct xe_device *xe);
> > > >    int xe_bo_pinned_init(struct xe_device *xe);
> > > > diff --git a/drivers/gpu/drm/xe/xe_device.c b/drivers/gpu/drm/xe/xe_device.c
> > > > index 207ad2eea412..ac51b04560df 100644
> > > > --- a/drivers/gpu/drm/xe/xe_device.c
> > > > +++ b/drivers/gpu/drm/xe/xe_device.c
> > > > @@ -1351,6 +1351,8 @@ void xe_device_declare_wedged(struct xe_device *xe)
> > > >    	for_each_gt(gt, xe, id)
> > > >    		xe_gt_declare_wedged(gt);
> > > > +	xe_bo_pci_dev_remove_pinned(xe);
> > > 
> > > AFAIK this just removes the iommu mappings for kernel BOs (small subset of
> > > BOs), if there are any. Also if you are not using iommu, then dma between
> > > GPU and system memory is still possible. And for userspace BOs nothing
> > > changes. But I guess this is still better than nothing and will maybe catch
> > > some misuse?
> > 
> > Yeah, I just floated this to start the discussion. Thanks for the pointers,
> > will explore this.
> > 
> > Raag
> > 
> > > >    	if (xe_device_wedged(xe)) {
> > > >    		/*
> > > >    		 * XE_WEDGED_MODE_UPON_ANY_HANG_NO_RESET is intended for debugging
> > > 
> 

  reply	other threads:[~2026-03-25 19:37 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-24  7:13 [PATCH v1] drm/xe: Drop dma mappings for wedged device Raag Jadav
2026-03-24  7:25 ` ✓ CI.KUnit: success for " Patchwork
2026-03-24  8:25 ` ✓ Xe.CI.BAT: " Patchwork
2026-03-24 12:52 ` [PATCH v1] " Matthew Auld
2026-03-24 15:14   ` Raag Jadav
2026-03-24 15:37     ` Matthew Auld
2026-03-25 19:37       ` Raag Jadav [this message]
2026-03-24 15:31 ` ✗ Xe.CI.FULL: failure for " 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=acQ5Y8UklS9EG-u9@black.igk.intel.com \
    --to=raag.jadav@intel.com \
    --cc=himal.prasad.ghimiray@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=thomas.hellstrom@linux.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