67 Commits

Author SHA1 Message Date
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
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
Chris Wilson
5459374120 lib: Remove dead gem_get_num_rings()
No users so time to die.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-14 14:17:12 +00:00
Chris Wilson
3d9bcd0804 lib: Remove unused gem_has_enable_ring()
No one uses this nor should they as it just gem_get_param() in disguise
and they are better feature queries for whether individual execution
engines are functional.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-14 14:17:12 +00:00
Chris Wilson
60eafc5489 igt/gem_exec_suspend: Do pre/post suspend double checks
Check that the system operates normally before and after the suspend (as
well as across the suspend). The goal is to isolate the breakage to the
subtest.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-08 09:57:33 +00:00
Chris Wilson
9ba9af2ea4 lib: Skip execution in gem_has_ring()
By looking for a particular error we can avoid actually executing
anything when testing whether the kernel supports an individual ring.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-08 09:57:33 +00:00
Chris Wilson
aed69b56d4 lib: Add read/write direction support for dmabuf synchronisation
Allow read-only synchronisation on dmabuf mmaps, useful to allow
concurrent read-read testing between the CPU and GPU.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-03-01 13:25:07 +00:00
Chris Wilson
f27d295fe3 lib: Move gem_wait() to ioctl-wrappers
We intend to use gem_wait() in more tests than gem_wait.c, so move the
simple ioctl wrapper into the core.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-23 18:03:46 +00:00
Chris Wilson
16038908de lib: Restore gem_available_aperture_size()
Missed an error whilst rebasing and trying to modify the previous patch
to keep this function intact... Instead, I now have to add this patch to
restore gem_available_aperture_size() and its one usage.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-18 10:36:45 +00:00
Chris Wilson
391b32c382 igt: Report the global GTT size
For many tests, the relevant aperture is not the ppGTT but the internal
global GTT managed by the kernel. Use this limit appropriately.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-18 10:30:56 +00:00
Tiago Vignatti
35debab2d9 lib: Add prime_sync_start and prime_sync_end helpers
This patch adds dma-buf mmap synchronization ioctls that can be used by tests
for cache coherency management e.g. when CPU and GPU domains are being accessed
through dma-buf at the same time.

v7: add sync invalid flags test.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2016-02-11 18:16:12 +01:00
Tiago Vignatti
4edfa09ae4 prime_mmap: Add basic tests to write in a bo using CPU
This patch adds test_correct_cpu_write, which maps the texture buffer through a
prime fd and then writes directly to it using the CPU. It stresses the driver
to guarantee cache synchronization among the different domains.

This test also adds test_forked_cpu_write, which creates the GEM bo in one
process and pass the prime handle of the it to another process, which in turn
uses the handle only to map and write. Roughly speaking this test simulates
Chrome OS  architecture, where the Web content ("unpriviledged process") maps
and CPU-draws a buffer, which was previously allocated in the GPU process
("priviledged process").

This requires kernel modifications (Daniel Thompson's "drm: prime: Honour
O_RDWR during prime-handle-to-fd") and therefore prime_handle_to_fd_for_mmap is
added to fail in case these lack. Also, upcoming tests (e.g. next patch) are
going to use it as well, so make it public and available in the lib.

v2: adds prime_handle_to_fd_with_mmap for skipping test in older kernels and
test for invalid flags.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2016-02-11 18:15:59 +01:00
Tiago Vignatti
e1f663b543 lib: Add gem_userptr and __gem_userptr helpers
This patch moves userptr definitions and helpers implementation that were
locally in gem_userptr_benchmark and gem_userptr_blits to the library, so other
tests can make use of them as well. There's no functional changes.

v2: added __ function to differentiate when errors want to be handled back in
the caller; bring gem_userptr_sync back to gem_userptr_blits; added gtkdoc.
v8: remove local_i915_gem_userptr from gem_concurrent_all.c to use the global
helpers instead.

Signed-off-by: Tiago Vignatti <tiago.vignatti@intel.com>
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2016-02-11 18:15:44 +01:00
Chris Wilson
ffbc59a3ef lib: Silence a common debug message when creating a context
In context tests, we may create thousands of contexts, the noise from
each requirement passing drowning out the real information. Let's only
do the requirement test (to detect if contexts are meant to be supported
or plain broken) only on the error path.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-05 13:31:29 +00:00
Chris Wilson
7b5a818581 igt/gem_reset_stats: Convert from stop-rings to real hang injection
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-02-04 15:25:40 +00:00
Chris Wilson
eaa03678b0 lib: Hide BSD1/BSD2 rings on hardware without BSD2
The kernel happily lets us run on I915_EXEC_BSD2 even with such hardware
existing. Sigh.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-01-28 14:04:07 +00:00
Chris Wilson
b7f150b606 lib: Query the kernel for support of a particular exec id
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-01-27 14:45:19 +00:00
Chris Wilson
e3b68bb666 lib: Share common __gem_execbuf()
An oft-repeated function to check EXECBUFFER2 for a particular fail
condition.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-01-27 14:45:18 +00:00
Michał Winiarski
e6ca4bd7cd lib/ioctl_wrappers: Add gem_has_softpin
We can move it from softpin test into lib, and since softpin support is
highly unlikely to go away in-between getparam ioctl calls, let's just
do a single call and store the value.

v2: rebase

Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-01-25 19:44:34 +01:00
Michał Winiarski
52b5d5016e lib/ioctl_wrappers: Add gem_gtt_type exposing raw HAS_ALIASING_PPGTT param
No functional changes.
While I'm here, let's also rename gem_uses_aliasing_ppgtt (since it's
being used to indicate if we are using ANY kind of ppgtt) and introduce
gem_uses_full_ppgtt to drop some unnecessary code from tests that were
previously calling getparam directly instead of using ioctl wrapper.

v2: drop gem_uses_full_48b_ppgtt since it's no longer used anywhere,
    s/48b/64b (Chris)
v3: rebase

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Michał Winiarski <michal.winiarski@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2016-01-25 19:44:31 +01:00
Chris Wilson
19642c604b lib: Expand igt_hang_ring() to select target context and various options
Some potential callers want to inject a hang into a particular context,
some want to trigger an actual ban and others may or may not want to
capture the associated error state. Expand the hang injection interface
to suit all.

v2: Disable the new kernel API, but push to provide a missing piece of
infrastucture to unbreak compilation.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-01-20 13:15:38 +00:00
Chris Wilson
a2eb63720b lib: Always double check igt_require_hang_ring() on use
If we move the igt_require() into the hang injector, this makes simple
test cases even more convenient. More complex test cases can always do
their own precursory check before settting up the test.

However, this does embed the assumption that the first context we are
called from is safe (i.e no i915.enable_hangcheck/i915.reset
interferrence).

v2: A couple of environment variables to skip hang testing or to force
hang injection even if the GPU cannot be reset.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2016-01-20 13:13:57 +00:00
Ankitprasad Sharma
70c3be83a0 igt/gem_stolen: Verifying extended gem_create ioctl
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)

Signed-off-by: Ankitprasad Sharma <ankitprasad.r.sharma@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-12-03 10:40:29 +00:00
Chris Wilson
3b75839b79 lib: gem_set_caching() use drmIoctl() rather than ioctl()
gem_set_caching() tries to be clever and detect when the ioctl isn't
supported (thereby skipping the test). However, it forget that we may be
acting on active objects and be subject to the usual EAGAIN/EINTR
errors. We can use the drmIoctl() to wrap the raw ioctl() in order to
get the automatic restart on the interrupted syscall.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-12-01 13:35:33 +00:00
Chris Wilson
a22719358d lib: Fix querying context GTT size
We need a new ioctl to find the correct GTT size to use when submitting
execbuffers (as opposed to wishing to know the global GTT size).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-10-19 11:33:01 +01:00
Ville Syrjälä
b8a77dd6c8 Make gem_mmap__{cpu,gtt,wc}() assert on failure
Rename the current gem_mmap__{cpu,gtt,wc}() functions into
__gem_mmap__{cpu,gtt,wc}(), and add back wrappers with the original name
that assert that the pointer is valid. Most callers will expect a valid
pointer and shouldn't have to bother with failures.

