Restrict BMG to use 64K pages for scanout buffers
Subsystems (2)
v4 cover Restrict BMG to use 64K pages for scanout buffers
According to talk to UMD teams they've asked to adjust allocation for scanout buffer transparently to required by display alignment. Previously we agreed we require explicitly aligned size, what was relaxed in creating dumb bo. I decided to relax this requirement for scanout as well to avoid changes from UMD side.
+Thomas, +Maarten for their statement about change For reference about explicit uAPI change please take a look to v3.
v2: Limit restriction to BMG
v3: Expose display alignment config to userspace
v4: Drop display alignment config
Handle buffer size adjustment transparently in the kernel
Zbigniew Kempczyński (2):
drm/xe: Separate 64K physical allocation for display drm/xe: Use 64K pages for scanout buffers for Battlemage
drivers/gpu/drm/xe/xe_bo.c | 20 ++++++++++++++++---- drivers/gpu/drm/xe/xe_device_types.h | 1 + drivers/gpu/drm/xe/xe_pci.c | 9 ++++++++- drivers/gpu/drm/xe/xe_vm.c | 2 +- 4 files changed, 26 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
PATCH v4 1/2 drm/xe: Separate 64K physical allocation for display
In case Tile4 + compression Battlemage requires physical 64K pages for allocating display framebuffer. Add flag which distincts buffer created for scanout from other buffers which don't need this restriction.
We previously agreed userspace requires passing buffer size which matches to region constraints. This restriction was already relaxed in xe_bo_dumb_create(). To avoid complex UMD changes related to uapi change let's extend this exception to scanout buffers for platforms which display requires allocation in 64K contiguous chunks.
--- drivers/gpu/drm/xe/xe_bo.c | 20 ++++++++++++++++---- drivers/gpu/drm/xe/xe_device_types.h | 1 + drivers/gpu/drm/xe/xe_vm.c | 2 +- 3 files changed, 18 insertions(+), 5 deletions(-)
drivers/gpu/drm/xe/xe_bo.c +16 -4
@@ -1238,6 +1238,15 @@ void xe_bo_free(struct xe_bo *bo)kfree (bo); } +static bool display_needs64k (u32 flags,u8 vram_flags) +{ +if (flags &XE_BO_FLAG_SCANOUT && + vram_flags &XE_VRAM_FLAGS_DISPLAY_NEED64K ) +return true; + +return false; +} + struct xe_bo *___xe_bo_create_locked(struct xe_device *xe, struct xe_bo *bo, struct xe_tile *tile, struct dma_resv *resv, struct ttm_lru_bulk_move *bulk, size_t size,
@@ -1263,10 +1272,12 @@ 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_NEEDS_64K ))) { + (xe->info.vram_flags &XE_VRAM_FLAGS_NEED64K || +display_needs64k (flags, xe->info.vram_flags) || + flags &XE_BO_NEEDS_64K )) { aligned_size =ALIGN (size,SZ_64K ); -if (type != ttm_bo_type_device) +if (type != ttm_bo_type_device || +display_needs64k (flags, xe->info.vram_flags)) size =ALIGN (size,SZ_64K ); flags |=XE_BO_FLAG_INTERNAL_64K ; alignment =SZ_64K >>PAGE_SHIFT ;
@@ -2315,8 +2326,9 @@ int xe_bo_dumb_create(struct drm_file *file_priv,uint32_t handle;int cpp =DIV_ROUND_UP (args->bpp,8 );int err; +u8 flags_64k =XE_VRAM_FLAGS_NEED64K |XE_VRAM_FLAGS_DISPLAY_NEED64K ;u32 page_size =max_t (u32,PAGE_SIZE , - xe->info.vram_flags &XE_VRAM_FLAGS_NEED64K ?SZ_64K :SZ_4K ); + xe->info.vram_flags & flags_64k ?SZ_64K :SZ_4K ); args->pitch =ALIGN (args->width * cpp,64 ); args->size = ALIGN(mul_u32_u32(args->pitch, args->height),
drivers/gpu/drm/xe/xe_device_types.h +1 -0
@@ -47,6 +47,7 @@ struct xe_pat_ops;#define HAS_HECI_CSCFI (xe) ((xe)->info.has_heci_cscfi)#define XE_VRAM_FLAGS_NEED64K BIT(0) +#define XE_VRAM_FLAGS_DISPLAY_NEED64K BIT(1)#define XE_GT0 0#define XE_GT1 1
drivers/gpu/drm/xe/xe_vm.c +1 -1
@@ -2904,7 +2904,7 @@ static int xe_vm_bind_ioctl_validate_bo(struct xe_device *xe, struct xe_bo *bo,return -EINVAL ; } -if (bo->flags &XE_BO_FLAG_INTERNAL_64K ) { +if (!(bo->flags &XE_BO_FLAG_SCANOUT ) && bo->flags &XE_BO_FLAG_INTERNAL_64K ) { if (XE_IOCTL_DBG(xe, obj_offset & XE_64K_PAGE_MASK) || XE_IOCTL_DBG(xe, addr & XE_64K_PAGE_MASK) ||
Signature · 1 line
2.34.1
PATCH v4 2/2 drm/xe: Use 64K pages for scanout buffers for Battlemage
In reply to Zbigniew KempczyńskiSet BMG platform to use 64K pages for display.
--- drivers/gpu/drm/xe/xe_pci.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/gpu/drm/xe/xe_pci.c +8 -1
@@ -180,6 +180,13 @@ static const struct xe_graphics_desc graphics_xe2 = { XE2_GFX_FEATURES, }; +static const struct xe_graphics_desc graphics_bmg = { + .name ="Xe2_BMG" , + +XE2_GFX_FEATURES , + .vram_flags =XE_VRAM_FLAGS_DISPLAY_NEED64K , +}; +static const struct xe_media_desc media_xem = { .name ="Xe_M" , .ver =12 ,
@@ -361,7 +368,7 @@ static const struct gmdid_map graphics_ip_map[] = { { 1270, &graphics_xelpg }, { 1271, &graphics_xelpg }, { 1274, &graphics_xelpg }, /* Xe_LPG+ */ - { 2001, &graphics_xe2 }, + { 2001, &graphics_bmg }, { 2004, &graphics_xe2 }, };
Signature · 1 line
2.34.1
Patchwork
CI✗ CI.Patch_applied: failure for Restrict BMG to use 64K pages for scanout buffers (rev3)
In reply to Zbigniew Kempczyński== Series Details ==
== Series Details ==
Series: Restrict BMG to use 64K pages for scanout buffers (rev3)
URL : https://patchwork.freedesktop.org/series/135900/
State : failure
== Summary ==
=== Applying kernel patches on branch 'drm-tip' with base: ===
Base commit: 4d1cf05441fc drm-tip: 2024y-07m-23d-07h-53m-13s UTC integration manifest === git am output follows ===
error: patch failed: drivers/gpu/drm/xe/xe_bo.c:1263
error: drivers/gpu/drm/xe/xe_bo.c: patch does not apply
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Applying: drm/xe: Separate 64K physical allocation for display
Patch failed at 0001 drm/xe: Separate 64K physical allocation for display When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".