diff mbox series

[2/2] drm/i915/selftests: Teach switch_to_context() to use the context

Message ID 20191022130221.20644-2-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show
Series [1/2] drm/i915: Teach record_defaults to operate on the intel_gt | expand

Commit Message

Chris Wilson Oct. 22, 2019, 1:02 p.m. UTC
The context details which engines to use, so use the ctx->engines[] to
generate the requests to cause the context switch.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/selftests/i915_gem.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

Comments

Tvrtko Ursulin Oct. 22, 2019, 1:41 p.m. UTC | #1
On 22/10/2019 14:02, Chris Wilson wrote:
> The context details which engines to use, so use the ctx->engines[] to
> generate the requests to cause the context switch.
> 
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> ---
>   drivers/gpu/drm/i915/selftests/i915_gem.c | 19 +++++++++----------
>   1 file changed, 9 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/selftests/i915_gem.c b/drivers/gpu/drm/i915/selftests/i915_gem.c
> index 97f89f744ee2..84e7ca778b7b 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_gem.c
> +++ b/drivers/gpu/drm/i915/selftests/i915_gem.c
> @@ -15,16 +15,15 @@
>   #include "igt_flush_test.h"
>   #include "mock_drm.h"
>   
> -static int switch_to_context(struct drm_i915_private *i915,
> -			     struct i915_gem_context *ctx)
> +static int switch_to_context(struct i915_gem_context *ctx)
>   {
> -	struct intel_engine_cs *engine;
> -	enum intel_engine_id id;
> +	struct i915_gem_engines_iter it;
> +	struct intel_context *ce;
>   
> -	for_each_engine(engine, i915, id) {
> +	for_each_gem_engine(ce, i915_gem_context_lock_engines(ctx), it) {
>   		struct i915_request *rq;
>   
> -		rq = igt_request_alloc(ctx, engine);
> +		rq = intel_context_create_request(ce);
>   		if (IS_ERR(rq))
>   			return PTR_ERR(rq);
>   
> @@ -140,7 +139,7 @@ static int igt_gem_suspend(void *arg)
>   	err = -ENOMEM;
>   	ctx = live_context(i915, file);
>   	if (!IS_ERR(ctx))
> -		err = switch_to_context(i915, ctx);
> +		err = switch_to_context(ctx);
>   	if (err)
>   		goto out;
>   
> @@ -155,7 +154,7 @@ static int igt_gem_suspend(void *arg)
>   
>   	pm_resume(i915);
>   
> -	err = switch_to_context(i915, ctx);
> +	err = switch_to_context(ctx);
>   out:
>   	mock_file_free(i915, file);
>   	return err;
> @@ -175,7 +174,7 @@ static int igt_gem_hibernate(void *arg)
>   	err = -ENOMEM;
>   	ctx = live_context(i915, file);
>   	if (!IS_ERR(ctx))
> -		err = switch_to_context(i915, ctx);
> +		err = switch_to_context(ctx);
>   	if (err)
>   		goto out;
>   
> @@ -190,7 +189,7 @@ static int igt_gem_hibernate(void *arg)
>   
>   	pm_resume(i915);
>   
> -	err = switch_to_context(i915, ctx);
> +	err = switch_to_context(ctx);
>   out:
>   	mock_file_free(i915, file);
>   	return err;
> 

Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>

Regards,

Tvrtko
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/selftests/i915_gem.c b/drivers/gpu/drm/i915/selftests/i915_gem.c
index 97f89f744ee2..84e7ca778b7b 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem.c
@@ -15,16 +15,15 @@ 
 #include "igt_flush_test.h"
 #include "mock_drm.h"
 
-static int switch_to_context(struct drm_i915_private *i915,
-			     struct i915_gem_context *ctx)
+static int switch_to_context(struct i915_gem_context *ctx)
 {
-	struct intel_engine_cs *engine;
-	enum intel_engine_id id;
+	struct i915_gem_engines_iter it;
+	struct intel_context *ce;
 
-	for_each_engine(engine, i915, id) {
+	for_each_gem_engine(ce, i915_gem_context_lock_engines(ctx), it) {
 		struct i915_request *rq;
 
-		rq = igt_request_alloc(ctx, engine);
+		rq = intel_context_create_request(ce);
 		if (IS_ERR(rq))
 			return PTR_ERR(rq);
 
@@ -140,7 +139,7 @@  static int igt_gem_suspend(void *arg)
 	err = -ENOMEM;
 	ctx = live_context(i915, file);
 	if (!IS_ERR(ctx))
-		err = switch_to_context(i915, ctx);
+		err = switch_to_context(ctx);
 	if (err)
 		goto out;
 
@@ -155,7 +154,7 @@  static int igt_gem_suspend(void *arg)
 
 	pm_resume(i915);
 
-	err = switch_to_context(i915, ctx);
+	err = switch_to_context(ctx);
 out:
 	mock_file_free(i915, file);
 	return err;
@@ -175,7 +174,7 @@  static int igt_gem_hibernate(void *arg)
 	err = -ENOMEM;
 	ctx = live_context(i915, file);
 	if (!IS_ERR(ctx))
-		err = switch_to_context(i915, ctx);
+		err = switch_to_context(ctx);
 	if (err)
 		goto out;
 
@@ -190,7 +189,7 @@  static int igt_gem_hibernate(void *arg)
 
 	pm_resume(i915);
 
-	err = switch_to_context(i915, ctx);
+	err = switch_to_context(ctx);
 out:
 	mock_file_free(i915, file);
 	return err;