From patchwork Thu Apr 12 18:08:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Wilson X-Patchwork-Id: 10339111 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 61D93600D0 for ; Thu, 12 Apr 2018 18:08:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 547AD27FA8 for ; Thu, 12 Apr 2018 18:08:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 492E627FAE; Thu, 12 Apr 2018 18:08:34 +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 C270227FA8 for ; Thu, 12 Apr 2018 18:08:33 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BA9166E1A7; Thu, 12 Apr 2018 18:08:32 +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 7D62D6E1A7 for ; Thu, 12 Apr 2018 18:08:31 +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 11352822-1500050 for multiple; Thu, 12 Apr 2018 19:08:22 +0100 Received: by haswell.alporthouse.com (sSMTP sendmail emulation); Thu, 12 Apr 2018 19:08:23 +0100 From: Chris Wilson To: intel-gfx@lists.freedesktop.org Date: Thu, 12 Apr 2018 19:08:23 +0100 Message-Id: <20180412180823.11998-1-chris@chris-wilson.co.uk> X-Mailer: git-send-email 2.17.0 X-Originating-IP: 78.156.65.138 X-Country: code=GB country="United Kingdom" ip=78.156.65.138 Subject: [Intel-gfx] [PATCH igt] igt/prime_mmap: Test for userptr support first 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: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Before we start trying to use userptr to test interoperability with PRIME, we first need to check that the device in question has userptr support. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=106013 Signed-off-by: Chris Wilson Reviewed-by: Tvrtko Ursulin --- tests/prime_mmap.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tests/prime_mmap.c b/tests/prime_mmap.c index 0da0aa68..67a6a232 100644 --- a/tests/prime_mmap.c +++ b/tests/prime_mmap.c @@ -307,6 +307,19 @@ static int prime_handle_to_fd_no_assert(uint32_t handle, int flags, int *fd_out) return ret; } +static bool has_userptr(void) +{ + uint32_t handle = 0; + void *ptr; + + igt_assert(posix_memalign(&ptr, 4096, 4096) == 0); + if ( __gem_userptr(fd, ptr, 4096, 0, 0, &handle) == 0) + gem_close(fd, handle); + free(ptr); + + return handle; +} + /* test for mmap(dma_buf_export(userptr)) */ static void test_userptr(void) @@ -315,6 +328,8 @@ test_userptr(void) void *ptr; uint32_t handle; + igt_require(has_userptr()); + /* create userptr bo */ ret = posix_memalign(&ptr, 4096, BO_SIZE); igt_assert_eq(ret, 0);