From patchwork Wed Apr 17 16:10:00 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Imre Deak X-Patchwork-Id: 2454381 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id 150B9DF23A for ; Wed, 17 Apr 2013 16:11:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 02C52E6188 for ; Wed, 17 Apr 2013 09:11:17 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id E9710E66D2 for ; Wed, 17 Apr 2013 09:10:03 -0700 (PDT) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga101.jf.intel.com with ESMTP; 17 Apr 2013 09:10:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,494,1363158000"; d="scan'208";a="319788288" Received: from intelbox.fi.intel.com (HELO localhost) ([10.237.72.70]) by orsmga002.jf.intel.com with ESMTP; 17 Apr 2013 09:10:02 -0700 From: Imre Deak To: intel-gfx@lists.freedesktop.org Date: Wed, 17 Apr 2013 19:10:00 +0300 Message-Id: <1366215000-2366-1-git-send-email-imre.deak@intel.com> X-Mailer: git-send-email 1.7.10.4 Subject: [Intel-gfx] [PATCH] tests/prime_self_import: export/import a second gem buffer X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Signed-off-by: Imre Deak --- tests/prime_self_import.c | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/tests/prime_self_import.c b/tests/prime_self_import.c index 111ed4d..a17e942 100644 --- a/tests/prime_self_import.c +++ b/tests/prime_self_import.c @@ -48,11 +48,13 @@ #define BO_SIZE (16*1024) +static char counter1; +static char counter2; + static void -check_bo(int fd1, uint32_t handle1, int fd2, uint32_t handle2) +check_bo(int fd1, uint32_t handle1, int fd2, uint32_t handle2, char *counter) { char *ptr1, *ptr2; - static char counter = 0; int i; ptr1 = gem_mmap(fd1, handle1, BO_SIZE, PROT_READ | PROT_WRITE); @@ -62,13 +64,13 @@ check_bo(int fd1, uint32_t handle1, int fd2, uint32_t handle2) /* check whether it's still our old object first. */ for (i = 0; i < BO_SIZE; i++) { - assert(ptr1[i] == counter); - assert(ptr2[i] == counter); + assert(ptr1[i] == *counter); + assert(ptr2[i] == *counter); } - counter++; + (*counter)++; - memset(ptr1, counter, BO_SIZE); + memset(ptr1, *counter, BO_SIZE); assert(memcmp(ptr1, ptr2, BO_SIZE) == 0); munmap(ptr1, BO_SIZE); @@ -79,17 +81,19 @@ int main(int argc, char **argv) { int fd1, fd2; uint32_t handle, handle_import1, handle_import2, handle_selfimport; + uint32_t handle2; int dma_buf_fd; fd1 = drm_open_any(); fd2 = drm_open_any(); handle = gem_create(fd1, BO_SIZE); + handle2 = gem_create(fd1, BO_SIZE); dma_buf_fd = prime_handle_to_fd(fd1, handle); handle_import1 = prime_fd_to_handle(fd2, dma_buf_fd); - check_bo(fd1, handle, fd2, handle_import1); + check_bo(fd1, handle, fd2, handle_import1, &counter1); /* reimport should give us the same handle so that userspace can check * whether it has that bo already somewhere. */ @@ -102,10 +106,17 @@ int main(int argc, char **argv) /* close dma_buf, check whether nothing disappears. */ close(dma_buf_fd); - check_bo(fd1, handle, fd2, handle_import1); + check_bo(fd1, handle, fd2, handle_import1, &counter1); gem_close(fd1, handle); - check_bo(fd2, handle_import1, fd2, handle_import1); + check_bo(fd2, handle_import1, fd2, handle_import1, &counter1); + + dma_buf_fd = prime_handle_to_fd(fd1, handle2); + handle = prime_fd_to_handle(fd2, dma_buf_fd); + check_bo(fd1, handle2, fd2, handle, &counter2); + gem_close(fd2, handle); + gem_close(fd1, handle2); + close(dma_buf_fd); /* re-import into old exporter */ dma_buf_fd = prime_handle_to_fd(fd2, handle_import1); @@ -113,11 +124,11 @@ int main(int argc, char **argv) gem_close(fd2, handle_import1); handle = prime_fd_to_handle(fd1, dma_buf_fd); handle_import1 = prime_fd_to_handle(fd2, dma_buf_fd); - check_bo(fd1, handle, fd2, handle_import1); + check_bo(fd1, handle, fd2, handle_import1, &counter1); /* Completely rip out exporting fd. */ close(fd1); - check_bo(fd2, handle_import1, fd2, handle_import1); + check_bo(fd2, handle_import1, fd2, handle_import1, &counter1); return 0; }