summaryrefslogtreecommitdiff
path: root/tests/i915/i915_query.c
diff options
context:
space:
mode:
authorMatt Roper <matthew.d.roper@intel.com>2022-04-11 20:28:19 -0700
committerMatt Roper <matthew.d.roper@intel.com>2022-04-14 12:14:31 -0700
commitea0144ed6ccb66b977f204b4d53b6062ed1cc8bc (patch)
treecab259eeeeee3cdedf2fa584ec3bcae32f378afe /tests/i915/i915_query.c
parente359750889b0caeac3a87d5fee4a16b653002173 (diff)
tests/i915_query: Test new DRM_I915_QUERY_GEOMETRY_SUBSLICES query
Ensure we get sensible responses for both valid and invalid usage of this query item. Note that unlike the traditional topology query we do not try to compare the values returned against the old I915_PARAM ioctl. Xe_HP already uses a full 32-bit mask for subslices and we expect upcoming platforms to increase the mask size to 64 or beyond (i.e., the hardware starts using multiple registers to express the mask); since the old I915_PARAM ioctl can only return a 32-bit value it will be unable to express the full mask for upcoming platforms. Cc: Matt Atwood <matthew.s.atwood@intel.com> Signed-off-by: Matt Roper <matthew.d.roper@intel.com> Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
Diffstat (limited to 'tests/i915/i915_query.c')
-rw-r--r--tests/i915/i915_query.c75
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/i915/i915_query.c b/tests/i915/i915_query.c
index 3c791b8b..246a979a 100644
--- a/tests/i915/i915_query.c
+++ b/tests/i915/i915_query.c
@@ -244,6 +244,15 @@ static bool query_topology_supported(int fd)
return __i915_query_items(fd, &item, 1) == 0 && item.length > 0;
}
+static bool query_geometry_subslices_supported(int fd)
+{
+ struct drm_i915_query_item item = {
+ .query_id= DRM_I915_QUERY_GEOMETRY_SUBSLICES,
+ };
+
+ return __i915_query_items(fd, &item, 1) == 0 && item.length > 0;
+}
+
static void test_query_topology_unsupported(int fd)
{
struct drm_i915_query_item item = {
@@ -842,6 +851,67 @@ static void engines(int fd)
free(engines);
}
+static void test_query_geometry_subslices(int fd)
+{
+ const struct intel_execution_engine2 *e;
+ struct drm_i915_query_item item = {};
+ struct drm_i915_query_topology_info *topo_info;
+
+ /*
+ * Submit an initial request with an invalid engine. Should return
+ * -EINVAL via item.length.
+ */
+ item.query_id = DRM_I915_QUERY_GEOMETRY_SUBSLICES;
+ item.flags = ~0;
+ i915_query_items(fd, &item, 1);
+ igt_assert_eq(item.length, -EINVAL);
+
+ for_each_physical_engine(fd, e) {
+ memset(&item, 0, sizeof(item));
+
+ /* Obtain the necessary topology buffer size */
+ item.query_id = DRM_I915_QUERY_GEOMETRY_SUBSLICES;
+ item.flags = e->class | (e->instance << 16);
+ i915_query_items(fd, &item, 1);
+
+ /* Non-render engines should return -EINVAL */
+ if (e->class != I915_ENGINE_CLASS_RENDER) {
+ igt_assert_eq(item.length, -EINVAL);
+ continue;
+ }
+ igt_assert(item.length > 0);
+
+ /* Re-submit with a properly allocated buffer */
+ topo_info = calloc(1, item.length);
+ igt_assert(topo_info);
+ item.data_ptr = to_user_pointer(topo_info);
+ i915_query_items(fd, &item, 1);
+
+ igt_assert(topo_info->max_subslices > 0);
+ igt_assert(topo_info->max_eus_per_subslice > 0);
+
+ igt_assert(topo_info->subslice_offset >=
+ DIV_ROUND_UP(topo_info->max_slices, 8));
+ igt_assert(topo_info->eu_offset >=
+ topo_info->subslice_offset + DIV_ROUND_UP(topo_info->max_subslices, 8));
+
+ igt_assert(topo_info->subslice_stride >=
+ DIV_ROUND_UP(topo_info->max_subslices, 8));
+ igt_assert(topo_info->eu_stride >=
+ DIV_ROUND_UP(topo_info->max_eus_per_subslice, 8));
+
+ /*
+ * This query is only supported on Xe_HP and beyond, and all
+ * such platforms don't have slices; we should just get a
+ * hardcoded 0x1 for the slice mask.
+ */
+ igt_assert_eq(topo_info->max_slices, 1);
+ igt_assert_eq(((char*)topo_info->data)[0], 0x1);
+
+ free(topo_info);
+ }
+}
+
igt_main
{
int fd = -1;
@@ -889,6 +959,11 @@ igt_main
test_query_topology_known_pci_ids(fd, devid);
}
+ igt_subtest("test-query-geometry-subslices") {
+ igt_require(query_geometry_subslices_supported(fd));
+ test_query_geometry_subslices(fd);
+ }
+
igt_subtest("query-regions-garbage-items") {
igt_require(query_regions_supported(fd));
test_query_regions_garbage_items(fd);