[PATCH v4 3/5] drm/i915: Create the locked version of the request create
Andi Shyti
andi.shyti at linux.intel.com
Sat Mar 4 03:20:33 UTC 2023
Make version of the request creation that doesn't hold any
lock.
Signed-off-by: Andi Shyti <andi.shyti at linux.intel.com>
Cc: stable at vger.kernel.org
---
drivers/gpu/drm/i915/i915_request.c | 38 +++++++++++++++++++++++------
drivers/gpu/drm/i915/i915_request.h | 2 ++
2 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index a1741c4a8cff..fdfbdbbc2e24 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -1029,6 +1029,35 @@ __i915_request_create(struct intel_context *ce, gfp_t gfp)
return ERR_PTR(ret);
}
+static struct i915_request *
+__i915_request_create_locked(struct intel_context *ce)
+{
+ struct i915_request *rq;
+ struct intel_timeline *tl = ce->timeline;
+
+ /* Move our oldest request to the slab-cache (if not in use!) */
+ rq = list_first_entry(&tl->requests, typeof(*rq), link);
+ if (!list_is_last(&rq->link, &tl->requests))
+ i915_request_retire(rq);
+
+ intel_context_enter(ce);
+ rq = __i915_request_create(ce, GFP_KERNEL);
+ intel_context_exit(ce); /* active reference transferred to request */
+
+ return rq;
+}
+
+struct i915_request *
+i915_request_create_locked(struct intel_context *ce)
+{
+ intel_context_assert_timeline_is_locked(ce->timeline);
+
+ if (intel_context_throttle(ce))
+ return ERR_PTR(-EINTR);
+
+ return __i915_request_create_locked(ce);
+}
+
struct i915_request *
i915_request_create(struct intel_context *ce)
{
@@ -1042,14 +1071,7 @@ i915_request_create(struct intel_context *ce)
if (IS_ERR(tl))
return ERR_CAST(tl);
- /* Move our oldest request to the slab-cache (if not in use!) */
- rq = list_first_entry(&tl->requests, typeof(*rq), link);
- if (!list_is_last(&rq->link, &tl->requests))
- i915_request_retire(rq);
-
- intel_context_enter(ce);
- rq = __i915_request_create(ce, GFP_KERNEL);
- intel_context_exit(ce); /* active reference transferred to request */
+ rq = __i915_request_create_locked(ce);
if (IS_ERR(rq))
goto err_unlock;
diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h
index f5e1bb5e857a..bb48bd4605c0 100644
--- a/drivers/gpu/drm/i915/i915_request.h
+++ b/drivers/gpu/drm/i915/i915_request.h
@@ -374,6 +374,8 @@ struct i915_request * __must_check
__i915_request_create(struct intel_context *ce, gfp_t gfp);
struct i915_request * __must_check
i915_request_create(struct intel_context *ce);
+struct i915_request * __must_check
+i915_request_create_locked(struct intel_context *ce);
void __i915_request_skip(struct i915_request *rq);
bool i915_request_set_error_once(struct i915_request *rq, int error);
--
2.39.2
More information about the Intel-gfx-trybot
mailing list