Tests for verifying the old and extended GEM_CREATE ioctl
v4 cover Tests for verifying the old and extended GEM_CREATE ioctl
From: Ankitprasad Sharma <[email protected]>
This new set of tests verifies the old and the new extended GEM_CREATE ioctl gem_stolen tries to verify the new extended GEM_CREATE ioctl, which tries to create an object backed by stolen memory and performs basic operations on it. It verifies the creation as well as the purging of an object when it is no longer needed, copying contents of a stolen backed object to another, doing a pread/pwrite on the object and verifying its contents.
We also try to pread/pwrite a stolen backed object multiple times to get the pread/pwrite speed, as well as pread speed when there is a page fault while accessing userspace buffer.
There is a new test gem_create to do a sanity check for creating both stolen/shmem backed objects with valid and invalid parameters.
v2: Rebased to the latest and added IGT_TEST_DESCRIPTION
v3: Addressed comments by Tvrtko and Dave, added one more testcase for verifying extended gem_create ioctl
v4: Addressed comments by Tvrtko, removed unused variables, addressed compiler warnings
v5: Added one more patch to verify contents of stolen backed object across hibernation
Ankitprasad Sharma (4):
igt/gem_stolen: Verifying extended gem_create ioctl igt/gem_pread: Support to verify pread/pwrite for non-shmem backed obj igt/gem_create: Test to validate parameters for GEM_CREATE ioctl igt/gem_stolen: Verify contents of stolen-backed objects across
hibernation
lib/ioctl_wrappers.c | 72 ++++++++ lib/ioctl_wrappers.h | 13 ++ tests/Makefile.sources | 2 + tests/gem_create.c | 166 ++++++++++++++++++ tests/gem_pread.c | 108 +++++++++++- tests/gem_pwrite.c | 55 +++++- tests/gem_stolen.c | 446 +++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 849 insertions(+), 13 deletions(-) create mode 100644 tests/gem_create.c create mode 100644 tests/gem_stolen.c
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 1/4 igt/gem_stolen: Verifying extended gem_create ioctl
From: Ankitprasad Sharma <[email protected]>
This patch adds the testcases for verifying the new extended gem_create ioctl. By means of this extended ioctl, memory placement of the GEM object can be specified, i.e. either shmem or stolen memory.
These testcases include functional tests and interface tests for testing the gem_create ioctl call for stolen memory placement
v2: Testing pread/pwrite functionality for stolen backed objects, added local struct for extended gem_create and gem_get_aperture, until headers catch up (Chris)
v3: Removed get_aperture related functions, extended gem_pread to compare speeds for user pages with and without page faults, unexposed local_gem_create struct, changed gem_create_stolen usage (Chris)
v4: Splitting patch to remove changes from gem_pread/gem_pwrite to another patch (Ankit)
v5: Fixed Rebase conflicts (Ankit)
Added IGT_TEST_DESCRIPTION (Thomas Wood)
v6: Added __gem_create_stolen for user to handle error, updated gem_create_stolen to align with gem_create function, corrected fill_purge test (out of bound access), added testcase to validate allocating of more than 32 bit sized buffers (Tvrtko)
v7: Removed unused variables, Corrected comments & formatting (Tvrtko)
--- lib/ioctl_wrappers.c | 72 ++++++++++ lib/ioctl_wrappers.h | 13 ++ tests/Makefile.sources | 1 + tests/gem_stolen.c | 360 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 446 insertions(+) create mode 100644 tests/gem_stolen.c
lib/ioctl_wrappers.c +72 -0
@@ -389,6 +389,78 @@ void gem_sync(int fd, uint32_t handle) I915_GEM_DOMAIN_GTT, I915_GEM_DOMAIN_GTT); } +bool gem_create__has_stolen_support (int fd) +{ +static int has_stolen_support =-1 ; +struct drm_i915_getparam gp; +int val =-1 ; + +if (has_stolen_support <0 ) { +memset (&gp,0 ,sizeof (gp)); + gp.param =36 ;/* CREATE_VERSION */ + gp.value = &val; + +/* Do we have the extended gem_create_ioctl? */ +ioctl (fd,DRM_IOCTL_I915_GETPARAM , &gp); + has_stolen_support = val >=2 ; + } + +return has_stolen_support; +} + +struct local_i915_gem_create_v2 { +uint64_t size; +uint32_t handle; +uint32_t pad; +#define I915_CREATE_PLACEMENT_STOLEN (1<<0) +uint32_t flags; +}; + +#define LOCAL_IOCTL_I915_GEM_CREATE DRM_IOWR(DRM_COMMAND_BASE + DRM_I915_GEM_CREATE, struct local_i915_gem_create_v2) +uint32_t __gem_create_stolen (int fd,uint64_t size) +{ +struct local_i915_gem_create_v2 create; +int ret; + +memset (&create,0 ,sizeof (create)); + create.handle =0 ; + create.size = size; + create.flags =I915_CREATE_PLACEMENT_STOLEN ; + ret =drmIoctl (fd,LOCAL_IOCTL_I915_GEM_CREATE , &create); + +if (ret <0 ) +return 0 ; + + errno =0 ; +return create.handle; +} + +/** +* gem_create_stolen: +* @fd: open i915 drm file descriptor +* @size: desired size of the buffer +* +* This wraps the new GEM_CREATE ioctl, which allocates a new gem buffer +* object of @size and placement in stolen memory region. +* +* Returns: The file-private handle of the created buffer object +*/ + +uint32_t gem_create_stolen (int fd,uint64_t size) +{ +struct local_i915_gem_create_v2 create; + +memset (&create,0 ,sizeof (create)); + create.handle =0 ; + create.size = size; + create.flags =I915_CREATE_PLACEMENT_STOLEN ; +do_ioctl (fd,LOCAL_IOCTL_I915_GEM_CREATE , &create); +igt_assert (create.handle); + +return create.handle; +} + +uint32_t __gem_create (int fd,int size) {struct drm_i915_gem_create create;
lib/ioctl_wrappers.h +13 -0
@@ -56,6 +56,9 @@ void gem_read(int fd, uint32_t handle, uint64_t offset, void *buf, uint64_t lengvoid gem_set_domain (int fd,uint32_t handle,uint32_t read_domains,uint32_t write_domain);void gem_sync (int fd,uint32_t handle); +bool gem_create__has_stolen_support (int fd); +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);void gem_execbuf (int fd,struct drm_i915_gem_execbuffer2 *execbuf);
@@ -67,6 +70,16 @@ bool gem_mmap__has_wc(int fd);void *gem_mmap__wc (int fd,uint32_t handle,uint64_t offset,uint64_t size,unsigned prot);/** +* gem_require_stolen_support: +* @fd: open i915 drm file descriptor +* +* Test macro to query whether support for allocating objects from stolen +* memory is available. Automatically skips through igt_require() if not. +*/ +#define gem_require_stolen_support (fd) \ + igt_require(gem_create__has_stolen_support(fd)) + +/** * gem_require_mmap_wc: * @fd: open i915 drm file descriptor *
tests/Makefile.sources +1 -0
@@ -55,6 +55,7 @@ TESTS_progs_M = \ gem_reset_stats \ gem_ringfill \ gem_set_tiling_vs_blt \ + gem_stolen \ gem_storedw_batches_loop \ gem_streaming_writes \ gem_tiled_blits \
tests/gem_stolen.c new file +360 -0
360 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 2/4 igt/gem_pread: Support to verify pread/pwrite for non-shmem backed obj
In reply to [email protected]From: Ankitprasad Sharma <[email protected]>
This patch adds support to verify pread/pwrite for non-shmem backed objects. It also shows the pread/pwrite speed.
It also tests speeds for pread with and without user side page faults
v2: Fixed Rebase conflicts (Ankit)
v3: Precalculating values to avoid redundant function calls (Dave) Replaced igt_subtest by igt_subtest_f, added asserts for mmap, corrected indentation (Tvrtko)
v4: Updated data types to avoid redundant type conversions (Tvrtko) Corrected pagefault-pread time calculation (Ankit)
--- tests/gem_pread.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++---- tests/gem_pwrite.c | 55 ++++++++++++++++++++++++--- 2 files changed, 150 insertions(+), 13 deletions(-)
tests/gem_pread.c +101 -7
@@ -41,6 +41,10 @@#include "drmtest.h" #define OBJECT_SIZE 16384 +#define LARGE_OBJECT_SIZE 1024 * 1024 +#define KGRN "\x1B[32m" +#define KRED "\x1B[31m" +#define KNRM "\x1B[0m"static void do_gem_read (int fd,uint32_t handle,void *buf,int len,int loops) {
@@ -76,12 +80,16 @@ static const char *bytes_per_sec(char *buf, double v)uint32_t *src, dst; +uint32_t *dst_user, src_stolen, large_stolen; +uint32_t *stolen_pf_user, *stolen_nopf_user;int fd, count;int main (int argc,char **argv) {int object_size =0 ; -uint32_t buf[20 ]; +double usecs; +char buf[100 ]; +char * bps; const struct { int level; const char *name;
@@ -106,6 +114,8 @@ int main(int argc, char **argv) dst =gem_create (fd, object_size); src =malloc (object_size); + src_stolen =gem_create_stolen (fd, object_size); + dst_user =malloc (object_size); } igt_subtest("normal") {
@@ -115,10 +125,10 @@ int main(int argc, char **argv)gettimeofday (&start,NULL );do_gem_read (fd, dst, src, object_size, count);gettimeofday (&end,NULL ); + usecs =elapsed (&start, &end, count); + bps =bytes_per_sec (buf, object_size/usecs*1e6 );igt_info ("Time to pread %d bytes x %6d: %7.3fµs, %s\n" , - object_size, count, -elapsed (&start, &end, count), -bytes_per_sec ((char *)buf, object_size/elapsed (&start, &end, count)*1e6 )); + object_size, count, usecs, bps);fflush (stdout); } }
@@ -133,18 +143,102 @@ int main(int argc, char **argv)gettimeofday (&start,NULL );do_gem_read (fd, dst, src, object_size, count);gettimeofday (&end,NULL ); + usecs =elapsed (&start, &end, count); + bps =bytes_per_sec (buf, object_size/usecs*1e6 );igt_info ("Time to %s pread %d bytes x %6d: %7.3fµs, %s\n" , - c->name, object_size, count, -elapsed (&start, &end, count), -bytes_per_sec ((char *)buf, object_size/elapsed (&start, &end, count)*1e6 )); + c->name, object_size, count, usecs, bps);fflush (stdout); } } } + igt_subtest("stolen-normal") { +for (count =1 ; count <=1 <<17 ; count <<=1 ) { +struct timeval start, end; + +gettimeofday (&start,NULL ); +do_gem_read (fd, src_stolen, dst_user, object_size, count); +gettimeofday (&end,NULL ); + usecs =elapsed (&start, &end, count); + bps =bytes_per_sec (buf, object_size/usecs*1e6 ); +igt_info ("Time to pread %d bytes x %6d: %7.3fµs, %s\n" , + object_size, count, usecs, bps); +fflush (stdout); + } + } +for (c = cache; c->level !=-1 ; c++) { + igt_subtest_f("stolen-%s", c->name) { +gem_set_caching (fd, src_stolen, c->level); + +for (count =1 ; count <=1 <<17 ; count <<=1 ) { +struct timeval start, end; + +gettimeofday (&start,NULL ); +do_gem_read (fd, src_stolen, dst_user, + object_size, count); +gettimeofday (&end,NULL ); + usecs =elapsed (&start, &end, count); + bps =bytes_per_sec (buf, object_size/usecs*1e6 ); +igt_info ("Time to stolen-%s pread %d bytes x %6d: %7.3fµs, %s\n" , + c->name, object_size, count, usecs, bps); +fflush (stdout); + } + } + } + +/* List the time taken in pread operation for stolen objects, with +* and without the overhead of page fault handling on accessing the +* user space buffer +*/ + igt_subtest("pagefault-pread") { + large_stolen =gem_create_stolen (fd,LARGE_OBJECT_SIZE ); + stolen_nopf_user = (uint32_t *)mmap (NULL ,LARGE_OBJECT_SIZE , +PROT_WRITE , +MAP_ANONYMOUS |MAP_PRIVATE , +-1 ,0 ); +igt_assert (stolen_nopf_user); + +for (count =1 ; count <=10 ; count ++) { +struct timeval start, end; +double t_elapsed =0 ; + +gettimeofday (&start,NULL ); +do_gem_read (fd, large_stolen, stolen_nopf_user, +LARGE_OBJECT_SIZE ,1 ); +gettimeofday (&end,NULL ); + t_elapsed =elapsed (&start, &end, count); + bps =bytes_per_sec (buf, object_size/t_elapsed*1e6 ); +igt_info ("Pagefault-N - Time to pread %d bytes: %7.3fµs, %s\n" , +LARGE_OBJECT_SIZE , t_elapsed, bps); + + stolen_pf_user = (uint32_t *)mmap (NULL ,LARGE_OBJECT_SIZE , +PROT_WRITE , +MAP_ANONYMOUS |MAP_PRIVATE , +-1 ,0 ); +igt_assert (stolen_pf_user); + +gettimeofday (&start,NULL ); +do_gem_read (fd, large_stolen, stolen_pf_user, +LARGE_OBJECT_SIZE ,1 ); +gettimeofday (&end,NULL ); + usecs =elapsed (&start, &end, count); + bps =bytes_per_sec (buf, object_size/usecs*1e6 ); +igt_info ("Pagefault-Y - Time to pread %d bytes: %7.3fµs, %s%s%s\n" , +LARGE_OBJECT_SIZE , usecs, + t_elapsed < usecs ?KGRN :KRED , bps,KNRM ); +fflush (stdout); +munmap (stolen_pf_user,LARGE_OBJECT_SIZE ); + } +munmap (stolen_nopf_user,LARGE_OBJECT_SIZE ); +gem_close (fd, large_stolen); + } + + igt_fixture {free (src);gem_close (fd, dst); +free (dst_user); +gem_close (fd, src_stolen);close (fd); }
tests/gem_pwrite.c +49 -6
93 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 3/4 igt/gem_create: Test to validate parameters for GEM_CREATE ioctl
In reply to [email protected]From: Ankitprasad Sharma <[email protected]>
This test validates the two parameters (size and flags) GEM_CREATE ioctl.
v2: Added IGT_TEST_DESCRIPTION (Thomas Wood)
v3: Removed use of hard coded values, updated comments (Tvrtko)
v4: Removed over-use of macros, updated with multiples of PAGE_SIZE (Tvrtko)
--- tests/Makefile.sources | 1 + tests/gem_create.c | 166 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 167 insertions(+) create mode 100644 tests/gem_create.c
tests/Makefile.sources +1 -0
@@ -15,6 +15,7 @@ TESTS_progs_M = \ gem_close_race \ gem_concurrent_blit \ gem_concurrent_all \ + gem_create \ gem_cs_tlb \ gem_ctx_param_basic \ gem_ctx_bad_exec \
tests/gem_create.c new file +166 -0
166 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH 4/4 igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
In reply to [email protected]From: Ankitprasad Sharma <[email protected]>
This patch verifies if the contents of the stolen backed object were preserved across hibernation. This is to validate kernel changes related to moving stolen-backed objects to shmem on hibernation.
--- tests/gem_stolen.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)
tests/gem_stolen.c +86 -0
@@ -290,6 +290,89 @@ static void stolen_fill_purge_test(int fd)gem_close (fd, handle[i]); } +static void stolen_hibernate (int fd) +{ +drm_intel_bo *bo; +drm_intel_bo *src, *dest; +int obj_count =0 , i =0 ; +int _ret =0 , j =0 ; +uint32_t handle[MAX_OBJECTS ], src_handle; +uint32_t *virt; + +gem_require_stolen_support (fd); + + src_handle =gem_create (fd,SIZE ); +igt_assert (!src_handle); + src =gem_handle_to_libdrm_bo (bufmgr, fd, +"bo" , src_handle); +igt_assert (src !=NULL ); + + _ret =drm_intel_gem_bo_map_gtt (src); +igt_assert (!_ret); + + virt = src->virtual; +for (j =0 ; j <SIZE /DWORD_SIZE ; j++) + virt[j] =DATA ; + +drm_intel_bo_unmap (src); +/* Exhaust Stolen space */ +do { + handle[i] =__gem_create_stolen (fd,SIZE ); +if (handle[i] !=0 ) { + bo =gem_handle_to_libdrm_bo (bufmgr, fd, +"verify_bo" , handle[i]); +igt_assert (bo !=NULL ); + _ret =drm_intel_gem_bo_map_gtt (bo); +igt_assert (!_ret); + + virt = bo->virtual; +for (j =0 ; j <SIZE /DWORD_SIZE ; j++) +igt_assert (!virt[j]); + +drm_intel_bo_unmap (bo); +drm_intel_bo_unreference (bo); + + obj_count++; + } + + i++; + }while (handle[i-1 ] && i <MAX_OBJECTS ); + +igt_assert (obj_count >0 ); + +for (i =0 ; i < obj_count; i++) { + dest =gem_handle_to_libdrm_bo (bufmgr, fd, +"dst_bo" , handle[i]); +igt_assert (dest !=NULL ); +intel_copy_bo (batch, dest, src,SIZE ); +drm_intel_bo_unreference (dest); + } + +drm_intel_bo_unreference (src); + +igt_system_hibernate_autoresume (); +/* Check if the object's memory contents are intact +* across hibernation. +*/ +for (i =0 ; i < obj_count; i++) { + bo =gem_handle_to_libdrm_bo (bufmgr, fd, +"verify_bo" , handle[i]); +igt_assert (bo !=NULL ); + _ret =drm_intel_gem_bo_map_gtt (bo); +igt_assert (!_ret); + virt = bo->virtual; +for (j =0 ; j <SIZE /DWORD_SIZE ; j++) +igt_assert_eq (virt[j],DATA ); + +drm_intel_bo_unmap (bo); +drm_intel_bo_unreference (bo); + } + +gem_close (fd, src_handle); +for (i =0 ; i < obj_count; i++) +gem_close (fd, handle[i]); +} +static void stolen_no_mmap (int fd) {
@@ -353,6 +436,9 @@ igt_main igt_subtest("stolen-fill-purge")stolen_fill_purge_test (fd); + igt_subtest("stolen-hibernate") +stolen_hibernate (fd); + igt_fixture {intel_batchbuffer_free (batch);drm_intel_bufmgr_destroy (bufmgr);
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/4] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
Hi,
Quoted 7 lines · On 02/12/15 09:24, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
This patch verifies if the contents of the stolen backed object were preserved across hibernation. This is to validate kernel changes related to moving stolen-backed objects to shmem on hibernation.
Signed-off-by Ankitprasad Sharma <[email protected]>
Please Cc me if it is expected I keep reviewing this.
Quoted 9 lines
--- tests/gem_stolen.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)tests/gem_stolen.c +0
-0
tests/gem_stolen.c static void stolen_fill_purge_test(int fd) · line 298
Quoted 9 lines
tests/gem_stolen.c +6
-0@@ -290,6 +290,89 @@ static void stolen_fill_purge_test(int fd)gem_close (fd, handle[i]); } +static void stolen_hibernate (int fd) +{ +drm_intel_bo *bo; +drm_intel_bo *src, *dest; +int obj_count =0 , i =0 ; +int _ret =0 , j =0 ;
Don't need to init _ret and j.
tests/gem_stolen.c static void stolen_fill_purge_test(int fd) · line 305
Quoted 7 lines
tests/gem_stolen.c +7
-0+uint32_t handle[MAX_OBJECTS ], src_handle; +uint32_t *virt; + +gem_require_stolen_support (fd); + + src_handle =gem_create (fd,SIZE ); +igt_assert (!src_handle);
gem_create already asserts this, but isn't it also reversed? Does it run and work?
tests/gem_stolen.c static void stolen_fill_purge_test(int fd) · line 311
Quoted 6 lines
tests/gem_stolen.c +6
-0+ src =gem_handle_to_libdrm_bo (bufmgr, fd, +"bo" , src_handle); +igt_assert (src !=NULL ); + + _ret =drm_intel_gem_bo_map_gtt (src); +igt_assert (!_ret);
I think igt_assert_eq(ret, 0) is a preferred way nowadays.
Also a question, what is the special significance of _ret vs just normal ret in this test?
tests/gem_stolen.c static void stolen_fill_purge_test(int fd) · line 315
Quoted 4 lines
tests/gem_stolen.c +4
-0+ + virt = src->virtual; +for (j =0 ; j <SIZE /DWORD_SIZE ; j++) + virt[j] =DATA ;
memset?
tests/gem_stolen.c static void stolen_fill_purge_test(int fd) · line 321
Quoted 6 lines
tests/gem_stolen.c +6
-0+ +drm_intel_bo_unmap (src); +/* Exhaust Stolen space */ + do { + handle[i] = __gem_create_stolen(fd, SIZE); + if (handle[i] != 0) {
Maybe it would be more readable and with less indentation:
for (i = 0; i < MAX_OBJECTS; i++) {
handle[i] = __gem_create_stolen(...);
if (!handle[i])
break;
...
obj_count++;
}tests/gem_stolen.c static void stolen_fill_purge_test(int fd) · line 330
Quoted 9 lines
tests/gem_stolen.c +9
-0+ bo =gem_handle_to_libdrm_bo (bufmgr, fd, +"verify_bo" , handle[i]); +igt_assert (bo !=NULL ); + _ret =drm_intel_gem_bo_map_gtt (bo); +igt_assert (!_ret); + + virt = bo->virtual; +for (j =0 ; j <SIZE /DWORD_SIZE ; j++) +igt_assert (!virt[j]);
Again, people will probably want igt_assert_eq.
Quoted 9 lines
tests/gem_stolen.c +9
-0+ +drm_intel_bo_unmap (bo); +drm_intel_bo_unreference (bo); + + obj_count++; + } + + i++; + }while (handle[i-1 ] && i <MAX_OBJECTS );
tests/gem_stolen.c static void stolen_fill_purge_test(int fd) · line 349
Quoted 10 lines
tests/gem_stolen.c +10
-0+ +igt_assert (obj_count >0 ); + +for (i =0 ; i < obj_count; i++) { + dest =gem_handle_to_libdrm_bo (bufmgr, fd, +"dst_bo" , handle[i]); +igt_assert (dest !=NULL ); +intel_copy_bo (batch, dest, src,SIZE ); +drm_intel_bo_unreference (dest); + }
Probably worth doing a verification step after each blit. So after resume is not the first time you are checking it.
Quoted 9 lines
tests/gem_stolen.c +9
-0+drm_intel_bo_unreference (src); + +igt_system_hibernate_autoresume (); +/* Check if the object's memory contents are intact +* across hibernation. +*/ +for (i =0 ; i < obj_count; i++) { + bo =gem_handle_to_libdrm_bo (bufmgr, fd, +"verify_bo" , handle[i]);
tests/gem_stolen.c static void stolen_fill_purge_test(int fd) · line 369
Quoted 10 lines
tests/gem_stolen.c +10
-0+igt_assert (bo !=NULL ); + _ret =drm_intel_gem_bo_map_gtt (bo); +igt_assert (!_ret); + virt = bo->virtual; +for (j =0 ; j <SIZE /DWORD_SIZE ; j++) +igt_assert_eq (virt[j],DATA ); + +drm_intel_bo_unmap (bo); +drm_intel_bo_unreference (bo); + }
Would it be interesting to fill the bos with some more elaborate pattern to potentially catch more potential corruption types?
Perhaps incrementing dwords would simply do?
Quoted 10 lines
tests/gem_stolen.c +5
-0+gem_close (fd, src_handle); +for (i =0 ; i < obj_count; i++) +gem_close (fd, handle[i]); +} +static void stolen_no_mmap (int fd) {
tests/gem_stolen.c igt_main · line 444
Quoted 9 lines
tests/gem_stolen.c +3
-0@@ -353,6 +436,9 @@ igt_main igt_subtest("stolen-fill-purge")stolen_fill_purge_test (fd); + igt_subtest("stolen-hibernate") +stolen_hibernate (fd); + igt_fixture {intel_batchbuffer_free (batch);drm_intel_bufmgr_destroy (bufmgr);
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH 4/4] igt/gem_stolen: Verify contents of stolen-backed objects across hibernation
In reply to [email protected]Hi,
One more thing below:
Quoted 58 lines · On 02/12/15 09:24, [email protected] wrote:
From: Ankitprasad Sharma <[email protected]>
This patch verifies if the contents of the stolen backed object were preserved across hibernation. This is to validate kernel changes related to moving stolen-backed objects to shmem on hibernation.
Signed-off-by Ankitprasad Sharma <[email protected]>--- tests/gem_stolen.c | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+)tests/gem_stolen.c +39
-0@@ -290,6 +290,89 @@ static void stolen_fill_purge_test(int fd)gem_close (fd, handle[i]); } +static void stolen_hibernate (int fd) +{ +drm_intel_bo *bo; +drm_intel_bo *src, *dest; +int obj_count =0 , i =0 ; +int _ret =0 , j =0 ; +uint32_t handle[MAX_OBJECTS ], src_handle; +uint32_t *virt; + +gem_require_stolen_support (fd); + + src_handle =gem_create (fd,SIZE ); +igt_assert (!src_handle); + src =gem_handle_to_libdrm_bo (bufmgr, fd, +"bo" , src_handle); +igt_assert (src !=NULL ); + + _ret =drm_intel_gem_bo_map_gtt (src); +igt_assert (!_ret); + + virt = src->virtual; +for (j =0 ; j <SIZE /DWORD_SIZE ; j++) + virt[j] =DATA ; + +drm_intel_bo_unmap (src); +/* Exhaust Stolen space */ + do { + handle[i] = __gem_create_stolen(fd, SIZE); + if (handle[i] != 0) { + bo = gem_handle_to_libdrm_bo(bufmgr, fd, + "verify_bo", handle[i]); + igt_assert(bo != NULL); + _ret = drm_intel_gem_bo_map_gtt(bo); + igt_assert(!_ret); + + virt = bo->virtual; + for (j = 0; j < SIZE/DWORD_SIZE; j++) + igt_assert(!virt[j]); +
tests/gem_stolen.c static void stolen_fill_purge_test(int fd) · line 341
Quoted 10 lines
tests/gem_stolen.c +10
-0+drm_intel_bo_unmap (bo); +drm_intel_bo_unreference (bo); + + obj_count++; + } + + i++; + }while (handle[i-1 ] && i <MAX_OBJECTS ); + +igt_assert (obj_count >0 );
Would it make sense to require a bit more than one object?
Maybe considering all the platforms we could come up with a more demanding expectation on what does it mean to exhaust the stolen space?
Maybe you could even query stolen size and set the expectation based on that? Is that possible?
Regards,
Tvrtko
Quoted 38 lines
tests/gem_stolen.c +33
-0+for (i =0 ; i < obj_count; i++) { + dest =gem_handle_to_libdrm_bo (bufmgr, fd, +"dst_bo" , handle[i]); +igt_assert (dest !=NULL ); +intel_copy_bo (batch, dest, src,SIZE ); +drm_intel_bo_unreference (dest); + } + +drm_intel_bo_unreference (src); + +igt_system_hibernate_autoresume (); +/* Check if the object's memory contents are intact +* across hibernation. +*/ +for (i =0 ; i < obj_count; i++) { + bo =gem_handle_to_libdrm_bo (bufmgr, fd, +"verify_bo" , handle[i]); +igt_assert (bo !=NULL ); + _ret =drm_intel_gem_bo_map_gtt (bo); +igt_assert (!_ret); + virt = bo->virtual; +for (j =0 ; j <SIZE /DWORD_SIZE ; j++) +igt_assert_eq (virt[j],DATA ); + +drm_intel_bo_unmap (bo); +drm_intel_bo_unreference (bo); + } + +gem_close (fd, src_handle); +for (i =0 ; i < obj_count; i++) +gem_close (fd, handle[i]); +} +static void stolen_no_mmap (int fd) {
tests/gem_stolen.c igt_main · line 444
Quoted 9 lines
tests/gem_stolen.c +3
-0@@ -353,6 +436,9 @@ igt_main igt_subtest("stolen-fill-purge")stolen_fill_purge_test (fd); + igt_subtest("stolen-hibernate") +stolen_hibernate (fd); + igt_fixture {intel_batchbuffer_free (batch);drm_intel_bufmgr_destroy (bufmgr);
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx