Igt-dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Mazur <robert.mazur@imgtec.com>
To: <igt-dev@lists.freedesktop.org>
Cc: Alessio Belle <alessio.belle@imgtec.com>,
	Luigi Santivetti <luigi.santivetti@imgtec.com>,
	Brajesh Gupta <brajesh.gupta@imgtec.com>,
	Robert Mazur <robert.mazur@imgtec.com>,
	Matt Coster <matt.coster@imgtec.com>
Subject: [PATCH i-g-t v2 01/10] tests/imagination: Add framework for Imagination tests
Date: Fri, 17 Jul 2026 11:18:14 +0200	[thread overview]
Message-ID: <20260717-test-imagination-add-support-v2-1-e1bf415adcee@imgtec.com> (raw)
In-Reply-To: <20260717-test-imagination-add-support-v2-0-e1bf415adcee@imgtec.com>

From: Matt Coster <matt.coster@imgtec.com>

Also added initial GEM buffer object creation tests.

Signed-off-by: Matt Coster <matt.coster@imgtec.com>
Signed-off-by: Robert Mazur <robert.mazur@imgtec.com>
---
 docs/platforms.md             |  1 +
 lib/drmtest.c                 | 11 +++++++
 lib/drmtest.h                 |  3 ++
 lib/igt_pvr.c                 | 56 ++++++++++++++++++++++++++++++++++++
 lib/igt_pvr.h                 | 17 +++++++++++
 lib/meson.build               |  1 +
 meson.build                   |  9 ++++++
 tests/imagination/meson.build | 13 +++++++++
 tests/imagination/pvr_gem.c   | 67 +++++++++++++++++++++++++++++++++++++++++++
 tests/meson.build             |  2 ++
 10 files changed, 180 insertions(+)

diff --git a/docs/platforms.md b/docs/platforms.md
index 214f53c1d..ea86a89c9 100644
--- a/docs/platforms.md
+++ b/docs/platforms.md
@@ -25,6 +25,7 @@ Support exists for the following platforms:
 - Panthor
 - Virtual GPUs (e.g., virtio_gpu in QEMU/KVM/AVD or vmwgfx)
 - Virtual display (vkms)
+- Imagination (powervr)
 
 #### Intel
 
diff --git a/lib/drmtest.c b/lib/drmtest.c
index b0be06a75..1e789d2af 100644
--- a/lib/drmtest.c
+++ b/lib/drmtest.c
@@ -143,6 +143,11 @@ bool is_msm_device(int fd)
 	return __is_device(fd, "msm");
 }
 
