diff mbox series

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

Message ID 20190821063236.19705-12-animesh.manna@intel.com (mailing list archive)
State New, archived
Headers show
Series DSB enablement. | expand

Commit Message

Animesh Manna Aug. 21, 2019, 6:32 a.m. UTC
Freed the gem object after completion of dsb workload.

Cc: Shashank Sharma <shashank.sharma@intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Animesh Manna <animesh.manna@intel.com>
---
 drivers/gpu/drm/i915/display/intel_dsb.c | 23 +++++++++++++++++++++++
 drivers/gpu/drm/i915/display/intel_dsb.h |  1 +
 2 files changed, 24 insertions(+)

Comments

Chris Wilson Aug. 21, 2019, 6:45 p.m. UTC | #1
Quoting Animesh Manna (2019-08-21 07:32:31)
> Freed the gem object after completion of dsb workload.
> 
> Cc: Shashank Sharma <shashank.sharma@intel.com>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: Animesh Manna <animesh.manna@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_dsb.c | 23 +++++++++++++++++++++++
>  drivers/gpu/drm/i915/display/intel_dsb.h |  1 +
>  2 files changed, 24 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c
> index 7e0a9b37f702..bfb138952f61 100644
> --- a/drivers/gpu/drm/i915/display/intel_dsb.c
> +++ b/drivers/gpu/drm/i915/display/intel_dsb.c
> @@ -234,3 +234,26 @@ 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;
> +       struct drm_i915_private *i915;
> +       struct i915_vma *vma;
> +
> +       if (!dsb)
> +               return;
> +
> +       crtc = dsb->crtc;
> +       i915 = to_i915(crtc->base.dev);
> +
> +       if (dsb->cmd_buf) {
> +               vma = dsb->vma;
> +               mutex_lock(&i915->drm.struct_mutex);
> +               crtc->dsb_in_use--;

That is complete garbage. This dsb just happens to be crtc->dsb_in_use?

> +               i915_gem_object_unpin_map(vma->obj);
> +               i915_vma_unpin_and_release(&vma, 0);

i915_vma_unpin_and_release(vma, I915_VMA_RELEASE_MAP);

Does not require struct_mutex.

Put this with the allocator.
-Chris
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c
index 7e0a9b37f702..bfb138952f61 100644
--- a/drivers/gpu/drm/i915/display/intel_dsb.c
+++ b/drivers/gpu/drm/i915/display/intel_dsb.c
@@ -234,3 +234,26 @@  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;
+	struct drm_i915_private *i915;
+	struct i915_vma *vma;
+
+	if (!dsb)
+		return;
+
+	crtc = dsb->crtc;
+	i915 = to_i915(crtc->base.dev);
+
+	if (dsb->cmd_buf) {
+		vma = dsb->vma;
+		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