[i-g-t 06/43] lib/intel_bufops: Add Xe path in bufops

Bhanuprakash Modem bhanuprakash.modem at intel.com
Fri Mar 24 08:09:26 UTC 2023


From: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>

Signed-off-by: Zbigniew Kempczyński <zbigniew.kempczynski at intel.com>
---
 lib/intel_bufops.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/lib/intel_bufops.c b/lib/intel_bufops.c
index 81f7b9518..95bee85b5 100644
--- a/lib/intel_bufops.c
+++ b/lib/intel_bufops.c
@@ -26,6 +26,8 @@
 #include <cairo.h>
 
 #include "i915/gem_create.h"
+#include "xe/xe_ioctl.h"
+#include "xe/xe_query.h"
 #include "igt.h"
 #include "igt_x86.h"
 #include "intel_bufops.h"
@@ -488,6 +490,9 @@ static void *mmap_write(int fd, struct intel_buf *buf)
 {
 	void *map = NULL;
 
+	if (is_xe_device(fd))
+		return xe_bo_map(fd, buf->handle, buf->surface[0].size);
+
 	if (gem_has_lmem(fd)) {
 		/*
 		 * set/get_caching and set_domain are no longer supported on
@@ -530,6 +535,9 @@ static void *mmap_read(int fd, struct intel_buf *buf)
 {
 	void *map = NULL;
 
+	if (is_xe_device(fd))
+		return xe_bo_map(fd, buf->handle, buf->surface[0].size);
+
 	if (gem_has_lmem(fd)) {
 		/*
 		 * set/get_caching and set_domain are no longer supported on
@@ -899,9 +907,18 @@ static void __intel_buf_init(struct buf_ops *bops,
 	buf->size = size;
 	buf->handle = handle;
 
-	if (!handle)
-		if (__gem_create_in_memory_regions(bops->fd, &buf->handle, &size, region))
-			igt_assert_eq(__gem_create(bops->fd, &size, &buf->handle), 0);
+	if (!handle) {
+		if (is_i915_device(bops->fd)) {
+			if (__gem_create_in_memory_regions(bops->fd, &buf->handle, &size, region))
+				igt_assert_eq(__gem_create(bops->fd, &size, &buf->handle), 0);
+		} else {
+			size = ALIGN(size, xe_get_default_alignment(bops->fd));
+			buf->handle = xe_bo_create_flags(bops->fd, 0, size,
+							 xe_has_vram(bops->fd) ?
+							 vram_memory(bops->fd, 0) :
+							 system_memory(bops->fd));
+		}
+	}
 
 	/* Store gem bo size */
 	buf->bo_size = size;
-- 
2.40.0



More information about the Intel-gfx-trybot mailing list