diff mbox series

[libdrm] tests: Test mapping different caching types on etnaviv

Message ID 20180914120553.GA19648@bogon.m.sigxcpu.org (mailing list archive)
State New, archived
Headers show
Series [libdrm] tests: Test mapping different caching types on etnaviv | expand

Commit Message

Guido Günther Sept. 14, 2018, 12:05 p.m. UTC
This makes it simple to test if all cache types are mappable.

Signed-off-by: Guido Günther <guido.gunther@puri.sm>
---
Prompted by 

  https://lists.freedesktop.org/archives/etnaviv/2018-September/001946.html

 tests/etnaviv/etnaviv_bo_cache_test.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

Comments

Emil Velikov Oct. 4, 2018, 1:20 p.m. UTC | #1
[adding etnaviv@ for bigger exposure]

Hi Guido,

On Fri, 14 Sep 2018 at 13:06, Guido Günther <agx@sigxcpu.org> wrote:
>
> This makes it simple to test if all cache types are mappable.
>
> Signed-off-by: Guido Günther <guido.gunther@puri.sm>
> ---
> Prompted by
>
>   https://lists.freedesktop.org/archives/etnaviv/2018-September/001946.html
>
>  tests/etnaviv/etnaviv_bo_cache_test.c | 26 ++++++++++++++++++++++++++
>  1 file changed, 26 insertions(+)
>
Patch looks spot on, sadly my etnaviv knowledge is a bit limited.

Ideally one of the etna devs will double-check it, but from my POV
Acked-by: Emil Velikov <emil.velikov@collabora.com>

-Emil
Lucas Stach Oct. 4, 2018, 1:43 p.m. UTC | #2
Am Donnerstag, den 04.10.2018, 14:20 +0100 schrieb Emil Velikov:
> [adding etnaviv@ for bigger exposure]
> 
> Hi Guido,
> 
> > On Fri, 14 Sep 2018 at 13:06, Guido Günther <agx@sigxcpu.org> wrote:
> > 
> > This makes it simple to test if all cache types are mappable.
> > 
> > > > Signed-off-by: Guido Günther <guido.gunther@puri.sm>
> > ---
> > Prompted by
> > 
> >   https://lists.freedesktop.org/archives/etnaviv/2018-September/001946.html
> > 
> >  tests/etnaviv/etnaviv_bo_cache_test.c | 26 ++++++++++++++++++++++++++
> >  1 file changed, 26 insertions(+)
> > 
> 
> Patch looks spot on, sadly my etnaviv knowledge is a bit limited.
> 
> Ideally one of the etna devs will double-check it, but from my POV
> > Acked-by: Emil Velikov <emil.velikov@collabora.com>

Nope, this test has nothing to do with the BO cache, which is a
userspace buffer cache layer, while the caching modes map to how CPU
accesses to the buffer mmap space are treated by the hardware.

So if we want to keep this test, it needs to be split into a separate
test.

Regards,
Lucas
Guido Günther Oct. 4, 2018, 2:53 p.m. UTC | #3
Hi,
On Thu, Oct 04, 2018 at 03:43:11PM +0200, Lucas Stach wrote:
> Am Donnerstag, den 04.10.2018, 14:20 +0100 schrieb Emil Velikov:
> > [adding etnaviv@ for bigger exposure]
> > 
> > Hi Guido,
> > 
> > > On Fri, 14 Sep 2018 at 13:06, Guido Günther <agx@sigxcpu.org> wrote:
> > > 
> > > This makes it simple to test if all cache types are mappable.
> > > 
> > > > > Signed-off-by: Guido Günther <guido.gunther@puri.sm>
> > > ---
> > > Prompted by
> > > 
> > >   https://lists.freedesktop.org/archives/etnaviv/2018-September/001946.html
> > > 
> > >  tests/etnaviv/etnaviv_bo_cache_test.c | 26 ++++++++++++++++++++++++++
> > >  1 file changed, 26 insertions(+)
> > > 
> > 
> > Patch looks spot on, sadly my etnaviv knowledge is a bit limited.
> > 
> > Ideally one of the etna devs will double-check it, but from my POV
> > > Acked-by: Emil Velikov <emil.velikov@collabora.com>
> 
> Nope, this test has nothing to do with the BO cache, which is a
> userspace buffer cache layer, while the caching modes map to how CPU
> accesses to the buffer mmap space are treated by the hardware.
> 
> So if we want to keep this test, it needs to be split into a separate
> test.

After sending this I also realized that it would might be better suited
for igt-gpu-tools. Would it fit in there? If so'd rework it and add it
there.
Cheers,
 -- Guido
diff mbox series

Patch

diff --git a/tests/etnaviv/etnaviv_bo_cache_test.c b/tests/etnaviv/etnaviv_bo_cache_test.c
index 7fb06293..0ad37e19 100644
--- a/tests/etnaviv/etnaviv_bo_cache_test.c
+++ b/tests/etnaviv/etnaviv_bo_cache_test.c
@@ -28,6 +28,7 @@ 
 #include <assert.h>
 
 #include <fcntl.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
 #include <unistd.h>
@@ -78,6 +79,28 @@  static void test_size_rounding(struct etna_device *dev)
 	printf("ok\n");
 }
 
+
+static void test_write(struct etna_device *dev, uint32_t flags)
+{
+	struct etna_bo *bo;
+	uint32_t *buf;
+
+	/* allocate, map, write to, and free of a bo */
+	printf("testing bo map with flags 0x%"PRIx32"... ", flags);
+	fflush(stdout);
+
+	bo = etna_bo_new(dev, 0x100, flags);
+	assert(bo);
+	buf = etna_bo_map(bo);
+	assert(buf);
+	assert(!etna_bo_cpu_prep(bo, DRM_ETNA_PREP_WRITE));
+	memset(buf, 0, 0x100);
+	etna_bo_cpu_fini(bo);
+	etna_bo_del(bo);
+
+	printf("ok\n");
+}
+
 int main(int argc, char *argv[])
 {
 	struct etna_device *dev;
@@ -107,6 +130,9 @@  int main(int argc, char *argv[])
 
 	test_cache(dev);
 	test_size_rounding(dev);
+	test_write(dev, ETNA_BO_CACHED);
+	test_write(dev, ETNA_BO_WC);
+	test_write(dev, ETNA_BO_UNCACHED);
 
 	etna_device_del(dev);