Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3] drm/xe: Align all 64k VRAM buffers physically when multiple of 64k.
@ 2024-08-22 14:23 Maarten Lankhorst
  2024-08-22 14:46 ` ✓ CI.Patch_applied: success for " Patchwork
                   ` (8 more replies)
  0 siblings, 9 replies; 11+ messages in thread
From: Maarten Lankhorst @ 2024-08-22 14:23 UTC (permalink / raw)
  To: intel-xe
  Cc: Maarten Lankhorst, Zbigniew Kempczyński, Matthew Auld,
	Rodrigo Vivi, Thomas Hellström, Juha-Pekka Heikkilä

For CCS formats on affected platforms, CCS can be used freely, but
display engine requires a multiple of 64k physical pages. No other
changes are needed.

At the BO creation time we don't know if the BO will be used for CCS
or not. If the scanout flag is set, and the BO is a multiple of 64k,
we take the safe route and force the physical alignment of 64k pages.

If the BO is not a multiple of 64k, or the scanout flag was not set
at BO creation, we reject it for usage as CCS in display. The physical
pages are likely not aligned correctly, and this will cause corruption
when used as FB.

This is a slightly different approach from my previous patch. Instead
of requiring a scanout flag at FB creation, we now make all buffers of
the right size physically aligned correctly, so no change from userspace
is needed.

It will be interesting to see if it affects performance in any way,
could potentially even improve things with 64k PTE's.

Inspired by Zbigniews patch.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Co-developed-by: Zbigniew Kempczyński <zbigniew.kempczynski@intel.com>
Cc: Matthew Auld <matthew.auld@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Juha-Pekka Heikkilä <juha-pekka.heikkila@intel.com>
---
Changes since previous version:
- Drop DISPLAY_NEED64K.
- Hardcode check for I915_FORMAT_MOD_4_TILED_BMG_CCS, only one affected.

 drivers/gpu/drm/xe/display/intel_fb_bo.c |  5 +++++
 drivers/gpu/drm/xe/xe_bo.c               | 10 ++++++++++
 drivers/gpu/drm/xe/xe_vm.c               |  3 ++-
 3 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/display/intel_fb_bo.c b/drivers/gpu/drm/xe/display/intel_fb_bo.c
index f835492f73fb4..de613325e0bb0 100644
--- a/drivers/gpu/drm/xe/display/intel_fb_bo.c
+++ b/drivers/gpu/drm/xe/display/intel_fb_bo.c
@@ -28,6 +29,10 @@ int intel_fb_bo_framebuffer_init(struct intel_framebuffer *intel_fb,
 	struct xe_device *xe = to_xe_device(bo->ttm.base.dev);
 	int ret;
 
+	if (XE_IOCTL_DBG(xe, mode_cmd->modifier[0] == I915_FORMAT_MOD_4_TILED_BMG_CCS &&
+			     !(bo->flags & XE_BO_FLAG_NEEDS_64K)))
+		return -EINVAL;
+
 	xe_bo_get(bo);
 
 	ret = ttm_bo_reserve(&bo->ttm, true, false, NULL);
diff --git a/drivers/gpu/drm/xe/xe_bo.c b/drivers/gpu/drm/xe/xe_bo.c
index 6ed0e19552159..dd54cbc14e9d8 100644
--- a/drivers/gpu/drm/xe/xe_bo.c
+++ b/drivers/gpu/drm/xe/xe_bo.c
@@ -2019,6 +2019,16 @@ int xe_gem_create_ioctl(struct drm_device *dev, void *data,
 
 	bo_flags |= args->placement << (ffs(XE_BO_FLAG_SYSTEM) - 1);
 
+	/*
+	 * Lets see what happens if we simply align any buffer that's
+	 * a multiple of 64k to 64k in places where it's not officially
+	 * needed.
+	 */
+	if ((bo_flags & XE_BO_FLAG_VRAM_MASK) &&
+	    !(xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K) &&
+	    !(args->size % SZ_64K))
+		bo_flags |= XE_BO_FLAG_NEEDS_64K;
+
 	if (args->flags & DRM_XE_GEM_CREATE_FLAG_NEEDS_VISIBLE_VRAM) {
 		if (XE_IOCTL_DBG(xe, !(bo_flags & XE_BO_FLAG_VRAM_MASK)))
 			return -EINVAL;
diff --git a/drivers/gpu/drm/xe/xe_vm.c b/drivers/gpu/drm/xe/xe_vm.c
index d1bfd0b6e9558..af215f6d6588b 100644
--- a/drivers/gpu/drm/xe/xe_vm.c
+++ b/drivers/gpu/drm/xe/xe_vm.c
@@ -2878,7 +2878,8 @@ 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_INTERNAL_64K) &&
+	    (xe->info.vram_flags & XE_VRAM_FLAGS_NEED64K)) {
 		if (XE_IOCTL_DBG(xe, obj_offset &
 				 XE_64K_PAGE_MASK) ||
 		    XE_IOCTL_DBG(xe, addr & XE_64K_PAGE_MASK) ||
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-08-22 20:56 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-22 14:23 [PATCH v3] drm/xe: Align all 64k VRAM buffers physically when multiple of 64k Maarten Lankhorst
2024-08-22 14:46 ` ✓ CI.Patch_applied: success for " Patchwork
2024-08-22 14:46 ` ✗ CI.checkpatch: warning " Patchwork
2024-08-22 14:48 ` ✓ CI.KUnit: success " Patchwork
2024-08-22 14:55 ` [PATCH v3] " Rodrigo Vivi
2024-08-22 16:16   ` Souza, Jose
2024-08-22 14:59 ` ✓ CI.Build: success for " Patchwork
2024-08-22 15:02 ` ✓ CI.Hooks: " Patchwork
2024-08-22 15:03 ` ✓ CI.checksparse: " Patchwork
2024-08-22 15:22 ` ✓ CI.BAT: " Patchwork
2024-08-22 20:56 ` ✓ CI.FULL: " Patchwork

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox