Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: <intel-xe@lists.freedesktop.org>,
	<umesh.nerlige.ramappa@intel.com>, <riana.tauro@intel.com>
Subject: Re: [PATCH 1/3] drm/xe: Add XE_BO_FLAG_PINNED_WONTNEED
Date: Tue, 29 Oct 2024 14:55:11 +0000	[thread overview]
Message-ID: <ZyD3T8pU8Q8H4k8k@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <ZyDjiuhhGqSPLEl_@intel.com>

On Tue, Oct 29, 2024 at 09:30:50AM -0400, Rodrigo Vivi wrote:
> On Mon, Oct 28, 2024 at 05:32:22PM -0700, Matthew Brost wrote:
> > Not all BOs need to restored on resume / d3cold exit, add
> > XE_BO_FLAG_PINNED_WONTNEED which skips restoring of BOs rather just
> > allocates VRAM for the BO. This should slighly speedup resume / d3cold
> > exit flows.
> > 
> > Marking GuC ADS, GuC CT, GuC log, GuC PC, and SA as WONTNEED.
> 
> What about s/WONTNEED/NORESTORE ?
> 

Yea that seems better.

Matt

> > 
> > Signed-off-by: Matthew Brost <matthew.brost@intel.com>
> > ---
> >  drivers/gpu/drm/xe/xe_bo.c      | 24 +++++++++++++++++-------
> >  drivers/gpu/drm/xe/xe_bo.h      |  1 +
> >  drivers/gpu/drm/xe/xe_guc_ads.c |  3 ++-
> >  drivers/gpu/drm/xe/xe_guc_ct.c  |  3 ++-
> >  drivers/gpu/drm/xe/xe_guc_log.c |  3 ++-
> >  drivers/gpu/drm/xe/xe_guc_pc.c  |  3 ++-
> >  drivers/gpu/drm/xe/xe_sa.c      |  3 ++-
> >  7 files changed, 28 insertions(+), 12 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> > index 5b232f2951b1..bd747e53eb9b 100644
> > --- a/drivers/gpu/drm/xe/xe_bo.c
> > +++ b/drivers/gpu/drm/xe/xe_bo.c
> > @@ -771,7 +771,9 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
> >  		xe_pm_runtime_get_noresume(xe);
> >  	}
> >  
> > -	if (xe_bo_is_pinned(bo) && !xe_bo_is_user(bo)) {
> > +	if (bo->flags & XE_BO_FLAG_PINNED_WONTNEED) {
> > +		ttm_bo_move_null(&bo->ttm, new_mem);
> > +	} else if (xe_bo_is_pinned(bo) && !xe_bo_is_user(bo)) {
> >  		/*
> >  		 * Kernel memory that is pinned should only be moved on suspend
> >  		 * / resume, some of the pinned memory is required for the
> > @@ -891,6 +893,11 @@ int xe_bo_evict_pinned(struct xe_bo *bo)
> >  	if (WARN_ON(!xe_bo_is_vram(bo)))
> >  		return -EINVAL;
> >  
> > +	if (bo->flags & XE_BO_FLAG_PINNED_WONTNEED) {
> > +		ttm_bo_move_null(&bo->ttm, NULL);
> > +		return 0;
> > +	}
> > +
> >  	ret = ttm_bo_mem_space(&bo->ttm, &placement, &new_mem, &ctx);
> >  	if (ret)
> >  		return ret;
> > @@ -943,14 +950,16 @@ int xe_bo_restore_pinned(struct xe_bo *bo)
> >  
> >  	xe_bo_assert_held(bo);
> >  
> > -	if (WARN_ON(!bo->ttm.resource))
> > -		return -EINVAL;
> > -
> >  	if (WARN_ON(!xe_bo_is_pinned(bo)))
> >  		return -EINVAL;
> >  
> > -	if (WARN_ON(xe_bo_is_vram(bo) || !bo->ttm.ttm))
> > -		return -EINVAL;
> > +	if (!(bo->flags & XE_BO_FLAG_PINNED_WONTNEED)) {
> > +		if (WARN_ON(!bo->ttm.resource))
> > +			return -EINVAL;
> > +
> > +		if (WARN_ON(xe_bo_is_vram(bo) || !bo->ttm.ttm))
> > +			return -EINVAL;
> > +	}
> >  
> >  	ret = ttm_bo_mem_space(&bo->ttm, &bo->placement, &new_mem, &ctx);
> >  	if (ret)
> > @@ -1692,7 +1701,8 @@ int xe_managed_bo_reinit_in_vram(struct xe_device *xe, struct xe_tile *tile, str
> >  	struct xe_bo *bo;
> >  	u32 dst_flags = XE_BO_FLAG_VRAM_IF_DGFX(tile) | XE_BO_FLAG_GGTT;
> >  
> > -	dst_flags |= (*src)->flags & XE_BO_FLAG_GGTT_INVALIDATE;
> > +	dst_flags |= (*src)->flags & (XE_BO_FLAG_GGTT_INVALIDATE |
> > +				      XE_BO_FLAG_PINNED_WONTNEED);
> >  
> >  	xe_assert(xe, IS_DGFX(xe));
> >  	xe_assert(xe, !(*src)->vmap.is_iomem);
> > diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
> > index 7fa44a0138b0..854ab8624d7a 100644
> > --- a/drivers/gpu/drm/xe/xe_bo.h
> > +++ b/drivers/gpu/drm/xe/xe_bo.h
> > @@ -39,6 +39,7 @@
> >  #define XE_BO_FLAG_NEEDS_64K		BIT(15)
> >  #define XE_BO_FLAG_NEEDS_2M		BIT(16)
> >  #define XE_BO_FLAG_GGTT_INVALIDATE	BIT(17)
> > +#define XE_BO_FLAG_PINNED_WONTNEED	BIT(18)
> >  /* this one is trigger internally only */
> >  #define XE_BO_FLAG_INTERNAL_TEST	BIT(30)
> >  #define XE_BO_FLAG_INTERNAL_64K		BIT(31)
> > diff --git a/drivers/gpu/drm/xe/xe_guc_ads.c b/drivers/gpu/drm/xe/xe_guc_ads.c
> > index 4e746ae98888..506b26ea7b74 100644
> > --- a/drivers/gpu/drm/xe/xe_guc_ads.c
> > +++ b/drivers/gpu/drm/xe/xe_guc_ads.c
> > @@ -418,7 +418,8 @@ int xe_guc_ads_init(struct xe_guc_ads *ads)
> >  	bo = xe_managed_bo_create_pin_map(xe, tile, guc_ads_size(ads) + MAX_GOLDEN_LRC_SIZE,
> >  					  XE_BO_FLAG_SYSTEM |
> >  					  XE_BO_FLAG_GGTT |
> > -					  XE_BO_FLAG_GGTT_INVALIDATE);
> > +					  XE_BO_FLAG_GGTT_INVALIDATE |
> > +					  XE_BO_FLAG_PINNED_WONTNEED);
> >  	if (IS_ERR(bo))
> >  		return PTR_ERR(bo);
> >  
> > diff --git a/drivers/gpu/drm/xe/xe_guc_ct.c b/drivers/gpu/drm/xe/xe_guc_ct.c
> > index 1b5d8fb1033a..61641329fa95 100644
> > --- a/drivers/gpu/drm/xe/xe_guc_ct.c
> > +++ b/drivers/gpu/drm/xe/xe_guc_ct.c
> > @@ -237,7 +237,8 @@ int xe_guc_ct_init(struct xe_guc_ct *ct)
> >  	bo = xe_managed_bo_create_pin_map(xe, tile, guc_ct_size(),
> >  					  XE_BO_FLAG_SYSTEM |
> >  					  XE_BO_FLAG_GGTT |
> > -					  XE_BO_FLAG_GGTT_INVALIDATE);
> > +					  XE_BO_FLAG_GGTT_INVALIDATE |
> > +					  XE_BO_FLAG_PINNED_WONTNEED);
> >  	if (IS_ERR(bo))
> >  		return PTR_ERR(bo);
> >  
> > diff --git a/drivers/gpu/drm/xe/xe_guc_log.c b/drivers/gpu/drm/xe/xe_guc_log.c
> > index fead96216243..2a4886f25835 100644
> > --- a/drivers/gpu/drm/xe/xe_guc_log.c
> > +++ b/drivers/gpu/drm/xe/xe_guc_log.c
> > @@ -261,7 +261,8 @@ int xe_guc_log_init(struct xe_guc_log *log)
> >  	bo = xe_managed_bo_create_pin_map(xe, tile, guc_log_size(),
> >  					  XE_BO_FLAG_SYSTEM |
> >  					  XE_BO_FLAG_GGTT |
> > -					  XE_BO_FLAG_GGTT_INVALIDATE);
> > +					  XE_BO_FLAG_GGTT_INVALIDATE |
> > +					  XE_BO_FLAG_PINNED_WONTNEED);
> >  	if (IS_ERR(bo))
> >  		return PTR_ERR(bo);
> >  
> > diff --git a/drivers/gpu/drm/xe/xe_guc_pc.c b/drivers/gpu/drm/xe/xe_guc_pc.c
> > index e8b9faeaef64..751c38c41f26 100644
> > --- a/drivers/gpu/drm/xe/xe_guc_pc.c
> > +++ b/drivers/gpu/drm/xe/xe_guc_pc.c
> > @@ -1086,7 +1086,8 @@ int xe_guc_pc_init(struct xe_guc_pc *pc)
> >  	bo = xe_managed_bo_create_pin_map(xe, tile, size,
> >  					  XE_BO_FLAG_VRAM_IF_DGFX(tile) |
> >  					  XE_BO_FLAG_GGTT |
> > -					  XE_BO_FLAG_GGTT_INVALIDATE);
> > +					  XE_BO_FLAG_GGTT_INVALIDATE |
> > +					  XE_BO_FLAG_PINNED_WONTNEED);
> >  	if (IS_ERR(bo))
> >  		return PTR_ERR(bo);
> >  
> > diff --git a/drivers/gpu/drm/xe/xe_sa.c b/drivers/gpu/drm/xe/xe_sa.c
> > index e055bed7ae55..a31b085d2d9b 100644
> > --- a/drivers/gpu/drm/xe/xe_sa.c
> > +++ b/drivers/gpu/drm/xe/xe_sa.c
> > @@ -49,7 +49,8 @@ struct xe_sa_manager *xe_sa_bo_manager_init(struct xe_tile *tile, u32 size, u32
> >  	bo = xe_managed_bo_create_pin_map(xe, tile, size,
> >  					  XE_BO_FLAG_VRAM_IF_DGFX(tile) |
> >  					  XE_BO_FLAG_GGTT |
> > -					  XE_BO_FLAG_GGTT_INVALIDATE);
> > +					  XE_BO_FLAG_GGTT_INVALIDATE |
> > +					  XE_BO_FLAG_PINNED_WONTNEED);
> >  	if (IS_ERR(bo)) {
> >  		drm_err(&xe->drm, "failed to allocate bo for sa manager: %ld\n",
> >  			PTR_ERR(bo));
> > -- 
> > 2.34.1
> > 

  reply	other threads:[~2024-10-29 14:56 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-29  0:32 [PATCH 0/3] Suspend, resume, and d3cold tweaks Matthew Brost
2024-10-29  0:32 ` [PATCH 1/3] drm/xe: Add XE_BO_FLAG_PINNED_WONTNEED Matthew Brost
2024-10-29 13:30   ` Rodrigo Vivi
2024-10-29 14:55     ` Matthew Brost [this message]
2024-10-31  4:23       ` Lucas De Marchi
2024-10-31  5:10         ` Matthew Brost
2024-10-29  0:32 ` [PATCH 2/3] drm/xe: Restore system memory GGTT mappings Matthew Brost
2024-10-29  9:44   ` Matthew Auld
2024-10-29 14:57     ` Matthew Brost
2024-10-30 11:53       ` Matthew Auld
2024-10-31  0:49         ` Matthew Brost
2024-10-31  8:44   ` Matthew Auld
2024-10-29  0:32 ` [PATCH 3/3] drm/xe: Add XE_BO_FLAG_PINNED_NEED_LOAD Matthew Brost
2024-10-29  1:07   ` Matthew Brost
2024-10-29  0:44 ` ✓ CI.Patch_applied: success for Suspend, resume, and d3cold tweaks Patchwork
2024-10-29  0:45 ` ✗ CI.checkpatch: warning " Patchwork
2024-10-29  0:46 ` ✓ CI.KUnit: success " Patchwork
2024-10-29  0:58 ` ✓ CI.Build: " Patchwork
2024-10-29  1:00 ` ✓ CI.Hooks: " Patchwork
2024-10-29  1:01 ` ✓ CI.checksparse: " Patchwork
2024-10-29  1:29 ` ✗ CI.BAT: failure " 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=ZyD3T8pU8Q8H4k8k@DUT025-TGLU.fm.intel.com \
    --to=matthew.brost@intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=riana.tauro@intel.com \
    --cc=rodrigo.vivi@intel.com \
    --cc=umesh.nerlige.ramappa@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