Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Brost <matthew.brost@intel.com>
To: Maarten Lankhorst <dev@lankhorst.se>
Cc: <intel-xe@lists.freedesktop.org>, <intel-gfx@lists.freedesktop.org>
Subject: Re: [PATCH 08/11] drm/xe/migrate: Support copying between sysmem and stolen
Date: Mon, 20 Jul 2026 12:09:46 -0700	[thread overview]
Message-ID: <al5yelaY34ls2/vw@gsse-cloud1.jf.intel.com> (raw)
In-Reply-To: <20260720161451.384968-21-dev@lankhorst.se>

On Mon, Jul 20, 2026 at 06:15:00PM +0200, Maarten Lankhorst wrote:
> In order to copy out the stolen BO, we have to add some support to
> xe_migrate_copy, since otherwise it tries to use the VRAM identity
> mapping on integrated, which obviously doesn't do the right thing.
> 
> Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
> ---
>  drivers/gpu/drm/xe/xe_migrate.c | 29 +++++++++++++++++++++--------
>  1 file changed, 21 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_migrate.c b/drivers/gpu/drm/xe/xe_migrate.c
> index c84e14e86a823..b346e743025b7 100644
> --- a/drivers/gpu/drm/xe/xe_migrate.c
> +++ b/drivers/gpu/drm/xe/xe_migrate.c
> @@ -559,6 +559,7 @@ static bool xe_migrate_allow_identity(u64 size, const struct xe_res_cursor *cur)
>  
>  #define PTE_UPDATE_FLAG_IS_VRAM		BIT(0)
>  #define PTE_UPDATE_FLAG_IS_COMP_PTE	BIT(1)
> +#define PTE_UPDATE_FLAG_ALLOW_IDENTITY	BIT(2)
>  
>  static u32 pte_update_size(struct xe_migrate *m,
>  			   u32 flags,
> @@ -570,9 +571,10 @@ static u32 pte_update_size(struct xe_migrate *m,
>  	u32 cmds = 0;
>  	bool is_vram = PTE_UPDATE_FLAG_IS_VRAM & flags;
>  	bool is_comp_pte = PTE_UPDATE_FLAG_IS_COMP_PTE & flags;
> +	bool allow_identity = PTE_UPDATE_FLAG_ALLOW_IDENTITY & flags;
>  
>  	*L0_pt = pt_ofs;
> -	if (is_vram && xe_migrate_allow_identity(*L0, cur)) {
> +	if (is_vram && allow_identity && xe_migrate_allow_identity(*L0, cur)) {
>  		/* Offset into identity map. */
>  		*L0_ofs = xe_migrate_vram_ofs(tile_to_xe(m->tile),
>  					      cur->start + vram_region_gpu_offset(res),
> @@ -858,6 +860,14 @@ static u32 xe_migrate_ccs_copy(struct xe_migrate *m,
>  	return flush_flags;
>  }
>  
> +static bool is_devmem(struct xe_bo *bo, struct ttm_resource *res)
> +{
> +	if (mem_type_is_vram(res->mem_type) || res->mem_type == XE_PL_STOLEN)
> +		return true;
> +
> +	return false;
> +}
> +
>  static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m,
>  					   struct xe_bo *src_bo,
>  					   struct xe_bo *dst_bo,
> @@ -878,8 +888,8 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m,
>  	int err;
>  	bool src_is_pltt = src->mem_type == XE_PL_TT;
>  	bool dst_is_pltt = dst->mem_type == XE_PL_TT;
> -	bool src_is_vram = mem_type_is_vram(src->mem_type);
> -	bool dst_is_vram = mem_type_is_vram(dst->mem_type);
> +	bool src_is_vram = is_devmem(src_bo, src);
> +	bool dst_is_vram = is_devmem(dst_bo, dst);
>  	bool type_device = src_bo->ttm.type == ttm_bo_type_device;
>  	bool needs_ccs_emit = type_device && xe_migrate_needs_ccs_emit(xe);
>  	bool copy_ccs = xe_device_has_flat_ccs(xe) &&
> @@ -939,6 +949,7 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m,
>  
>  		pte_flags = src_is_vram ? PTE_UPDATE_FLAG_IS_VRAM : 0;
>  		pte_flags |= use_comp_pat ? PTE_UPDATE_FLAG_IS_COMP_PTE : 0;
> +		pte_flags |= IS_DGFX(xe) ? PTE_UPDATE_FLAG_ALLOW_IDENTITY : 0;

Can we make allow identity a stack variable?

>  		batch_size += pte_update_size(m, pte_flags, src, &src_it, &src_L0,
>  					      &src_L0_ofs, &src_L0_pt, 0, 0,
>  					      avail_pts);
> @@ -946,6 +957,7 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m,
>  			dst_L0_ofs = src_L0_ofs;
>  		} else {
>  			pte_flags = dst_is_vram ? PTE_UPDATE_FLAG_IS_VRAM : 0;
> +			pte_flags |= IS_DGFX(xe) ? PTE_UPDATE_FLAG_ALLOW_IDENTITY : 0;
>  			batch_size += pte_update_size(m, pte_flags, dst,
>  						      &dst_it, &src_L0,
>  						      &dst_L0_ofs, &dst_L0_pt,
> @@ -972,13 +984,13 @@ static struct dma_fence *__xe_migrate_copy(struct xe_migrate *m,
>  			goto err_sync;
>  		}
>  
> -		if (src_is_vram && xe_migrate_allow_identity(src_L0, &src_it))
> +		if (src_is_vram && IS_DGFX(xe) && xe_migrate_allow_identity(src_L0, &src_it))

Then use it here too or maybe update xe_migrate_allow_identity to accept
an 'xe' argument which does IS_DGFX(xe) check?

I basically don't like the duplicate IS_DGFX(xe) scattered over these
functions.

Matt 

>  			xe_res_next(&src_it, src_L0);
>  		else
>  			emit_pte(m, bb, src_L0_pt, src_is_vram, copy_system_ccs || use_comp_pat,
>  				 &src_it, src_L0, src);
>  
> -		if (dst_is_vram && xe_migrate_allow_identity(src_L0, &dst_it))
> +		if (dst_is_vram && IS_DGFX(xe) && xe_migrate_allow_identity(src_L0, &dst_it))
>  			xe_res_next(&dst_it, src_L0);
>  		else if (!copy_only_ccs)
>  			emit_pte(m, bb, dst_L0_pt, dst_is_vram, copy_system_ccs,
> @@ -1386,7 +1398,7 @@ struct dma_fence *xe_migrate_vram_copy_chunk(struct xe_bo *vram_bo, u64 vram_off
>  	xe_res_first_sg(xe_bo_sg(sysmem_bo), sysmem_offset, size, &sysmem_it);
>  
>  	while (size) {
> -		u32 pte_flags = PTE_UPDATE_FLAG_IS_VRAM;
> +		u32 pte_flags = PTE_UPDATE_FLAG_IS_VRAM | PTE_UPDATE_FLAG_ALLOW_IDENTITY;
>  		u32 batch_size = 2; /* arb_clear() + MI_BATCH_BUFFER_END */
>  		struct xe_sched_job *job;
>  		struct xe_bb *bb;
> @@ -1576,7 +1588,7 @@ struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
>  				   struct ttm_resource *dst,
>  				   u32 clear_flags)
>  {
> -	bool clear_vram = mem_type_is_vram(dst->mem_type);
> +	bool clear_vram = is_devmem(bo, dst);
>  	bool clear_bo_data = XE_MIGRATE_CLEAR_FLAG_BO_DATA & clear_flags;
>  	bool clear_ccs = XE_MIGRATE_CLEAR_FLAG_CCS_DATA & clear_flags;
>  	struct xe_gt *gt = m->tile->primary_gt;
> @@ -1616,6 +1628,7 @@ struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
>  
>  		/* Calculate final sizes and batch size.. */
>  		pte_flags = clear_vram ? PTE_UPDATE_FLAG_IS_VRAM : 0;
> +		pte_flags |= IS_DGFX(xe) ? PTE_UPDATE_FLAG_ALLOW_IDENTITY : 0;
>  		batch_size = 1 +
>  			pte_update_size(m, pte_flags, src, &src_it,
>  					&clear_L0, &clear_L0_ofs, &clear_L0_pt,
> @@ -1638,7 +1651,7 @@ struct dma_fence *xe_migrate_clear(struct xe_migrate *m,
>  
>  		size -= clear_L0;
>  		/* Preemption is enabled again by the ring ops. */
> -		if (clear_vram && xe_migrate_allow_identity(clear_L0, &src_it)) {
> +		if (clear_vram && IS_DGFX(xe) && xe_migrate_allow_identity(clear_L0, &src_it)) {
>  			xe_res_next(&src_it, clear_L0);
>  		} else {
>  			emit_pte(m, bb, clear_L0_pt, clear_vram,
> -- 
> 2.53.0
> 

  reply	other threads:[~2026-07-20 19:09 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-20 16:14 [PATCH 00/11] drm/xe/display: Transparant fallback from stolen to sysmem Maarten Lankhorst
2026-07-20 16:14 ` [DO NOT REVIEW 01/11] drm/xe/ggtt: Add xe_ggtt_reserve_area Maarten Lankhorst
2026-07-20 16:14 ` [DO NOT REVIEW 02/11] drm/xe/ggtt: Add xe_ggtt_node_remove_noclear Maarten Lankhorst
2026-07-20 16:14 ` [DO NOT REVIEW 03/11] drm/xe/display: Reserve the original GGTT space before creating a bo Maarten Lankhorst
2026-07-20 16:14 ` [DO NOT REVIEW 04/11] drm/xe/display: Use the correct calculation for phys_base on integrated Maarten Lankhorst
2026-07-20 16:14 ` [DO NOT REVIEW 05/11] drm/xe/display: Remove duplicated code Maarten Lankhorst
2026-07-20 16:14 ` [DO NOT REVIEW 06/11] drm/xe/ggtt: Remove xe_ggtt_insert_bo_at Maarten Lankhorst
2026-07-20 16:14 ` [PATCH 07/11] drm/xe/display: Avoid using stolen memory for framebuffer when media gt exists Maarten Lankhorst
2026-07-20 16:15 ` [PATCH 08/11] drm/xe/migrate: Support copying between sysmem and stolen Maarten Lankhorst
2026-07-20 19:09   ` Matthew Brost [this message]
2026-07-20 20:28     ` Maarten Lankhorst
2026-07-20 16:15 ` [PATCH 09/11] drm/xe: Raise gt frequency slightly earlier Maarten Lankhorst
2026-07-20 19:00   ` Matthew Brost
2026-07-20 16:15 ` [PATCH 10/11] HACK: Always fallback Maarten Lankhorst
2026-07-20 16:15 ` [PATCH 11/11] drm/i915: Introduce intel_bo_fbdev_bios_fb_takeover() Maarten Lankhorst
2026-07-20 22:44 ` ✓ i915.CI.BAT: success for drm/xe/display: Transparant fallback from stolen to sysmem 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=al5yelaY34ls2/vw@gsse-cloud1.jf.intel.com \
    --to=matthew.brost@intel.com \
    --cc=dev@lankhorst.se \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=intel-xe@lists.freedesktop.org \
    /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