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>,
	Donald Robson <donald.robson@imgtec.com>
Subject: [PATCH i-g-t v2 03/10] tests/imagination: Add DEV_QUERY tests
Date: Fri, 17 Jul 2026 11:18:16 +0200	[thread overview]
Message-ID: <20260717-test-imagination-add-support-v2-3-e1bf415adcee@imgtec.com> (raw)
In-Reply-To: <20260717-test-imagination-add-support-v2-0-e1bf415adcee@imgtec.com>

From: Donald Robson <donald.robson@imgtec.com>

Add subtests exercising DRM_IOCTL_PVR_DEV_QUERY: invalid type,
successful query of all types, and undersized buffer error paths.

Signed-off-by: Donald Robson <donald.robson@imgtec.com>
Signed-off-by: Robert Mazur <robert.mazur@imgtec.com>
---
 lib/igt_pvr.c                     | 19 ++++++++
 lib/igt_pvr.h                     |  4 ++
 tests/imagination/meson.build     |  3 +-
 tests/imagination/pvr_dev_query.c | 99 +++++++++++++++++++++++++++++++++++++++
 4 files changed, 124 insertions(+), 1 deletion(-)

diff --git a/lib/igt_pvr.c b/lib/igt_pvr.c
index 957d459b1..a729618d0 100644
--- a/lib/igt_pvr.c
+++ b/lib/igt_pvr.c
@@ -54,3 +54,22 @@ off_t igt_pvr_ioctl_get_bo_mmap_offset(int fd, uint32_t handle)
 
 	return (off_t)arg.offset;
 }
+
+struct drm_pvr_ioctl_dev_query_args
+igt_pvr_ioctl_dev_query(int fd, enum drm_pvr_dev_query type, uint64_t size,
+			void *pointer, int expect_err)
+{
+	struct drm_pvr_ioctl_dev_query_args args = {
+		.type = type,
+		.size = size,
+		.pointer = (uint64_t)pointer,
+	};
+
+	if (expect_err)
+		do_ioctl_err(fd, DRM_IOCTL_PVR_DEV_QUERY, &args, expect_err);
+	else
+		do_ioctl(fd, DRM_IOCTL_PVR_DEV_QUERY, &args);
+
+	return args;
+}
+
diff --git a/lib/igt_pvr.h b/lib/igt_pvr.h
index 33d826077..e949772e4 100644
--- a/lib/igt_pvr.h
+++ b/lib/igt_pvr.h
@@ -14,4 +14,8 @@
 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);
 
+struct drm_pvr_ioctl_dev_query_args
+igt_pvr_ioctl_dev_query(int fd, enum drm_pvr_dev_query type, uint64_t size,
+			void *pointer, int expect_err);
+
 #endif /* IGT_PVR_H */
