All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: [PATCH i-g-t 1/5] igt/kms_getfb: Check the iface exists before use
Date: Fri, 28 Sep 2018 11:19:58 +0100	[thread overview]
Message-ID: <20180928102002.10541-1-chris@chris-wilson.co.uk> (raw)

If the driver doesn't support the getfb iface (e.g. because KMS has been
disabled), the ioctls will fail with ENOTSUP. This is expected, so skip
the test as nothing useful can be learnt.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/kms_getfb.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
index 81d796a42..71d65488f 100644
--- a/tests/kms_getfb.c
+++ b/tests/kms_getfb.c
@@ -40,6 +40,40 @@
 #include "drm.h"
 #include "drm_fourcc.h"
 
+static bool has_getfb_iface(int fd)
+{
+	struct drm_mode_fb_cmd arg = { };
+	int err;
+
+	err = 0;
+	if (drmIoctl(fd, DRM_IOCTL_MODE_GETFB, &arg))
+		err = -errno;
+	switch (err) {
+	case -ENOTTY: /* ioctl unrecognised (kernel too old) */
+	case -ENOTSUP: /* driver doesn't support KMS */
+		return false;
+	default:
+		return true;
+	}
+}
+
+static bool has_addfb2_iface(int fd)
+{
+	struct drm_mode_fb_cmd2 arg = { };
+	int err;
+
+	err = 0;
+	if (drmIoctl(fd, DRM_IOCTL_MODE_ADDFB2, &arg) == 0)
+		err = -errno;
+	switch (err) {
+	case -ENOTTY: /* ioctl unrecognised (kernel too old) */
+	case -ENOTSUP: /* driver doesn't support KMS */
+		return false;
+	default:
+		return true;
+	}
+}
+
 static void get_ccs_fb(int fd, struct drm_mode_fb_cmd2 *ret)
 {
 	struct drm_mode_fb_cmd2 add = {
@@ -54,6 +88,7 @@ static void get_ccs_fb(int fd, struct drm_mode_fb_cmd2 *ret)
 	};
 	int size;
 
+	igt_require(has_addfb2_iface(fd));
 	igt_require_intel(fd);
 
 	/* An explanation of the magic numbers can be found in kms_ccs.c. */
@@ -191,15 +226,16 @@ static void test_duplicate_handles(int fd)
 		do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add.fb_id);
 		gem_close(fd, add.handles[0]);
 	}
-
 }
 
 igt_main
 {
 	int fd;
 
-	igt_fixture
+	igt_fixture {
 		fd = drm_open_driver_master(DRIVER_ANY);
+		igt_require(has_getfb_iface(fd));
+	}
 
 	igt_subtest_group
 		test_handle_input(fd);
-- 
2.19.0

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: igt-dev@lists.freedesktop.org
Subject: [igt-dev] [PATCH i-g-t 1/5] igt/kms_getfb: Check the iface exists before use
Date: Fri, 28 Sep 2018 11:19:58 +0100	[thread overview]
Message-ID: <20180928102002.10541-1-chris@chris-wilson.co.uk> (raw)

If the driver doesn't support the getfb iface (e.g. because KMS has been
disabled), the ioctls will fail with ENOTSUP. This is expected, so skip
the test as nothing useful can be learnt.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 tests/kms_getfb.c | 40 ++++++++++++++++++++++++++++++++++++++--
 1 file changed, 38 insertions(+), 2 deletions(-)

diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
index 81d796a42..71d65488f 100644
--- a/tests/kms_getfb.c
+++ b/tests/kms_getfb.c
@@ -40,6 +40,40 @@
 #include "drm.h"
 #include "drm_fourcc.h"
 
