1118 Commits

Author SHA1 Message Date
Chris Wilson
f201495575 lib: compute exitcode first
Before we print the exitcode to the debug/kmsg logs, we should inspect
what its final value will be. For example, in the case of running
multiple subtests which all happen to be skipped, igt_exitcode is 0, but
the final exit code will be 77.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Tested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2016-05-03 12:12:37 +01:00
Jani Nikula
c038518438 lib/intel_chipset: drop unused IS_9XX()
It's also confusing as the style differs from the kernel (exact platform
in the kernel vs. the platform and any later ones in igt).

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
2016-05-03 11:19:32 +03:00
Chris Wilson
cf07aa2fc6 lib: Fixup u64 multiply for computing nanoseconds
32bit builds ran into a silly multiplication issue when computing
elapsed nanoseconds of more than 2s...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-05-02 15:37:32 +01:00
Chris Wilson
4782591873 lib: Tweak calibration of initial settimer delay
If we assume that the first settimer and clock_gettime() itself have
appreciable overhead, try to exclude those from the calibration delay.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-05-02 14:58:00 +01:00
Chris Wilson
7d08913aeb lib: Enable clflush for 32bit x86 builds
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-05-01 16:40:16 +01:00
Chris Wilson
b481705208 lib: Apply magic clflush serialisation
On Baytrail, Braswell and Atoms beyond we see an issue where the mfence
is insufficient to force the cacheline to be coherent (i.e. such that
writes from the GPU are visible by the CPU after the call to clflush). A
second clflush is ordered with an earlier clflush to the same address
and this appears sufficient to give the coherency required for GPU/CPU
interop.

Testcase: igt/gem_exec_flush
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Akash Goel <akash.goel@intel.com>
2016-05-01 09:14:16 +01:00
Tvrtko Ursulin
1aebeeb440 igt_kms: Fix use after free in kmstest_get_pipe_from_crtc_id
Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2016-04-28 10:12:56 +01:00
marius vlad
90a7e3bae5 lib/igt_aux: Half the timeout for suspend to RAM and a third for suspend to disk.
Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
2016-04-25 13:23:53 +03:00
Daniel Vetter
d9dca5f12a lib/igt_kms: Move IGT_MAX_PLANES into the igt_plane enum
Makes sure we automatically extend that when adding more planes.
Inspired by a patch from Robert Foss who extended the max, but forgot
all about the enum.

While at it, also fix up the whitespace damage.

Cc: robert.foss@collabora.com
Acked-by: robert.foss@collabora.com
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2016-04-22 14:57:20 +02:00
Ville Syrjälä
27372851c8 lib: Pass format instead of bpp to create_bo_for_fb()
create_bo_for_fb() expects the drm format as a parameter since
commit 8a1a38661f56 ("lib: Add igt_create_bo_with_dimensions")
but not all callers were updated. Fix that up.

Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Fixes: 8a1a38661f56 ("lib: Add igt_create_bo_with_dimensions")
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=93328
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
2016-04-21 13:08:23 +03:00
Chris Wilson
f650aa2dd6 igt/gem_close_race: Batify
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-04-20 18:48:23 +01:00
Tomeu Vizoso
3450cba30e lib: Declare loop variable as volatile before setjmp
The variable used as loop counter in the igt_fixture macro had
unspecified value from the setjmp(3) man page quoted below. Because of
that, in certain circumstances and with -O2 and -Os, the initialization
of that variable would be eliminated and the compiler would complain of
uninitialized usage. Below can be found a snippet that reproduces the
problem with GCC 5.3.1 and 4.9.3 and the errors as printed by 5.3.1.

"The compiler may optimize variables into registers, and longjmp() may
restore the values of other registers in addition to the stack pointer
and program  counter. Consequently, the values of automatic variables
are unspecified after a call to longjmp() if they meet all the following
criteria:

·  they are local to the function that made the corresponding setjmp(3)
call;

·  their values are changed between the calls to setjmp(3) and
longjmp(); and

·  they are not declared as volatile."

static void test(void)
{
	igt_subtest_group {
		igt_fixture {
		}

		igt_subtest("foo") {
		}

		igt_fixture {
		}
	}
}

In file included from lib/intel_batchbuffer.h:8:0,
                 from lib/drmtest.h:39,
                 from lib/igt.h:27,
                 from tests/kms_addfb_basic.c:28:
