[11/15] drm/i915/dsb: function to destroy DSB context.

Submitted by Animesh Manna on Aug. 19, 2019, 3:44 p.m.

Details

Message ID 20190819154445.1096-11-animesh.manna@intel.com
State New
Headers show
Series "Series without cover letter" ( rev: 1 ) in Intel GFX - Try Bot

Not browsing as part of any series.

Commit Message

Animesh Manna Aug. 19, 2019, 3:44 p.m.
Freed the gem object after completion of dsb workload.

Signed-off-by: Animesh Manna <animesh.manna@intel.com>
---
 drivers/gpu/drm/i915/display/intel_dsb.c | 16 ++++++++++++++++
 drivers/gpu/drm/i915/display/intel_dsb.h |  1 +
 2 files changed, 17 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c
index 7e0a9b37f702..f2eb9d1a40f1 100644
--- a/drivers/gpu/drm/i915/display/intel_dsb.c
+++ b/drivers/gpu/drm/i915/display/intel_dsb.c
@@ -234,3 +234,19 @@  void intel_dsb_commit(struct intel_dsb *dsb)
 	dsb->free_pos = 0;
 	intel_dsb_disable_engine(dsb);
 }
+
+void intel_dsb_put(struct intel_dsb *dsb)
+{
+	struct intel_crtc *crtc = dsb->crtc;
+	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
+	struct i915_vma *vma = dsb->vma;
+
+	if (dsb->cmd_buf) {
+		mutex_lock(&i915->drm.struct_mutex);
+		crtc->dsb_in_use--;
+		i915_gem_object_unpin_map(vma->obj);
+		i915_vma_unpin_and_release(&vma, 0);
+		dsb->cmd_buf = NULL;
+		mutex_unlock(&i915->drm.struct_mutex);
+	}
+}
diff --git a/drivers/gpu/drm/i915/display/intel_dsb.h b/drivers/gpu/drm/i915/display/intel_dsb.h
index 7330add3c96f..7b94fd9bc067 100644
--- a/drivers/gpu/drm/i915/display/intel_dsb.h
+++ b/drivers/gpu/drm/i915/display/intel_dsb.h
@@ -43,5 +43,6 @@  struct intel_dsb *
 intel_dsb_get(struct intel_crtc *crtc);
 void intel_dsb_reg_write(struct intel_dsb *dsb, i915_reg_t reg, u32 val);
 void intel_dsb_commit(struct intel_dsb *dsb);
+void intel_dsb_put(struct intel_dsb *dsb);
 
 #endif