All of lore.kernel.org
 help / color / mirror / Atom feed
From: "André Almeida" <andrealmeid@igalia.com>
To: igt-dev@lists.freedesktop.org, Jeevan B <jeevan.b@intel.com>,
	Kamil Konieczny <kamil.konieczny@linux.intel.com>
Cc: kernel-dev@igalia.com, "Vitaly Prosyak" <vitaly.prosyak@amd.com>,
	"Alex Hung" <alex.hung@amd.com>, "Melissa Wen" <mwen@igalia.com>,
	"Rodrigo Siqueira" <siqueira@igalia.com>,
	"André Almeida" <andrealmeid@igalia.com>
Subject: [PATCH v6 1/4] lib/ioctl_wrappers: let the caller handle capability check result
Date: Mon,  7 Apr 2025 21:02:18 -0300	[thread overview]
Message-ID: <20250408000221.140459-2-andrealmeid@igalia.com> (raw)
In-Reply-To: <20250408000221.140459-1-andrealmeid@igalia.com>

From: Melissa Wen <mwen@igalia.com>

Rework igt_has_drm_cap to just check if a DRM capability is supported
and let the called decide what to do from this check. It prevents the
test fails because of an assert done when it's called in
igt_subtest_with_dynamics.

Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
 lib/ioctl_wrappers.c    | 13 ++++++++-----
 lib/ioctl_wrappers.h    |  2 +-
 tests/kms_async_flips.c | 13 +++++++++----
 3 files changed, 18 insertions(+), 10 deletions(-)

diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c
index 146973f0d..33f593295 100644
--- a/lib/ioctl_wrappers.c
+++ b/lib/ioctl_wrappers.c
@@ -1288,14 +1288,17 @@ int __kms_addfb(int fd, uint32_t handle,
  * This helper verifies if the passed capability is
  * supported by the kernel
  *
- * Returns: Whether the capability is supported or not.
+ * Returns: negative value if error, 0 if cap is not supported, 1 if cap is
+ * supported.
  */
-bool igt_has_drm_cap(int fd, uint64_t capability)
+int igt_has_drm_cap(int fd, uint64_t capability)
 {
-	struct drm_get_cap cap = { .capability = capability };
+	uint64_t value = 0;
+
+	if (drmGetCap(fd, capability, &value))
+		return -errno;
 
-	igt_assert(drmIoctl(fd, DRM_IOCTL_GET_CAP, &cap) == 0);
-	return cap.value;
+	return value ? 1 : 0;
 }
 
 /**
diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h
index b7d7c2ad9..7cf05e626 100644
--- a/lib/ioctl_wrappers.h
+++ b/lib/ioctl_wrappers.h
@@ -144,7 +144,7 @@ void prime_sync_end(int dma_buf_fd, bool write);
 
 bool igt_has_fb_modifiers(int fd);
 void igt_require_fb_modifiers(int fd);
-bool igt_has_drm_cap(int fd, uint64_t capability);
+int igt_has_drm_cap(int fd, uint64_t capability);
 bool igt_has_set_caching(uint32_t devid);
 
 /**
diff --git a/tests/kms_async_flips.c b/tests/kms_async_flips.c
index da426f753..126b96d6b 100644
--- a/tests/kms_async_flips.c
+++ b/tests/kms_async_flips.c
@@ -203,8 +203,10 @@ static void make_fb(data_t *data, struct igt_fb *fb,
 
 static void require_monotonic_timestamp(int fd)
 {
-	igt_require_f(igt_has_drm_cap(fd, DRM_CAP_TIMESTAMP_MONOTONIC),
-		      "Monotonic timestamps not supported\n");
+	int ret = igt_has_drm_cap(fd, DRM_CAP_TIMESTAMP_MONOTONIC);
+
+	igt_assert(ret >= 0);
+	igt_require_f(ret, "Monotonic timestamps not supported\n");
 }
 
 static void test_init(data_t *data)
@@ -747,13 +749,16 @@ igt_main
 	int i;
 
 	igt_fixture {
+		int ret;
+
 		data.drm_fd = drm_open_driver_master(DRIVER_ANY);
 		kmstest_set_vt_graphics_mode();
 		igt_display_require(&data.display, data.drm_fd);
 		igt_display_require_output(&data.display);
 
-		igt_require_f(igt_has_drm_cap(data.drm_fd, DRM_CAP_ASYNC_PAGE_FLIP),
-			      "Async Flip is not supported\n");
+		ret = igt_has_drm_cap(data.drm_fd, DRM_CAP_ASYNC_PAGE_FLIP);
+		igt_assert(ret >= 0);
+		igt_require_f(ret, "Async Flip is not supported\n");
 
 		if (is_intel_device(data.drm_fd))
 			data.bops = buf_ops_create(data.drm_fd);
-- 
2.49.0


  reply	other threads:[~2025-04-08  0:02 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-08  0:02 [PATCH v6 0/4] tests/kms_async_flips: Create subtest for overlay planes André Almeida
2025-04-08  0:02 ` André Almeida [this message]
2025-04-08 12:08   ` [PATCH v6 1/4] lib/ioctl_wrappers: let the caller handle capability check result Kamil Konieczny
2025-04-08 16:09   ` Melissa Wen
2025-04-08  0:02 ` [PATCH v6 2/4] tests/kms_async_flips: Check for atomic async flip cap André Almeida
2025-04-08 16:01   ` Melissa Wen
2025-04-08 16:07     ` André Almeida
2025-04-08 18:48       ` Melissa Wen
2025-04-08  0:02 ` [PATCH v6 3/4] kms_async_flips: Refactor data options André Almeida
2025-04-08  0:02 ` [PATCH v6 4/4] tests/kms_async_flips: Create subtest for overlay planes André Almeida
2025-04-08 16:16   ` Melissa Wen
2025-04-08 18:53     ` Alex Hung
2025-04-08 19:26       ` André Almeida
2025-04-08 20:45         ` André Almeida
2025-04-08 21:46           ` Alex Hung
2025-04-08  0:05 ` [PATCH v6 0/4] " André Almeida
2025-04-08  1:02 ` ✓ Xe.CI.BAT: success for " Patchwork
2025-04-08  1:12 ` ✓ i915.CI.BAT: " Patchwork
2025-04-08  3:06 ` ✗ i915.CI.Full: failure " Patchwork
2025-04-08  8:01 ` ✗ Xe.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=20250408000221.140459-2-andrealmeid@igalia.com \
    --to=andrealmeid@igalia.com \
    --cc=alex.hung@amd.com \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=jeevan.b@intel.com \
    --cc=kamil.konieczny@linux.intel.com \
    --cc=kernel-dev@igalia.com \
    --cc=mwen@igalia.com \
    --cc=siqueira@igalia.com \
    --cc=vitaly.prosyak@amd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.