diff options
| -rw-r--r-- | drivers/gpu/drm/i915/i915_drv.h | 14 | ||||
| -rw-r--r-- | drivers/gpu/drm/i915/i915_gem.c | 3 | ||||
| -rw-r--r-- | drivers/gpu/drm/i915/intel_lrc.c | 8 |
3 files changed, 18 insertions, 7 deletions
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index b38c770a22f5..8727086cf48c 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h | |||
| @@ -2114,6 +2114,9 @@ void i915_gem_track_fb(struct drm_i915_gem_object *old, | |||
| 2114 | * number comparisons on buffer last_read|write_seqno. It also allows an | 2114 | * number comparisons on buffer last_read|write_seqno. It also allows an |
| 2115 | * emission time to be associated with the request for tracking how far ahead | 2115 | * emission time to be associated with the request for tracking how far ahead |
| 2116 | * of the GPU the submission is. | 2116 | * of the GPU the submission is. |
| 2117 | * | ||
| 2118 | * The requests are reference counted, so upon creation they should have an | ||
| 2119 | * initial reference taken using kref_init | ||
| 2117 | */ | 2120 | */ |
| 2118 | struct drm_i915_gem_request { | 2121 | struct drm_i915_gem_request { |
| 2119 | struct kref ref; | 2122 | struct kref ref; |
| @@ -2137,7 +2140,16 @@ struct drm_i915_gem_request { | |||
| 2137 | /** Position in the ringbuffer of the end of the whole request */ | 2140 | /** Position in the ringbuffer of the end of the whole request */ |
| 2138 | u32 tail; | 2141 | u32 tail; |
| 2139 | 2142 | ||
| 2140 | /** Context related to this request */ | 2143 | /** |
| 2144 | * Context related to this request | ||
| 2145 | * Contexts are refcounted, so when this request is associated with a | ||
| 2146 | * context, we must increment the context's refcount, to guarantee that | ||
| 2147 | * it persists while any request is linked to it. Requests themselves | ||
| 2148 | * are also refcounted, so the request will only be freed when the last | ||
| 2149 | * reference to it is dismissed, and the code in | ||
| 2150 | * i915_gem_request_free() will then decrement the refcount on the | ||
| 2151 | * context. | ||
| 2152 | */ | ||
| 2141 | struct intel_context *ctx; | 2153 | struct intel_context *ctx; |
| 2142 | 2154 | ||
| 2143 | /** Batch buffer related to this request if any */ | 2155 | /** Batch buffer related to this request if any */ |
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c index c26d36cc4b31..e5daad5f75fb 100644 --- a/drivers/gpu/drm/i915/i915_gem.c +++ b/drivers/gpu/drm/i915/i915_gem.c | |||
| @@ -2659,8 +2659,7 @@ static void i915_gem_reset_ring_cleanup(struct drm_i915_private *dev_priv, | |||
| 2659 | if (submit_req->ctx != ring->default_context) | 2659 | if (submit_req->ctx != ring->default_context) |
| 2660 | intel_lr_context_unpin(ring, submit_req->ctx); | 2660 | intel_lr_context_unpin(ring, submit_req->ctx); |
| 2661 | 2661 | ||
| 2662 | i915_gem_context_unreference(submit_req->ctx); | 2662 | i915_gem_request_unreference(submit_req); |
| 2663 | kfree(submit_req); | ||
| 2664 | } | 2663 | } |
| 2665 | 2664 | ||
| 2666 | /* | 2665 | /* |
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c index 0f358c5999ec..e8d3da9f3373 100644 --- a/drivers/gpu/drm/i915/intel_lrc.c +++ b/drivers/gpu/drm/i915/intel_lrc.c | |||
| @@ -503,18 +503,19 @@ static int execlists_context_queue(struct intel_engine_cs *ring, | |||
| 503 | * If there isn't a request associated with this submission, | 503 | * If there isn't a request associated with this submission, |
| 504 | * create one as a temporary holder. | 504 | * create one as a temporary holder. |
| 505 | */ | 505 | */ |
| 506 | WARN(1, "execlist context submission without request"); | ||
| 507 | request = kzalloc(sizeof(*request), GFP_KERNEL); | 506 | request = kzalloc(sizeof(*request), GFP_KERNEL); |
| 508 | if (request == NULL) | 507 | if (request == NULL) |
| 509 | return -ENOMEM; | 508 | return -ENOMEM; |
| 510 | request->ring = ring; | 509 | request->ring = ring; |
| 511 | request->ctx = to; | 510 | request->ctx = to; |
| 511 | kref_init(&request->ref); | ||
| 512 | request->uniq = dev_priv->request_uniq++; | ||
| 513 | i915_gem_context_reference(request->ctx); | ||
| 512 | } else { | 514 | } else { |
| 515 | i915_gem_request_reference(request); | ||
| 513 | WARN_ON(to != request->ctx); | 516 | WARN_ON(to != request->ctx); |
| 514 | } | 517 | } |
| 515 | request->tail = tail; | 518 | request->tail = tail; |
| 516 | i915_gem_request_reference(request); | ||
| 517 | i915_gem_context_reference(request->ctx); | ||
| 518 | 519 | ||
| 519 | intel_runtime_pm_get(dev_priv); | 520 | intel_runtime_pm_get(dev_priv); |
| 520 | 521 | ||
| @@ -731,7 +732,6 @@ void intel_execlists_retire_requests(struct intel_engine_cs *ring) | |||
| 731 | if (ctx_obj && (ctx != ring->default_context)) | 732 | if (ctx_obj && (ctx != ring->default_context)) |
| 732 | intel_lr_context_unpin(ring, ctx); | 733 | intel_lr_context_unpin(ring, ctx); |
| 733 | intel_runtime_pm_put(dev_priv); | 734 | intel_runtime_pm_put(dev_priv); |
| 734 | i915_gem_context_unreference(ctx); | ||
| 735 | list_del(&req->execlist_link); | 735 | list_del(&req->execlist_link); |
| 736 | i915_gem_request_unreference(req); | 736 | i915_gem_request_unreference(req); |
| 737 | } | 737 | } |
