All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Tejas Upadhyay <tejas.upadhyay@intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [PATCH] drm/xe: Hold VM reference in preempt rebind worker
Date: Mon, 30 Nov 2026 14:37:10 -0800	[thread overview]
Message-ID: <aw36lnP2+sZFjOVT@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <20261130102837.4056493-2-tejas.upadhyay@intel.com>

On Mon, Nov 30, 2026 at 03:58:38PM +0530, Tejas Upadhyay wrote:

Can you include this patch as part of next post? This patch is good a change.

https://sashiko.dev/#/message/20261130101720.2734555-2-arvind.yadav%40intel.com

Sashiko is correctly complaining the last put rebind work item is a
problem without the above patch. 

> vm_destroy_work_func() runs on a WQ_MEM_RECLAIM workqueue and currently
> flushes vm->preempt.rebind_work, which is queued on the non-reclaim
> rebind_wq. This triggers a workqueue flush dependency warning:
> 
>   workqueue: WQ_MEM_RECLAIM xe-destroy-wq:vm_destroy_work_func [xe] is flushing !WQ_MEM_RECLAIM xe-ordered-wq:preempt_rebind_work_func [xe]
>   WARNING: kernel/workqueue.c:3921 at check_flush_dependency.part.0+0xd9/0x110
> 
> Take a VM reference when queuing vm->preempt.rebind_work and drop it
> when preempt_rebind_work_func() exits. Since the VM cannot be destroyed
> while rebind_work is pending or running, drop the redundant flush_work()
> from vm_destroy_work_func().
>

Fixes: ...
 
> Signed-off-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
> ---
>  drivers/gpu/drm/xe/xe_vm.c | 11 +++++------
>  drivers/gpu/drm/xe/xe_vm.h |  5 +++--
>  2 files changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index ab138d495f3f..547d2c2980a7 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -586,14 +586,14 @@ static void preempt_rebind_work_func(struct work_struct *w)
>  	if (xe_vm_is_closed_or_banned(vm)) {
>  		up_write(&vm->lock);
>  		trace_xe_vm_rebind_worker_exit(vm);

Drop trace_xe_vm_rebind_worker_exit here.

> -		return;
> +		goto out_put_vm;
>  	}
>  
>  	if (!try_wait_for_completion(&vm->xe->pm_block) && vm_suspend_rebind_worker(vm)) {
>  		up_write(&vm->lock);
>  		/* We don't actually block but don't make progress. */
>  		xe_pm_might_block_on_suspend();
> -		return;
> +		goto out_put_vm;
>  	}
>  
>  	if (xe_vm_userptr_check_repin(vm)) {
> @@ -669,7 +669,7 @@ static void preempt_rebind_work_func(struct work_struct *w)
>  		free_preempt_fences(&preempt_fences);
>  		xe_vm_queue_rebind_worker(vm);
>  		trace_xe_vm_rebind_worker_exit(vm);

And here.

> -		return;
> +		goto out_put_vm;
>  	}
>  
>  	xe_vm_rebind_worker_reset_inject(vm);
> @@ -683,6 +683,8 @@ static void preempt_rebind_work_func(struct work_struct *w)
>  	free_preempt_fences(&preempt_fences);
>  

out_put_vm:

>  	trace_xe_vm_rebind_worker_exit(vm);
> +out_put_vm:
> +	xe_vm_put(vm);
>  }
>  
>  /**
> @@ -2109,9 +2111,6 @@ static void vm_destroy_work_func(struct work_struct *w)
>  	/* xe_vm_close_and_put was not called? */
>  	xe_assert(xe, !vm->size);
>  
> -	if (xe_vm_in_preempt_fence_mode(vm))
> -		flush_work(&vm->preempt.rebind_work);
> -
>  	mutex_destroy(&vm->snap_mutex);
>  
>  	if (vm->flags & XE_VM_FLAG_LR_MODE)
> diff --git a/drivers/gpu/drm/xe/xe_vm.h b/drivers/gpu/drm/xe/xe_vm.h
> index ed590bad892c..1917deca4679 100644
> --- a/drivers/gpu/drm/xe/xe_vm.h
> +++ b/drivers/gpu/drm/xe/xe_vm.h
> @@ -262,8 +262,9 @@ int xe_vm_validate_protected(struct xe_vm *vm);
>  static inline void xe_vm_queue_rebind_worker(struct xe_vm *vm)
>  {
>  	xe_assert(vm->xe, xe_vm_in_preempt_fence_mode(vm));


xe_vm_get(vm);
if (!queue_work_node(....))
	xe_vm_put(vm);

Matt

> -	queue_work_node(dev_to_node(vm->xe->drm.dev), vm->xe->rebind_wq,
> -			&vm->preempt.rebind_work);
> +	if (queue_work_node(dev_to_node(vm->xe->drm.dev), vm->xe->rebind_wq,
> +			    &vm->preempt.rebind_work))
> +		xe_vm_get(vm);
>  }
>  
>  /**
> -- 
> 2.52.0
> 

      parent reply	other threads:[~2026-11-30 22:37 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-30 10:28 [PATCH] drm/xe: Hold VM reference in preempt rebind worker Tejas Upadhyay
2026-11-30 10:36 ` ✗ CI.checkpatch: warning for " Patchwork
2026-11-30 10:38 ` ✓ CI.KUnit: success " Patchwork
2026-11-30 10:45 ` [PATCH] " sashiko-bot
2026-11-30 11:26 ` ✗ Xe.CI.BAT: failure for " Patchwork
2026-11-30 15:45 ` ✗ Xe.CI.FULL: " Patchwork
2026-11-30 22:37 ` Matthew Brost [this message]

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=aw36lnP2+sZFjOVT@gsse-cloud1.jf.intel.com \
    --to=matthew.brost@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=tejas.upadhyay@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.