Re: [PATCH libdrm 5/5] [libdrm] add syncobj timeline tests

2018-11-06 Thread Daniel Vetter
On Mon, Nov 05, 2018 at 10:07:24AM +, Zhou, David(ChunMing) wrote:
> 
> 
> > -Original Message-
> > From: Daniel Vetter  On Behalf Of Daniel Vetter
> > Sent: Monday, November 05, 2018 5:39 PM
> > To: Zhou, David(ChunMing) 
> > Cc: dri-devel@lists.freedesktop.org; amd-...@lists.freedesktop.org
> > Subject: Re: [PATCH libdrm 5/5] [libdrm] add syncobj timeline tests
> > 
> > On Fri, Nov 02, 2018 at 04:26:49PM +0800, Chunming Zhou wrote:
> > > Signed-off-by: Chunming Zhou 
> > > ---
> > >  tests/amdgpu/Makefile.am |   3 +-
> > >  tests/amdgpu/amdgpu_test.c   |  12 ++
> > >  tests/amdgpu/amdgpu_test.h   |  21 +++
> > >  tests/amdgpu/meson.build |   2 +-
> > >  tests/amdgpu/syncobj_tests.c | 263
> > > +++
> > >  5 files changed, 299 insertions(+), 2 deletions(-)  create mode
> > > 100644 tests/amdgpu/syncobj_tests.c
> > 
> > This testcase seems very much a happy sunday scenario, no tests at all for
> > corner cases, invalid input, and generally trying to pull the kernel over 
> > the
> > table. I think we need a lot more, and preferrably in igt, where we already
> > have a good baseline of drm_syncobj tests.
> Hi Daniel,
> 
> OK, if you insist on that, I would switch to implement a timeline test on IGT.
> Btw,  timeline syncobj test needs based on command submission, Can I write it 
> with amdgpu driver on IGT?
> And after that, where should I send igt patch to review? 

We have used vgem and sw_fence in the past to be able to have very
controlled timelines. This allows us to write generic testcases. The
current igt tests for syncobj are neither i915 nor amdgpu specific.

You might still want to have an amgpu test on top, we do have some i915
tests for the i915 execbuf integration of syncobj of course. But that's a
fairly minor part of the syncobj api.

For contributing to igt, see 
https://gitlab.freedesktop.org/drm/igt-gpu-tools/blob/master/CONTRIBUTING.md

> Last, if you are free, Could you also take a look the u/k interface of 
> timeline syncobj?

Looked reasonable, the detailed questions need userspace (and so probably
better answered by someone who has mesa/vk/gl clue). I can help review
corner cases of the uapi, but that's much easier to do once we have
test-cases to exercise them all. See existing igts for an idea of what
exhaustive testing of uapi corner cases looks like.
-Daniel


