tests: add write-verify test to gem_fence_thrash

Add write-verify test to gem_fence_thrash. Test will create
multiple threads per fence then verify the write into fenced region.

v2: non-threaded, non-tiled tests added. suggested by Chris Wilson.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests/Makefile.am: gem_fence_trash has grown subtests

Need to move it to the right make target now!

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
intel_perf_counters: a little tool for dumping performance counters.

This reads the GPU's performance counters via MI_REPORT_PERF_COUNT and
prints them in a top-style interface.  While it can be useful in and of
itself, it also documents the performance counters and lets us verify
that they're working.

Currently, it only supports Ironlake.

v2 [Ken]: Rebase on master and fix compilation failures; make it abort
on non-Ironlake platforms to avoid GPU hangs; rename from 'chaps' to
intel_perf_counters since that acronym isn't used any longer; write the
above commit message.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
intel_perf_counters: Abstract out Ironlake-specific code.

We want to support this tool on more platforms.  This lays the
groundwork for making that possible.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
intel_perf_counters: Add support for Sandybridge.

While the Sandybridge PRM doesn't have any documentation on the GPU's
performance counters, a lot of information can be gleaned from the older
Ironlake PRM.  Oddly, none of the information documented there actually
appears to apply to Ironlake.  However, it apparently works just great
on Sandybridge.

Since this information has all been publicly available on the internet
for around three years, we can use it.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
gem_fence_thrash: Fix array allocation size for LP64 systems
lib: fixup register access on gen2/3

This wreaked havoc with intel_reg_dumper since it's been broken in

commit c6fe31bc473a7ae44bc42bad7da5faca3c924821
Author: Eugeni Dodonov <eugeni.dodonov@intel.com>
Date:   Thu Jun 21 14:31:34 2012 -0300

    intel_reg_dumper: use intel_register_access_init/fini

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests/prime_udl: proper return values

... especially skip properly if there's no udl device.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests/prime_udl: skip harder

I fail.
tests/kms_flip: don't leak gpu hang state

We need to clear out the error_state. While at it also make sure that
the hang was indeed detected.

Whoever writes the next test to race against gpu hangs should probably
extract these two functions into the drmtest library. Which just one
user that's not really worth it right now.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
lib/drmtest: tune down signal handler stats

Avoids tests with a spurious WARN result in piglit.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests/gem_fence_trash: make threaded tests more through-rough

With this at least the y-tiled test reliably fails on my machines, but
x-tiled still passes on some. More ideas to tune this highly welcome.

v2: Fill cpu caches with data for each newly allocated bo. This seems
to do the trick on my snb here _really_ reliably. So apparently the
backsnoop for llc gtt writes is the crucial ingredient here to make
the test fail.

While at it, also stop leaking mmap space.

v3: Fixup commit message.

Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
m4: Updates to ax_python_devel.m4

Signed-off-by: Ben Widawsky <ben@bwidawsk.net>
intel_reg_dumper: improve the dumping of backlight registers

Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
tests/gem_fenced_exec_thrash: Increase MAX_FENCES to 32

IVB+ supports 32 fence registers, bump the maximum in the test.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests: Use gem_available_fences()

lib/drmtest.c provides gem_available_fences(). Use it where
appropriate.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests/gem_tiling_max_stride: Add a test for max fence stride

gem_tiling_max_stride writes a data pattern to an X-tiled buffer using
the maximum supported stride, reads the data back as linear, and
verifies that the data didn't get scrambled on the way.

The test also checks that some invalid stride values are rejected
properly.

v2: Check invalid strides
v3: Check invalid stride with Y-tiling
    Include a few more invalid stride values
    Fix gen3 X-tile size
v4: A few more invalid strides :)
    Drop the useless memset()

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests/gem_seqno_wrap: verify debugfs write with readback

Make sure that debugfs entry works as expected by reading
back the sequence number that was written.

Signed-off-by: Mika Kuoppala <mika.kuoppala@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
tests/gem_fenced_exec_thrash: Test with > max fences

Make sure the kernel returns EDEADLK when the number of fences is
exceeded for gen2-3. For gen4+ the test makes sure the kernel ignores
the EXEC_OBJECT_NEEDS_FENCE flag.

Note that I changed the code not to round the num_fences to an even
number. Not sure why that was there, and if there's a reason for it,
we need to add it back.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
assembler: Add a regions visualizer tool

This adds a html/js tool for helping to visualise GEN instruction
source operand regions by generating diagrams similar to those used in
the Programmer's Reference Manual. To use the tool, open the file
assembler/gen_regions/gen_regions.html in your browser of preference.