[igt-dev] [i-g-t V4 16/45] lib/igt_fb: Add copy engine support for XE
Bhanuprakash Modem
bhanuprakash.modem at intel.com
Thu Apr 27 11:29:08 UTC 2023
Add copy engine support for kms framebuffer mappings.
V2: - Drop unused syncobj(Zbigniew)
Signed-off-by: Bhanuprakash Modem <bhanuprakash.modem at intel.com>
---
lib/igt_fb.c | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 76f2e1245..cf24d9e66 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -45,6 +45,7 @@
#include "igt_amd.h"
#include "igt_x86.h"
#include "igt_nouveau.h"
+#include "igt_syncobj.h"
#include "ioctl_wrappers.h"
#include "intel_batchbuffer.h"
#include "intel_chipset.h"
@@ -2489,12 +2490,13 @@ static bool blitter_ok(const struct igt_fb *fb)
static bool use_enginecopy(const struct igt_fb *fb)
{
- if (blitter_ok(fb))
+ if (!is_xe_device(fb->fd) && blitter_ok(fb))
return false;
return fb->modifier == I915_FORMAT_MOD_Yf_TILED ||
is_ccs_modifier(fb->modifier) ||
- !gem_has_mappable_ggtt(fb->fd);
+ (is_xe_device(fb->fd) && fb->modifier == DRM_FORMAT_MOD_LINEAR) ||
+ (is_i915_device(fb->fd) && !gem_has_mappable_ggtt(fb->fd));
}
static bool use_blitter(const struct igt_fb *fb)
@@ -2504,7 +2506,7 @@ static bool use_blitter(const struct igt_fb *fb)
return fb->modifier == I915_FORMAT_MOD_Y_TILED ||
fb->modifier == I915_FORMAT_MOD_Yf_TILED ||
- !gem_has_mappable_ggtt(fb->fd);
+ (is_i915_device(fb->fd) && !gem_has_mappable_ggtt(fb->fd));
}
static void init_buf_ccs(struct intel_buf *buf, int ccs_idx,
@@ -2706,7 +2708,7 @@ static void blitcopy(const struct igt_fb *dst_fb,
src_tiling = igt_fb_mod_to_tiling(src_fb->modifier);
dst_tiling = igt_fb_mod_to_tiling(dst_fb->modifier);
- if (!gem_has_relocations(dst_fb->fd)) {
+ if (is_i915_device(dst_fb->fd) && !gem_has_relocations(dst_fb->fd)) {
igt_require(gem_has_contexts(dst_fb->fd));
ctx = gem_context_create(dst_fb->fd);
ahnd = get_reloc_ahnd(dst_fb->fd, ctx);
@@ -2786,6 +2788,12 @@ static void free_linear_mapping(struct fb_blit_upload *blit)
} else if (is_nouveau_device(fd)) {
igt_nouveau_fb_blit(fb, &linear->fb);
igt_nouveau_delete_bo(&linear->fb);
+ } else if (is_xe_device(fd)) {
+ gem_munmap(linear->map, linear->fb.size);
+ copy_with_engine(blit, fb, &linear->fb);
+
+ syncobj_wait(fd, &blit->ibb->engine_syncobj, 1, INT64_MAX, 0, NULL);
+ gem_close(fd, linear->fb.gem_handle);
} else {
gem_munmap(linear->map, linear->fb.size);
gem_set_domain(fd, linear->fb.gem_handle,
@@ -2863,6 +2871,11 @@ static void setup_linear_mapping(struct fb_blit_upload *blit)
igt_nouveau_fb_blit(&linear->fb, fb);
linear->map = igt_nouveau_mmap_bo(&linear->fb, PROT_READ | PROT_WRITE);
+ } else if (is_xe_device(fd)) {
+ copy_with_engine(blit, &linear->fb, fb);
+
+ linear->map = xe_bo_mmap_ext(fd, linear->fb.gem_handle,
+ linear->fb.size, PROT_READ | PROT_WRITE);
} else {
/* Copy fb content to linear BO */
gem_set_domain(fd, linear->fb.gem_handle,
@@ -2969,6 +2982,9 @@ static void *map_bo(int fd, struct igt_fb *fb)
PROT_READ | PROT_WRITE);
else if (is_nouveau_device(fd))
ptr = igt_nouveau_mmap_bo(fb, PROT_READ | PROT_WRITE);
+ else if (is_xe_device(fd))
+ ptr = xe_bo_mmap_ext(fd, fb->gem_handle,
+ fb->size, PROT_READ | PROT_WRITE);
else
igt_assert(false);
--
2.40.0
More information about the igt-dev
mailing list