diff mbox

horror

Message ID 20180627111915.14221-1-chris@chris-wilson.co.uk (mailing list archive)
State New, archived
Headers show

Commit Message

Chris Wilson June 27, 2018, 11:19 a.m. UTC
---
 drivers/gpu/drm/i915/i915_drv.c     |  8 ++++++++
 drivers/gpu/drm/i915/i915_drv.h     | 12 ++++++++++++
 drivers/gpu/drm/i915/i915_request.c |  7 +++++--
 3 files changed, 25 insertions(+), 2 deletions(-)

Comments

Chris Wilson June 27, 2018, 11:22 a.m. UTC | #1
I really must remember to proof read git send-email.
-Chris
Jani Nikula June 27, 2018, 12:37 p.m. UTC | #2
On Wed, 27 Jun 2018, Chris Wilson <chris@chris-wilson.co.uk> wrote:
> I really must remember to proof read git send-email.

I did like the subsequent "warning for horror" and "failure for horror"
messages from CI though.

BR,
Jani.
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index 5ba785387c2b..3c2625b50448 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -1479,6 +1479,14 @@  static void i915_driver_release(struct drm_device *dev)
 	kfree(dev_priv);
 }
 
+void i915_release(struct kref *kref)
+{
+	struct drm_i915_private *i915 = 
+		container_of(kref, struct drm_i915_private, drm.ref);
+
+	i915_driver_release(&i915->drm);
+}
+
 static int i915_driver_open(struct drm_device *dev, struct drm_file *file)
 {
 	struct drm_i915_private *i915 = to_i915(dev);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 397e587a8688..052e4952e370 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3552,4 +3552,16 @@  static inline int intel_hws_csb_write_index(struct drm_i915_private *i915)
 		return I915_HWS_CSB_WRITE_INDEX;
 }
 
+static inline struct drm_i915_private *i915_get(struct drm_i915_private *i915)
+{
+	kref_get(&i915->drm.ref);
+	return i915;
+}
+
+void i915_release(struct kref *kref);
+static inline void i915_put(struct drm_i915_private *i915)
+{
+	kref_put(&i915->drm.ref, i915_release);
+}
+
 #endif
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index e808087928f7..6753fe8e6400 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -74,6 +74,7 @@  static signed long i915_fence_wait(struct dma_fence *fence,
 static void i915_fence_release(struct dma_fence *fence)
 {
 	struct i915_request *rq = to_request(fence);
+	struct drm_i915_private *i915 = rq->i915;
 
 	/*
 	 * The request is put onto a RCU freelist (i.e. the address
@@ -84,7 +85,8 @@  static void i915_fence_release(struct dma_fence *fence)
 	 */
 	i915_sw_fence_fini(&rq->submit);
 
-	kmem_cache_free(rq->i915->requests, rq);
+	kmem_cache_free(i915->requests, rq);
+	i915_put(i915);
 }
 
 const struct dma_fence_ops i915_fence_ops = {
@@ -717,7 +719,7 @@  i915_request_alloc(struct intel_engine_cs *engine, struct i915_gem_context *ctx)
 	}
 
 	INIT_LIST_HEAD(&rq->active_list);
-	rq->i915 = i915;
+	rq->i915 = i915_get(i915);
 	rq->engine = engine;
 	rq->gem_context = ctx;
 	rq->hw_context = ce;
@@ -795,6 +797,7 @@  i915_request_alloc(struct intel_engine_cs *engine, struct i915_gem_context *ctx)
 	GEM_BUG_ON(!list_empty(&rq->sched.waiters_list));
 
 	kmem_cache_free(i915->requests, rq);
+	i915_put(i915);
 err_unreserve:
 	unreserve_gt(i915);
 err_unpin: