Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
Cc: <intel-xe@lists.freedesktop.org>
Subject: Re: [CI 4/7] drm/xe: Move vma rebinding to the drm_exec locking loop
Date: Thu, 21 Mar 2024 19:21:22 +0000	[thread overview]
Message-ID: <ZfyIsim3qY/W38DY@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <20240312140447.50437-4-thomas.hellstrom@linux.intel.com>

On Tue, Mar 12, 2024 at 03:04:44PM +0100, Thomas Hellström wrote:
> Rebinding might allocate page-table bos, causing evictions.
> To support blocking locking during these evictions,
> perform the rebinding in the drm_exec locking loop.
> 
> Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> ---
>  drivers/gpu/drm/xe/xe_exec.c | 13 ++++++++++---
>  drivers/gpu/drm/xe/xe_vm.c   | 16 +++++++++-------
>  2 files changed, 19 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_exec.c b/drivers/gpu/drm/xe/xe_exec.c
> index 13d1fba2c9d7..f36fb22a7861 100644
> --- a/drivers/gpu/drm/xe/xe_exec.c
> +++ b/drivers/gpu/drm/xe/xe_exec.c
> @@ -96,13 +96,20 @@
>  
>  static int xe_exec_fn(struct drm_gpuvm_exec *vm_exec)
>  {
> +	struct xe_vm *vm = container_of(vm_exec->vm, struct xe_vm, gpuvm);
>  	struct drm_gem_object *obj;
>  	unsigned long index;
>  	int ret;
>  
> -	ret = drm_gpuvm_validate(vm_exec->vm, &vm_exec->exec);
> -	if (ret)
> -		return ret;
> +	do {
> +		ret = drm_gpuvm_validate(vm_exec->vm, &vm_exec->exec);
> +		if (ret)
> +			return ret;
> +
> +		ret = xe_vm_rebind(vm, false);
> +		if (ret)
> +			return ret;
> +	} while (!list_empty(&vm->gpuvm.evict.list));
>  

You need to delete xe_vm_rebind from xe_exec_ioctl too.

>  	drm_exec_for_each_locked_object(&vm_exec->exec, index, obj) {
>  		ret = dma_resv_reserve_fences(obj->resv, 1);
> diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
> index faad7f52b3ca..fad5b1ae7f2d 100644
> --- a/drivers/gpu/drm/xe/xe_vm.c
> +++ b/drivers/gpu/drm/xe/xe_vm.c
> @@ -513,9 +513,15 @@ static int xe_preempt_work_begin(struct drm_exec *exec, struct xe_vm *vm,
>  	if (err)
>  		return err;
>  
> -	err = drm_gpuvm_validate(&vm->gpuvm, exec);
> -	if (err)
> -		return err;
> +	do {
> +		err = drm_gpuvm_validate(&vm->gpuvm, exec);
> +		if (err)
> +			return err;
> +
> +		err = xe_vm_rebind(vm, true);
> +		if (err)
> +			return err;
> +	} while (!list_empty(&vm->gpuvm.evict.list));

Same code pattern twice here? Opportunity for a helper?

Matt

>  
>  	drm_exec_for_each_locked_object(exec, index, obj) {
>  		err = dma_resv_reserve_fences(obj->resv, vm->preempt.num_exec_queues);
> @@ -575,10 +581,6 @@ static void preempt_rebind_work_func(struct work_struct *w)
>  	if (err)
>  		goto out_unlock;
>  
> -	err = xe_vm_rebind(vm, true);
> -	if (err)
> -		goto out_unlock;
> -
>  	if (vm->rebind_fence) {
>  		dma_fence_wait(vm->rebind_fence, false);
>  		dma_fence_put(vm->rebind_fence);
> -- 
> 2.44.0
> 

  reply	other threads:[~2024-03-21 19:22 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-12 14:04 [CI 1/7] drm/xe: Make TLB invalidation fences unordered Thomas Hellström
2024-03-12 14:04 ` [CI 2/7] drm/xe: Rework xe_vm_rebind() Thomas Hellström
2024-03-12 14:04 ` [CI 3/7] drm/xe: Reserve fences where needed Thomas Hellström
2024-03-12 14:04 ` [CI 4/7] drm/xe: Move vma rebinding to the drm_exec locking loop Thomas Hellström
2024-03-21 19:21   ` Matthew Brost [this message]
2024-03-21 21:18     ` Thomas Hellström
2024-03-12 14:04 ` [CI 5/7] drm/xe/bo: Forward the decision to evict local objects during validation Thomas Hellström
2024-03-12 14:04 ` [CI 6/7] drm/xe/bo: Allow eviction of unbound local bos Thomas Hellström
2024-03-12 14:04 ` [CI 7/7] drm/xe/bo: Allow migrating local bos to TT to make room in VRAM Thomas Hellström
2024-03-12 14:09 ` ✓ CI.Patch_applied: success for series starting with [CI,1/7] drm/xe: Make TLB invalidation fences unordered Patchwork
2024-03-12 14:10 ` ✓ CI.checkpatch: " Patchwork
2024-03-12 14:11 ` ✓ CI.KUnit: " Patchwork
2024-03-12 14:21 ` ✓ CI.Build: " Patchwork
2024-03-12 14:24 ` ✗ CI.Hooks: failure " Patchwork
2024-03-12 14:25 ` ✓ CI.checksparse: success " Patchwork
2024-03-12 14:56 ` ✗ CI.BAT: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2024-03-12 15:34 [CI 1/7] " Thomas Hellström
2024-03-12 15:34 ` [CI 4/7] drm/xe: Move vma rebinding to the drm_exec locking loop Thomas Hellström

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=ZfyIsim3qY/W38DY@DUT025-TGLU.fm.intel.com \
    --to=matthew.brost@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --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