tests/kms_addfb_basic.c: In function 'tiling_tests.isra.0':
lib/igt_core.h:110:43: warning: '__tmpint245' is used uninitialized in
this function [-Wuninitialized]
 #define igt_fixture for (int igt_tokencat(__tmpint,__LINE__) = 0; \
                                           ^
lib/igt_core.h:110:43: note: '__tmpint245' was declared here
 #define igt_fixture for (int igt_tokencat(__tmpint,__LINE__) = 0; \
                                           ^
lib/igt_core.h:148:31: note: in definition of macro '__igt_tokencat2'
 #define __igt_tokencat2(x, y) x ## y
                               ^
lib/igt_core.h:110:30: note: in expansion of macro 'igt_tokencat'
 #define igt_fixture for (int igt_tokencat(__tmpint,__LINE__) = 0; \
                              ^
tests/kms_addfb_basic.c:245:3: note: in expansion of macro 'igt_fixture'
   igt_fixture {

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-20 14:54:46 +02:00
Micah Fedke
be354f444e lib: update kmstest_get_pipe_from_crtc_id
This function uses an intel-specific ioctl to fetch a mapping between pipes and
crtc ids, but this technique is outdated as the crtc id is now always
equivalent to its index in the array of crtcs returned by the kernel.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-20 14:35:23 +02:00
Daniel Vetter
286992102e lib: Fix doc warnings for real!
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2016-04-14 16:03:36 +02:00
Tomeu Vizoso
f4718c2b6c tests: Open any driver
For those tests that now pass on drivers other than i915, call
drm_open_driver_master with DRIVER_ANY.

Also do so from igt_enable_connectors.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Tomeu Vizoso
8a1a38661f lib: Add igt_create_bo_with_dimensions
igt_create_bo_with_dimensions() is intended to abstract differences
between drivers in buffer object creation.

The driver-specific ioctls will be called if the driver that is being
tested can satisfy the needs of the calling subtest, or it will be
skipped otherwise.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Tomeu Vizoso
89b3ffe02c lib: Map dumb buffers
If a buffer object is dumb, call DRM_IOCTL_MODE_MAP_DUMB when mapping
it. Also, don't call DRM_IOCTL_I915_GEM_SET_DOMAIN on dumb buffers.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Tomeu Vizoso
a2d5b348ee lib: Add igt_dirty_fb
Just wraps drmModeDirtyFB and for now invalidates the whole FB.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Tomeu Vizoso
fb66a5df93 lib: Add helper kmstest_dumb_map_buffer
Which basically just calls DRM_IOCTL_MODE_MAP_DUMB and is similar to
gem_mmap__gtt().

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Tomeu Vizoso
dc84e7d6ad lib: Add wrapper for DRM_IOCTL_MODE_CREATE_DUMB
In order to test drivers that don't have support for proper buffer
objects, add a wrapper for creating dumb buffer objects that will be
called from the lib code for those subtests that don't need to care.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Tomeu Vizoso
85a1d45c4a lib: Call intel_get_drm_devid only from intel code
It only makes sense when testing the i915 driver, so don't call it
otherwise.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Tomeu Vizoso
644f364da2 lib: Assert we are on i915 from intel_get_drm_devid
I915_PARAM_CHIPSET_ID is a i915-only thing, so if a subtest ends up
calling it when testing another driver, the subtest (or the library)
needs to be fixed.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Tomeu Vizoso
e0e3a063ae lib: Expose is_i915_device
Lib and test code can use this function to avoid i915-specific behavior
when running on other drivers.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Tomeu Vizoso
6755757e9f lib: Have gem_set_tiling require intel
Before calling a i915-specific IOCTL, require i915.

This allows us to skip subtests that are specific to that driver, though
what should eventually happen is that tests don't generally call
gem_set_tiling directly but go through an abstraction layer that
constructs the buffer object in a driver-specific way.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Tomeu Vizoso
3fee80efcf lib: add igt_require_intel
Add function that requires that the driver we are talking to is i915.

This allows us to skip subtests that are specific to that driver.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Tomeu Vizoso
0eadf638e4 lib: Rename is_intel to has_known_intel_chipset
As it reflects more clearly what the function actually does.

Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Daniel Stone <daniels@collabora.com>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-04-14 13:54:24 +01:00
Peter Antoine
8af67d1980 test/gem_mocs_settings: Testing MOCS register settings
The MOCS registers were added in Gen9 and define the caching policy.
The registers are split into two sets. The first set controls the
EDRAM policy and have a set for each engine, the second set controls
the L3 policy. The two sets use the same index.

The RCS registers and the L3CC registers are stored in the RCS context.

The test checks that the registers are correct by checking the values by
directly reading them via MMIO, then again it tests them by reading them
from within a batch buffer. RCS engine is tested last as it programs the
registers via a batch buffer and this will invalidate the test for
workloads that don't use the render ring or don't run a render batch
first.

v2: Reorganised the structure.
    Added more tests. (Chris Wilson)
v3: Fixed a few bugs. (Chris Wilson)
v4: More Tidy-ups.    (Chris Wilson)
    SKL does does not have a snoop bit. (Peter Antoine)

Signed-off-by: Peter Antoine <peter.antoine@intel.com>
2016-04-12 10:45:49 +01:00
Chris Wilson
4a3fa3532a lib: Tidy presentations of pread/pwrite failures
Make the assertion failure message readable if gem_read or gem_write
fail.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-04-11 07:40:11 +01:00
Chris Wilson
645c95400c lib: Remove defunct stop_rings
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-04-09 13:38:12 +01:00
Lionel Landwerlin
cd8da3f65d lib: kms: move framebuffer scanout offset/size to plane
This fixes potential crashes when the framebuffer is unset from a
given plane.

v2: s/with/within/ typo in header

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Marius Vlad <marius.c.vlad@intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Marius Vlad <marius.c.vlad@intel.com>
2016-04-05 17:09:29 +03:00
Chris Wilson
bd292436ed lib: Avoid assertion if sig_ioctl is unsed from a child accidentally
The timer is tied to the creator thread, i.e. it is not inheritable
across fork() or clone()/pthread_create(). Using it thus causes an
assertion failure in the test after the one that aborts (and so on until
we perform an interruptible test correctly) - one mistake snowballs. We
can stop the snowball by doing an initial check and diverting back to
drmIoctl().

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-04-03 13:40:48 +01:00
Chris Wilson
cb12d05e79 lib: Don't report the last errno inside the async GPU hang detector
Since the last errno doesn't correspond with the signal, reporting it
when we detect the GPU hang is confusing.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-04-03 13:40:48 +01:00
Chris Wilson
c89e8dbfd8 lib: Ignore udev failure to report an event
Fixes gem_exec_suspend complaining that the hang detector spontaneously
combusts.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-29 17:22:41 +01:00
Chris Wilson
2b804c33e7 lib: Tidy error message for a helper process who unexpectedly dies
Transform

gem_exec_suspend: igt_core.c:1429: igt_stop_helper: Assertion `(((signed char) ((((__extension__ (((union { __typeof(status) __in; int __i; }) { .__in = (status) }).__i))) & 0x7f) + 1) >> 1) > 0) && (((__extension__ (((union { __typeof(status) __in; int __i; }) { .__in = (status) }).__i))) & 0x7f) == (proc->use_SIGKILL ? 9 : 15)' failed.

into

(gem_exec_suspend:16589) igt-core-DEBUG: Helper died too early with status=0
gem_exec_suspend: igt_core.c:1437: igt_stop_helper: Assertion `helper_was_alive(proc, status)' failed.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-29 17:22:41 +01:00
Chris Wilson
98dcf2f0dc igt/gem_concurrent_blit: Relax maxfiles restrictions
Only fail the dmabuf tests if we cannot prep the system to support
"unlimited" fd.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-25 18:23:56 +00:00
Chris Wilson
756f3e0cb7 lib: Add a GPU error detector
If we listen to the uevents from the kernel, we can detect when the GPU
hangs. This requires us to fork a helper process to do so and send a
signal back to the parent.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-24 11:25:38 +00:00
Lionel Landwerlin
c7e9be2302 lib: add crc comparison function without an assert
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
2016-03-21 11:47:22 -07:00
Lionel Landwerlin
a511310244 lib: fb: add igt_paint_color_gradient_range
This is a helper to draw a gradient between 2 colors.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
2016-03-21 11:47:04 -07:00
Lionel Landwerlin
1716625e1e lib: kms: add helpers for color management properties on pipes
v2: Rename CTM_MATRIX property to CTM

v3: Add support for atomic commits

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
2016-03-21 11:46:18 -07:00
Lionel Landwerlin
59b5487625 lib: kms: add crtc_id to igt_pipe_t
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
2016-03-21 11:45:45 -07:00
Chris Wilson
8520037e54 lib: Measure the cost of calling timer_settimer() for sigiter
We wish to delay the first signal from the igt_sigiter_ioctl
sufficiently to skip over the timer_settime() and into the drmIoctl
kernel context before firing. If we fire too early, we will think that
the ioctl doesn't respond to signals and ignore it in future. If we fire
too late, we won't probe the ioctl for signal handling at all. Let's try
measuring the timer_settime() call time as a first approximation.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-21 16:26:04 +00:00
Chris Wilson
82e9113bfb lib/igt_aux: Refine decision to stop signal injection
The goal of injecting signals into the ioctl() is to trigger an EINTR.
If we did not succeed on the last pass, we are not going to on the next
or subsequent passes either.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-19 16:00:02 +00:00
Chris Wilson
e85613b47c igt/gem_concurrent_blit: dmabuf requires twice the number of files
In order to keep the dmabuf mmap around whilst we keep the object alive,
we need a file descriptor for each. Check that the VFS supports that
many fd.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-19 15:21:28 +00:00
Chris Wilson
d545610861 lib/igt_aux: Divert ioctls for signal injection
To simplify and speed up running interruptible tests, use a custom
ioctl() function that control the signaling and detect when we need no
more iterations to trigger an interruption.

We use a realtime timer to inject the signal after a certain delay,
increasing the delay on every loop to try and exercise different code
paths within the function. The first delay is very short such that we
hopefully enter the kernel with a pending signal.

Clients should use

struct igt_sigiter iter = {};
while (igt_sigiter_repeat(&iter, enable_interrupts=true))
	do_test()

to automatically repeat the test until we can inject no more signals
into the ioctls. This is condensed into a macro

igt_interruptible(enable_interrupts=true)
	do_test();

for convenience.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-19 15:20:43 +00:00
Chris Wilson
c1fed522ae lib: Replace drmIoctl() with a layer of indirection
Insted of calling drmIoctl() directly, call igt_ioctl() instead. In the
normal scenario this is function pointer that calls drmIoctl() (so no
penalty), but allows us to divert ioctls into our own routines for
nefarious purposes. One such purpose will be to control interrupt
generation into the ioctl, to be able to detect when we successfully
interrupt the ioctl and when we no longer need more interrupts.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-19 13:15:08 +00:00
Daniel Vetter
4e4f5b4fdc lib/tests: More igt_subtest_group checks
... for some cases discussed with Chris on irc. We seem to get them all
right.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-03-19 12:15:47 +01:00
Daniel Vetter
483d1c0a23 lib: Fix some doc warnings
Cc: Marius Vlad <marius.c.vlad@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-03-19 12:12:47 +01:00
Daniel Vetter
72d04b8453 lib: Add igt_subtest_group
Useful for creating common setup code in igt_fixture which is only
needed by a subset of tests. And since I'm a good citizen it comes
with a library testcase/example included.

v2: Make testcase nastier to ensure a subtest group SKIPS when it's
parent is skipping already. I accidentally got this right, but let's
make sure.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-03-19 10:37:40 +01:00
Rodrigo Vivi
dbc74dd990 intel: Adding missing Broxton PCI IDs.
These IDs were already part of the kernel since:

kernel commit 985dd4360fdf2533fe48a33a4a2094f2e4718dc0
Author: Imre Deak <imre.deak@intel.com>
Date:   Thu Jan 28 16:04:12 2016 +0200

     drm/i915/bxt: update list of PCIIDs

Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Reviewed-by: Arun Siluvery <arun.siluvery@linux.intel.com>
2016-03-18 09:30:08 -07:00
Chris Wilson
95090bb50b lib/ioctl_wrappers: Explain a couple of igt_require(ret == 0)
Use more verbose igt_require(), here assocaited with SET_CACHING, such
that the requirements are explained in the debug/failure log.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-18 14:46:23 +00:00