Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Summers, Stuart" <stuart.summers@intel.com>
To: "Brost, Matthew" <matthew.brost@intel.com>
Cc: "intel-xe@lists.freedesktop.org" <intel-xe@lists.freedesktop.org>,
	"Dong,  Zhanjun" <zhanjun.dong@intel.com>,
	"Lin, Shuicheng" <shuicheng.lin@intel.com>,
	"Vishwanathapura,
	Niranjana" <niranjana.vishwanathapura@intel.com>
Subject: Re: [PATCH 5/7] drm/xe: Correct migration VM teardown order
Date: Thu, 23 Oct 2025 17:18:05 +0000	[thread overview]
Message-ID: <5229a4a78156e9b694914782fa95d0bc45fc25d0.camel@intel.com> (raw)
In-Reply-To: <aPk+3LWPfFeLmwU9@lstrano-desk.jf.intel.com>

On Wed, 2025-10-22 at 13:30 -0700, Matthew Brost wrote:
> On Mon, Oct 20, 2025 at 09:45:27PM +0000, Stuart Summers wrote:
> > Adjust the sequence of the migration teardown to match what
> > is happening in the init() function.
> > 
> > v2: Take a reference to the migrate queue before put (Matt)
> > 
> 
> You need to store the VM on the stack, not the queue;
> 
> > Signed-off-by: Stuart Summers <stuart.summers@intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_migrate.c | 9 +++++----
> >  1 file changed, 5 insertions(+), 4 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_migrate.c
> > b/drivers/gpu/drm/xe/xe_migrate.c
> > index 7345a5b65169..ae42917918e5 100644
> > --- a/drivers/gpu/drm/xe/xe_migrate.c
> > +++ b/drivers/gpu/drm/xe/xe_migrate.c
> > @@ -91,17 +91,18 @@ struct xe_migrate {
> >  static void xe_migrate_fini(void *arg)
> >  {
> >         struct xe_migrate *m = arg;
> > +       struct xe_exec_queue *q = m->q;
> >  
> > -       xe_vm_lock(m->q->vm, false);
> > +       xe_vm_lock(q->vm, false);
> >         xe_bo_unpin(m->pt_bo);
> > -       xe_vm_unlock(m->q->vm);
> > +       xe_vm_unlock(q->vm);
> >  
> >         dma_fence_put(m->fence);
> >         xe_bo_put(m->pt_bo);
> >         drm_suballoc_manager_fini(&m->vm_update_sa);
> >         mutex_destroy(&m->job_mutex);
> > -       xe_vm_close_and_put(m->q->vm);
> > -       xe_exec_queue_put(m->q);
> > +       xe_exec_queue_put(q);
> 
> ^^^ This can destroy the 'q'.
> 
> > +       xe_vm_close_and_put(q->vm);
> 
> ^^^ Now 'q->' can dereference invalid memory.

Bah you're right, sorry about that :(. Thanks for the feedback!

-Stuart

> 
> Matt
> 
> >  }
> >  
> >  static u64 xe_migrate_vm_addr(u64 slot, u32 level)
> > -- 
> > 2.34.1
> > 


  reply	other threads:[~2025-10-23 17:18 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-20 21:45 [PATCH 0/7] Fix a couple of wedge corner-case memory leaks Stuart Summers
2025-10-20 21:45 ` [PATCH 1/7] drm/xe: Add additional trace points for LRCs Stuart Summers
2025-10-20 21:45 ` [PATCH 2/7] drm/xe: Add a trace point for VM close Stuart Summers
2025-10-20 21:45 ` [PATCH 3/7] drm/xe: Add the BO pointer info to the BO trace Stuart Summers
2025-10-20 21:45 ` [PATCH 4/7] drm/xe: Add new exec queue trace points Stuart Summers
2025-10-20 21:45 ` [PATCH 5/7] drm/xe: Correct migration VM teardown order Stuart Summers
2025-10-22 20:30   ` Matthew Brost
2025-10-23 17:18     ` Summers, Stuart [this message]
2025-10-20 21:45 ` [PATCH 6/7] drm/xe: Clean up GuC software state after a wedge Stuart Summers
2025-10-22 21:15   ` Matthew Brost
2025-10-23 17:43     ` Summers, Stuart
2025-10-23 18:26       ` Matthew Brost
2025-10-20 21:45 ` [PATCH 7/7] drm/xe/doc: Add GuC submission kernel-doc Stuart Summers
2025-10-20 22:05   ` Matthew Brost
2025-10-20 22:07     ` Summers, Stuart
  -- strict thread matches above, loose matches on Subject: below --
2025-10-13 22:31 [PATCH 0/7] Fix a couple of wedge corner-case memory leaks Stuart Summers
2025-10-13 22:31 ` [PATCH 5/7] drm/xe: Correct migration VM teardown order Stuart Summers
2025-10-13 16:24 [PATCH 0/7] Fix a couple of wedge corner-case memory leaks Stuart Summers
2025-10-13 16:25 ` [PATCH 5/7] drm/xe: Correct migration VM teardown order Stuart Summers

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=5229a4a78156e9b694914782fa95d0bc45fc25d0.camel@intel.com \
    --to=stuart.summers@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=matthew.brost@intel.com \
    --cc=niranjana.vishwanathapura@intel.com \
    --cc=shuicheng.lin@intel.com \
    --cc=zhanjun.dong@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