To avoid changing anything (yet), sed 's/gem_mmap__/__gem_mmap__/g'
over the entire codebase.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Stochastically-reviwewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-10-09 19:16:26 +03:00
Ville Syrjälä
8986bbc0ce lib: Document that gem_mmap__{cpu,gtt,wc} return NULL on failure
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Stochastically-reviwewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-10-09 16:59:13 +03:00
Thomas Wood
f0381d1abe lib: various documentation fixes
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-09-08 16:15:16 +01:00
Thomas Wood
d01ebbd97d docs: various documentation fixes
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-07-02 08:17:17 +01:00
Chris Wilson
fc69bb0de5 igt/gem_exec_big: Check 64bit relocation values
On gen8, we should check that the full 64bit relocation value is
correct, and we should be sure to poison the relocation offset between
runs.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-04-27 21:12:20 +01:00
Chris Wilson
019ae907ff lib: Fix types for gem_mmap*
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-04-26 12:18:15 +01:00
Chris Wilson
fb950bc17f lib: Cache static queries
We frequently check for device capabilities, for which we can safely
assume that there is but one on a system and so cache the first query
value and return it for all future queries. The benefit is to reduce
dmesg debug spam which helps when either bringing up a test or trying to
track down why a test fails.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-04-26 12:18:15 +01:00
Chris Wilson
236bab5cfd lib: Fix types for gem_create()
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-04-26 11:12:38 +01:00
Chris Wilson
41fe1d1a44 lib: Implement gem_sync() using WAIT
When synchronising to rendering, we only want to wait for it to complete
and avoid the cache-domain side-effects of SET_DOMAIN if possible. This
has the advantage of speeding up a few tests (and thereby making the
actual test more explicit in terms of kernel operations). Of course some
tests may be reliant on the side-effects...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-04-14 15:46:56 +01:00
Chris Wilson
43a1f64e72 igt/gem_cpu_reloc: Pretty print execbuf failures
References: https://bugs.freedesktop.org/show_bug.cgi?id=85672
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-04-03 09:25:42 +01:00
Thomas Wood
3b8e121552 lib: small documentation fixes
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-03-12 17:05:18 +00:00
Tvrtko Ursulin
c7bac3c62a lib: Add support for new extension to the ADDFB2 ioctl.
New functionality accessesed via the __kms_addfb wrapper.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2015-03-12 14:24:05 +00:00
Tvrtko Ursulin
0a087733d2 tests/kms_addfb: Add support for fb modifiers
Just a few basic tests to make sure fb modifiers can be used and
behave sanely when mixed with the old set_tiling API.

v2:
   * Review feedback from Daniel Vetter:
      1. Move cap detection into the subtest so skipping works.
      2. Added some gtkdoc comments.
      3. Two more test cases.
      4. Removed unused parts for now.

v3:
   * Removed two tests which do not make sense any more after the
     fb modifier rewrite.

v4:
   * Moved gtkdoc comments into .c file.
   * Moved all initialization into fixtures.
   * Rebased for fb modifier changes.

v5:
   * Added bad modifier subtest.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
2015-03-12 14:14:27 +00:00
Thomas Wood
26f40811d7 lib: small documentation fixes
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-25 16:59:22 +00:00
Thomas Wood
a22548fec0 lib: small documentation fixes
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-02-17 11:24:04 +00:00
Daniel Vetter
75c075cb26 lib/ioctl: Document ctx param functions
And move them so that they're grouped with the other context wrappers.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-02-13 09:35:35 +01:00
Daniel Vetter
09b8211d41 lib/ioctl: Add gem_context_destroy helpers
We also need a raw version for some tests.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-02-13 09:35:35 +01:00
Daniel Vetter
8d21b39251 lib/ioctls: make gem_context_set/get_param infallible
We have separate require checks already, so these failing is a bug in
the test logic.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-02-13 09:35:35 +01:00
Daniel Vetter
c18b2d57a9 lib/ioctl: api polish for gem_context_has_param
Just push the igt_require down to align with the usual style.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-02-13 09:35:35 +01:00
Zhipeng Gong
17937a0114 i-g-t: check whether kernel has dual bsd ring
v2: change the number to be consistent with upstream (Zhipeng)

Signed-off-by: Zhipeng Gong <zhipeng.gong@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-01-22 09:27:52 +01:00
Chris Wilson
16bafdf5bf igt/gem_concurrent_blit: Inject hangs before verifying contents
After setting up the copy operations, add a hanging batch. This should
mean that we complete the copy and the compare then races against the
GEM reset. Hopefully, this will catch driver bugs where the target
object is no longer accessible after the hang.

Note: hang injection is disabled until the required kernel interface is
completed. But there are useful additional tests here...

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-01-07 17:35:14 +00:00
Chris Wilson
eaa1e8e127 ioct_wrappers: Add some mmap(wc) blurb dropped between authors
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-01-06 10:07:08 +00:00
Chris Wilson
a464fb758e igt/gem_mmap_wc: Exercise mmap(wc) interface
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-01-06 09:29:45 +01:00
Thomas Wood
f59bbf7e8f lib: fix a few documentation warnings
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-12-12 14:18:12 +00:00
Thomas Wood
ae3a946631 lib: fix symbol names in documentation comments
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-11-25 11:59:37 +00:00