[RFC PATCH 33/37] drm: i915/tegra: atomic: Reference, not duplicate, modes

Daniel Stone daniels at collabora.com
Wed Mar 18 21:33:32 PDT 2015


Take a reference to existing modes, rather than duplicating them to
create new ones.

Signed-off-by: Daniel Stone <daniels at collabora.com>
---
 drivers/gpu/drm/i915/intel_atomic.c |  8 ++------
 drivers/gpu/drm/tegra/dc.c          | 11 ++---------
 2 files changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index 80cb562..8b80a54 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -227,12 +227,8 @@ intel_crtc_duplicate_state(struct drm_crtc *crtc)
 
 	crtc_state->base.crtc = crtc;
 
-	if (intel_crtc->config && intel_crtc->config->mode) {
-		crtc_state->mode =
-			drm_mode_duplicate(crtc->dev, intel_crtc->config->mode);
-		if (!crtc_state->mode)
-			goto err;
-	}
+	if (crtc_state->base.mode)
+		drm_mode_reference(crtc_state->base.mode);
 
 	return &crtc_state->base;
 err:
diff --git a/drivers/gpu/drm/tegra/dc.c b/drivers/gpu/drm/tegra/dc.c
index 4dd51fe..888fcbd 100644
--- a/drivers/gpu/drm/tegra/dc.c
+++ b/drivers/gpu/drm/tegra/dc.c
@@ -1018,12 +1018,8 @@ tegra_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
 	if (!copy)
 		return NULL;
 
-	if (state->base.mode) {
-		copy->base.mode =
-			drm_mode_duplicate(crtc->dev, state->base.mode);
-		if (!copy->base.mode)
-			goto err;
-	}
+	if (copy->base.mode)
+		drm_mode_reference(copy->base.mode);
 
 	copy->base.mode_changed = false;
 	copy->base.active_changed = false;
@@ -1031,9 +1027,6 @@ tegra_crtc_atomic_duplicate_state(struct drm_crtc *crtc)
 	copy->base.event = NULL;
 
 	return &copy->base;
-err:
-	kfree(copy);
-	return NULL;
 }
 
 static void tegra_crtc_atomic_destroy_state(struct drm_crtc *crtc,
-- 
2.3.2



More information about the dri-devel mailing list