@@ -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:
@@ -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 ©->base;
-err:
- kfree(copy);
- return NULL;
}
static void tegra_crtc_atomic_destroy_state(struct drm_crtc *crtc,
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(-)