[PATCH] tests/vmwgfx: Check for 3d support on context and surface creation.
Maaz Mombasawala
maaz.mombasawala at broadcom.com
Fri Jan 10 20:11:16 UTC 2025
Creating a vmwgfx context or surface will fail on a vm without 3d support.
Check for 3d support when creating them so that the tests which use them
skip instead of crashing.
Signed-off-by: Maaz Mombasawala <maaz.mombasawala at broadcom.com>
---
lib/igt_vmwgfx.c | 12 +++++++++-
tests/vmwgfx/vmw_execution_buffer.c | 35 +++++++----------------------
2 files changed, 19 insertions(+), 28 deletions(-)
diff --git a/lib/igt_vmwgfx.c b/lib/igt_vmwgfx.c
index 74c13b52b..94d255655 100644
--- a/lib/igt_vmwgfx.c
+++ b/lib/igt_vmwgfx.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0 OR MIT
/*
- * Copyright (c) 2021-2024 Broadcom. All Rights Reserved. The term
+ * Copyright (c) 2021-2025 Broadcom. All Rights Reserved. The term
* “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
*/
@@ -175,6 +175,11 @@ uint64 vmw_ioctl_get_param(int fd, uint32 param)
return arg.value;
}
+static inline uint64 vmw_supports_3d(int fd)
+{
+ return vmw_ioctl_get_param(fd, DRM_VMW_PARAM_3D);
+}
+
void vmw_ioctl_get_3d_cap(int fd, uint64 buffer, uint32 max_size)
{
struct drm_vmw_get_3d_cap_arg arg = { 0 };
@@ -445,6 +450,9 @@ struct vmw_surface *vmw_ioctl_create_surface_full(
int32 ret;
union drm_vmw_gb_surface_create_ext_arg arg = { 0 };
+ /* Surface creation will fail if 3d is not supported. */
+ igt_require(vmw_supports_3d(fd));
+
surface = calloc(1, sizeof(struct vmw_surface));
if (!surface)
goto out_err1;
@@ -721,6 +729,8 @@ int32 vmw_ioctl_context_create(int drm_fd)
int ret;
union drm_vmw_extended_context_arg arg = { 0 };
+ /* Context creation will fail if 3d is not supported. */
+ igt_require(vmw_supports_3d(drm_fd));
arg.req = drm_vmw_context_dx;
do {
diff --git a/tests/vmwgfx/vmw_execution_buffer.c b/tests/vmwgfx/vmw_execution_buffer.c
index b89770b30..23c5f900d 100644
--- a/tests/vmwgfx/vmw_execution_buffer.c
+++ b/tests/vmwgfx/vmw_execution_buffer.c
@@ -1,28 +1,8 @@
// SPDX-License-Identifier: GPL-2.0 OR MIT
-/**********************************************************
- * Copyright 2021-2022 VMware, Inc.
- *
- * Permission is hereby granted, free of charge, to any person
- * obtaining a copy of this software and associated documentation
- * files (the "Software"), to deal in the Software without
- * restriction, including without limitation the rights to use, copy,
- * modify, merge, publish, distribute, sublicense, and/or sell copies
- * of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
- * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
- * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
- * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- *
- **********************************************************/
+/*
+ * Copyright (c) 2021-2025 Broadcom. All Rights Reserved. The term
+ * “Broadcom” refers to Broadcom Inc. and/or its subsidiaries.
+ */
#include "igt_vmwgfx.h"
@@ -271,12 +251,10 @@ static void execbuf_stress_test(int fd)
igt_main_args("st:", long_options, NULL, parse_options, NULL)
{
int fd;
- int32 cid;
igt_fixture
{
fd = drm_open_driver_render(DRIVER_VMWGFX);
- cid = vmw_ioctl_context_create(fd);
}
igt_describe("Test creation/mapping of a basic mob.");
@@ -294,7 +272,11 @@ igt_main_args("st:", long_options, NULL, parse_options, NULL)
igt_describe("Test basic fencing on command buffers.");
igt_subtest("execution-buffer-submit-sync")
{
+ int32 cid;
+
+ cid = vmw_ioctl_context_create(fd);
check_execbuf_submit_fence(fd, cid);
+ vmw_ioctl_context_destroy(fd, cid);
}
if (options.stress_test) {
@@ -307,7 +289,6 @@ igt_main_args("st:", long_options, NULL, parse_options, NULL)
igt_fixture
{
- vmw_ioctl_context_destroy(fd, cid);
drm_close_driver(fd);
}
}
--
2.43.0
More information about the igt-dev
mailing list