From patchwork Fri Sep 14 20:13:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10601187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DA69C933 for ; Fri, 14 Sep 2018 20:13:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C03F12B9EE for ; Fri, 14 Sep 2018 20:13:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B47422BA80; Fri, 14 Sep 2018 20:13:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6B4542B9EE for ; Fri, 14 Sep 2018 20:13:22 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BF19F6E801; Fri, 14 Sep 2018 20:13:21 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from fireflyinternet.com (mail.fireflyinternet.com [109.228.58.192]) by gabe.freedesktop.org (Postfix) with ESMTPS id 307C36E080; Fri, 14 Sep 2018 20:13:19 +0000 (UTC) X-Default-Received-SPF: pass (skip=forwardok (res=PASS)) x-ip-name=78.156.65.138; Received: from haswell.alporthouse.com (unverified [78.156.65.138]) by fireflyinternet.com (Firefly Internet (M1)) with ESMTP id 13774242-1500050 for multiple; Fri, 14 Sep 2018 21:13:06 +0100 From: Chris Wilson To: igt-dev@lists.freedesktop.org Date: Fri, 14 Sep 2018 21:13:06 +0100 Message-Id: <20180914201310.19527-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.19.0 MIME-Version: 1.0 Subject: [Intel-gfx] [PATCH i-g-t 1/5] igt/kms_getfb: Check the iface exists before use X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: intel-gfx@lists.freedesktop.org Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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);