From patchwork Tue Nov 25 08:58:52 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: akash.goel@intel.com X-Patchwork-Id: 5374511 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id AF99E9F2F5 for ; Tue, 25 Nov 2014 08:54:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D3FD5201C0 for ; Tue, 25 Nov 2014 08:54:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 9FF732015D for ; Tue, 25 Nov 2014 08:54:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3836D6E614; Tue, 25 Nov 2014 00:54:15 -0800 (PST) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTP id 36D616E614 for ; Tue, 25 Nov 2014 00:54:14 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 25 Nov 2014 00:53:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,454,1413270000"; d="scan'208";a="637673208" Received: from akashgoe-desktop.iind.intel.com ([10.223.82.144]) by fmsmga002.fm.intel.com with ESMTP; 25 Nov 2014 00:53:41 -0800 From: akash.goel@intel.com To: intel-gfx@lists.freedesktop.org Date: Tue, 25 Nov 2014 14:28:52 +0530 Message-Id: <1416905932-10566-1-git-send-email-akash.goel@intel.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <20141117183634.GG25711@phenom.ffwll.local> References: <20141117183634.GG25711@phenom.ffwll.local> Cc: Akash Goel Subject: [Intel-gfx] [PATCH] igt/gem_mmap_wc: Add the invalid flags subtest X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Akash Goel A new subtest added to validate the new version of gem_mmap ioctl, for creating the wc mappings, on yet to be supported flags. Older kernel is also checked against the flags field, which should be treated as a don't care by it. Signed-off-by: Akash Goel Signed-off-by: Chris Wilson --- tests/gem_mmap_wc.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/tests/gem_mmap_wc.c b/tests/gem_mmap_wc.c index 6f91a89..f923553 100644 --- a/tests/gem_mmap_wc.c +++ b/tests/gem_mmap_wc.c @@ -41,6 +41,17 @@ #include "drmtest.h" #include "igt_debugfs.h" +struct local_i915_gem_mmap_v2 { + uint32_t handle; + uint32_t pad; + uint64_t offset; + uint64_t size; + uint64_t addr_ptr; + uint64_t flags; +#define I915_MMAP_WC 0x1 +}; +#define LOCAL_IOCTL_I915_GEM_MMAP_v2 DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_MMAP, struct local_i915_gem_mmap_v2) + static int OBJECT_SIZE = 16*1024*1024; static void set_domain(int fd, uint32_t handle) @@ -75,6 +86,59 @@ create_pointer(int fd) } static void +test_invalid_flags(int fd) +{ + struct drm_i915_getparam gp; + struct local_i915_gem_mmap_v2 arg; + uint64_t flag = I915_MMAP_WC; + int val = -1; + + memset(&arg, 0, sizeof(arg)); + arg.handle = gem_create(fd, 4096); + arg.offset = 0; + arg.size = 4096; + + memset(&gp, 0, sizeof(gp)); + gp.param = 30; /* MMAP_VERSION */ + gp.value = &val; + + /* Do we have the new mmap_ioctl? */ + do_ioctl(fd, DRM_IOCTL_I915_GETPARAM, &gp); + + if (val >= 1) { + /* + * Only MMAP_WC flag is supported in version 1, so any other + * flag should be rejected. + */ + flag <<= 1; + while (flag) { + arg.flags = flag; + igt_assert(drmIoctl(fd, + LOCAL_IOCTL_I915_GEM_MMAP_v2, + &arg) == -1); + igt_assert_eq(errno, EINVAL); + flag <<= 1; + } + } else { + /* + * flags field should be ignored by older kernel + * and so irrespective of the flag value passed, + * mmap call should succeed + */ + while (flag) { + arg.flags = flag; + igt_assert(drmIoctl(fd, + LOCAL_IOCTL_I915_GEM_MMAP_v2, + &arg) == 0); + munmap(arg.addr_ptr, 4096); + flag <<= 1; + } + } + + gem_close(fd, arg.handle); +} + +static void test_copy(int fd) { void *src, *dst; @@ -331,6 +395,8 @@ igt_main igt_fixture fd = drm_open_any(); + igt_subtest("invalid flags") + test_invalid_flags(fd); igt_subtest("copy") test_copy(fd); igt_subtest("read")