Commit a8c9a7f5 authored by Chris Wilson's avatar Chris Wilson
Browse files

drm/i915/selftests: Complete transition to a real struct file mock



Since drm provided us with a real struct file we can use for our
anonymous internal clients (mock_file), complete our transition to using
that as the primary interface (and not the mocked up struct drm_file we
previous were using).

Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191107213929.23286-1-chris@chris-wilson.co.uk
parent ab11a927
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1912,9 +1912,9 @@ int i915_gem_huge_page_live_selftests(struct drm_i915_private *i915)
		SUBTEST(igt_ppgtt_smoke_huge),
		SUBTEST(igt_ppgtt_sanity_check),
	};
	struct drm_file *file;
	struct i915_gem_context *ctx;
	struct i915_address_space *vm;
	struct file *file;
	int err;

	if (!HAS_PPGTT(i915)) {
@@ -1944,6 +1944,6 @@ int i915_gem_huge_page_live_selftests(struct drm_i915_private *i915)
	err = i915_subtests(tests, ctx);

out_file:
	mock_file_put(file);
	fput(file);
	return err;
}
+17 −17
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ static int live_nop_switch(void *arg)
	struct intel_engine_cs *engine;
	struct i915_gem_context **ctx;
	struct igt_live_test t;
	struct drm_file *file;
	struct file *file;
	unsigned long n;
	int err = -ENODEV;

@@ -149,7 +149,7 @@ static int live_nop_switch(void *arg)
	}

out_file:
	mock_file_put(file);
	fput(file);
	return err;
}

@@ -255,7 +255,7 @@ static int live_parallel_switch(void *arg)
	int (* const *fn)(void *arg);
	struct i915_gem_context *ctx;
	struct intel_context *ce;
	struct drm_file *file;
	struct file *file;
	int n, m, count;
	int err = 0;

@@ -377,7 +377,7 @@ out:
	}
	kfree(data);
out_file:
	mock_file_put(file);
	fput(file);
	return err;
}

@@ -502,15 +502,15 @@ out_unmap:
	return err;
}

static int file_add_object(struct drm_file *file,
			    struct drm_i915_gem_object *obj)
static int file_add_object(struct file *file, struct drm_i915_gem_object *obj)
{
	int err;

	GEM_BUG_ON(obj->base.handle_count);

	/* tie the object to the drm_file for easy reaping */
	err = idr_alloc(&file->object_idr, &obj->base, 1, 0, GFP_KERNEL);
	err = idr_alloc(&to_drm_file(file)->object_idr,
			&obj->base, 1, 0, GFP_KERNEL);
	if (err < 0)
		return err;

@@ -521,7 +521,7 @@ static int file_add_object(struct drm_file *file,

static struct drm_i915_gem_object *
create_test_object(struct i915_address_space *vm,
		   struct drm_file *file,
		   struct file *file,
		   struct list_head *objects)
{
	struct drm_i915_gem_object *obj;
@@ -621,9 +621,9 @@ static int igt_ctx_exec(void *arg)
		unsigned long ncontexts, ndwords, dw;
		struct i915_request *tq[5] = {};
		struct igt_live_test t;
		struct drm_file *file;
		IGT_TIMEOUT(end_time);
		LIST_HEAD(objects);
		struct file *file;

		if (!intel_engine_can_store_dword(engine))
			continue;
@@ -716,7 +716,7 @@ out_file:
		if (igt_live_test_end(&t))
			err = -EIO;

		mock_file_put(file);
		fput(file);
		if (err)
			return err;

@@ -733,7 +733,7 @@ static int igt_shared_ctx_exec(void *arg)
	struct i915_gem_context *parent;
	struct intel_engine_cs *engine;
	struct igt_live_test t;
	struct drm_file *file;
	struct file *file;
	int err = 0;

	/*
@@ -854,7 +854,7 @@ out_test:
	if (igt_live_test_end(&t))
		err = -EIO;
out_file:
	mock_file_put(file);
	fput(file);
	return err;
}

@@ -1317,10 +1317,10 @@ static int igt_ctx_readonly(void *arg)
	struct i915_gem_context *ctx;
	unsigned long idx, ndwords, dw;
	struct igt_live_test t;
	struct drm_file *file;
	I915_RND_STATE(prng);
	IGT_TIMEOUT(end_time);
	LIST_HEAD(objects);
	struct file *file;
	int err = -ENODEV;

	/*
@@ -1426,7 +1426,7 @@ out_file:
	if (igt_live_test_end(&t))
		err = -EIO;

	mock_file_put(file);
	fput(file);
	return err;
}

@@ -1663,9 +1663,9 @@ static int igt_vm_isolation(void *arg)
	struct i915_gem_context *ctx_a, *ctx_b;
	struct intel_engine_cs *engine;
	struct igt_live_test t;
	struct drm_file *file;
	I915_RND_STATE(prng);
	unsigned long count;
	struct file *file;
	u64 vm_total;
	int err;

@@ -1750,7 +1750,7 @@ static int igt_vm_isolation(void *arg)
out_file:
	if (igt_live_test_end(&t))
		err = -EIO;
	mock_file_put(file);
	fput(file);
	return err;
}

+4 −4
Original line number Diff line number Diff line
@@ -198,7 +198,7 @@ static int igt_fill_blt_thread(void *arg)
	struct drm_i915_gem_object *obj;
	struct i915_gem_context *ctx;
	struct intel_context *ce;
	struct drm_file *file;
	struct file *file;
	unsigned int prio;
	IGT_TIMEOUT(end);
	int err;
@@ -301,7 +301,7 @@ err_flush:

	intel_context_put(ce);
out_file:
	mock_file_put(file);
	fput(file);
	return err;
}

@@ -313,7 +313,7 @@ static int igt_copy_blt_thread(void *arg)
	struct drm_i915_gem_object *src, *dst;
	struct i915_gem_context *ctx;
	struct intel_context *ce;
	struct drm_file *file;
	struct file *file;
	unsigned int prio;
	IGT_TIMEOUT(end);
	int err;
@@ -432,7 +432,7 @@ err_flush:

	intel_context_put(ce);
out_file:
	mock_file_put(file);
	fput(file);
	return err;
}

+3 −2
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
 */

#include "mock_context.h"
#include "selftests/mock_drm.h"
#include "selftests/mock_gtt.h"

struct i915_gem_context *
@@ -74,7 +75,7 @@ void mock_init_contexts(struct drm_i915_private *i915)
}

struct i915_gem_context *
live_context(struct drm_i915_private *i915, struct drm_file *file)
live_context(struct drm_i915_private *i915, struct file *file)
{
	struct i915_gem_context *ctx;
	int err;
@@ -83,7 +84,7 @@ live_context(struct drm_i915_private *i915, struct drm_file *file)
	if (IS_ERR(ctx))
		return ctx;

	err = gem_context_register(ctx, file->driver_priv);
	err = gem_context_register(ctx, to_drm_file(file)->driver_priv);
	if (err < 0)
		goto err_ctx;

+1 −1
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@ mock_context(struct drm_i915_private *i915,
void mock_context_close(struct i915_gem_context *ctx);

struct i915_gem_context *
live_context(struct drm_i915_private *i915, struct drm_file *file);
live_context(struct drm_i915_private *i915, struct file *file);

struct i915_gem_context *kernel_context(struct drm_i915_private *i915);
void kernel_context_close(struct i915_gem_context *ctx);
Loading