summaryrefslogtreecommitdiff
path: root/tests/prime_vgem.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2018-08-07 16:40:55 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2018-08-08 17:01:57 +0100
commite897d8d2c12f90025130a011561d2ee0155831d7 (patch)
tree02800c8bade6714a92102b717c5763d2dc64ec13 /tests/prime_vgem.c
parent9ec3471f6e4f5e51880713d4c03e801167d34d00 (diff)
igt/prime_vgem: Ask the shrinker to purge a vgem bo from inside i915
Link a vgem dmabuf into an i915 bo and then ask the i915 shrinker to purge/invalidate its pages. This should establish the lockdep link from the fs_reclaim shrinker section to whatever locks are used to acquire/release dmabuf mappings; if any are required ofc. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Daniel Vetter <daniel@ffwll.ch> Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Diffstat (limited to 'tests/prime_vgem.c')
-rw-r--r--tests/prime_vgem.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/prime_vgem.c b/tests/prime_vgem.c
index d886044a..b821fbb8 100644
--- a/tests/prime_vgem.c
+++ b/tests/prime_vgem.c
@@ -237,6 +237,32 @@ static void test_gtt(int vgem, int i915)
gem_close(vgem, scratch.handle);
}
+static void test_shrink(int vgem, int i915)
+{
+ struct vgem_bo scratch = {
+ .width = 1024,
+ .height = 1024,
+ .bpp = 32
+ };
+ int dmabuf;
+
+ vgem_create(vgem, &scratch);
+
+ dmabuf = prime_handle_to_fd(vgem, scratch.handle);
+ gem_close(vgem, scratch.handle);
+
+ scratch.handle = prime_fd_to_handle(i915, dmabuf);
+ close(dmabuf);
+
+ /* Populate the i915_bo->pages. */
+ gem_set_domain(i915, scratch.handle, I915_GEM_DOMAIN_GTT, 0);
+
+ /* Now evict them, establishing the link from i915:shrinker to vgem. */
+ igt_drop_caches_set(i915, DROP_SHRINK_ALL);
+
+ gem_close(i915, scratch.handle);
+}
+
static bool is_coherent(int i915)
{
int val = 1; /* by default, we assume GTT is coherent, hence the test */
@@ -794,6 +820,9 @@ igt_main
igt_subtest("basic-gtt")
test_gtt(vgem, i915);
+ igt_subtest("shrink")
+ test_shrink(vgem, i915);
+
igt_subtest("coherency-gtt")
test_gtt_interleaved(vgem, i915);