From patchwork Thu Mar 19 04:33:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Stone X-Patchwork-Id: 6045951 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F0CDEBF910 for ; Thu, 19 Mar 2015 04:34:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 17485204D3 for ; Thu, 19 Mar 2015 04:34:16 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 435B0204AF for ; Thu, 19 Mar 2015 04:34:15 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 126BB6E966; Wed, 18 Mar 2015 21:34:08 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [93.93.135.160]) by gabe.freedesktop.org (Postfix) with ESMTP id E37ED6E95D for ; Wed, 18 Mar 2015 21:34:06 -0700 (PDT) Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: daniels) with ESMTPSA id C8360600EAE From: Daniel Stone To: dri-devel@lists.freedesktop.org Subject: [RFC PATCH 30/37] drm: fb_helper: Reference, not duplicate, modes Date: Thu, 19 Mar 2015 04:33:29 +0000 Message-Id: <1426739616-10635-30-git-send-email-daniels@collabora.com> X-Mailer: git-send-email 2.3.2 In-Reply-To: <1426739616-10635-1-git-send-email-daniels@collabora.com> References: <1426739556-10429-1-git-send-email-daniels@collabora.com> <1426739616-10635-1-git-send-email-daniels@collabora.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Take a reference to existing modes, rather than duplicating them to create new ones. Signed-off-by: Daniel Stone --- drivers/gpu/drm/drm_fb_helper.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 71e2420..130b35d 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c @@ -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;