diff --git a/tests/imagination/meson.build b/tests/imagination/meson.build
index 65b90c39f..62930da2b 100644
--- a/tests/imagination/meson.build
+++ b/tests/imagination/meson.build
@@ -1,4 +1,5 @@
-pvr_progs = [ 'pvr_gem',
+pvr_progs = [ 'pvr_dev_query',
+	      'pvr_gem',
 	    ]
 
 pvr_deps = test_deps
diff --git a/tests/imagination/pvr_dev_query.c b/tests/imagination/pvr_dev_query.c
new file mode 100644
index 000000000..cda2b73cc
--- /dev/null
+++ b/tests/imagination/pvr_dev_query.c
@@ -0,0 +1,99 @@
+// 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 <errno.h>
+#include <stdint.h>
+#include <unistd.h>
+
+int igt_main()
+{
+	const enum drm_pvr_dev_query types[] = {
+		DRM_PVR_DEV_QUERY_GPU_INFO_GET,
+		DRM_PVR_DEV_QUERY_RUNTIME_INFO_GET,
+		DRM_PVR_DEV_QUERY_QUIRKS_GET,
+		DRM_PVR_DEV_QUERY_ENHANCEMENTS_GET,
+		DRM_PVR_DEV_QUERY_HEAP_INFO_GET,
+		DRM_PVR_DEV_QUERY_STATIC_DATA_AREAS_GET,
+	};
+
+	const uint64_t sizes[] = {
+		[DRM_PVR_DEV_QUERY_GPU_INFO_GET] =
+			sizeof(struct drm_pvr_dev_query_gpu_info),
+		[DRM_PVR_DEV_QUERY_RUNTIME_INFO_GET] =
+			sizeof(struct drm_pvr_dev_query_runtime_info),
+		[DRM_PVR_DEV_QUERY_QUIRKS_GET] =
+			sizeof(struct drm_pvr_dev_query_quirks),
+		[DRM_PVR_DEV_QUERY_ENHANCEMENTS_GET] =
+			sizeof(struct drm_pvr_dev_query_enhancements),
+		[DRM_PVR_DEV_QUERY_HEAP_INFO_GET] =
+			sizeof(struct drm_pvr_dev_query_heap_info),
+		[DRM_PVR_DEV_QUERY_STATIC_DATA_AREAS_GET] =
+			sizeof(struct drm_pvr_dev_query_static_data_areas),
+	};
+
+	struct drm_pvr_dev_query_gpu_info gpu_info = {0};
+	struct drm_pvr_dev_query_runtime_info runtime_info = {0};
+	struct drm_pvr_dev_query_quirks quirks = {0};
+	struct drm_pvr_dev_query_enhancements enhancements = {0};
+	struct drm_pvr_dev_query_heap_info heap_info = {0};
+	struct drm_pvr_dev_query_static_data_areas static_data_areas = {0};
+
+	void *const containers[] = {
+		[DRM_PVR_DEV_QUERY_GPU_INFO_GET] = &gpu_info,
+		[DRM_PVR_DEV_QUERY_RUNTIME_INFO_GET] = &runtime_info,
+		[DRM_PVR_DEV_QUERY_QUIRKS_GET] = &quirks,
+		[DRM_PVR_DEV_QUERY_ENHANCEMENTS_GET] = &enhancements,
+		[DRM_PVR_DEV_QUERY_HEAP_INFO_GET] = &heap_info,
+		[DRM_PVR_DEV_QUERY_STATIC_DATA_AREAS_GET] = &static_data_areas,
+	};
+
+	int fd;
+
+	static_assert(ARRAY_SIZE(types) == ARRAY_SIZE(sizes));
+	static_assert(ARRAY_SIZE(types) == ARRAY_SIZE(containers));
+
+	igt_fixture()
+	{
+		fd = drm_open_driver(DRIVER_POWERVR);
+
+		for (int i = 0; i < ARRAY_SIZE(types); i++)
+			memset(containers[i], 0, sizes[i]);
+	}
+
+	igt_describe("Test invalid dev query");
+	igt_subtest("dev-query-invalid") {
+		igt_pvr_ioctl_dev_query(fd, (enum drm_pvr_dev_query)-1, 0, NULL,
+					EINVAL);
+	}
+
+	igt_describe("Test valid dev query");
+	igt_subtest("dev-query-success-all") {
+		for (int i = 0; i < ARRAY_SIZE(types); i++) {
+			struct drm_pvr_ioctl_dev_query_args args =
+				igt_pvr_ioctl_dev_query(fd, types[i], 0, NULL, 0);
+
+			igt_assert(args.size);
+			igt_assert(args.size <= sizes[i]);
+
+			igt_pvr_ioctl_dev_query(fd, types[i], args.size, containers[i], 0);
+		}
+	}
+
+	igt_describe("Test dev query with too small size");
+	igt_subtest("dev-query-fail-too-small") {
+		for (int i = 0; i < ARRAY_SIZE(types); i++) {
+			igt_pvr_ioctl_dev_query(fd, types[i], 0, containers[i], EINVAL);
+			igt_pvr_ioctl_dev_query(fd, types[i], 1, containers[i],	EINVAL);
+		}
+	}
+
+	igt_fixture()
+	{
+		close(fd);
+	}
+}

-- 
2.43.0


  parent reply	other threads:[~2026-07-17  9:23 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 ` [PATCH i-g-t v2 01/10] tests/imagination: Add framework for Imagination tests Robert Mazur
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 ` Robert Mazur [this message]
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-3-e1bf415adcee@imgtec.com \
    --to=robert.mazur@imgtec.com \
    --cc=alessio.belle@imgtec.com \
    --cc=brajesh.gupta@imgtec.com \
    --cc=donald.robson@imgtec.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=luigi.santivetti@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