diff mbox

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

Message ID 1426739616-10635-33-git-send-email-daniels@collabora.com (mailing list archive)
State New, archived
Headers show

Commit Message

Daniel Stone March 19, 2015, 4:33 a.m. UTC
Take a reference to existing modes, rather than duplicating them to
create new ones.

Signed-off-by: Daniel Stone <daniels@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 mbox

Patch

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,