> 
> 
> Thanks,
> David Zhou
> > -Daniel
> > 
> > >
> > > diff --git a/tests/amdgpu/Makefile.am b/tests/amdgpu/Makefile.am index
> > > 447ff217..d3fbe2bb 100644
> > > --- a/tests/amdgpu/Makefile.am
> > > +++ b/tests/amdgpu/Makefile.am
> > > @@ -33,4 +33,5 @@ amdgpu_test_SOURCES = \
> > >   vcn_tests.c \
> > >   uve_ib.h \
> > >   deadlock_tests.c \
> > > - vm_tests.c
> > > + vm_tests.c \
> > > + syncobj_tests.c
> > > diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
> > > index 96fcd687..cdcb93a5 100644
> > > --- a/tests/amdgpu/amdgpu_test.c
> > > +++ b/tests/amdgpu/amdgpu_test.c
> > > @@ -56,6 +56,7 @@
> > >  #define UVD_ENC_TESTS_STR "UVD ENC Tests"
> > >  #define DEADLOCK_TESTS_STR "Deadlock Tests"
> > >  #define VM_TESTS_STR "VM Tests"
> > > +#define SYNCOBJ_TIMELINE_TESTS_STR "SYNCOBJ TIMELINE Tests"
> > >
> > >  /**
> > >   *  Open handles for amdgpu devices
> > > @@ -116,6 +117,12 @@ static CU_SuiteInfo suites[] = {
> > >   .pCleanupFunc = suite_vm_tests_clean,
> > >   .pTests = vm_tests,
> > >   },
> > > + {
> > > + .pName = SYNCOBJ_TIMELINE_TESTS_STR,
> > > + .pInitFunc = suite_syncobj_timeline_tests_init,
> > > + .pCleanupFunc = suite_syncobj_timeline_tests_clean,
> > > + .pTests = syncobj_timeline_tests,
> > > + },
> > >
> > >   CU_SUITE_INFO_NULL,
> > >  };
> > > @@ -165,6 +172,11 @@ static Suites_Active_Status suites_active_stat[] = {
> > >   .pName = VM_TESTS_STR,
> > >   .pActive = suite_vm_tests_enable,
> > >   },
> > > + {
> > > + .pName = SYNCOBJ_TIMELINE_TESTS_STR,
> > > + .pActive = suite_syncobj_timeline_tests_enable,
> > > + },
> > > +
> > >  };
> > >
> > >
> > > diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
> > > index 0609a74b..946e91c2 100644
> > > ---

RE: [PATCH libdrm 5/5] [libdrm] add syncobj timeline tests

2018-11-05 Thread Zhou, David(ChunMing)


> -Original Message-
> From: Daniel Vetter  On Behalf Of Daniel Vetter
> Sent: Monday, November 05, 2018 5:39 PM
> To: Zhou, David(ChunMing) 
> Cc: dri-devel@lists.freedesktop.org; amd-...@lists.freedesktop.org
> Subject: Re: [PATCH libdrm 5/5] [libdrm] add syncobj timeline tests
> 
> On Fri, Nov 02, 2018 at 04:26:49PM +0800, Chunming Zhou wrote:
> > Signed-off-by: Chunming Zhou 
> > ---
> >  tests/amdgpu/Makefile.am |   3 +-
> >  tests/amdgpu/amdgpu_test.c   |  12 ++
> >  tests/amdgpu/amdgpu_test.h   |  21 +++
> >  tests/amdgpu/meson.build |   2 +-
> >  tests/amdgpu/syncobj_tests.c | 263
> > +++
> >  5 files changed, 299 insertions(+), 2 deletions(-)  create mode
> > 100644 tests/amdgpu/syncobj_tests.c
> 
> This testcase seems very much a happy sunday scenario, no tests at all for
> corner cases, invalid input, and generally trying to pull the kernel over the
> table. I think we need a lot more, and preferrably in igt, where we already
> have a good baseline of drm_syncobj tests.
Hi Daniel,

OK, if you insist on that, I would switch to implement a timeline test on IGT.
Btw,  timeline syncobj test needs based on command submission, Can I write it 
with amdgpu driver on IGT?
And after that, where should I send igt patch to review? 

Last, if you are free, Could you also take a look the u/k interface of timeline 
syncobj?


Thanks,
David Zhou
> -Daniel
> 
> >
> > diff --git a/tests/amdgpu/Makefile.am b/tests/amdgpu/Makefile.am index
> > 447ff217..d3fbe2bb 100644
> > --- a/tests/amdgpu/Makefile.am
> > +++ b/tests/amdgpu/Makefile.am
> > @@ -33,4 +33,5 @@ amdgpu_test_SOURCES = \
> > vcn_tests.c \
> > uve_ib.h \
> > deadlock_tests.c \
> > -   vm_tests.c
> > +   vm_tests.c \
> > +   syncobj_tests.c
> > diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
> > index 96fcd687..cdcb93a5 100644
> > --- a/tests/amdgpu/amdgpu_test.c
> > +++ b/tests/amdgpu/amdgpu_test.c
> > @@ -56,6 +56,7 @@
> >  #define UVD_ENC_TESTS_STR "UVD ENC Tests"
> >  #define DEADLOCK_TESTS_STR "Deadlock Tests"
> >  #define VM_TESTS_STR "VM Tests"
> > +#define SYNCOBJ_TIMELINE_TESTS_STR "SYNCOBJ TIMELINE Tests"
> >
> >  /**
> >   *  Open handles for amdgpu devices
> > @@ -116,6 +117,12 @@ static CU_SuiteInfo suites[] = {
> > .pCleanupFunc = suite_vm_tests_clean,
> > .pTests = vm_tests,
> > },
> > +   {
> > +   .pName = SYNCOBJ_TIMELINE_TESTS_STR,
> > +   .pInitFunc = suite_syncobj_timeline_tests_init,
> > +   .pCleanupFunc = suite_syncobj_timeline_tests_clean,
> > +   .pTests = syncobj_timeline_tests,
> > +   },
> >
> > CU_SUITE_INFO_NULL,
> >  };
> > @@ -165,6 +172,11 @@ static Suites_Active_Status suites_active_stat[] = {
> > .pName = VM_TESTS_STR,
> > .pActive = suite_vm_tests_enable,
> > },
> > +   {
> > +   .pName = SYNCOBJ_TIMELINE_TESTS_STR,
> > +   .pActive = suite_syncobj_timeline_tests_enable,
> > +   },
> > +
> >  };
> >
> >
> > diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
> > index 0609a74b..946e91c2 100644
> > --- a/tests/amdgpu/amdgpu_test.h
> > +++ b/tests/amdgpu/amdgpu_test.h
> > @@ -194,6 +194,27 @@ CU_BOOL suite_vm_tests_enable(void);
> >   */
> >  extern CU_TestInfo vm_tests[];
> >
> > +/**
> > + * Initialize syncobj timeline test suite  */ int
> > +suite_syncobj_timeline_tests_init();
> > +
> > +/**
> > + * Deinitialize syncobj timeline test suite  */ int
> > +suite_syncobj_timeline_tests_clean();
> > +
> > +/**
> > + * Decide if the suite is enabled by default or not.
> > + */
> > +CU_BOOL suite_syncobj_timeline_tests_enable(void);
> > +
> > +/**
> > + * Tests in syncobj timeline test suite  */ extern CU_TestInfo
> > +syncobj_timeline_tests[];
> > +
> > +
> >  /**
> >   * Helper functions
> >   */
> > diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build index
> > 4c1237c6..3ceec715 100644
> > --- a/tests/amdgpu/meson.build
> > +++ b/tests/amdgpu/meson.build
> > @@ -24,7 +24,7 @@ if dep_cunit.found()
> >  files(
> >'amdgpu_test.c', 'basic_tests.c', 'bo_tests.c', 'cs_tests.c',
> >'vce_tests.c', 'uvd_enc_tests.c', 'vcn_tests.c', 'deadlock_tests.c',
> > -  'vm_tests.c'

Re: [PATCH libdrm 5/5] [libdrm] add syncobj timeline tests

2018-11-05 Thread Daniel Vetter
On Fri, Nov 02, 2018 at 04:26:49PM +0800, Chunming Zhou wrote:
> Signed-off-by: Chunming Zhou 
> ---
>  tests/amdgpu/Makefile.am |   3 +-
>  tests/amdgpu/amdgpu_test.c   |  12 ++
>  tests/amdgpu/amdgpu_test.h   |  21 +++
>  tests/amdgpu/meson.build |   2 +-
>  tests/amdgpu/syncobj_tests.c | 263 +++
>  5 files changed, 299 insertions(+), 2 deletions(-)
>  create mode 100644 tests/amdgpu/syncobj_tests.c

This testcase seems very much a happy sunday scenario, no tests at all for
corner cases, invalid input, and generally trying to pull the kernel over
the table. I think we need a lot more, and preferrably in igt, where we
already have a good baseline of drm_syncobj tests.
-Daniel

> 
> diff --git a/tests/amdgpu/Makefile.am b/tests/amdgpu/Makefile.am
> index 447ff217..d3fbe2bb 100644
> --- a/tests/amdgpu/Makefile.am
> +++ b/tests/amdgpu/Makefile.am
> @@ -33,4 +33,5 @@ amdgpu_test_SOURCES = \
>   vcn_tests.c \
>   uve_ib.h \
>   deadlock_tests.c \
> - vm_tests.c
> + vm_tests.c \
> + syncobj_tests.c
> diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
> index 96fcd687..cdcb93a5 100644
> --- a/tests/amdgpu/amdgpu_test.c
> +++ b/tests/amdgpu/amdgpu_test.c
> @@ -56,6 +56,7 @@
>  #define UVD_ENC_TESTS_STR "UVD ENC Tests"
>  #define DEADLOCK_TESTS_STR "Deadlock Tests"
>  #define VM_TESTS_STR "VM Tests"
> +#define SYNCOBJ_TIMELINE_TESTS_STR "SYNCOBJ TIMELINE Tests"
>  
>  /**
>   *  Open handles for amdgpu devices
> @@ -116,6 +117,12 @@ static CU_SuiteInfo suites[] = {
>   .pCleanupFunc = suite_vm_tests_clean,
>   .pTests = vm_tests,
>   },
> + {
> + .pName = SYNCOBJ_TIMELINE_TESTS_STR,
> + .pInitFunc = suite_syncobj_timeline_tests_init,
> + .pCleanupFunc = suite_syncobj_timeline_tests_clean,
> + .pTests = syncobj_timeline_tests,
> + },
>  
>   CU_SUITE_INFO_NULL,
>  };
> @@ -165,6 +172,11 @@ static Suites_Active_Status suites_active_stat[] = {
>   .pName = VM_TESTS_STR,
>   .pActive = suite_vm_tests_enable,
>   },
> + {
> + .pName = SYNCOBJ_TIMELINE_TESTS_STR,
> + .pActive = suite_syncobj_timeline_tests_enable,
> + },
> +
>  };
>  
>  
> diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
> index 0609a74b..946e91c2 100644
> --- a/tests/amdgpu/amdgpu_test.h
> +++ b/tests/amdgpu/amdgpu_test.h
> @@ -194,6 +194,27 @@ CU_BOOL suite_vm_tests_enable(void);
>   */
>  extern CU_TestInfo vm_tests[];
>  
> +/**
> + * Initialize syncobj timeline test suite
> + */
> +int suite_syncobj_timeline_tests_init();
> +
> +/**
> + * Deinitialize syncobj timeline test suite
> + */
> +int suite_syncobj_timeline_tests_clean();
> +
> +/**
> + * Decide if the suite is enabled by default or not.
> + */
> +CU_BOOL suite_syncobj_timeline_tests_enable(void);
> +
> +/**
> + * Tests in syncobj timeline test suite
> + */
> +extern CU_TestInfo syncobj_timeline_tests[];
> +
> +
>  /**
>   * Helper functions
>   */
> diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build
> index 4c1237c6..3ceec715 100644
> --- a/tests/amdgpu/meson.build
> +++ b/tests/amdgpu/meson.build
> @@ -24,7 +24,7 @@ if dep_cunit.found()
>  files(
>'amdgpu_test.c', 'basic_tests.c', 'bo_tests.c', 'cs_tests.c',
>'vce_tests.c', 'uvd_enc_tests.c', 'vcn_tests.c', 'deadlock_tests.c',
> -  'vm_tests.c',
> +  'vm_tests.c', 'syncobj_tests.c',
>  ),
>  dependencies : [dep_cunit, dep_threads],
>  include_directories : [inc_root, inc_drm, 
> include_directories('../../amdgpu')],
> diff --git a/tests/amdgpu/syncobj_tests.c b/tests/amdgpu/syncobj_tests.c
> new file mode 100644
> index ..2a345490
> --- /dev/null
> +++ b/tests/amdgpu/syncobj_tests.c
> @@ -0,0 +1,263 @@
> +/*
> + * Copyright 2017 Advanced Micro Devices, Inc.
> + *
> + * Permission is hereby granted, free of charge, to any person obtaining a
> + * copy of this software and associated documentation files (the "Software"),
> + * to deal in the Software without restriction, including without limitation
> + * the rights to use, copy, modify, merge, publish, distribute, sublicense,
> + * and/or sell copies of the Software, and to permit persons to whom the
> + * Software is furnished to do so, subject to the following conditions:
> + *
> + * The above copyright notice and this permission notice shall be included in
> + * all copies or substantial portions of the Software.
> + *
> + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
> + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
> + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
> + * ARISING 

[PATCH libdrm 5/5] [libdrm] add syncobj timeline tests

2018-11-02 Thread Chunming Zhou
Signed-off-by: Chunming Zhou 
---
 tests/amdgpu/Makefile.am |   3 +-
 tests/amdgpu/amdgpu_test.c   |  12 ++
 tests/amdgpu/amdgpu_test.h   |  21 +++
 tests/amdgpu/meson.build |   2 +-
 tests/amdgpu/syncobj_tests.c | 263 +++
 5 files changed, 299 insertions(+), 2 deletions(-)
 create mode 100644 tests/amdgpu/syncobj_tests.c

diff --git a/tests/amdgpu/Makefile.am b/tests/amdgpu/Makefile.am
index 447ff217..d3fbe2bb 100644
--- a/tests/amdgpu/Makefile.am
+++ b/tests/amdgpu/Makefile.am
@@ -33,4 +33,5 @@ amdgpu_test_SOURCES = \
vcn_tests.c \
uve_ib.h \
deadlock_tests.c \
-   vm_tests.c
+   vm_tests.c \
+   syncobj_tests.c
diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
index 96fcd687..cdcb93a5 100644
--- a/tests/amdgpu/amdgpu_test.c
+++ b/tests/amdgpu/amdgpu_test.c
@@ -56,6 +56,7 @@
 #define UVD_ENC_TESTS_STR "UVD ENC Tests"
 #define DEADLOCK_TESTS_STR "Deadlock Tests"
 #define VM_TESTS_STR "VM Tests"
+#define SYNCOBJ_TIMELINE_TESTS_STR "SYNCOBJ TIMELINE Tests"
 
 /**
  *  Open handles for amdgpu devices
@@ -116,6 +117,12 @@ static CU_SuiteInfo suites[] = {
.pCleanupFunc = suite_vm_tests_clean,
.pTests = vm_tests,
},
+   {
+   .pName = SYNCOBJ_TIMELINE_TESTS_STR,
+   .pInitFunc = suite_syncobj_timeline_tests_init,
+   .pCleanupFunc = suite_syncobj_timeline_tests_clean,
+   .pTests = syncobj_timeline_tests,
+   },
 
CU_SUITE_INFO_NULL,
 };
@@ -165,6 +172,11 @@ static Suites_Active_Status suites_active_stat[] = {
.pName = VM_TESTS_STR,
.pActive = suite_vm_tests_enable,
},
+   {
+   .pName = SYNCOBJ_TIMELINE_TESTS_STR,
+   .pActive = suite_syncobj_timeline_tests_enable,
+   },
+
 };
 
 
diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index 0609a74b..946e91c2 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -194,6 +194,27 @@ CU_BOOL suite_vm_tests_enable(void);
  */
 extern CU_TestInfo vm_tests[];
 
+/**
+ * Initialize syncobj timeline test suite
+ */
+int suite_syncobj_timeline_tests_init();
+
+/**
+ * Deinitialize syncobj timeline test suite
+ */
+int suite_syncobj_timeline_tests_clean();
+
+/**
+ * Decide if the suite is enabled by default or not.
+ */
+CU_BOOL suite_syncobj_timeline_tests_enable(void);
+
+/**
+ * Tests in syncobj timeline test suite
+ */
+extern CU_TestInfo syncobj_timeline_tests[];
+
+
 /**
  * Helper functions
  */
diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build
index 4c1237c6..3ceec715 100644
--- a/tests/amdgpu/meson.build
+++ b/tests/amdgpu/meson.build
@@ -24,7 +24,7 @@ if dep_cunit.found()
 files(
   'amdgpu_test.c', 'basic_tests.c', 'bo_tests.c', 'cs_tests.c',
   'vce_tests.c', 'uvd_enc_tests.c', 'vcn_tests.c', 'deadlock_tests.c',
-  'vm_tests.c',
+  'vm_tests.c', 'syncobj_tests.c',
 ),
 dependencies : [dep_cunit, dep_threads],
 include_directories : [inc_root, inc_drm, 
include_directories('../../amdgpu')],
diff --git a/tests/amdgpu/syncobj_tests.c b/tests/amdgpu/syncobj_tests.c
new file mode 100644
index ..2a345490
--- /dev/null
+++ b/tests/amdgpu/syncobj_tests.c
@@ -0,0 +1,263 @@
+/*
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+*/
+
+#include "CUnit/Basic.h"
+
+#include "amdgpu_test.h"
+#include "amdgpu_drm.h"
+#include "amdgpu_internal.h"
+#include 
+
+static  amdgpu_device_handle device_handle;
+static  uint32_t  major_version;
+static  uint32_t  minor_version;
+
+static void amdgpu_syncobj_timeline_test(void);
+
+CU_BOOL suite_syncobj_timeline_tests_enable(void)
+{
+   return CU_TRUE;
+}
+
+int suite_syncobj_timeline_tests_init(void)
+{
+   int r;
+
+   r = 

[PATCH libdrm 5/5] [libdrm] add syncobj timeline tests

2018-09-19 Thread Chunming Zhou
Signed-off-by: Chunming Zhou 
---
 tests/amdgpu/Makefile.am |   3 +-
 tests/amdgpu/amdgpu_test.c   |  12 ++
 tests/amdgpu/amdgpu_test.h   |  21 +++
 tests/amdgpu/meson.build |   2 +-
 tests/amdgpu/syncobj_tests.c | 259 +++
 5 files changed, 295 insertions(+), 2 deletions(-)
 create mode 100644 tests/amdgpu/syncobj_tests.c

diff --git a/tests/amdgpu/Makefile.am b/tests/amdgpu/Makefile.am
index e79c1bd3..61f2b426 100644
--- a/tests/amdgpu/Makefile.am
+++ b/tests/amdgpu/Makefile.am
@@ -32,4 +32,5 @@ amdgpu_test_SOURCES = \
vcn_tests.c \
uve_ib.h \
deadlock_tests.c \
-   vm_tests.c
+   vm_tests.c \
+   syncobj_tests.c
diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
index 96fcd687..cdcb93a5 100644
--- a/tests/amdgpu/amdgpu_test.c
+++ b/tests/amdgpu/amdgpu_test.c
@@ -56,6 +56,7 @@
 #define UVD_ENC_TESTS_STR "UVD ENC Tests"
 #define DEADLOCK_TESTS_STR "Deadlock Tests"
 #define VM_TESTS_STR "VM Tests"
+#define SYNCOBJ_TIMELINE_TESTS_STR "SYNCOBJ TIMELINE Tests"
 
 /**
  *  Open handles for amdgpu devices
@@ -116,6 +117,12 @@ static CU_SuiteInfo suites[] = {
.pCleanupFunc = suite_vm_tests_clean,
.pTests = vm_tests,
},
+   {
+   .pName = SYNCOBJ_TIMELINE_TESTS_STR,
+   .pInitFunc = suite_syncobj_timeline_tests_init,
+   .pCleanupFunc = suite_syncobj_timeline_tests_clean,
+   .pTests = syncobj_timeline_tests,
+   },
 
CU_SUITE_INFO_NULL,
 };
@@ -165,6 +172,11 @@ static Suites_Active_Status suites_active_stat[] = {
.pName = VM_TESTS_STR,
.pActive = suite_vm_tests_enable,
},
+   {
+   .pName = SYNCOBJ_TIMELINE_TESTS_STR,
+   .pActive = suite_syncobj_timeline_tests_enable,
+   },
+
 };
 
 
diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index f2ece3c3..960df046 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -194,6 +194,27 @@ CU_BOOL suite_vm_tests_enable(void);
  */
 extern CU_TestInfo vm_tests[];
 
+/**
+ * Initialize syncobj timeline test suite
+ */
+int suite_syncobj_timeline_tests_init();
+
+/**
+ * Deinitialize syncobj timeline test suite
+ */
+int suite_syncobj_timeline_tests_clean();
+
+/**
+ * Decide if the suite is enabled by default or not.
+ */
+CU_BOOL suite_syncobj_timeline_tests_enable(void);
+
+/**
+ * Tests in syncobj timeline test suite
+ */
+extern CU_TestInfo syncobj_timeline_tests[];
+
+
 /**
  * Helper functions
  */
diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build
index 4c1237c6..3ceec715 100644
--- a/tests/amdgpu/meson.build
+++ b/tests/amdgpu/meson.build
@@ -24,7 +24,7 @@ if dep_cunit.found()
 files(
   'amdgpu_test.c', 'basic_tests.c', 'bo_tests.c', 'cs_tests.c',
   'vce_tests.c', 'uvd_enc_tests.c', 'vcn_tests.c', 'deadlock_tests.c',
-  'vm_tests.c',
+  'vm_tests.c', 'syncobj_tests.c',
 ),
 dependencies : [dep_cunit, dep_threads],
 include_directories : [inc_root, inc_drm, 
include_directories('../../amdgpu')],
diff --git a/tests/amdgpu/syncobj_tests.c b/tests/amdgpu/syncobj_tests.c
new file mode 100644
index ..a70bd92d
--- /dev/null
+++ b/tests/amdgpu/syncobj_tests.c
@@ -0,0 +1,259 @@
+/*
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+*/
+
+#include "CUnit/Basic.h"
+
+#include "amdgpu_test.h"
+#include "amdgpu_drm.h"
+#include "amdgpu_internal.h"
+#include 
+
+static  amdgpu_device_handle device_handle;
+static  uint32_t  major_version;
+static  uint32_t  minor_version;
+
+static void amdgpu_syncobj_timeline_test(void);
+
+CU_BOOL suite_syncobj_timeline_tests_enable(void)
+{
+   return CU_TRUE;
+}
+
+int suite_syncobj_timeline_tests_init(void)
+{
+   int r;
+
+   r = 

[PATCH libdrm 5/5] [libdrm] add syncobj timeline tests

2018-09-12 Thread Chunming Zhou
Signed-off-by: Chunming Zhou 
---
 tests/amdgpu/Makefile.am |   3 +-
 tests/amdgpu/amdgpu_test.c   |  12 ++
 tests/amdgpu/amdgpu_test.h   |  21 +++
 tests/amdgpu/meson.build |   2 +-
 tests/amdgpu/syncobj_tests.c | 258 +++
 5 files changed, 294 insertions(+), 2 deletions(-)
 create mode 100644 tests/amdgpu/syncobj_tests.c

diff --git a/tests/amdgpu/Makefile.am b/tests/amdgpu/Makefile.am
index e79c1bd3..61f2b426 100644
--- a/tests/amdgpu/Makefile.am
+++ b/tests/amdgpu/Makefile.am
@@ -32,4 +32,5 @@ amdgpu_test_SOURCES = \
vcn_tests.c \
uve_ib.h \
deadlock_tests.c \
-   vm_tests.c
+   vm_tests.c \
+   syncobj_tests.c
diff --git a/tests/amdgpu/amdgpu_test.c b/tests/amdgpu/amdgpu_test.c
index 96fcd687..cdcb93a5 100644
--- a/tests/amdgpu/amdgpu_test.c
+++ b/tests/amdgpu/amdgpu_test.c
@@ -56,6 +56,7 @@
 #define UVD_ENC_TESTS_STR "UVD ENC Tests"
 #define DEADLOCK_TESTS_STR "Deadlock Tests"
 #define VM_TESTS_STR "VM Tests"
+#define SYNCOBJ_TIMELINE_TESTS_STR "SYNCOBJ TIMELINE Tests"
 
 /**
  *  Open handles for amdgpu devices
@@ -116,6 +117,12 @@ static CU_SuiteInfo suites[] = {
.pCleanupFunc = suite_vm_tests_clean,
.pTests = vm_tests,
},
+   {
+   .pName = SYNCOBJ_TIMELINE_TESTS_STR,
+   .pInitFunc = suite_syncobj_timeline_tests_init,
+   .pCleanupFunc = suite_syncobj_timeline_tests_clean,
+   .pTests = syncobj_timeline_tests,
+   },
 
CU_SUITE_INFO_NULL,
 };
@@ -165,6 +172,11 @@ static Suites_Active_Status suites_active_stat[] = {
.pName = VM_TESTS_STR,
.pActive = suite_vm_tests_enable,
},
+   {
+   .pName = SYNCOBJ_TIMELINE_TESTS_STR,
+   .pActive = suite_syncobj_timeline_tests_enable,
+   },
+
 };
 
 
diff --git a/tests/amdgpu/amdgpu_test.h b/tests/amdgpu/amdgpu_test.h
index f2ece3c3..960df046 100644
--- a/tests/amdgpu/amdgpu_test.h
+++ b/tests/amdgpu/amdgpu_test.h
@@ -194,6 +194,27 @@ CU_BOOL suite_vm_tests_enable(void);
  */
 extern CU_TestInfo vm_tests[];
 
+/**
+ * Initialize syncobj timeline test suite
+ */
+int suite_syncobj_timeline_tests_init();
+
+/**
+ * Deinitialize syncobj timeline test suite
+ */
+int suite_syncobj_timeline_tests_clean();
+
+/**
+ * Decide if the suite is enabled by default or not.
+ */
+CU_BOOL suite_syncobj_timeline_tests_enable(void);
+
+/**
+ * Tests in syncobj timeline test suite
+ */
+extern CU_TestInfo syncobj_timeline_tests[];
+
+
 /**
  * Helper functions
  */
diff --git a/tests/amdgpu/meson.build b/tests/amdgpu/meson.build
index 4c1237c6..3ceec715 100644
--- a/tests/amdgpu/meson.build
+++ b/tests/amdgpu/meson.build
@@ -24,7 +24,7 @@ if dep_cunit.found()
 files(
   'amdgpu_test.c', 'basic_tests.c', 'bo_tests.c', 'cs_tests.c',
   'vce_tests.c', 'uvd_enc_tests.c', 'vcn_tests.c', 'deadlock_tests.c',
-  'vm_tests.c',
+  'vm_tests.c', 'syncobj_tests.c',
 ),
 dependencies : [dep_cunit, dep_threads],
 include_directories : [inc_root, inc_drm, 
include_directories('../../amdgpu')],
diff --git a/tests/amdgpu/syncobj_tests.c b/tests/amdgpu/syncobj_tests.c
new file mode 100644
index ..196c66d2
--- /dev/null
+++ b/tests/amdgpu/syncobj_tests.c
@@ -0,0 +1,258 @@
+/*
+ * Copyright 2017 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+*/
+
+#include "CUnit/Basic.h"
+
+#include "amdgpu_test.h"
+#include "amdgpu_drm.h"
+#include "amdgpu_internal.h"
+#include 
+
+static  amdgpu_device_handle device_handle;
+static  uint32_t  major_version;
+static  uint32_t  minor_version;
+
+static void amdgpu_syncobj_timeline_test(void);
+
+CU_BOOL suite_syncobj_timeline_tests_enable(void)
+{
+   return CU_TRUE;
+}
+
+int suite_syncobj_timeline_tests_init(void)
+{
+   int r;
+
+   r =