All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Matthew Brost <matthew.brost@intel.com>
Cc: intel-xe@lists.freedesktop.org,
	Joonas Lahtinen	 <joonas.lahtinen@linux.intel.com>,
	Jani Nikula <jani.nikula@intel.com>,
	 Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Matthew Auld <matthew.auld@intel.com>
Subject: Re: [PATCH 07/15] drm/xe: Convert SVM validation for exhaustive eviction
Date: Thu, 14 Aug 2025 14:24:27 +0200	[thread overview]
Message-ID: <e1c080a5dc2e9b1903e93ceadb19870d1e2c07a2.camel@linux.intel.com> (raw)
In-Reply-To: <aJyv9J8I/NGYpmHj@lstrano-desk.jf.intel.com>

On Wed, 2025-08-13 at 08:32 -0700, Matthew Brost wrote:
> On Wed, Aug 13, 2025 at 12:51:13PM +0200, Thomas Hellström wrote:
> > Convert SVM validation to support exhaustive eviction,
> > using xe_validation_guard().
> > 
> 
> Do we not need to validation guard + xe_vm_set_validation_exec around
> xe_vm_range_rebind, given that on first fault of range we can
> allocate
> PTs?

Yes, you're right. I see this comment in a later patch as well.
The reason the asserts didn't trigger here is that we were leaking an
xe_vm_set_validation(). I'm fixing that up in v2 and add more asserts
so that's much less likely to happen.

Ideally we'd want to pass the drm_exec (perhaps part of a pt_details
struct) all the way down to pt allocation. But when I tried that during
developement the headers became quite bloated.

/Thomas


> 
> Matt
> 
> > Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_svm.c | 63 ++++++++++++++++++---------------
> > ----
> >  1 file changed, 30 insertions(+), 33 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_svm.c
> > b/drivers/gpu/drm/xe/xe_svm.c
> > index 39e3aa6df25a..ba85665d85d4 100644
> > --- a/drivers/gpu/drm/xe/xe_svm.c
> > +++ b/drivers/gpu/drm/xe/xe_svm.c
> > @@ -699,51 +699,48 @@ static int xe_drm_pagemap_populate_mm(struct
> > drm_pagemap *dpagemap,
> >  	struct xe_device *xe = vr->xe;
> >  	struct device *dev = xe->drm.dev;
> >  	struct drm_buddy_block *block;
> > +	struct xe_validation_ctx vctx;
> >  	struct list_head *blocks;
> > -	struct drm_exec *exec;
> > +	struct drm_exec exec;
> >  	struct xe_bo *bo;
> > -	ktime_t time_end = 0;
> > -	int err, idx;
> > +	int err = 0, idx;
> >  
> >  	if (!drm_dev_enter(&xe->drm, &idx))
> >  		return -ENODEV;
> >  
> >  	xe_pm_runtime_get(xe);
> > -	exec = XE_VALIDATION_UNIMPLEMENTED;
> > -
> > - retry:
> > -	bo = xe_bo_create_locked(vr->xe, NULL, NULL, end - start,
> > -				 ttm_bo_type_device,
> > -				 (IS_DGFX(xe) ?
> > XE_BO_FLAG_VRAM(vr) : XE_BO_FLAG_SYSTEM) |
> > -				 XE_BO_FLAG_CPU_ADDR_MIRROR,
> > exec);
> > -	if (IS_ERR(bo)) {
> > -		err = PTR_ERR(bo);
> > -		if (xe_vm_validate_should_retry(NULL, err,
> > &time_end))
> > -			goto retry;
> > -		goto out_pm_put;
> > -	}
> >  
> > -	drm_pagemap_devmem_init(&bo->devmem_allocation, dev, mm,
> > -				&dpagemap_devmem_ops, dpagemap,
> > end - start);
> > -
> > -	blocks = &to_xe_ttm_vram_mgr_resource(bo->ttm.resource)-
> > >blocks;
> > -	list_for_each_entry(block, blocks, link)
> > -		block->private = vr;
> > +	xe_validation_guard(&vctx, &xe->val, &exec, 0, err, false)
> > {
> > +		bo = xe_bo_create_locked(xe, NULL, NULL, end -
> > start,
> > +					 ttm_bo_type_device,
> > +					 (IS_DGFX(xe) ?
> > XE_BO_FLAG_VRAM(vr) : XE_BO_FLAG_SYSTEM) |
> > +					
> > XE_BO_FLAG_CPU_ADDR_MIRROR, &exec);
> > +		drm_exec_retry_on_contention(&exec);
> > +		if (IS_ERR(bo)) {
> > +			err = PTR_ERR(bo);
> > +			xe_validation_retry_on_oom(&vctx, &err);
> > +			break;
> > +		}
> >  
> > -	xe_bo_get(bo);
> > +		drm_pagemap_devmem_init(&bo->devmem_allocation,
> > dev, mm,
> > +					&dpagemap_devmem_ops,
> > dpagemap, end - start);
> >  
> > -	/* Ensure the device has a pm ref while there are device
> > pages active. */
> > -	xe_pm_runtime_get_noresume(xe);
> > -	err = drm_pagemap_migrate_to_devmem(&bo-
> > >devmem_allocation, mm,
> > -					    start, end,
> > timeslice_ms,
> > -					   
> > xe_svm_devm_owner(xe));
> > -	if (err)
> > -		xe_svm_devmem_release(&bo->devmem_allocation);
> > +		blocks = &to_xe_ttm_vram_mgr_resource(bo-
> > >ttm.resource)->blocks;
> > +		list_for_each_entry(block, blocks, link)
> > +			block->private = vr;
> >  
> > -	xe_bo_unlock(bo);
> > -	xe_bo_put(bo);
> > +		xe_bo_get(bo);
> >  
> > -out_pm_put:
> > +		/* Ensure the device has a pm ref while there are
> > device pages active. */
> > +		xe_pm_runtime_get_noresume(xe);
> > +		err = drm_pagemap_migrate_to_devmem(&bo-
> > >devmem_allocation, mm,
> > +						    start, end,
> > timeslice_ms,
> > +						   
> > xe_svm_devm_owner(xe));
> > +		if (err)
> > +			xe_svm_devmem_release(&bo-
> > >devmem_allocation);
> > +		xe_bo_unlock(bo);
> > +		xe_bo_put(bo);
> > +	}
> >  	xe_pm_runtime_put(xe);
> >  	drm_dev_exit(idx);
> >  
> > -- 
> > 2.50.1
> > 


  reply	other threads:[~2025-08-14 12:24 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-13 10:51 [PATCH 00/15] Driver-managed exhaustive eviction Thomas Hellström
2025-08-13 10:51 ` [PATCH 01/15] drm/xe/vm: Don't use a pin the vm_resv during validation Thomas Hellström
2025-08-13 14:28   ` Matthew Brost
2025-08-13 14:33     ` Thomas Hellström
2025-08-13 15:17       ` Matthew Brost
2025-08-13 10:51 ` [PATCH 02/15] drm/xe/tests/xe_dma_buf: Set the drm_object::dma_buf member Thomas Hellström
2025-08-14  2:52   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 03/15] drm/xe/vm: Clear the scratch_pt pointer on error Thomas Hellström
2025-08-13 14:45   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 04/15] drm/xe: Pass down drm_exec context to validation Thomas Hellström
2025-08-13 16:42   ` Matthew Brost
2025-08-14  7:49     ` Thomas Hellström
2025-08-14 19:09       ` Matthew Brost
2025-08-22  7:40     ` Thomas Hellström
2025-08-13 10:51 ` [PATCH 05/15] drm/xe: Introduce an xe_validation wrapper around drm_exec Thomas Hellström
2025-08-13 17:25   ` Matthew Brost
2025-08-15 15:04     ` Thomas Hellström
2025-08-14  2:33   ` Matthew Brost
2025-08-14  4:23     ` Matthew Brost
2025-08-15 15:23     ` Thomas Hellström
2025-08-15 19:01       ` Matthew Brost
2025-08-17 14:05   ` [05/15] " Simon Richter
2025-08-18  2:19     ` Matthew Brost
2025-08-18  5:24       ` Simon Richter
2025-08-18  9:19     ` Thomas Hellström
2025-08-13 10:51 ` [PATCH 06/15] drm/xe: Convert xe_bo_create_user() for exhaustive eviction Thomas Hellström
2025-08-14  2:23   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 07/15] drm/xe: Convert SVM validation " Thomas Hellström
2025-08-13 15:32   ` Matthew Brost
2025-08-14 12:24     ` Thomas Hellström [this message]
2025-08-13 10:51 ` [PATCH 08/15] drm/xe: Convert existing drm_exec transactions " Thomas Hellström
2025-08-14  2:48   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 09/15] drm/xe: Convert the CPU fault handler " Thomas Hellström
2025-08-13 22:06   ` Matthew Brost
2025-08-15 15:16     ` Thomas Hellström
2025-08-15 19:04       ` Matthew Brost
2025-08-18  9:11         ` Thomas Hellström
2025-08-13 10:51 ` [PATCH 10/15] drm/xe/display: Convert __xe_pin_fb_vma() Thomas Hellström
2025-08-14  2:35   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 11/15] drm/xe: Convert xe_dma_buf.c for exhaustive eviction Thomas Hellström
2025-08-13 21:37   ` Matthew Brost
2025-08-15 15:05     ` Thomas Hellström
2025-08-14 20:37   ` Matthew Brost
2025-08-15  6:57     ` Thomas Hellström
2025-08-13 10:51 ` [PATCH 12/15] drm/xe: Rename ___xe_bo_create_locked() Thomas Hellström
2025-08-13 21:33   ` Matthew Brost
2025-08-13 10:51 ` [PATCH 13/15] drm/xe: Convert xe_bo_create_pin_map_at() for exhaustive eviction Thomas Hellström
2025-08-14  3:58   ` Matthew Brost
2025-08-15 15:25     ` Thomas Hellström
2025-08-14  4:05   ` Matthew Brost
2025-08-15 15:27     ` Thomas Hellström
2025-08-14 18:48   ` Matthew Brost
2025-08-15  9:37     ` Thomas Hellström
2025-08-13 10:51 ` [PATCH 14/15] drm/xe: Convert xe_bo_create_pin_map() " Thomas Hellström
2025-08-14  4:18   ` Matthew Brost
2025-08-14 13:14     ` Thomas Hellström
2025-08-14 18:39       ` Matthew Brost
2025-08-13 10:51 ` [PATCH 15/15] drm/xe: Convert pinned suspend eviction " Thomas Hellström
2025-08-13 12:13   ` Matthew Auld
2025-08-13 12:30     ` Thomas Hellström
2025-08-14 20:30   ` Matthew Brost
2025-08-15 15:29     ` Thomas Hellström
2025-08-13 11:54 ` ✗ CI.checkpatch: warning for Driver-managed " Patchwork
2025-08-13 11:55 ` ✓ CI.KUnit: success " Patchwork
2025-08-13 13:20 ` ✗ Xe.CI.BAT: failure " Patchwork
2025-08-13 14:25 ` ✗ Xe.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=e1c080a5dc2e9b1903e93ceadb19870d1e2c07a2.camel@linux.intel.com \
    --to=thomas.hellstrom@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=jani.nikula@intel.com \
    --cc=joonas.lahtinen@linux.intel.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=matthew.auld@intel.com \
    --cc=matthew.brost@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.