From patchwork Wed Mar 2 14:00:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomeu Vizoso X-Patchwork-Id: 8480781 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.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 54901C0553 for ; Wed, 2 Mar 2016 14:01:20 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 333332038E for ; Wed, 2 Mar 2016 14:01:19 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2ED842038A for ; Wed, 2 Mar 2016 14:01:18 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ACC6E6E87E; Wed, 2 Mar 2016 14:01:16 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wm0-x241.google.com (mail-wm0-x241.google.com [IPv6:2a00:1450:400c:c09::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0F0276E87B for ; Wed, 2 Mar 2016 14:01:12 +0000 (UTC) Received: by mail-wm0-x241.google.com with SMTP id 1so9785263wmg.2 for ; Wed, 02 Mar 2016 06:01:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=zQmy0CJqEPjWoduzvSGwj3fIh6jLINfksse1noj6LwQ=; b=dTT7ypLkYpRvASnJLzAjAdDEP2aHZsGJtQPbncX37ETLQ4o0izvk/PagnjAOwfMWg6 ZH6YjKONXNWOK1FMdzmjhwgWyphMIdsSNIbrxyUL872LZpPg6zK2R+xny5epoD1iZDS7 cv9YpadqBuPiJARDHOPK6zHGM9EU5uCeXb6rUbtQ3x5iAXw2xRdA9AaFHDuBvk66pONV HQLLJIQ9uCC0FbITRYSTHjN+WIwd3zgegzCQ7yxmP0zqAYenFJvTjMGStWHdtz9v08lB oTQ0P76BDEUYYKxB5bpZ+nCSuwdjQTzQL7/sPR8VyTnShQehwFPSpT/b7mPkuzALi+tM HbkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=zQmy0CJqEPjWoduzvSGwj3fIh6jLINfksse1noj6LwQ=; b=h4DkYj8PWI4OTV5MBPo01Om/wZVVVe9dKlA7EnIMcQopJ6Y0t9WDQDV2SoS12/F84O SIXaQ10zNJXpFMluue7qd8dbcMXPK24+zxifip+dvow+t5HVgm7Daq1lj616pETHaPkt uvvVqLkj7mxmhrttiLP9IABAbWRI45J8w4fO2+YbKAY+UmcTf7wkf+pCSo10hHfB9XGS 2WJ4OcZ4bqNZ5nSELxM8B9OOTqd/h74a0n+OTMJoRlUfPEylhErpKnRC0IUbbtmPshYb VsYh/jGWKhagzEUvFjMt0So5P31iSVJMTpOJC31g8Q/vbEi+WwB+MV0+Nd+QuUjOcqLx 1Zhw== X-Gm-Message-State: AD7BkJLOK5w233SNOmwbHlyvj69iC1vqgaHVx5pNFDZZvKhP46HrQ1tywPGg+wrexTwjHA== X-Received: by 10.194.115.8 with SMTP id jk8mr28838783wjb.136.1456927270338; Wed, 02 Mar 2016 06:01:10 -0800 (PST) Received: from cizrna.lan ([109.72.12.223]) by smtp.gmail.com with ESMTPSA id e19sm4359876wmd.1.2016.03.02.06.01.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 02 Mar 2016 06:01:09 -0800 (PST) From: Tomeu Vizoso To: Intel GFX discussion Date: Wed, 2 Mar 2016 15:00:13 +0100 Message-Id: <1456927221-32421-7-git-send-email-tomeu.vizoso@collabora.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1456927221-32421-1-git-send-email-tomeu.vizoso@collabora.com> References: <1456927221-32421-1-git-send-email-tomeu.vizoso@collabora.com> Cc: Daniel Stone , Tomeu Vizoso , Micah Fedke , Gustavo Padovan , Emil Velikov Subject: [Intel-gfx] [i-g-t PATCH v1 06/14] lib: Add wrapper for DRM_IOCTL_MODE_CREATE_DUMB 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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham 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 In order to test drivers that don't have support for proper buffer objects, add a wrapper for creating dumb buffer objects that will be called from the lib code for those subtests that don't need to care. Signed-off-by: Tomeu Vizoso --- lib/ioctl_wrappers.c | 36 ++++++++++++++++++++++++++++++++++++ lib/ioctl_wrappers.h | 1 + tests/drm_read.c | 16 +--------------- tests/gem_exec_blt.c | 18 +----------------- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/lib/ioctl_wrappers.c b/lib/ioctl_wrappers.c index 0221b7fef3a1..d842d860ba65 100644 --- a/lib/ioctl_wrappers.c +++ b/lib/ioctl_wrappers.c @@ -531,6 +531,42 @@ uint32_t gem_create(int fd, uint64_t size) } /** + * dumb_create: + * @fd: open drm file descriptor + * @width: width of the buffer in pixels + * @height: height of the buffer in pixels + * @bpp: bytes per pixel of the buffer + * + * This wraps the CREATE_DUMB ioctl, which allocates a new dumb buffer object + * for the specified dimensions. + * + * Returns: The file-private handle of the created buffer object + */ +uint32_t dumb_create(int fd, int width, int height, int bpp, unsigned *stride, + unsigned *size) +{ + struct drm_mode_create_dumb create; + + memset(&create, 0, sizeof(create)); + create.width = width; + create.height = height; + create.bpp = bpp; + + create.handle = 0; + do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &create); + igt_assert(create.handle); + igt_assert(create.size >= width * height * bpp / 8); + + if (stride) + *stride = create.pitch; + + if (size) + *size = create.size; + + return create.handle; +} + +/** * __gem_execbuf: * @fd: open i915 drm file descriptor * @execbuf: execbuffer data structure diff --git a/lib/ioctl_wrappers.h b/lib/ioctl_wrappers.h index f59eafba4bdd..9282ffdd8520 100644 --- a/lib/ioctl_wrappers.h +++ b/lib/ioctl_wrappers.h @@ -62,6 +62,7 @@ uint32_t __gem_create_stolen(int fd, uint64_t size); uint32_t gem_create_stolen(int fd, uint64_t size); uint32_t __gem_create(int fd, int size); uint32_t gem_create(int fd, uint64_t size); +uint32_t dumb_create(int fd, int width, int height, int bpp, unsigned *stride, unsigned *size); void gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf); int __gem_execbuf(int fd, struct drm_i915_gem_execbuffer2 *execbuf); diff --git a/tests/drm_read.c b/tests/drm_read.c index faa3df862ea6..a27e5522daa0 100644 --- a/tests/drm_read.c +++ b/tests/drm_read.c @@ -120,20 +120,6 @@ static void test_invalid_buffer(int in) teardown(fd); } -static uint32_t dumb_create(int fd) -{ - struct drm_mode_create_dumb arg; - - arg.bpp = 32; - arg.width = 32; - arg.height = 32; - - do_ioctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg); - igt_assert(arg.size >= 4096); - - return arg.handle; -} - static void test_fault_buffer(int in) { int fd = setup(in, 0); @@ -141,7 +127,7 @@ static void test_fault_buffer(int in) char *buf; memset(&arg, 0, sizeof(arg)); - arg.handle = dumb_create(fd); + arg.handle = dumb_create(fd, 32, 32, 32, NULL, NULL); do_ioctl(fd, DRM_IOCTL_MODE_MAP_DUMB, &arg); diff --git a/tests/gem_exec_blt.c b/tests/gem_exec_blt.c index 74f5c2ba87ad..42a030fb4f57 100644 --- a/tests/gem_exec_blt.c +++ b/tests/gem_exec_blt.c @@ -170,22 +170,6 @@ static const char *bytes_per_sec(char *buf, double v) return buf; } -static uint32_t dumb_create(int fd) -{ - struct drm_mode_create_dumb arg; - int ret; - - arg.bpp = 32; - arg.width = 32; - arg.height = 32; - - ret = drmIoctl(fd, DRM_IOCTL_MODE_CREATE_DUMB, &arg); - igt_assert_eq(ret, 0); - igt_assert(arg.size >= 4096); - - return arg.handle; -} - static int dcmp(const void *A, const void *B) { const double *a = A, *b = B; @@ -209,7 +193,7 @@ static void run(int object_size, bool dumb) fd = drm_open_driver(DRIVER_INTEL); if (dumb) - handle = dumb_create(fd); + handle = dumb_create(fd, 32, 32, 32, NULL, NULL); else handle = gem_create(fd, 4096);