+static bool has_getfb_iface(int fd)
+{
+	struct drm_mode_fb_cmd arg = { };
+	int err;
+
+	err = 0;
+	if (drmIoctl(fd, DRM_IOCTL_MODE_GETFB, &arg))
+		err = -errno;
+	switch (err) {
+	case -ENOTTY: /* ioctl unrecognised (kernel too old) */
+	case -ENOTSUP: /* driver doesn't support KMS */
+		return false;
+	default:
+		return true;
+	}
+}
+
+static bool has_addfb2_iface(int fd)
+{
+	struct drm_mode_fb_cmd2 arg = { };
+	int err;
+
+	err = 0;
+	if (drmIoctl(fd, DRM_IOCTL_MODE_ADDFB2, &arg) == 0)
+		err = -errno;
+	switch (err) {
+	case -ENOTTY: /* ioctl unrecognised (kernel too old) */
+	case -ENOTSUP: /* driver doesn't support KMS */
+		return false;
+	default:
+		return true;
+	}
+}
+
 static void get_ccs_fb(int fd, struct drm_mode_fb_cmd2 *ret)
 {
 	struct drm_mode_fb_cmd2 add = {
@@ -54,6 +88,7 @@ static void get_ccs_fb(int fd, struct drm_mode_fb_cmd2 *ret)
 	};
 	int size;
 
+	igt_require(has_addfb2_iface(fd));
 	igt_require_intel(fd);
 
 	/* An explanation of the magic numbers can be found in kms_ccs.c. */
@@ -191,15 +226,16 @@ static void test_duplicate_handles(int fd)
 		do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add.fb_id);
 		gem_close(fd, add.handles[0]);
 	}
-
 }
 
 igt_main
 {
 	int fd;
 
-	igt_fixture
+	igt_fixture {
 		fd = drm_open_driver_master(DRIVER_ANY);
+		igt_require(has_getfb_iface(fd));
+	}
 
 	igt_subtest_group
 		test_handle_input(fd);
-- 
2.19.0

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

             reply	other threads:[~2018-09-28 10:19 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-28 10:19 Chris Wilson [this message]
2018-09-28 10:19 ` [igt-dev] [PATCH i-g-t 1/5] igt/kms_getfb: Check the iface exists before use Chris Wilson
2018-09-28 10:19 ` [PATCH i-g-t 2/5] igt/prime_vgem: Skip flip if no display Chris Wilson
2018-09-28 10:19   ` [igt-dev] " Chris Wilson
2018-09-28 10:20 ` [PATCH i-g-t 3/5] lib: Report if kms is enabled on the display Chris Wilson
2018-09-28 10:20   ` [igt-dev] " Chris Wilson
2018-09-28 10:20 ` [PATCH i-g-t 4/5] lib/kms: Skip no-op display updates Chris Wilson
2018-09-28 10:20   ` [igt-dev] " Chris Wilson
2018-09-28 10:20 ` [PATCH i-g-t 5/5] igt: Require a display (KMS enabled) for KMS tests Chris Wilson
2018-09-28 10:20   ` [Intel-gfx] " Chris Wilson
2018-09-28 10:52 ` [igt-dev] ✓ Fi.CI.BAT: success for series starting with [i-g-t,1/5] igt/kms_getfb: Check the iface exists before use Patchwork
2018-09-28 11:41 ` [igt-dev] ✓ Fi.CI.IGT: " Patchwork
2018-10-01 18:36 ` [igt-dev] [PATCH i-g-t 1/5] " Antonio Argenziano
2018-10-01 18:36   ` Antonio Argenziano
2018-10-01 19:43   ` Chris Wilson
2018-10-01 19:43     ` [Intel-gfx] " Chris Wilson
2018-10-01 19:53     ` Antonio Argenziano
2018-10-01 19:53       ` Antonio Argenziano
2018-10-02  8:30       ` Joonas Lahtinen
2018-10-02  8:30         ` [Intel-gfx] " Joonas Lahtinen
2018-10-02 20:27         ` Antonio Argenziano
2018-10-02 20:27           ` [igt-dev] [Intel-gfx] " Antonio Argenziano
2018-10-03 13:04           ` [igt-dev] " Joonas Lahtinen
2018-10-03 13:04             ` [igt-dev] [Intel-gfx] " Joonas Lahtinen
2018-10-04 13:02             ` [igt-dev] " Daniel Vetter
2018-10-04 13:02               ` [igt-dev] [Intel-gfx] " Daniel Vetter
  -- strict thread matches above, loose matches on Subject: below --
2018-09-14 20:13 Chris Wilson

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=20180928102002.10541-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /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.