+bool is_pvr_device(int fd)
+{
+	return __is_device(fd, "powervr");
+}
+
 bool is_nouveau_device(int fd)
 {
 	/* Currently all nouveau-specific codepaths require libdrm */
@@ -227,6 +232,7 @@ static const struct module {
 	{ DRIVER_MSM, "msm" },
 	{ DRIVER_PANFROST, "panfrost" },
 	{ DRIVER_PANTHOR, "panthor" },
+	{ DRIVER_POWERVR, "powervr" },
 	{ DRIVER_V3D, "v3d" },
 	{ DRIVER_VC4, "vc4" },
 	{ DRIVER_VGEM, "vgem" },
@@ -988,6 +994,11 @@ void igt_require_amdgpu(int fd)
 	igt_require(is_amdgpu_device(fd));
 }
 
+void igt_require_imagination(int fd)
+{
+	igt_require(is_pvr_device(fd));
+}
+
 void igt_require_intel(int fd)
 {
 	igt_require(is_intel_device(fd));
diff --git a/lib/drmtest.h b/lib/drmtest.h
index 9d488b274..012de9dee 100644
--- a/lib/drmtest.h
+++ b/lib/drmtest.h
@@ -59,6 +59,7 @@ int __get_drm_device_name(int fd, char *name, int name_size);
 #define DRIVER_VIRTIO	(1 << 10)
 #define DRIVER_PANTHOR	(1 << 11)
 #define DRIVER_ASAHI	(1 << 12)
+#define DRIVER_POWERVR	(1 << 13)
 
 /*
  * Exclude DRIVER_VGEM and DRIVER_VIRTIO from DRIVER_ANY since if you run
@@ -137,6 +138,7 @@ int drm_prepare_filtered_multigpu(int chipset);
 int drm_open_filtered_card(int idx);
 
 void igt_require_amdgpu(int fd);
+void igt_require_imagination(int fd);
 void igt_require_intel(int fd);
 void igt_require_i915(int fd);
 void igt_require_nouveau(int fd);
@@ -150,6 +152,7 @@ bool is_i915_device(int fd);
 bool is_mtk_device(int fd);
 bool is_msm_device(int fd);
 bool is_nouveau_device(int fd);
+bool is_pvr_device(int fd);
 bool is_vc4_device(int fd);
 bool is_xe_device(int fd);
 bool is_intel_device(int fd);
diff --git a/lib/igt_pvr.c b/lib/igt_pvr.c
new file mode 100644
index 000000000..957d459b1
--- /dev/null
+++ b/lib/igt_pvr.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+/* Copyright (c) 2026 Imagination Technologies Ltd. All Rights Reserved */
+
+#include "igt_pvr.h"
+
+#include "drmtest.h"
+#include "ioctl_wrappers.h"
+
+#include "pvr_drm.h"
+
+#include <limits.h>
+#include <stddef.h>
+#include <stdint.h>
+
+#include <sys/types.h>
+
+/**
+ * SECTION:igt_pvr
+ * @short_description: PowerVR support library
+ * @title: pvr
+ * @include: igt.h
+ *
+ * This library provides various auxiliary helper functions for writing PowerVR
+ * tests.
+ */
+
+uint32_t igt_pvr_ioctl_create_bo(int fd, size_t *size)
+{
+	struct drm_pvr_ioctl_create_bo_args arg = {
+		.size = *size,
+	};
+
+	do_ioctl(fd, DRM_IOCTL_PVR_CREATE_BO, &arg);
+
+	igt_assert(arg.size >= *size && arg.size <= SIZE_MAX);
+	*size = (size_t)arg.size;
+
+	return arg.handle;
+}
+
+off_t igt_pvr_ioctl_get_bo_mmap_offset(int fd, uint32_t handle)
+{
+	struct drm_pvr_ioctl_get_bo_mmap_offset_args arg = {
+		.handle = handle,
+	};
+
+	do_ioctl(fd, DRM_IOCTL_PVR_GET_BO_MMAP_OFFSET, &arg);
+
+	/*
+	 * There is no OFF_MAX equivalent to SIZE_MAX; use the identical (by
+	 * definition) PTRDIFF_MAX instead.
+	 */
+	igt_assert(arg.offset <= PTRDIFF_MAX);
+
+	return (off_t)arg.offset;
+}
diff --git a/lib/igt_pvr.h b/lib/igt_pvr.h
new file mode 100644
index 000000000..33d826077
--- /dev/null
+++ b/lib/igt_pvr.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0 or MIT */
+/* Copyright (c) 2026 Imagination Technologies Ltd. All Rights Reserved */
+
+#ifndef IGT_PVR_H
+#define IGT_PVR_H
+
+#include "pvr_drm.h"
+
+#include <stddef.h>
+#include <stdint.h>
+
+#include <sys/types.h>
+
+uint32_t igt_pvr_ioctl_create_bo(int fd, size_t *size);
+off_t igt_pvr_ioctl_get_bo_mmap_offset(int fd, uint32_t handle);
+
+#endif /* IGT_PVR_H */
diff --git a/lib/meson.build b/lib/meson.build
index c45a96530..c1bc81bab 100644
--- a/lib/meson.build
+++ b/lib/meson.build
@@ -135,6 +135,7 @@ lib_sources = [
 	'xe/xe_sriov_debugfs.c',
 	'xe/xe_sriov_provisioning.c',
 	'xe/xe_util.c',
+	'igt_pvr.c',
 
 	# Vendored libraries:
 	'vendor/uwildmat/uwildmat.c',
diff --git a/meson.build b/meson.build
index e09122a09..55c39c2ea 100644
--- a/meson.build
+++ b/meson.build
@@ -289,6 +289,7 @@ asahidir = join_paths(libexecdir, 'asahi')
 msmdir = join_paths(libexecdir, 'msm')
 panfrostdir = join_paths(libexecdir, 'panfrost')
 panthordir = join_paths(libexecdir, 'panthor')
+pvrdir = join_paths(libexecdir, 'imagination')
 unigrafdir = join_paths(libexecdir, 'unigraf')
 v3ddir = join_paths(libexecdir, 'v3d')
 vc4dir = join_paths(libexecdir, 'vc4')
@@ -384,6 +385,13 @@ if get_option('use_rpath')
 		vmwgfx_rpathdir = join_paths(vmwgfx_rpathdir, '..')
 	endforeach
 	vmwgfx_rpathdir = join_paths(vmwgfx_rpathdir, libdir)
+
+	pvrdir_rpathdir = '$ORIGIN'
+	foreach p : pvrdir.split('/')
+		pvrdir_rpathdir = join_paths(pvrdir_rpathdir, '..')
+	endforeach
+	pvrdir_rpathdir = join_paths(pvrdir_rpathdir, libdir)
+
 else
 	bindir_rpathdir = ''
 	libexecdir_rpathdir = ''
@@ -397,6 +405,7 @@ else
 	vkms_rpathdir = ''
 	unigraf_rpathdir = ''
 	vmwgfx_rpathdir = ''
+	pvrdir_rpathdir = ''
 endif
 
 build_testplan = get_option('testplan')
diff --git a/tests/imagination/meson.build b/tests/imagination/meson.build
new file mode 100644
index 000000000..65b90c39f
--- /dev/null
+++ b/tests/imagination/meson.build
@@ -0,0 +1,13 @@
+pvr_progs = [ 'pvr_gem',
+	    ]
+
+pvr_deps = test_deps
+
+foreach prog : pvr_progs
+	test_executables += executable(prog, prog + '.c',
+				       dependencies : pvr_deps,
+				       install_dir : pvrdir,
+				       install_rpath : pvrdir_rpathdir,
+				       install : true)
+	test_list += join_paths('pvr', prog)
+endforeach
diff --git a/tests/imagination/pvr_gem.c b/tests/imagination/pvr_gem.c
new file mode 100644
index 000000000..b80d202a2
--- /dev/null
+++ b/tests/imagination/pvr_gem.c
@@ -0,0 +1,67 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+/* Copyright (c) 2026 Imagination Technologies Ltd. All Rights Reserved */
+
+#include "igt.h"
+#include "igt_pvr.h"
+
+#include "pvr_drm.h"
+
+#include <linux/errno.h>
+
+#include <stddef.h>
+#include <stdint.h>
+
+int igt_main()
+{
+	int fd;
+
+	igt_fixture()
+	{
+		fd = drm_open_driver(DRIVER_POWERVR);
+	}
+
+	igt_describe("Test valid buffer object creation");
+	igt_subtest("create-bo-4096")
+	{
+		size_t size = 4096;
+		uint32_t handle = igt_pvr_ioctl_create_bo(fd, &size);
+
+		gem_close(fd, handle);
+	}
+
+	igt_describe("Test buffer object creation with 0 size");
+	igt_subtest("create-bo-0")
+	{
+		struct drm_pvr_ioctl_create_bo_args arg = {
+			.size = 0,
+		};
+
+		do_ioctl_err(fd, DRM_IOCTL_PVR_CREATE_BO, &arg, EINVAL);
+	}
+
+	igt_describe("Test buffer object creation with bad padding");
+	igt_subtest("create-bo-bad-padding")
+	{
+		struct drm_pvr_ioctl_create_bo_args arg = {
+			.size = 4096,
+			._padding_c = 0xbad6bad6,
+		};
+
+		do_ioctl_err(fd, DRM_IOCTL_PVR_CREATE_BO, &arg, EINVAL);
+	}
+
+	igt_describe("Test buffer object creation with unaligned size");
+	igt_subtest("create-bo-unaligned-fail")
+	{
+		struct drm_pvr_ioctl_create_bo_args arg = {
+			.size = 4000,
+		};
+
+		do_ioctl_err(fd, DRM_IOCTL_PVR_CREATE_BO, &arg, EINVAL);
+	}
+
+	igt_fixture()
+	{
+		close(fd);
+	}
+}
diff --git a/tests/meson.build b/tests/meson.build
index 6d90627b9..63adc61b9 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -561,3 +561,5 @@ if not meson.is_cross_build()
 endif
 
 subdir('intel-ci')
+
+subdir('imagination')

-- 
2.43.0


  reply	other threads:[~2026-07-17  9:19 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17  9:18 [PATCH i-g-t v2 00/10] tests/imagination: Add initial test coverage for Imagination DRM driver Robert Mazur
2026-07-17  9:18 ` Robert Mazur [this message]
2026-07-17  9:18 ` [PATCH i-g-t v2 02/10] tests/imagination: Add GEM mmap tests Robert Mazur
2026-07-17  9:18 ` [PATCH i-g-t v2 03/10] tests/imagination: Add DEV_QUERY tests Robert Mazur
2026-07-17  9:18 ` [PATCH i-g-t v2 04/10] tests/imagination: Add GPU ID test Robert Mazur
2026-07-17  9:18 ` [PATCH i-g-t v2 05/10] tests/imagination: Add DEV_QUERY heap info tests Robert Mazur
2026-07-17  9:18 ` [PATCH i-g-t v2 06/10] tests/imagination: Add DEV_QUERY static data area tests Robert Mazur
2026-07-17  9:18 ` [PATCH i-g-t v2 07/10] tests/imagination: Add VM_CONTEXT tests Robert Mazur
2026-07-17  9:18 ` [PATCH i-g-t v2 08/10] tests/imagination: Add tests for free list and hwrt creation ioctls Robert Mazur
2026-07-17  9:18 ` [PATCH i-g-t v2 09/10] tests/imagination: Add DEV_QUERY quirks and enhancements tests Robert Mazur
2026-07-17  9:18 ` [PATCH i-g-t v2 10/10] tests/imagination: Add DEV_QUERY runtime_info tests Robert Mazur
2026-07-17 11:10 ` ✓ Xe.CI.BAT: success for tests/imagination: Add initial test coverage for Imagination DRM driver (rev2) Patchwork
2026-07-17 12:06 ` ✓ i915.CI.BAT: " Patchwork
2026-07-17 16:51 ` ✓ Xe.CI.FULL: " Patchwork
2026-07-17 22:08 ` ✗ i915.CI.Full: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260717-test-imagination-add-support-v2-1-e1bf415adcee@imgtec.com \
    --to=robert.mazur@imgtec.com \
    --cc=alessio.belle@imgtec.com \
    --cc=brajesh.gupta@imgtec.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=luigi.santivetti@imgtec.com \
    --cc=matt.coster@imgtec.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox