[PATCH v4 1/2] drm/xe: Separate 64K physical allocation for display

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Tue Jul 23 09:02:25 UTC 2024


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.

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
Cc: Matthew Auld <matthew.auld at intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi at intel.com>
Cc: Thomas Hellström <thomas.hellstrom at linux.intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Cc: Juha-Pekka Heikkilä <juha-pekka.heikkila at intel.com>
---
 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(-)

diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 31192d983d9e..079f24cc6cbf 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -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),
diff --git a/drivers/gpu/drm/xe/xe_device_types.h b/drivers/gpu/drm/xe/xe_device_types.h
index 36252d5b1663..2c5b60dda778 100644
--- a/drivers/gpu/drm/xe/xe_device_types.h
+++ b/drivers/gpu/drm/xe/xe_device_types.h
@@ -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
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index 3fde2c8292ad..1b49c8dedc30 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -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) ||
-- 
2.34.1



More information about the Intel-xe mailing list