From: Daniel Vetter Subject: Re: [PATCH] tests/prime_self_import: export/import a second gem buffer Date: Wed, 17 Apr 2013 19:06:28 +0200 Message-ID: <20130417170628.GD27272@phenom.ffwll.local> References: <1366215000-2366-1-git-send-email-imre.deak@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mail-ea0-f176.google.com (mail-ea0-f176.google.com [209.85.215.176]) by gabe.freedesktop.org (Postfix) with ESMTP id 7D3DEE6721 for ; Wed, 17 Apr 2013 10:03:27 -0700 (PDT) Received: by mail-ea0-f176.google.com with SMTP id h14so211294eak.35 for ; Wed, 17 Apr 2013 10:03:26 -0700 (PDT) Content-Disposition: inline In-Reply-To: <1366215000-2366-1-git-send-email-imre.deak@intel.com> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+gcfxdi-intel-gfx=m.gmane.org@lists.freedesktop.org To: Imre Deak Cc: intel-gfx@lists.freedesktop.org List-Id: intel-gfx@lists.freedesktop.org On Wed, Apr 17, 2013 at 07:10:00PM +0300, Imre Deak wrote: > Signed-off-by: Imre Deak I'm a bit confused what this does ... can you please elaborate? -Daniel > --- > 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; > } > -- > 1.7.10.4 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > http://lists.freedesktop.org/mailman/listinfo/intel-gfx -- Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch