[PATCH i-g-t 4/8] lib/igt_fb: Add support for allocating buffers for XE

Zbigniew Kempczyński zbigniew.kempczynski at intel.com
Thu Mar 23 21:11:59 UTC 2023


From: Bhanuprakash Modem <bhanuprakash.modem at intel.com>

Add support to create a buffer object to the XE driver.

Credits-to: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
 lib/igt_fb.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index ba89e1f60e..6f7ea59788 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -49,6 +49,8 @@
 #include "intel_batchbuffer.h"
 #include "intel_chipset.h"
 #include "intel_bufops.h"
+#include "xe/xe_ioctl.h"
+#include "xe/xe_query.h"
 
 /**
  * SECTION:igt_fb
@@ -434,7 +436,7 @@ void igt_get_fb_tile_size(int fd, uint64_t modifier, int fb_bpp,
 
 	switch (modifier) {
 	case DRM_FORMAT_MOD_LINEAR :
-		if (is_i915_device(fd))
+		if (is_intel_device(fd))
 			*width_ret = 64;
 		else
 			*width_ret = 1;
@@ -838,7 +840,7 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
 
 		return (uint64_t) fb->strides[plane] *
 			ALIGN(fb->plane_height[plane], tile_height);
-	} else if (is_gen12_ccs_plane(fb, plane)) {
+	} else if (is_i915_device(fb->fd) && is_gen12_ccs_plane(fb, plane)) {
 		uint64_t size;
 
 		/* The AUX CCS surface must be page aligned */
@@ -888,7 +890,7 @@ static unsigned int get_plane_alignment(struct igt_fb *fb, int color_plane)
 	unsigned int tile_row_size;
 	unsigned int alignment;
 
-	if (!(is_i915_device(fb->fd) &&
+	if (!(is_intel_device(fb->fd) &&
 	      is_gen12_ccs_modifier(fb->modifier) &&
 	      is_yuv_semiplanar_plane(fb, color_plane)))
 		return 0;
@@ -924,6 +926,9 @@ static uint64_t calc_fb_size(struct igt_fb *fb)
 		size += calc_plane_size(fb, plane);
 	}
 
+	if (is_xe_device(fb->fd))
+		size = ALIGN(size, xe_get_default_alignment(fb->fd));
+
 	return size;
 }
 
@@ -1143,8 +1148,8 @@ static int create_bo_for_fb(struct igt_fb *fb, bool prefer_sysmem)
 	 * them, so we need to make sure to use a device BO then.
 	 */
 	if (fb->modifier || fb->size || fb->strides[0] ||
-	    (is_i915_device(fd) && igt_format_is_yuv(fb->drm_format)) ||
-	    (is_i915_device(fd) && igt_format_is_fp16(fb->drm_format)) ||
+	    (is_intel_device(fd) && igt_format_is_yuv(fb->drm_format)) ||
+	    (is_intel_device(fd) && igt_format_is_fp16(fb->drm_format)) ||
 	    (is_amdgpu_device(fd) && igt_format_is_yuv(fb->drm_format)) ||
 	    is_nouveau_device(fd))
 		device_bo = true;
@@ -1168,6 +1173,11 @@ static int create_bo_for_fb(struct igt_fb *fb, bool prefer_sysmem)
 					       fb->strides[0]);
 			/* If we can't use fences, we won't use ggtt detiling later. */
 			igt_assert(err == 0 || err == -EOPNOTSUPP);
+		} else if (is_xe_device(fd)) {
+			fb->gem_handle = xe_bo_create_flags(fd, 0, fb->size,
+							    xe_has_vram(fd) ?
+							      vram_memory(fd, 0) :
+							      system_memory(fd));
 		} else if (is_vc4_device(fd)) {
 			fb->gem_handle = igt_vc4_create_bo(fd, fb->size);
 
@@ -2447,10 +2457,10 @@ static bool fast_blit_ok(const struct igt_fb *fb)
 
 static bool blitter_ok(const struct igt_fb *fb)
 {
-	if (!is_i915_device(fb->fd))
+	if (!is_intel_device(fb->fd))
 		return false;
 
-	if (is_ccs_modifier(fb->modifier))
+	if (is_i915_device(fb->fd) && is_ccs_modifier(fb->modifier))
 		return false;
 
 	for (int i = 0; i < fb->num_planes; i++) {
@@ -2485,6 +2495,7 @@ static bool use_enginecopy(const struct igt_fb *fb)
 		return false;
 
 	return fb->modifier == I915_FORMAT_MOD_Yf_TILED ||
+	       (is_xe_device(fb->fd) && fb->modifier == DRM_FORMAT_MOD_LINEAR) ||
 	       is_ccs_modifier(fb->modifier) ||
 	       !gem_has_mappable_ggtt(fb->fd);
 }
-- 
2.34.1



More information about the Intel-gfx-trybot mailing list