37 Commits

Author SHA1 Message Date
Ville Syrjälä
f52e7ec787 Replace __gem_mmap__{cpu,gtt,wc}() + igt_assert() with gem_mmap__{cpu,gtt,wc}()
gem_mmap__{cpu,gtt,wc}() already has the assert built in, so replace
 __gem_mmap__{cpu,gtt,wc}() + igt_assert() with it.

Mostly done with coccinelle, with some manual help:
@@
identifier I;
expression E1, E2, E3, E4, E5, E6;
@@
(
-  I = __gem_mmap__gtt(E1, E2, E3, E4);
+  I = gem_mmap__gtt(E1, E2, E3, E4);
...
-  igt_assert(I);
|
-  I = __gem_mmap__cpu(E1, E2, E3, E4, E5);
+  I = gem_mmap__cpu(E1, E2, E3, E4, E5);
...
-  igt_assert(I);
|
-  I = __gem_mmap__wc(E1, E2, E3, E4, E5);
+  I = gem_mmap__wc(E1, E2, E3, E4, E5);
...
-  igt_assert(I);
)

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Stochastically-reviwewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-10-12 19:57:58 +03: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ä
7eaae3c201 Sprinkle igt_assert(ptr) after gem_mmap__{cpu,gtt,wc}
Do the following
 ptr = gem_mmap__{cpu,gtt,wc}()
+igt_assert(ptr);

whenever the code doesn't handle the NULL ptr in any kind of
specific way.

Makes it easier to move the assert into gem_mmap__{cpu,gtt,wc}() itself.

Mostly done with coccinelle, with some manual cleanups:
@@
identifier I;
@@
<... when != igt_assert(I)
     when != igt_require(I)
     when != igt_require_f(I, ...)
     when != I != NULL
     when != I == NULL
(
  I = gem_mmap__gtt(...);
+ igt_assert(I);
|
  I = gem_mmap__cpu(...);
+ igt_assert(I);
|
  I = gem_mmap__wc(...);
+ igt_assert(I);
)
...>

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Stochastically-reviwewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-10-09 18:33:30 +03:00
Ville Syrjälä
91d295cf06 Remove gem_mmap__{cpu,gtt,wc} return value MAP_FAILED asserts
gem_mmap__{cpu,gtt,wc} never return MAP_FAILED, it gets converted to
NULL internally. So don't go asserting that the returned value is
not MAP_FAILED.

Done with coccinelle:
@@
type T;
identifier I;
@@
(
 I = gem_mmap__gtt(...);
|
 I = gem_mmap__cpu(...);
|
 I = gem_mmap__wc(...);
)
 ...
(
- igt_assert(I != MAP_FAILED);
+ igt_assert(I);
|
- igt_assert(I && I != MAP_FAILED);
+ igt_assert(I);
|
- igt_assert(I != (T *) MAP_FAILED);
+ igt_assert(I);
|
- igt_assert(I != NULL);
+ igt_assert(I);
)

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Stochastically-reviwewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-10-09 17:09:45 +03:00
Ville Syrjälä
9792e7b580 s/gem_mmap/gem_mmap__gtt/
Get rid of the gem_mmap() alias of gem_mmap__gtt(). I don't see any
point in having it.

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:47:05 +03:00
Micah Fedke
c81d293aed convert drm_open_any*() calls to drm_open_driver*(DRIVER_INTEL) calls with cocci
Apply the new API to all call sites within the test suite using the following
semantic patch:

// Semantic patch for replacing drm_open_any* with arch-specific drm_open_driver* calls
@@
identifier i =~ "\bdrm_open_any\b";
@@
- i()
+ drm_open_driver(DRIVER_INTEL)

@@
identifier i =~ "\bdrm_open_any_master\b";
@@
- i()
+ drm_open_driver_master(DRIVER_INTEL)

@@
identifier i =~ "\bdrm_open_any_render\b";
@@
- i()
+ drm_open_driver_render(DRIVER_INTEL)

@@
identifier i =~ "\b__drm_open_any\b";
@@
- i()
+ __drm_open_driver(DRIVER_INTEL)

Signed-off-by: Micah Fedke <micah.fedke@collabora.co.uk>
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-09-11 14:39:43 +01:00
Thomas Wood
804e11f40d lib: add a single include header
Add a header that includes all the headers for the library. This allows
reorganisation of the library without affecting programs using it and
also simplifies the headers that need to be included to use the library.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-08-21 09:37:10 +01:00
Thomas Wood
7a5e1c6f0a tests: match gem_create prototype in igt_eviction_test_ops create function
This avoids a warning when using gem_create as the create function.

Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2015-05-14 17:01:57 +01:00
Chris Wilson
068f9ceb62 igt/gem_evict_everything: Use mlock to reduce available memory
The idea here is to check what happens when a large process requests
memory from us - we create and utilize a bunch of surfaces then have to
relinquish some but continue using the whole working set (so as to force
reloads).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2015-03-29 15:57:50 +01:00
Matt Roper
07be8fec15 igt.cocci: Replace igt_assert() with igt_assert_CMP() where possible
The integer comparison macros give us better error output by including
the actual values that failed the comparison.

Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2015-03-06 18:06:10 +01:00
Michał Winiarski
bef692d9f3 tests/gem_userptr_blits: Race between close and invalidate
It was possible for invalidate range start mmu notifier callback to race
with releasing userptr object. If the object is released prior to
taking a spinlock in the callback, we'll encounter a null pointer
dereference.

