[Intel-gfx] [PATCH v2] horror
Chris Wilson
chris at chris-wilson.co.uk
Fri Jun 29 22:00:10 UTC 2018
---
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(-)
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 4460e0b32c2f..16f8062807cd 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3547,4 +3547,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 d05ce92551b5..bc84f5d183d2 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:
--
2.18.0
More information about the Intel-gfx
mailing list