From: Deborah Brouwer <deborah.brouwer@collabora.com>
To: igt-dev@lists.freedesktop.org
Cc: boris.brezillon@collabora.com, adrian.larumbe@collabora.com,
liviu.dudau@arm.com, steven.price@arm.com,
daniel.almeida@collabora.com, kamil.konieczny@linux.intel.com,
Deborah Brouwer <deborah.brouwer@collabora.com>
Subject: [PATCH i-g-t v2 2/2] panthor: test dev_query buffer size variations
Date: Fri, 16 Oct 2026 15:35:46 -0700 [thread overview]
Message-ID: <20261016-b4-dev_query-v2-2-067661858810@collabora.com> (raw)
In-Reply-To: <20261016-b4-dev_query-v2-0-067661858810@collabora.com>
Add tests to check that the kernel driver will gracefully handle userspace
buffers that are smaller or larger than the kernel driver expected.
Also, add a test to ensure that the kernel driver will provide the size
when the userpointer is null.
This ensures UAPI compliance for DRM_IOCTL_PANTHOR_DEV_QUERY.
Signed-off-by: Deborah Brouwer <deborah.brouwer@collabora.com>
---
tests/panthor/panthor_query.c | 56 ++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 55 insertions(+), 1 deletion(-)
diff --git a/tests/panthor/panthor_query.c b/tests/panthor/panthor_query.c
index afd58a5bd..30e3a9cf3 100644
--- a/tests/panthor/panthor_query.c
+++ b/tests/panthor/panthor_query.c
@@ -7,6 +7,10 @@
#include "panthor_drm.h"
#include <stdint.h>
+#define GPU_INFO_MIN_SIZE \
+ (offsetof(struct drm_panthor_gpu_info, tiler_present) + \
+ sizeof(((struct drm_panthor_gpu_info *)0)->tiler_present))
+
int igt_main() {
int fd = -1;
@@ -20,10 +24,60 @@ int igt_main() {
struct drm_panthor_gpu_info gpu = {};
igt_panthor_query(fd, DRM_PANTHOR_DEV_QUERY_GPU_INFO, &gpu, sizeof(gpu), 0);
-
igt_assert_neq(gpu.gpu_id, 0);
}
+ igt_describe("Ensure kernel returns a GPU_INFO size.");
+ igt_subtest("query-size-null-pointer") {
+ uint32_t size;
+
+ size = igt_panthor_query(fd, DRM_PANTHOR_DEV_QUERY_GPU_INFO, NULL, 0, 0);
+
+ /*
+ * The kernel returns its output structure size, which may be out
+ * of sync with the header used to build these tests, so don't expect
+ * that the sizes will match necessarily.
+ */
+ igt_assert(size >= GPU_INFO_MIN_SIZE);
+ }
+
+ igt_describe("Ensure kernel enforces GPU_INFO minimum size.");
+ igt_subtest("query-size-too-small") {
+ struct drm_panthor_gpu_info gpu = {};
+
+ igt_panthor_query(fd, DRM_PANTHOR_DEV_QUERY_GPU_INFO,
+ &gpu, GPU_INFO_MIN_SIZE - 1, EINVAL);
+ }
+
+ igt_describe("Ensure kernel zeros out unused part of buffer.");
+ igt_subtest("query-too-big") {
+ uint32_t size;
+ size_t buf_size;
+ uint8_t *buf;
+
+ /*
+ * Create a buffer that is larger than necessary.
+ * Start with the size returned by the kernel in case it is out of
+ * sync with these tests. Then add an extra 16 bytes and initialize
+ * the entire buffer to non-zero values.
+ */
+ size = igt_panthor_query(fd, DRM_PANTHOR_DEV_QUERY_GPU_INFO,
+ NULL, 0, 0);
+ buf_size = (size_t)size + 16;
+ buf = malloc(buf_size);
+ igt_assert(buf);
+ memset(buf, 0xff, buf_size);
+
+ igt_panthor_query(fd, DRM_PANTHOR_DEV_QUERY_GPU_INFO,
+ buf, buf_size, 0);
+
+ /* Check that the extra bytes were zeroed. */
+ for (size_t i = size; i < buf_size; i++)
+ igt_assert_eq(buf[i], 0);
+
+ free(buf);
+ }
+
igt_fixture() {
drm_close_driver(fd);
}
--
2.56.0
next prev parent reply other threads:[~2026-10-16 22:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 22:35 [PATCH i-g-t v2 0/2] panthor: add dev_query tests for userspace buffer Deborah Brouwer
2026-10-16 22:35 ` [PATCH i-g-t v2 1/2] panthor: Return size from PANTHOR_DEV_QUERY Deborah Brouwer
2026-10-16 22:35 ` Deborah Brouwer [this message]
2026-10-16 23:34 ` ✗ Xe.CI.BAT: failure for panthor: add dev_query tests for userspace buffer Patchwork
2026-10-16 23:48 ` ✓ i915.CI.BAT: success " Patchwork
2026-10-17 1:55 ` ✓ i915.CI.Full: " 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=20261016-b4-dev_query-v2-2-067661858810@collabora.com \
--to=deborah.brouwer@collabora.com \
--cc=adrian.larumbe@collabora.com \
--cc=boris.brezillon@collabora.com \
--cc=daniel.almeida@collabora.com \
--cc=igt-dev@lists.freedesktop.org \
--cc=kamil.konieczny@linux.intel.com \
--cc=liviu.dudau@arm.com \
--cc=steven.price@arm.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