[19/19] drm/i915: Use ww pinning for intel_context_create_request()
diff mbox series

Message ID 20200214103055.2117836-20-maarten.lankhorst@linux.intel.com
State New
Headers show
Series
  • drm/i915/gem: Implement parallel execbuf submission.
Related show

Commit Message

Maarten Lankhorst Feb. 14, 2020, 10:30 a.m. UTC
We want to get rid of intel_context_pin(), convert
intel_context_create_request() first. :)

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/gt/intel_context.c | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

Comments

Ruhl, Michael J Feb. 14, 2020, 8:01 p.m. UTC | #1
>-----Original Message-----
>From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of
>Maarten Lankhorst
>Sent: Friday, February 14, 2020 5:31 AM
>To: intel-gfx@lists.freedesktop.org
>Subject: [Intel-gfx] [PATCH 19/19] drm/i915: Use ww pinning for
>intel_context_create_request()
>
>We want to get rid of intel_context_pin(), convert
>intel_context_create_request() first. :)
>
>Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>---
> drivers/gpu/drm/i915/gt/intel_context.c | 20 +++++++++++++++-----
> 1 file changed, 15 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/gpu/drm/i915/gt/intel_context.c
>b/drivers/gpu/drm/i915/gt/intel_context.c
>index 87f9f9e61916..44868b10be0a 100644
>--- a/drivers/gpu/drm/i915/gt/intel_context.c
>+++ b/drivers/gpu/drm/i915/gt/intel_context.c
>@@ -436,15 +436,25 @@ int intel_context_prepare_remote_request(struct
>intel_context *ce,
>
> struct i915_request *intel_context_create_request(struct intel_context *ce)
> {
>+	struct i915_gem_ww_ctx ww;
> 	struct i915_request *rq;
> 	int err;
>
>-	err = intel_context_pin(ce);
>-	if (unlikely(err))
>-		return ERR_PTR(err);
>+	i915_gem_ww_ctx_init(&ww, true);
>+retry:
>+	err = intel_context_pin_ww(ce, &ww);
>+	if (!err) {
>+		rq = i915_request_create(ce);
>+		intel_context_unpin(ce);
>+	} else if (err == -EDEADLK) {
>+		err = i915_gem_ww_ctx_backoff(&ww);
>+		if (!err)
>+			goto retry;
>+	} else {
>+		rq = ERR_PTR(err);
>+	}

If you have the pathological path:

err = intel_context_pin_ww(cd, &&))
	else if (err == -EDEADLK)
		err = i915_gem_ww_ctx_backoff(&ww) ; (where err != 0)

It appears that you can get to IS_ERR(rq) with rq being garbage from the
stack.

Do you need to preset rq, or set it on: 

if (!err)
	goto retry;
else
	rq = ERR_PTR(err);

?

Thanks,

Mike


>
>-	rq = i915_request_create(ce);
>-	intel_context_unpin(ce);
>+	i915_gem_ww_ctx_fini(&ww);
>
> 	if (IS_ERR(rq))
> 		return rq;
>--
>2.25.0.24.g3f081b084b0
>
>_______________________________________________
>Intel-gfx mailing list
>Intel-gfx@lists.freedesktop.org
>https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Patch
diff mbox series

diff --git a/drivers/gpu/drm/i915/gt/intel_context.c b/drivers/gpu/drm/i915/gt/intel_context.c
index 87f9f9e61916..44868b10be0a 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.c
+++ b/drivers/gpu/drm/i915/gt/intel_context.c
@@ -436,15 +436,25 @@  int intel_context_prepare_remote_request(struct intel_context *ce,
 
 struct i915_request *intel_context_create_request(struct intel_context *ce)
 {
+	struct i915_gem_ww_ctx ww;
 	struct i915_request *rq;
 	int err;
 
-	err = intel_context_pin(ce);
-	if (unlikely(err))
-		return ERR_PTR(err);
+	i915_gem_ww_ctx_init(&ww, true);
+retry:
+	err = intel_context_pin_ww(ce, &ww);
+	if (!err) {
+		rq = i915_request_create(ce);
+		intel_context_unpin(ce);
+	} else if (err == -EDEADLK) {
+		err = i915_gem_ww_ctx_backoff(&ww);
+		if (!err)
+			goto retry;
+	} else {
+		rq = ERR_PTR(err);
+	}
 
-	rq = i915_request_create(ce);
-	intel_context_unpin(ce);
+	i915_gem_ww_ctx_fini(&ww);
 
 	if (IS_ERR(rq))
 		return rq;