From patchwork Thu Dec 4 04:41:14 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: 5435281 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 84D4BBEEA8 for ; Thu, 4 Dec 2014 04:36:06 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4BBF320272 for ; Thu, 4 Dec 2014 04:36:05 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 1B52720265 for ; Thu, 4 Dec 2014 04:36:04 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5A6ED6E4BB; Wed, 3 Dec 2014 20:36:03 -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 5C92B6E4BB for ; Wed, 3 Dec 2014 20:36:01 -0800 (PST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 03 Dec 2014 20:36:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.07,512,1413270000"; d="scan'208";a="642121231" Received: from akashgoe-desktop.iind.intel.com ([10.223.82.76]) by fmsmga002.fm.intel.com with ESMTP; 03 Dec 2014 20:35:59 -0800 From: akash.goel@intel.com To: intel-gfx@lists.freedesktop.org Date: Thu, 4 Dec 2014 10:11:14 +0530 Message-Id: <1417668074-18221-1-git-send-email-akash.goel@intel.com> X-Mailer: git-send-email 1.9.2 In-Reply-To: <20141125113034.GY25711@phenom.ffwll.local> References: <20141125113034.GY25711@phenom.ffwll.local> Cc: Akash Goel Subject: [Intel-gfx] [PATCH v2] 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. v2: Removed the flags checking for older kernels (Daniel) Signed-off-by: Akash Goel Signed-off-by: Chris Wilson --- tests/gem_mmap_wc.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/tests/gem_mmap_wc.c b/tests/gem_mmap_wc.c index 6f91a89..18ff1f5 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,45 @@ 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; + } + } + + gem_close(fd, arg.handle); +} + +static void test_copy(int fd) { void *src, *dst; @@ -331,6 +381,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")