v2: Moved expressions inside igt_assert(), added mem barrier (Chris)

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>
2015-02-04 10:29:12 +01:00
Alan Coopersmith
33d52a8543 Skip MADV_DOFORK & MADV_DONTFORK calls on OS'es that don't support them
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2015-01-06 09:29:45 +01:00
Daniel Vetter
16f99ee419 lib/os: Push simulation test down into intel_require_memory
This has the upside that we'll never forget to add it to thrashing
tests. But we'll also never miss to move it when adding basic
functionality tests to existing binaries. Chris already started this
refining work in e.g.

commit d77eda6614a1955717f224be023dedf74eb7735d
Author: Chris Wilson <chris@chris-wilson.co.uk>
Date:   Fri Nov 14 07:45:40 2014 +0000

    igt/gem_linear_blits: Require that we do the full test

by moving igt_skip_on_simulation into subtests.

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2014-11-17 15:12:52 +01:00
Daniel Vetter
a535cdedfb lib/os: Pust igt_require into memory check function
More in line with the usual igt pattern and simplifies the code -
every called just wrapped it in igt_require.

Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2014-11-17 14:43:33 +01:00
Chris Wilson
6fff1f8787 ioctl_wrappers: Pass in offset to CPU mmaps
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-11-04 12:08:50 +00:00
Chris Wilson
e497600fb7 igt/gem_userptr_blits/dmabuf: Map the right pointer for !llc
References: https://bugs.freedesktop.org/show_bug.cgi?id=85354#c2
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-10-24 07:40:44 +01:00
Chris Wilson
18cb650318 igt/gem_userptr_blits/dmabuf: Provide partial coverage on !llc platforms
Without LLC, we cannot assume coherency between system RAM and the GTT.
If we try to use the GTT with snooped memory, the machine may lock up,
so the kernel prevents us from doing so, causing the test to fail.
However, we still do want to verify that we can access the userptr
through a dmabuf, so just check that we can make a copy from it using
the GPU and ignore the GTT cross-checking.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=85354
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-10-23 08:03:48 +01:00
Thomas Wood
be4710a541 lib: add common min and max macros
Signed-off-by: Thomas Wood <thomas.wood@intel.com>
2014-10-17 15:34:43 +01:00
Daniel Vetter
4306538d1d tests: Sprinkle missing igt_exit() where needed.
Yay for breaking piles of tests.

This regression has been introduced with

commit 5782eca1e19e85a04ad402fa4094aa1b5f9c53ce
Author: Tim Gore <tim.gore@intel.com>
Date:   Wed Oct 1 13:25:20 2014 +0100

    lib/igt_core.c: disable lowmemorykiller during tests

Cc: Tim Gore <tim.gore@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
2014-10-02 11:34:55 +02:00
Chris Wilson
f2775039b1 igt/gem_userptr_blits: Test interruptible create-destroy
In order to exercise https://bugs.freedesktop.org/show_bug.cgi?id=84207
we need to interrupt the mmu_notifier_register with a signal. This is
likely to be quite difficult, but let's just try running the
create-destroy test in an interruptible loop for 5s.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-09-26 10:29:22 +01:00
Chris Wilson
855dc6284d igt/gem_userptr_blits: GTT mmaping a userptr requires llc
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=83790
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-09-12 09:10:01 +01:00
Tvrtko Ursulin
8b3ded404c igt/gem_userptr_blits: Fix multi-threaded mm stress tester
Two parts to the fix:
  1. Do not use pthread_cancel since not available on Android.
  2. Do not assert in the thread since that does not get propagated
     to the process. Rather pass out any failures so we know test
     did not work as expected.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Tim Gore <tim.gore@intel.com>
Reviewed-by: Tim Gore <tim.gore@intel.com>
2014-07-24 09:31:31 +01:00
Tvrtko Ursulin
700bdf1401 igt/gem_userptr_blits: Fix forked access test
copy() blit helper assumes a certain object size much larger than a page size.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-24 08:46:38 +01:00
Chris Wilson
784b77257b igt/gem_userptr_blits: New tests, old issues
Introduce a new test to keep that we clean up on process exit (if the
userptr is busy or it has been gtt mmapped). This revealed a few bugs in
the existing tests so clean those up.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-21 16:32:42 +01:00
Daniel Vetter
43784baa13 tests/gem_userptr_blits: Polish
- Drop return values for test functions - we rely on the implicit
  control flow from igt_ checks.
- Don't use assert directly, this upsets the test flow logic (and
  results in a CRASH result instead of FAIL).

Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-07-15 10:18:28 +02:00
Tvrtko Ursulin
abbfecb015 tests/gem_userptr_blits: Race between object creation and multi-threaded mm ops
Userptr v23 was not thread safe against memory map operations and object
creation from separate threads. MMU notifier callback would get triggered
on a partially constructed object causing a NULL pointer dereference.

This test excercises that path a bit. In my testing it would trigger it
every time and easily, but unfortunately a test pass here does not guarantee
the absence of the race.

v2: Added explicit cancellation point and removed the stop flag.
    Use only igt_assert().

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-07-15 10:11:27 +02:00
Chris Wilson
b3d038a2b9 igt/gem_userptr_blits: Add missing RAM check before coherency tests
-ENOCOFFE.

References: https://bugs.freedesktop.org/show_bug.cgi?id=79237
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-14 10:33:55 +01:00
Chris Wilson
52ac9a4b57 igt/gem_userptr_blits: Add missing RAM check before coherency tests
References: https://bugs.freedesktop.org/show_bug.cgi?id=79237
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-14 10:30:36 +01:00
Chris Wilson
9b6ae3cb6f igt/gem_userptr_blits: Verify that userptr bo work on unshared memory
If the parent passes a userptr to some private memory, we expect to
still be able to use the userptr in the child.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-11 10:41:29 +01:00
Chris Wilson
9344aa78e8 igt/gem_userptr_blits: Shared memory allocations
The forked tests allocate the bo (and thus for userptr, the memory) in
the parent and pass them to all children. The difference for userptr is
that we allocate system memory which the kernel then copies into each
child. As the children need to access the memory for their checks, it
does need to be shared - so allocate the userptr from shared memory!

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=80208
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-07-11 10:41:28 +01:00
Chris Wilson
a384e55b49 igt/gem_evict_everything: Move assertion
If we move the assertion from out of the callback, we can get a much
more useful error message.

References: https://bugs.freedesktop.org/show_bug.cgi?id=79573
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-06-03 07:35:54 +01:00
Chris Wilson
9911f3f0cf igt/gem_userptr_blits: Fix up last minute API changes
When the patch was merged, the ioctl numbers had to be adjusted to leave
no holes. Also there was a final piece of munging of the API to
downgrade unsynced userptr for export over dma-buf.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
2014-05-22 10:22:04 +01:00
Daniel Vetter
0b7ce4ac29 tests: Use igt macros more
Often just folding together of the common if (cond) printf;
abort|igt_skip|igt_fail; pattern. But in a few cases I've ripped out
more since the igt macros will already print the condition and errno.

A few tests where more work (like ripping out return codes en masse)
is needed left as-is.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-05-14 09:56:53 +02:00
Daniel Vetter
e624fa8a2e tests: sprinkle igt logging
All the cases that simply dump some debug information and couldn't be
converted to some of the fancier macros.

Some information output removed when it's redundant with the subtest
status.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-05-14 00:36:04 +02:00
Daniel Vetter
e36c896a71 test: Fixup for the previous patch
Oops, failed to git add.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-04-25 17:57:22 +02:00
Daniel Vetter
1b55886c4b test/gem_userptr_*: Fix compile fail
Also shut up warnings. Those revealed incorrect usage of local
variables in conjunction with igt_fixture/igt_subtest. Since those use
longjmps we need to move the out of the stackframe those magic blocks
are declared in.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-04-25 17:54:08 +02:00
Tvrtko Ursulin
863c0730f3 tests/gem_userptr_blits: Expanded userptr test cases
A set of userptr test cases to support the new feature.

For the eviction and swapping stress testing I have extracted
some common behaviour from gem_evict_everything and made both
test cases use it to avoid duplicating the code.

Both unsynchronized and synchronized userptr objects are
tested but the latter set of tests will be skipped if kernel
is compiled without MMU_NOTIFIERS.

Also, with 32-bit userspace swapping tests are skipped if
the system has a lot more RAM than process address space.
Forking swapping tests are not skipped since they can still
trigger swapping by cumulative effect.

v2:
   * Fixed dmabuf test.
   * Added test for rejecting read-only.
   * Fixed ioctl detection for latest kernel patch.

v3:
   * Use ALIGN macro.
   * Catchup with big lib/ reorganization.
   * Fixed up some warnings.

Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Brad Volkin <bradley.d.volkin@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
2014-04-25 17:48:41 +02:00