tests/gem_mmap_gtt: add huge BO test
PATCH 1/1 tests/gem_mmap_gtt: add huge BO test
Add a straightforward test that allocates a BO that is bigger than (by 1 page currently) the mappable aperture, tests mmap access to it by CPU directly and through GTT in sequence.
Currently it is expected for the GTT access to gracefully fail as all objects are attempted to get pinned to GTT completely for mmap access. Once the partial view support is merged to kernel, the test should pass for all parts.
--- tests/gem_mmap_gtt.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)
tests/gem_mmap_gtt.c +68 -0
@@ -41,6 +41,10 @@#include "drmtest.h" #include "igt_debugfs.h" +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +static int OBJECT_SIZE =16 *1024 *1024 ;static void set_domain (int fd,uint32_t handle)
@@ -258,6 +262,68 @@ test_write_gtt(int fd) }static void +test_huge_bo (int fd) +{ +uint32_t bo; +char *ptr_cpu; +char *ptr_gtt; +char *cpu_pattern; +uint64_t mappable_aperture_pages =gem_mappable_aperture_size () / +PAGE_SIZE ; +uint64_t huge_object_size = (mappable_aperture_pages +1 ) *PAGE_SIZE ; +uint64_t last_offset = huge_object_size -PAGE_SIZE ; + + cpu_pattern =malloc (PAGE_SIZE ); +igt_assert (cpu_pattern); +memset (cpu_pattern,0xaa ,PAGE_SIZE ); + + bo =gem_create (fd, huge_object_size); + + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_cpu) { +igt_warn ("Not enough free memory for huge BO test!\n" ); + goto out; + } + +/* Test read/write to first/last page with CPU. */ +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; + + ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_gtt) { +igt_debug ("Huge BO GTT mapping not supported!\n" ); + goto out; + } + +/* Test read/write to first/last page through GTT. */ +set_domain (fd, bo); + +igt_assert (memcmp (ptr_gtt, cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memset (ptr_gtt,0x55 ,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memset (ptr_gtt + last_offset,0x55 ,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt, ptr_gtt + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_gtt, huge_object_size); +out: +gem_close (fd, bo); +free (cpu_pattern); +} + +static void test_read (int fd) {void *dst;
@@ -395,6 +461,8 @@ igt_mainrun_without_prefault (fd, test_write_gtt); igt_subtest("write-cpu-read-gtt")test_write_cpu_read_gtt (fd); + igt_subtest("huge-bo") +test_huge_bo (fd);igt_fixture close (fd );
Signature · 8 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 14 lines · Joonas Lahtinen
static void
tests/gem_mmap_gtt.c +13
-0+test_huge_bo(int fd) +{ +uint32_t bo; +char *ptr_cpu; +char *ptr_gtt; +char *cpu_pattern; +uint64_t mappable_aperture_pages =gem_mappable_aperture_size () / +PAGE_SIZE ; +uint64_t huge_object_size = (mappable_aperture_pages +1 ) *PAGE_SIZE ; +uint64_t last_offset = huge_object_size -PAGE_SIZE ; + + cpu_pattern =malloc (PAGE_SIZE ); +igt_assert (cpu_pattern);
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 287
Quoted 10 lines
tests/gem_mmap_gtt.c +10
-0+memset (cpu_pattern,0xaa ,PAGE_SIZE ); + + bo =gem_create (fd, huge_object_size); + + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_cpu) { +igt_warn ("Not enough free memory for huge BO test!\n" ); + goto out; + }
Should be a set-domain(CPU, CPU) here.
Quoted 22 lines
tests/gem_mmap_gtt.c +22
-0+/* Test read/write to first/last page with CPU. */ +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; + + ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_gtt) { +igt_debug ("Huge BO GTT mapping not supported!\n" ); + goto out; + } + +/* Test read/write to first/last page through GTT. */ +set_domain (fd, bo); +
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 320
Quoted 10 lines
tests/gem_mmap_gtt.c +10
-0+igt_assert (memcmp (ptr_gtt, cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memset (ptr_gtt,0x55 ,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memset (ptr_gtt + last_offset,0x55 ,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt, ptr_gtt + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_gtt, huge_object_size);
And repeat the CPU sanity check (for 0x55). Perhaps using pread this time.
And tiling checks.
-Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi,
Quoted 1 line · Chris Wilson
On Tue, Apr 07, 2015 at 03:23:08PM +0300, Joonas Lahtinen wrote:
[snip]
Quoted 11 lines
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 287
Quoted 9 lines
tests/gem_mmap_gtt.c +9
-0+ + bo =gem_create (fd, huge_object_size); + + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_cpu) { +igt_warn ("Not enough free memory for huge BO test!\n" ); + goto out; + }Should be a set-domain(CPU, CPU) here.
Corrected, that went unnoticed when I moved the test to be last test.
Quoted 27 lines
Quoted 27 lines
tests/gem_mmap_gtt.c +26
-0+/* Test read/write to first/last page with CPU. */ +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; + + ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_gtt) { +igt_debug ("Huge BO GTT mapping not supported!\n" ); + goto out; + } + +/* Test read/write to first/last page through GTT. */ +set_domain (fd, bo); + +igt_assert (memcmp (ptr_gtt, cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memset (ptr_gtt,0x55 ,PAGE_SIZE );
Quoted 9 lines
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 320
Quoted 6 lines
tests/gem_mmap_gtt.c +6
-0+igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memset (ptr_gtt + last_offset,0x55 ,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt, ptr_gtt + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_gtt, huge_object_size);And repeat the CPU sanity check (for
0x55). Perhaps using pread this time.
I stuck to mmap in this test. Initial partial views revision will not have fencing as agreed with Daniel, just checks to bail out if somebody attempts to to partially map a tiled buffer because it's going to require reworking all the fence calculation functions to calculate the stride based on view size and not buffer size.
Will send a new patch (two actually) shortly.
Regards, Joonas
Quoted 3 lines
And tiling checks.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/2 tests/gem_mmap_gtt: Clarify BO domain setting functions
In reply to Chris WilsonAdd suffix and complementary function for CPU domain.
--- tests/gem_mmap_gtt.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
tests/gem_mmap_gtt.c +7 -2
@@ -43,11 +43,16 @@static int OBJECT_SIZE =16 *1024 *1024 ; -static void set_domain (int fd,uint32_t handle) +static void set_domain_gtt (int fd,uint32_t handle) {gem_set_domain (fd, handle,I915_GEM_DOMAIN_GTT ,I915_GEM_DOMAIN_GTT ); } +static void set_domain_cpu (int fd,uint32_t handle) +{ +gem_set_domain (fd, handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU ); +} +static void *mmap_bo (int fd,uint32_t handle) {
@@ -245,7 +250,7 @@ test_write_gtt(int fd)/* prefault object into gtt */ dst_gtt =mmap_bo (fd, dst); -set_domain (fd, dst); +set_domain_gtt (fd, dst);memset (dst_gtt,0 ,OBJECT_SIZE );munmap (dst_gtt,OBJECT_SIZE );
Signature · 8 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 2/2 tests/gem_mmap_gtt: add huge BO test
In reply to Chris WilsonAdd a straightforward test that allocates a BO that is bigger than (by 1 page currently) the mappable aperture, tests mmap access to it by CPU directly and through GTT in sequence.
Currently it is expected for the GTT access to gracefully fail as all objects are attempted to get pinned to GTT completely for mmap access. Once the partial view support is merged to kernel, the test should pass for all parts.
v2:
- Corrected BO domain handling (Chris Wilson)
- Check again after GTT access for added paranoia (Chris Wilson)
--- tests/gem_mmap_gtt.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+)
tests/gem_mmap_gtt.c +104 -0
@@ -41,6 +41,10 @@#include "drmtest.h" #include "igt_debugfs.h" +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +static int OBJECT_SIZE =16 *1024 *1024 ;static void set_domain_gtt (int fd,uint32_t handle)
@@ -263,6 +267,104 @@ test_write_gtt(int fd) }static void +test_huge_bo (int fd) +{ +uint32_t bo; +char *ptr_cpu; +char *ptr_gtt; +char *cpu_pattern; +char *gtt_pattern; +uint64_t mappable_aperture_pages =gem_mappable_aperture_size () / +PAGE_SIZE ; +uint64_t huge_object_size = (mappable_aperture_pages +1 ) *PAGE_SIZE ; +uint64_t last_offset = huge_object_size -PAGE_SIZE ; + + cpu_pattern =malloc (PAGE_SIZE ); + gtt_pattern =malloc (PAGE_SIZE ); +igt_assert (cpu_pattern && gtt_pattern); +memset (cpu_pattern,0xaa ,PAGE_SIZE ); +memset (gtt_pattern, ~0xaa ,PAGE_SIZE ); + + bo =gem_create (fd, huge_object_size); + +/* Test read/write to first/last page with CPU. */ + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_cpu) { +igt_warn ("Not enough free memory to begin huge BO test!\n" ); + goto out; + } + +set_domain_cpu (fd, bo); + +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; + +/* Test read/write to first/last page through GTT after CPU writes. +* Require that previous CPU written values still exist. +*/ + ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_gtt) { +igt_debug ("Huge BO GTT mapping not supported!\n" ); + goto out; + } + +set_domain_gtt (fd, bo); + +igt_assert (memcmp (ptr_gtt , cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_gtt, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ) ==0 ); + +munmap (ptr_gtt, huge_object_size); + ptr_gtt =NULL ; + +/* Test read/write to first/last page through CPU after GTT writes. +* Require that previous GTT written values still exist. +*/ + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_cpu) { +igt_warn ("Not enough free memory to complete huge BO test!\n" ); + goto out; + } + +set_domain_cpu (fd, bo); + +igt_assert (memcmp (ptr_cpu , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_cpu + last_offset, gtt_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu , cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_cpu + last_offset, gtt_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu , cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; +out: +gem_close (fd, bo); +free (cpu_pattern); +} + +static void test_read (int fd) {void *dst;
@@ -400,6 +502,8 @@ igt_mainrun_without_prefault (fd, test_write_gtt); igt_subtest("write-cpu-read-gtt")test_write_cpu_read_gtt (fd); + igt_subtest("huge-bo") +test_huge_bo (fd);igt_fixture close (fd );
Signature · 8 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 12 lines · Joonas Lahtinen
tests/gem_mmap_gtt.c +12
-0+/* Test read/write to first/last page through CPU after GTT writes. +* Require that previous GTT written values still exist. +*/ + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_cpu) { +igt_warn ("Not enough free memory to complete huge BO test!\n" ); + goto out; + } + +set_domain_cpu (fd, bo); +
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 358
Quoted 10 lines
tests/gem_mmap_gtt.c +10
-0+igt_assert (memcmp (ptr_cpu , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_cpu + last_offset, gtt_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu , cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_cpu + last_offset, gtt_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu , cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 );
On second thought I think this is better using pread as on non-llc platforms this will a second gigantic clflush. Otherwise lgtm. -Chris
Signature · 5 lines
Chris Wilson, Intel Open Source Technology Centre _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 1/2 tests/gem_mmap_gtt: clarify BO domain setting functions
Add suffix and complementary function for CPU domain.
v2:
- Change function signatures to be consistent with the rest
--- tests/gem_mmap_gtt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
tests/gem_mmap_gtt.c +9 -2
@@ -43,11 +43,18 @@static int OBJECT_SIZE =16 *1024 *1024 ; -static void set_domain (int fd,uint32_t handle) +static void +set_domain_gtt (int fd,uint32_t handle) {gem_set_domain (fd, handle,I915_GEM_DOMAIN_GTT ,I915_GEM_DOMAIN_GTT ); } +static void +set_domain_cpu (int fd,uint32_t handle) +{ +gem_set_domain (fd, handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU ); +} +static void *mmap_bo (int fd,uint32_t handle) {
@@ -245,7 +252,7 @@ test_write_gtt(int fd)/* prefault object into gtt */ dst_gtt =mmap_bo (fd, dst); -set_domain (fd, dst); +set_domain_gtt (fd, dst);memset (dst_gtt,0 ,OBJECT_SIZE );munmap (dst_gtt,OBJECT_SIZE );
Signature · 8 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH i-g-t v3 1/2] tests/gem_mmap_gtt: clarify BO domain setting functions
These two patches still have something to work on, or could they be committed?
Quoted 35 lines · Joonas Lahtinen
Add suffix and complementary function for CPU domain.
v2:
- Change function signatures to be consistent with the restSigned-off-by Joonas Lahtinen <[email protected]>--- tests/gem_mmap_gtt.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)tests/gem_mmap_gtt.c +8
-1@@ -43,11 +43,18 @@static int OBJECT_SIZE =16 *1024 *1024 ; -static void set_domain (int fd,uint32_t handle) +static void +set_domain_gtt (int fd,uint32_t handle) {gem_set_domain (fd, handle,I915_GEM_DOMAIN_GTT ,I915_GEM_DOMAIN_GTT ); } +static void +set_domain_cpu (int fd,uint32_t handle) +{ +gem_set_domain (fd, handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU ); +} +static void *mmap_bo (int fd,uint32_t handle) {
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 258
Quoted 8 lines
tests/gem_mmap_gtt.c +1
-1@@ -245,7 +252,7 @@ test_write_gtt(int fd)/* prefault object into gtt */ dst_gtt =mmap_bo (fd, dst); -set_domain (fd, dst); +set_domain_gtt (fd, dst);memset (dst_gtt,0 ,OBJECT_SIZE );munmap (dst_gtt,OBJECT_SIZE );
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 2/2 tests/gem_mmap_gtt: add huge BO test
In reply to Chris WilsonAdd a straightforward test that allocates a BO that is bigger than (by 1 page currently) the mappable aperture, tests mmap access to it by CPU directly and through GTT in sequence.
Currently it is expected for the GTT access to gracefully fail as all objects are attempted to get pinned to GTT completely for mmap access. Once the partial view support is merged to kernel, the test should pass for all parts.
v2:
- Corrected BO domain handling (Chris Wilson)
- Check again after GTT access for added paranoia (Chris Wilson)
v3:
- Avoid flush by using pread (Chris Wilson)
- Free gtt_pattern buffer too.
--- tests/gem_mmap_gtt.c | 104 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+)
tests/gem_mmap_gtt.c +104 -0
@@ -41,6 +41,10 @@#include "drmtest.h" #include "igt_debugfs.h" +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +static int OBJECT_SIZE =16 *1024 *1024 ; static void
@@ -55,6 +59,20 @@ set_domain_cpu(int fd, uint32_t handle)gem_set_domain (fd, handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU ); } +static void +pread_bo (int fd,int handle,void *buf,int offset,int size) +{ +struct drm_i915_gem_pread gem_pread; + +memset (&gem_pread,0 ,sizeof (gem_pread)); + gem_pread.handle = handle; + gem_pread.data_ptr = (uintptr_t )buf; + gem_pread.size = size; + gem_pread.offset = offset; + +igt_assert (ioctl (fd,DRM_IOCTL_I915_GEM_PREAD , &gem_pread) ==0 ); +} +static void *mmap_bo (int fd,uint32_t handle) {
@@ -265,6 +283,90 @@ test_write_gtt(int fd) }static void +test_huge_bo (int fd) +{ +uint32_t bo; +char *ptr_cpu; +char *ptr_gtt; +char *cpu_pattern; +char *gtt_pattern; +uint64_t mappable_aperture_pages =gem_mappable_aperture_size () / +PAGE_SIZE ; +uint64_t huge_object_size = (mappable_aperture_pages +1 ) *PAGE_SIZE ; +uint64_t last_offset = huge_object_size -PAGE_SIZE ; + + cpu_pattern =malloc (PAGE_SIZE ); + gtt_pattern =malloc (PAGE_SIZE ); +igt_assert (cpu_pattern && gtt_pattern); +memset (cpu_pattern,0xaa ,PAGE_SIZE ); +memset (gtt_pattern, ~0xaa ,PAGE_SIZE ); + + bo =gem_create (fd, huge_object_size); + +/* Test read/write to first/last page with CPU. */ + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_cpu) { +igt_warn ("Not enough free memory to begin huge BO test!\n" ); + goto out; + } + +set_domain_cpu (fd, bo); + +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; + +/* Test read/write to first/last page through GTT after CPU writes. +* Require that previous CPU written values still exist. +*/ + ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_gtt) { +igt_debug ("Huge BO GTT mapping not supported!\n" ); + goto out; + } + +set_domain_gtt (fd, bo); + +igt_assert (memcmp (ptr_gtt , cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_gtt, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ) ==0 ); + +munmap (ptr_gtt, huge_object_size); + ptr_gtt =NULL ; + +/* Verify the page contents after GTT writes. +* Avoid mapping the object back to CPU domain to avoid huge flush. +*/ +pread_bo (fd, bo, cpu_pattern,0 ,PAGE_SIZE ); +igt_assert (memcmp (cpu_pattern, gtt_pattern,PAGE_SIZE ) ==0 ); + +memset (cpu_pattern,0x00 ,PAGE_SIZE ); + +pread_bo (fd, bo, cpu_pattern, last_offset,PAGE_SIZE ); +igt_assert (memcmp (cpu_pattern, gtt_pattern,PAGE_SIZE ) ==0 ); +out: +gem_close (fd, bo); +free (cpu_pattern); +free (gtt_pattern); +} + +static void test_read (int fd) {void *dst;
@@ -402,6 +504,8 @@ igt_mainrun_without_prefault (fd, test_write_gtt); igt_subtest("write-cpu-read-gtt")test_write_cpu_read_gtt (fd); + igt_subtest("huge-bo") +test_huge_bo (fd);igt_fixture close (fd );
Signature · 8 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi,
Quoted 36 lines · Joonas Lahtinen
Add a straightforward test that allocates a BO that is bigger than (by 1 page currently) the mappable aperture, tests mmap access to it by CPU directly and through GTT in sequence.
Currently it is expected for the GTT access to gracefully fail as all objects are attempted to get pinned to GTT completely for mmap access. Once the partial view support is merged to kernel, the test should pass for all parts.
Signed-off-by Joonas Lahtinen <[email protected]>--- tests/gem_mmap_gtt.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)tests/gem_mmap_gtt.c +7
-0@@ -41,6 +41,10 @@#include "drmtest.h" #include "igt_debugfs.h" +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +static int OBJECT_SIZE =16 *1024 *1024 ;static void set_domain (int fd,uint32_t handle)@@ -258,6 +262,68 @@ test_write_gtt(int fd) }static void +test_huge_bo (int fd) +{ +uint32_t bo;
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 277
Quoted 10 lines
tests/gem_mmap_gtt.c +10
-0+char *ptr_cpu; +char *ptr_gtt; +char *cpu_pattern; +uint64_t mappable_aperture_pages =gem_mappable_aperture_size () / +PAGE_SIZE ; +uint64_t huge_object_size = (mappable_aperture_pages +1 ) *PAGE_SIZE ; +uint64_t last_offset = huge_object_size -PAGE_SIZE ; + + cpu_pattern =malloc (PAGE_SIZE ); +igt_assert (cpu_pattern);
I'd be tempted to use 4k from the stack for simplicity.
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 286
Quoted 9 lines
tests/gem_mmap_gtt.c +9
-0+memset (cpu_pattern,0xaa ,PAGE_SIZE ); + + bo =gem_create (fd, huge_object_size); + + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_cpu) { +igt_warn ("Not enough free memory for huge BO test!\n" ); + goto out;
Free address space or free memory?
Also, igt_require so test skips in that case?
Quoted 9 lines
tests/gem_mmap_gtt.c +9
-0+ } + +/* Test read/write to first/last page with CPU. */ +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); +
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 305
Quoted 10 lines
tests/gem_mmap_gtt.c +10
-0+igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; + + ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_gtt) { +igt_debug ("Huge BO GTT mapping not supported!\n" ); + goto out;
igt_require as above? Hm, although ideally test would be able to detect the feature (once it is added to the kernel) so it could assert here.
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 318
Quoted 13 lines
tests/gem_mmap_gtt.c +13
-0+ } + +/* Test read/write to first/last page through GTT. */ +set_domain (fd, bo); + +igt_assert (memcmp (ptr_gtt, cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memset (ptr_gtt,0x55 ,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memset (ptr_gtt + last_offset,0x55 ,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt, ptr_gtt + last_offset,PAGE_SIZE ) ==0 );
Comments for the above would be nice just to explain what is being tested and how.
Won't the last test has side effects with partial views since it is accessing beginning and end of the object? Would it be better to memcmp against a pattern on stack or in heap like cpu_pattern?
Will you support two simultaneous partial views or the last memcmp will cause a lot of partial view creation/destruction?
Quoted 13 lines
tests/gem_mmap_gtt.c +8
-0+ +munmap (ptr_gtt, huge_object_size); +out: +gem_close (fd, bo); +free (cpu_pattern); +} + +static void test_read (int fd) {void *dst;
tests/gem_mmap_gtt.c igt_main · line 468
Quoted 8 lines
tests/gem_mmap_gtt.c +2
-0@@ -395,6 +461,8 @@ igt_mainrun_without_prefault (fd, test_write_gtt); igt_subtest("write-cpu-read-gtt")test_write_cpu_read_gtt (fd); + igt_subtest("huge-bo") +test_huge_bo (fd);igt_fixture close (fd );
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 35 lines · Tvrtko Ursulin
Hi,
Quoted 32 lines · Joonas Lahtinen
Add a straightforward test that allocates a BO that is bigger than (by 1 page currently) the mappable aperture, tests mmap access to it by CPU directly and through GTT in sequence.
Currently it is expected for the GTT access to gracefully fail as all objects are attempted to get pinned to GTT completely for mmap access. Once the partial view support is merged to kernel, the test should pass for all parts.
Signed-off-by Joonas Lahtinen <[email protected]>--- tests/gem_mmap_gtt.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)tests/gem_mmap_gtt.c +4
-0@@ -41,6 +41,10 @@#include "drmtest.h" #include "igt_debugfs.h" +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +static int OBJECT_SIZE =16 *1024 *1024 ;static void set_domain (int fd,uint32_t handle)@@ -258,6 +262,68 @@ test_write_gtt(int fd) }
Quoted 16 lines
Quoted 4 lines
tests/gem_mmap_gtt.c +3
-0static void +test_huge_bo (int fd) +{ +uint32_t bo;tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 277
Quoted 10 lines
tests/gem_mmap_gtt.c +10
-0+char *ptr_cpu; +char *ptr_gtt; +char *cpu_pattern; +uint64_t mappable_aperture_pages =gem_mappable_aperture_size () / +PAGE_SIZE ; +uint64_t huge_object_size = (mappable_aperture_pages +1 ) *PAGE_SIZE ; +uint64_t last_offset = huge_object_size -PAGE_SIZE ; + + cpu_pattern =malloc (PAGE_SIZE ); +igt_assert (cpu_pattern);I'd be tempted to use 4k from the stack for simplicity.
It's not a nice thing to allocate two 4k objects from stack. So lets just not.
Quoted 12 lines
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 286
Quoted 9 lines
tests/gem_mmap_gtt.c +9
-0+memset (cpu_pattern,0xaa ,PAGE_SIZE ); + + bo =gem_create (fd, huge_object_size); + + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_cpu) { +igt_warn ("Not enough free memory for huge BO test!\n" ); + goto out;Free address space or free memory?
It is not really relevant to the test which condition caused it. But yeah, correcting the error message into 'Can not allocate memory'.
Quoted 2 lines
Also,
igt_requireso test skips in that case?
Ack using igt_require_f. Because the condition is bit unclear without the text.
Quoted 14 lines
Quoted 14 lines
tests/gem_mmap_gtt.c +14
-0+ } + +/* Test read/write to first/last page with CPU. */ +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; +
Quoted 9 lines
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 305
Quoted 5 lines
tests/gem_mmap_gtt.c +5
-0+ ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_gtt) { +igt_debug ("Huge BO GTT mapping not supported!\n" ); + goto out;
igt_requireas above? Hm, although ideally test would be able to detect the feature (once it is added to the kernel) so it could assert here.
I think the point is somewhat that UMP should not need to know/care about it. Before introducing the feature the above will always fail, and after introducing it, it will always succeed (unless there is less than 1MB aperture space available). So I think it should be good as it is.
Quoted 8 lines
Quoted 8 lines
tests/gem_mmap_gtt.c +8
-0+ } + +/* Test read/write to first/last page through GTT. */ +set_domain (fd, bo); + +igt_assert (memcmp (ptr_gtt, cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); +
Quoted 9 lines
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 318
Quoted 5 lines
tests/gem_mmap_gtt.c +5
-0+memset (ptr_gtt,0x55 ,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memset (ptr_gtt + last_offset,0x55 ,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt, ptr_gtt + last_offset,PAGE_SIZE ) ==0 );Comments for the above would be nice just to explain what is being tested and how.
The level of commenting was higher already than I noticed to be in other tests, but I'll add a few more.
Quoted 6 lines
Won't the last test has side effects with partial views since it is accessing beginning and end of the object? Would it be better to memcmp against a pattern on stack or in heap like
cpu_pattern?Will you support two simultaneous partial views or the last memcmp will cause a lot of partial view creation/destruction?
Yes, there will be multiple partial views, but it's all internal to the kernel implementation. Above access pattern should be supported.
Regards, Joonas
Quoted 19 lines
Quoted 19 lines
tests/gem_mmap_gtt.c +10
-0+ +munmap (ptr_gtt, huge_object_size); +out: +gem_close (fd, bo); +free (cpu_pattern); +} + +static void test_read (int fd) {void *dst;@@ -395,6 +461,8 @@ igt_mainrun_without_prefault (fd, test_write_gtt); igt_subtest("write-cpu-read-gtt")test_write_cpu_read_gtt (fd); + igt_subtest("huge-bo") +test_huge_bo (fd);
Quoted 7 lines
tests/gem_mmap_gtt.c igt_main · line 468
Quoted 3 lines
tests/gem_mmap_gtt.c +0
-0igt_fixture close (fd );Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 53 lines · Joonas Lahtinen
Quoted 35 lines · Tvrtko Ursulin
Hi,
Quoted 32 lines · Joonas Lahtinen
Add a straightforward test that allocates a BO that is bigger than (by 1 page currently) the mappable aperture, tests mmap access to it by CPU directly and through GTT in sequence.
Currently it is expected for the GTT access to gracefully fail as all objects are attempted to get pinned to GTT completely for mmap access. Once the partial view support is merged to kernel, the test should pass for all parts.
Signed-off-by Joonas Lahtinen <[email protected]>--- tests/gem_mmap_gtt.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+)tests/gem_mmap_gtt.c +4
-0@@ -41,6 +41,10 @@#include "drmtest.h" #include "igt_debugfs.h" +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +static int OBJECT_SIZE =16 *1024 *1024 ;static void set_domain (int fd,uint32_t handle)@@ -258,6 +262,68 @@ test_write_gtt(int fd) }Quoted 16 lines
Quoted 4 lines
tests/gem_mmap_gtt.c +3
-0static void +test_huge_bo (int fd) +{ +uint32_t bo;tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 277
Quoted 10 lines
tests/gem_mmap_gtt.c +10
-0+char *ptr_cpu; +char *ptr_gtt; +char *cpu_pattern; +uint64_t mappable_aperture_pages =gem_mappable_aperture_size () / +PAGE_SIZE ; +uint64_t huge_object_size = (mappable_aperture_pages +1 ) *PAGE_SIZE ; +uint64_t last_offset = huge_object_size -PAGE_SIZE ; + + cpu_pattern =malloc (PAGE_SIZE ); +igt_assert (cpu_pattern);I'd be tempted to use 4k from the stack for simplicity.
Quoted 2 lines
It's not a nice thing to allocate two 4k objects from stack. So lets just not.
Why not? It's not kernel stack but 8MiB default for a simple IGT... and changelog to v3 says otherwise. ;) But ok..
Quoted 13 lines
Quoted 12 lines
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 286
Quoted 9 lines
tests/gem_mmap_gtt.c +9
-0+memset (cpu_pattern,0xaa ,PAGE_SIZE ); + + bo =gem_create (fd, huge_object_size); + + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_cpu) { +igt_warn ("Not enough free memory for huge BO test!\n" ); + goto out;Free address space or free memory?
Quoted 2 lines
It is not really relevant to the test which condition caused it. But yeah, correcting the error message into 'Can not allocate memory'.
Is it really memory and not address space?
Quoted 30 lines
Quoted 2 lines
Also,
igt_requireso test skips in that case?Ack using
igt_require_f. Because the condition is bit unclear without the text.Quoted 14 lines
Quoted 14 lines
tests/gem_mmap_gtt.c +14
-0+ } + +/* Test read/write to first/last page with CPU. */ +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; +Quoted 9 lines
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 305
Quoted 5 lines
tests/gem_mmap_gtt.c +5
-0+ ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +if (!ptr_gtt) { +igt_debug ("Huge BO GTT mapping not supported!\n" ); + goto out;
igt_requireas above? Hm, although ideally test would be able to detect the feature (once it is added to the kernel) so it could assert here.
Quoted 4 lines
I think the point is somewhat that UMP should not need to know/care about it. Before introducing the feature the above will always fail, and after introducing it, it will always succeed (unless there is less than 1MB aperture space available). So I think it should be good as it is.
I suppose there isn't really a way to be smarter in this case.
Quoted 18 lines
Quoted 8 lines
Quoted 8 lines
tests/gem_mmap_gtt.c +8
-0+ } + +/* Test read/write to first/last page through GTT. */ +set_domain (fd, bo); + +igt_assert (memcmp (ptr_gtt, cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); +Quoted 9 lines
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 318
Quoted 5 lines
tests/gem_mmap_gtt.c +5
-0+memset (ptr_gtt,0x55 ,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +memset (ptr_gtt + last_offset,0x55 ,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt, ptr_gtt + last_offset,PAGE_SIZE ) ==0 );Comments for the above would be nice just to explain what is being tested and how.
Quoted 2 lines
The level of commenting was higher already than I noticed to be in other tests, but I'll add a few more.
Thanks, it's best to lead by example!
Quoted 9 lines
Quoted 6 lines
Won't the last test has side effects with partial views since it is accessing beginning and end of the object? Would it be better to memcmp against a pattern on stack or in heap like
cpu_pattern?Will you support two simultaneous partial views or the last memcmp will cause a lot of partial view creation/destruction?
Yes, there will be multiple partial views, but it's all internal to the kernel implementation. Above access pattern should be supported.
Very well then!
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v5 1/1 tests/gem_mmap_gtt: add huge BO test
Add a straightforward test that allocates a BO that is bigger than (by 1 page currently) the mappable aperture, tests mmap access to it by CPU directly and through GTT in sequence.
Currently it is expected for the GTT access to gracefully fail as all objects are attempted to get pinned to GTT completely for mmap access. Once the partial view support is merged to kernel, the test should pass for all parts.
v2:
- Corrected BO domain handling (Chris Wilson)
- Check again after GTT access for added paranoia (Chris Wilson)
v3:
- Avoid flush by using pread (Chris Wilson)
- Free gtt_pattern buffer too.
v4:
- Add more comments (Tvrtko Ursulin)
- Use igt_require (Tvrtko Ursulin)
v5:
- Remove wrong message from igt_require_f (Tvrtko Ursulin)
- After digging deeper to it, just igt_assert that the CPU mapping needs to succeed.
--- tests/gem_mmap_gtt.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+)
tests/gem_mmap_gtt.c +106 -0
@@ -41,6 +41,10 @@#include "drmtest.h" #include "igt_debugfs.h" +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +static int OBJECT_SIZE =16 *1024 *1024 ; static void
@@ -55,6 +59,20 @@ set_domain_cpu(int fd, uint32_t handle)gem_set_domain (fd, handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU ); } +static void +pread_bo (int fd,int handle,void *buf,int offset,int size) +{ +struct drm_i915_gem_pread gem_pread; + +memset (&gem_pread,0 ,sizeof (gem_pread)); + gem_pread.handle = handle; + gem_pread.data_ptr = (uintptr_t )buf; + gem_pread.size = size; + gem_pread.offset = offset; + +igt_assert (ioctl (fd,DRM_IOCTL_I915_GEM_PREAD , &gem_pread) ==0 ); +} +static void *mmap_bo (int fd,uint32_t handle) {
@@ -265,6 +283,92 @@ test_write_gtt(int fd) }static void +test_huge_bo (int fd) +{ +uint32_t bo; +char *ptr_cpu; +char *ptr_gtt; +char *cpu_pattern; +char *gtt_pattern; +uint64_t mappable_aperture_pages =gem_mappable_aperture_size () / +PAGE_SIZE ; +uint64_t huge_object_size = (mappable_aperture_pages +1 ) *PAGE_SIZE ; +uint64_t last_offset = huge_object_size -PAGE_SIZE ; + + cpu_pattern =malloc (PAGE_SIZE ); + gtt_pattern =malloc (PAGE_SIZE ); +igt_assert (cpu_pattern && gtt_pattern); +memset (cpu_pattern,0xaa ,PAGE_SIZE ); +memset (gtt_pattern, ~0xaa ,PAGE_SIZE ); + + bo =gem_create (fd, huge_object_size); + +/* Obtain CPU mapping for the object. */ + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +igt_assert (ptr_cpu); + +set_domain_cpu (fd, bo); + +/* Write first page through the mapping and assert reading it back +* works. */ +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Write last page through the mapping and assert reading it back +* works. */ +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Cross check that accessing two simultaneous pages works. */ +igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; + +/* Obtain mapping for the object through GTT. */ + ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +igt_require_f (ptr_gtt,"Huge BO GTT mapping not supported.\n" ); + +set_domain_gtt (fd, bo); + +/* Access through GTT should still provide the CPU written values. */ +igt_assert (memcmp (ptr_gtt , cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Try replacing first page through GTT mapping and make sure other page +* stays intact. */ +memcpy (ptr_gtt, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* And make sure that after writing, both pages contain what they +* should.*/ +memcpy (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ) ==0 ); + +munmap (ptr_gtt, huge_object_size); + ptr_gtt =NULL ; + +/* Verify the page contents after GTT writes by reading without mapping. +* Mapping to CPU domain is avoided not to cause a huge flush. +*/ +pread_bo (fd, bo, cpu_pattern,0 ,PAGE_SIZE ); +igt_assert (memcmp (cpu_pattern, gtt_pattern,PAGE_SIZE ) ==0 ); + +memset (cpu_pattern,0x00 ,PAGE_SIZE ); + +pread_bo (fd, bo, cpu_pattern, last_offset,PAGE_SIZE ); +igt_assert (memcmp (cpu_pattern, gtt_pattern,PAGE_SIZE ) ==0 ); +out: +gem_close (fd, bo); +free (cpu_pattern); +free (gtt_pattern); +} + +static void test_read (int fd) {void *dst;
@@ -402,6 +506,8 @@ igt_mainrun_without_prefault (fd, test_write_gtt); igt_subtest("write-cpu-read-gtt")test_write_cpu_read_gtt (fd); + igt_subtest("huge-bo") +test_huge_bo (fd);igt_fixture close (fd );
Signature · 8 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 164 lines · Joonas Lahtinen
Add a straightforward test that allocates a BO that is bigger than (by 1 page currently) the mappable aperture, tests mmap access to it by CPU directly and through GTT in sequence.
Currently it is expected for the GTT access to gracefully fail as all objects are attempted to get pinned to GTT completely for mmap access. Once the partial view support is merged to kernel, the test should pass for all parts.
v2:
- Corrected BO domain handling (Chris Wilson)
- Check again after GTT access for added paranoia (Chris Wilson)v3:
- Avoid flush by using pread (Chris Wilson)
- Freegtt_patternbuffer too.v4:
- Add more comments (Tvrtko Ursulin)
- Useigt_require(Tvrtko Ursulin)v5:
- Remove wrong message fromigt_require_f(Tvrtko Ursulin)
- After digging deeper to it, justigt_assertthat the CPU mapping needs to succeed.Cc Tvrtko Ursulin <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Joonas Lahtinen <[email protected]>--- tests/gem_mmap_gtt.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+)tests/gem_mmap_gtt.c +104
-0@@ -41,6 +41,10 @@#include "drmtest.h" #include "igt_debugfs.h" +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +static int OBJECT_SIZE =16 *1024 *1024 ; static void@@ -55,6 +59,20 @@ set_domain_cpu(int fd, uint32_t handle)gem_set_domain (fd, handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU ); } +static void +pread_bo (int fd,int handle,void *buf,int offset,int size) +{ +struct drm_i915_gem_pread gem_pread; + +memset (&gem_pread,0 ,sizeof (gem_pread)); + gem_pread.handle = handle; + gem_pread.data_ptr = (uintptr_t )buf; + gem_pread.size = size; + gem_pread.offset = offset; + +igt_assert (ioctl (fd,DRM_IOCTL_I915_GEM_PREAD , &gem_pread) ==0 ); +} +static void *mmap_bo (int fd,uint32_t handle) {@@ -265,6 +283,92 @@ test_write_gtt(int fd) }static void +test_huge_bo (int fd) +{ +uint32_t bo; +char *ptr_cpu; +char *ptr_gtt; +char *cpu_pattern; +char *gtt_pattern; +uint64_t mappable_aperture_pages =gem_mappable_aperture_size () / +PAGE_SIZE ; +uint64_t huge_object_size = (mappable_aperture_pages +1 ) *PAGE_SIZE ; +uint64_t last_offset = huge_object_size -PAGE_SIZE ; + + cpu_pattern =malloc (PAGE_SIZE ); + gtt_pattern =malloc (PAGE_SIZE ); +igt_assert (cpu_pattern && gtt_pattern); +memset (cpu_pattern,0xaa ,PAGE_SIZE ); +memset (gtt_pattern, ~0xaa ,PAGE_SIZE ); + + bo =gem_create (fd, huge_object_size); + +/* Obtain CPU mapping for the object. */ + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +igt_assert (ptr_cpu); + +set_domain_cpu (fd, bo); + +/* Write first page through the mapping and assert reading it back +* works. */ +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Write last page through the mapping and assert reading it back +* works. */ +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Cross check that accessing two simultaneous pages works. */ +igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; + +/* Obtain mapping for the object through GTT. */ + ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +igt_require_f (ptr_gtt,"Huge BO GTT mapping not supported.\n" ); + +set_domain_gtt (fd, bo); + +/* Access through GTT should still provide the CPU written values. */ +igt_assert (memcmp (ptr_gtt , cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Try replacing first page through GTT mapping and make sure other page +* stays intact. */ +memcpy (ptr_gtt, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* And make sure that after writing, both pages contain what they +* should.*/ +memcpy (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ) ==0 ); + +munmap (ptr_gtt, huge_object_size); + ptr_gtt =NULL ; + +/* Verify the page contents after GTT writes by reading without mapping. +* Mapping to CPU domain is avoided not to cause a huge flush. +*/ +pread_bo (fd, bo, cpu_pattern,0 ,PAGE_SIZE ); +igt_assert (memcmp (cpu_pattern, gtt_pattern,PAGE_SIZE ) ==0 ); + +memset (cpu_pattern,0x00 ,PAGE_SIZE ); + +pread_bo (fd, bo, cpu_pattern, last_offset,PAGE_SIZE ); +igt_assert (memcmp (cpu_pattern, gtt_pattern,PAGE_SIZE ) ==0 ); +out: +gem_close (fd, bo); +free (cpu_pattern); +free (gtt_pattern); +} + +static void test_read (int fd) {void *dst;
tests/gem_mmap_gtt.c igt_main · line 513
Quoted 8 lines
tests/gem_mmap_gtt.c +2
-0@@ -402,6 +506,8 @@ igt_mainrun_without_prefault (fd, test_write_gtt); igt_subtest("write-cpu-read-gtt")test_write_cpu_read_gtt (fd); + igt_subtest("huge-bo") +test_huge_bo (fd);igt_fixture close (fd );
I suspect in the future you may want to create a dedicated test for partial views since there will be many more specific test cases, but for now:
Regards,
Tvrtko
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 143 lines · Joonas Lahtinen
Add a straightforward test that allocates a BO that is bigger than (by 1 page currently) the mappable aperture, tests mmap access to it by CPU directly and through GTT in sequence.
Currently it is expected for the GTT access to gracefully fail as all objects are attempted to get pinned to GTT completely for mmap access. Once the partial view support is merged to kernel, the test should pass for all parts.
v2:
- Corrected BO domain handling (Chris Wilson)
- Check again after GTT access for added paranoia (Chris Wilson)v3:
- Avoid flush by using pread (Chris Wilson)
- Freegtt_patternbuffer too.v4:
- Add more comments (Tvrtko Ursulin)
- Useigt_require(Tvrtko Ursulin)v5:
- Remove wrong message fromigt_require_f(Tvrtko Ursulin)
- After digging deeper to it, justigt_assertthat the CPU mapping needs to succeed.Cc Tvrtko Ursulin <[email protected]>Cc Chris Wilson <[email protected]>Signed-off-by Joonas Lahtinen <[email protected]>--- tests/gem_mmap_gtt.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+)tests/gem_mmap_gtt.c +88
-0@@ -41,6 +41,10 @@#include "drmtest.h" #include "igt_debugfs.h" +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +static int OBJECT_SIZE =16 *1024 *1024 ; static void@@ -55,6 +59,20 @@ set_domain_cpu(int fd, uint32_t handle)gem_set_domain (fd, handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU ); } +static void +pread_bo (int fd,int handle,void *buf,int offset,int size) +{ +struct drm_i915_gem_pread gem_pread; + +memset (&gem_pread,0 ,sizeof (gem_pread)); + gem_pread.handle = handle; + gem_pread.data_ptr = (uintptr_t )buf; + gem_pread.size = size; + gem_pread.offset = offset; + +igt_assert (ioctl (fd,DRM_IOCTL_I915_GEM_PREAD , &gem_pread) ==0 ); +} +static void *mmap_bo (int fd,uint32_t handle) {@@ -265,6 +283,92 @@ test_write_gtt(int fd) }static void +test_huge_bo (int fd) +{ +uint32_t bo; +char *ptr_cpu; +char *ptr_gtt; +char *cpu_pattern; +char *gtt_pattern; +uint64_t mappable_aperture_pages =gem_mappable_aperture_size () / +PAGE_SIZE ; +uint64_t huge_object_size = (mappable_aperture_pages +1 ) *PAGE_SIZE ; +uint64_t last_offset = huge_object_size -PAGE_SIZE ; + + cpu_pattern =malloc (PAGE_SIZE ); + gtt_pattern =malloc (PAGE_SIZE ); +igt_assert (cpu_pattern && gtt_pattern); +memset (cpu_pattern,0xaa ,PAGE_SIZE ); +memset (gtt_pattern, ~0xaa ,PAGE_SIZE ); + + bo =gem_create (fd, huge_object_size); + +/* Obtain CPU mapping for the object. */ + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +igt_assert (ptr_cpu); + +set_domain_cpu (fd, bo); + +/* Write first page through the mapping and assert reading it back +* works. */ +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Write last page through the mapping and assert reading it back +* works. */ +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Cross check that accessing two simultaneous pages works. */ +igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; + +/* Obtain mapping for the object through GTT. */ + ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +igt_require_f (ptr_gtt,"Huge BO GTT mapping not supported.\n" ); + +set_domain_gtt (fd, bo); + +/* Access through GTT should still provide the CPU written values. */ +igt_assert (memcmp (ptr_gtt , cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Try replacing first page through GTT mapping and make sure other page +* stays intact. */ +memcpy (ptr_gtt, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* And make sure that after writing, both pages contain what they +* should.*/ +memcpy (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ) ==0 ); + +munmap (ptr_gtt, huge_object_size); + ptr_gtt =NULL ; + +/* Verify the page contents after GTT writes by reading without mapping.
tests/gem_mmap_gtt.c test_write_gtt(int fd) · line 365
Quoted 10 lines
tests/gem_mmap_gtt.c +10
-0+* Mapping to CPU domain is avoided not to cause a huge flush. +*/ +pread_bo (fd, bo, cpu_pattern,0 ,PAGE_SIZE ); +igt_assert (memcmp (cpu_pattern, gtt_pattern,PAGE_SIZE ) ==0 ); + +memset (cpu_pattern,0x00 ,PAGE_SIZE ); + +pread_bo (fd, bo, cpu_pattern, last_offset,PAGE_SIZE ); +igt_assert (memcmp (cpu_pattern, gtt_pattern,PAGE_SIZE ) ==0 ); +out:
I removed the unused label here and pushed this and the BO domain setting functions patch.
Quoted 19 lines
tests/gem_mmap_gtt.c +8
-1+gem_close (fd, bo); +free (cpu_pattern); +free (gtt_pattern); +} + +static void test_read (int fd) {void *dst;@@ -402,6 +506,8 @@ igt_mainrun_without_prefault (fd, test_write_gtt); igt_subtest("write-cpu-read-gtt")test_write_cpu_read_gtt (fd); + igt_subtest("huge-bo") +test_huge_bo (fd);igt_fixture close (fd ); --
Quoted 1 line
1.9.3
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v4 2/2 tests/gem_mmap_gtt: add huge BO test
In reply to Tvrtko UrsulinAdd a straightforward test that allocates a BO that is bigger than (by 1 page currently) the mappable aperture, tests mmap access to it by CPU directly and through GTT in sequence.
Currently it is expected for the GTT access to gracefully fail as all objects are attempted to get pinned to GTT completely for mmap access. Once the partial view support is merged to kernel, the test should pass for all parts.
v2:
- Corrected BO domain handling (Chris Wilson)
- Check again after GTT access for added paranoia (Chris Wilson)
v3:
- Avoid flush by using pread (Chris Wilson)
- Free gtt_pattern buffer too.
v4:
- Add more comments (Tvrtko Ursulin)
- Use igt_require (Tvrtko Ursulin)
--- tests/gem_mmap_gtt.c | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+)
tests/gem_mmap_gtt.c +106 -0
@@ -41,6 +41,10 @@#include "drmtest.h" #include "igt_debugfs.h" +#ifndef PAGE_SIZE +#define PAGE_SIZE 4096 +#endif +static int OBJECT_SIZE =16 *1024 *1024 ; static void
@@ -55,6 +59,20 @@ set_domain_cpu(int fd, uint32_t handle)gem_set_domain (fd, handle,I915_GEM_DOMAIN_CPU ,I915_GEM_DOMAIN_CPU ); } +static void +pread_bo (int fd,int handle,void *buf,int offset,int size) +{ +struct drm_i915_gem_pread gem_pread; + +memset (&gem_pread,0 ,sizeof (gem_pread)); + gem_pread.handle = handle; + gem_pread.data_ptr = (uintptr_t )buf; + gem_pread.size = size; + gem_pread.offset = offset; + +igt_assert (ioctl (fd,DRM_IOCTL_I915_GEM_PREAD , &gem_pread) ==0 ); +} +static void *mmap_bo (int fd,uint32_t handle) {
@@ -265,6 +283,92 @@ test_write_gtt(int fd) }static void +test_huge_bo (int fd) +{ +uint32_t bo; +char *ptr_cpu; +char *ptr_gtt; +char *cpu_pattern; +char *gtt_pattern; +uint64_t mappable_aperture_pages =gem_mappable_aperture_size () / +PAGE_SIZE ; +uint64_t huge_object_size = (mappable_aperture_pages +1 ) *PAGE_SIZE ; +uint64_t last_offset = huge_object_size -PAGE_SIZE ; + + cpu_pattern =malloc (PAGE_SIZE ); + gtt_pattern =malloc (PAGE_SIZE ); +igt_assert (cpu_pattern && gtt_pattern); +memset (cpu_pattern,0xaa ,PAGE_SIZE ); +memset (gtt_pattern, ~0xaa ,PAGE_SIZE ); + + bo =gem_create (fd, huge_object_size); + +/* Obtain CPU mapping for the object. */ + ptr_cpu =gem_mmap__cpu (fd, bo,0 , huge_object_size, +PROT_READ |PROT_WRITE ); +igt_require_f (ptr_cpu,"Can not allocate memory for test.\n" ); + +set_domain_cpu (fd, bo); + +/* Write first page through the mapping and assert reading it back +* works. */ +memcpy (ptr_cpu, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Write last page through the mapping and assert reading it back +* works. */ +memcpy (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_cpu + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Cross check that accessing two simultaneous pages works. */ +igt_assert (memcmp (ptr_cpu, ptr_cpu + last_offset,PAGE_SIZE ) ==0 ); + +munmap (ptr_cpu, huge_object_size); + ptr_cpu =NULL ; + +/* Obtain mapping for the object through GTT. */ + ptr_gtt =gem_mmap__gtt (fd, bo, huge_object_size, +PROT_READ |PROT_WRITE ); +igt_require_f (ptr_gtt,"Huge BO GTT mapping not supported.\n" ); + +set_domain_gtt (fd, bo); + +/* Access through GTT should still provide the CPU written values. */ +igt_assert (memcmp (ptr_gtt , cpu_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* Try replacing first page through GTT mapping and make sure other page +* stays intact. */ +memcpy (ptr_gtt, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, cpu_pattern,PAGE_SIZE ) ==0 ); + +/* And make sure that after writing, both pages contain what they +* should.*/ +memcpy (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ); +igt_assert (memcmp (ptr_gtt , gtt_pattern,PAGE_SIZE ) ==0 ); +igt_assert (memcmp (ptr_gtt + last_offset, gtt_pattern,PAGE_SIZE ) ==0 ); + +munmap (ptr_gtt, huge_object_size); + ptr_gtt =NULL ; + +/* Verify the page contents after GTT writes by reading without mapping. +* Mapping to CPU domain is avoided not to cause a huge flush. +*/ +pread_bo (fd, bo, cpu_pattern,0 ,PAGE_SIZE ); +igt_assert (memcmp (cpu_pattern, gtt_pattern,PAGE_SIZE ) ==0 ); + +memset (cpu_pattern,0x00 ,PAGE_SIZE ); + +pread_bo (fd, bo, cpu_pattern, last_offset,PAGE_SIZE ); +igt_assert (memcmp (cpu_pattern, gtt_pattern,PAGE_SIZE ) ==0 ); +out: +gem_close (fd, bo); +free (cpu_pattern); +free (gtt_pattern); +} + +static void test_read (int fd) {void *dst;
@@ -402,6 +506,8 @@ igt_mainrun_without_prefault (fd, test_write_gtt); igt_subtest("write-cpu-read-gtt")test_write_cpu_read_gtt (fd); + igt_subtest("huge-bo") +test_huge_bo (fd);igt_fixture close (fd );
Signature · 8 lines
1.9.3 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx