@@ -1317,7 +1317,7 @@ struct drm_display_mode *drm_pick_cmdline_mode(struct drm_fb_helper_connector *f
if (mode->flags & DRM_MODE_FLAG_INTERLACE)
continue;
}
- return mode;
+ return drm_mode_reference(mode);
}
if (prefer_non_interlace) {
@@ -1329,7 +1329,7 @@ create_mode:
mode = drm_mode_create_from_cmdline_mode(fb_helper_conn->connector->dev,
cmdline_mode);
list_add(&mode->head, &fb_helper_conn->connector->modes);
- return mode;
+ return drm_mode_reference(mode);
}
EXPORT_SYMBOL(drm_pick_cmdline_mode);
@@ -1429,7 +1429,7 @@ static bool drm_target_cloned(struct drm_fb_helper *fb_helper,
fb_helper_conn = fb_helper->connector_info[i];
list_for_each_entry(mode, &fb_helper_conn->connector->modes, head) {
if (drm_mode_equal(mode, dmt_mode))
- modes[i] = mode;
+ modes[i] = drm_mode_reference(mode);
}
if (!modes[i])
can_clone = false;
@@ -1527,16 +1527,14 @@ retry:
fb_helper_conn->connector->base.id, fb_helper_conn->connector->tile_group ? fb_helper_conn->connector->tile_group->id : 0);
modes[i] = drm_has_preferred_mode(fb_helper_conn, width, height);
if (modes[i])
- modes[i] = drm_mode_duplicate(fb_helper->dev,
- modes[i]);
+ drm_mode_reference(modes[i]);
}
/* No preferred modes, pick one off the list */
if (!modes[i] && !list_empty(&fb_helper_conn->connector->modes)) {
list_for_each_entry(modes[i], &fb_helper_conn->connector->modes, head)
break;
if (modes[i])
- modes[i] = drm_mode_duplicate(fb_helper->dev,
- modes[i]);
+ drm_mode_reference(modes[i]);
}
DRM_DEBUG_KMS("found mode %s\n", modes[i] ? modes[i]->name :
"none");
@@ -1704,8 +1702,8 @@ static void drm_setup_crtcs(struct drm_fb_helper *fb_helper)
fb_crtc->y = offset->y;
if (fb_crtc->mode)
drm_mode_destroy(dev, fb_crtc->mode);
- fb_crtc->mode = drm_mode_duplicate(dev,
- fb_crtc->desired_mode);
+ fb_crtc->mode =
+ drm_mode_reference(fb_crtc->desired_mode);
modeset->mode = fb_crtc->mode;
modeset->connectors[modeset->num_connectors++] = fb_helper->connector_info[i]->connector;
modeset->fb = fb_helper->fb;
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/drm_fb_helper.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-)