[PATCH 2/2] drm/xe: Add NEEDS_2M BO flag

Cavitt, Jonathan jonathan.cavitt at intel.com
Mon Jul 15 20:52:27 UTC 2024


-----Original Message-----
From: Intel-xe <intel-xe-bounces at lists.freedesktop.org> On Behalf Of Michal Wajdeczko
Sent: Monday, July 15, 2024 11:06 AM
To: intel-xe at lists.freedesktop.org
Subject: [PATCH 2/2] drm/xe: Add NEEDS_2M BO flag
> 
> In addition of NEEDS_64K BO flag, add similar one to force 2 MiB
> alignment of the buffer objects. Explicitly use this flag during
> VF LMEM provisioning as LMTT uses 2 MiB pages and one day we may
> drop requirement of allocating pinned objects as contiguous.
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko at intel.com>

Read through it.  Initially felt like suggesting that a separate flag be used
to denote "any" alignment was necessary, then storing the necessary
alignment separately, but I can see in xe_gt_sriov_pf_config.c that such
a change would not work.  No other notes:

Reviewed-by: Jonathan Cavitt <jonathan.cavitt at intel.com>
-Jonathan Cavitt

> ---
>  drivers/gpu/drm/xe/xe_bo.c                 | 11 ++++++-----
>  drivers/gpu/drm/xe/xe_bo.h                 |  3 ++-
>  drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c |  1 +
>  3 files changed, 9 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
> index da35b4a21739..3295bc92d7aa 100644
> --- a/drivers/gpu/drm/xe/xe_bo.c
> +++ b/drivers/gpu/drm/xe/xe_bo.c
> @@ -1264,13 +1264,14 @@ struct xe_bo *___xe_bo_create_locked(struct xe_device *xe, struct xe_bo *bo,
>  	if (flags & (XE_BO_FLAG_VRAM_MASK | XE_BO_FLAG_STOLEN) &&
>  	    !(flags & XE_BO_FLAG_IGNORE_MIN_PAGE_SIZE) &&
>  	    ((xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K) ||
> -	     (flags & XE_BO_FLAG_NEEDS_64K))) {
> -		aligned_size = ALIGN(size, SZ_64K);
> +	     (flags & (XE_BO_FLAG_NEEDS_64K | XE_BO_FLAG_NEEDS_2M)))) {
> +		size_t align = flags & XE_BO_FLAG_NEEDS_2M ? SZ_2M : SZ_64K;
> +
> +		aligned_size = ALIGN(size, align);
>  		if (type != ttm_bo_type_device)
> -			size = ALIGN(size, SZ_64K);
> +			size = ALIGN(size, align);
>  		flags |= XE_BO_FLAG_INTERNAL_64K;
> -		alignment = SZ_64K >> PAGE_SHIFT;
> -
> +		alignment = align >> PAGE_SHIFT;
>  	} else {
>  		aligned_size = ALIGN(size, SZ_4K);
>  		flags &= ~XE_BO_FLAG_INTERNAL_64K;
> diff --git a/drivers/gpu/drm/xe/xe_bo.h b/drivers/gpu/drm/xe/xe_bo.h
> index 2afc50132c2b..1c9dc8adaaa3 100644
> --- a/drivers/gpu/drm/xe/xe_bo.h
> +++ b/drivers/gpu/drm/xe/xe_bo.h
> @@ -37,7 +37,8 @@
>  #define XE_BO_FLAG_NEEDS_CPU_ACCESS	BIT(13)
>  #define XE_BO_FLAG_NEEDS_UC		BIT(14)
>  #define XE_BO_FLAG_NEEDS_64K		BIT(15)
> -#define XE_BO_FLAG_GGTT_INVALIDATE	BIT(16)
> +#define XE_BO_FLAG_NEEDS_2M		BIT(16)
> +#define XE_BO_FLAG_GGTT_INVALIDATE	BIT(17)
>  /* 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_gt_sriov_pf_config.c b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> index 4699b7836001..52c7277d243d 100644
> --- a/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> +++ b/drivers/gpu/drm/xe/xe_gt_sriov_pf_config.c
> @@ -1401,6 +1401,7 @@ static int pf_provision_vf_lmem(struct xe_gt *gt, unsigned int vfid, u64 size)
>  				  ALIGN(size, PAGE_SIZE),
>  				  ttm_bo_type_kernel,
>  				  XE_BO_FLAG_VRAM_IF_DGFX(tile) |
> +				  XE_BO_FLAG_NEEDS_2M |
>  				  XE_BO_FLAG_PINNED);
>  	if (IS_ERR(bo))
>  		return PTR_ERR(bo);
> -- 
> 2.43.0
> 
> 


More information about the Intel-xe mailing list