From patchwork Thu Dec 13 11:05:19 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1871781 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id CAD493FC71 for ; Thu, 13 Dec 2012 11:09:02 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B4C0143649 for ; Thu, 13 Dec 2012 03:09:02 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ee0-f49.google.com (mail-ee0-f49.google.com [74.125.83.49]) by gabe.freedesktop.org (Postfix) with ESMTP id 047F543689 for ; Thu, 13 Dec 2012 03:05:27 -0800 (PST) Received: by mail-ee0-f49.google.com with SMTP id c4so1132790eek.36 for ; Thu, 13 Dec 2012 03:05:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=CkWYP8fYcs5J4DCQcImR0j6LCPZ24b10xiES9lsrWuk=; b=JQfiNJul2I9pa6YtvPvL3ojM+fiKvu87CuLiNG+bl++ydQTUTlKB1koILfEDCY0oYj lg2KHn1Dm7wHSqhSBE4gIaT7kNO7s8ZsZ+cC3X03FII+iMvypun3BO6xQoZOephf8Uml aH3NxkPtQDtbvGgfZRdlAqWmlVbSTd7tZDRno= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :x-gm-message-state; bh=CkWYP8fYcs5J4DCQcImR0j6LCPZ24b10xiES9lsrWuk=; b=l+aKVW1vkbW9w5bPXh8YrWDZjalLtnWQdGziXe7OuHQ/CcnxxrQ2s74G00aDmpZUeR uX4yt+mNSDzkKcR5/oAKfeUqheJ1BLBM0UXnXWHV6i5XtFUBpWtM5+Bl7tGBg7YeN8vu z5qaJKt5nZIkHiFmAjLEipnTiBjM4d2pTmBB20skWVYckMEz0ze4TZiAGSqtpFzRuWhk oQPYGhOow365p3U0JJUTvySuhjlWXMXFO2SrpplEFiGEgbbpWZfh5280brDLy35V1js9 oR72+LEGHt6y+Sn/R/XL8eojLe89Ctf7hftJxjfn51sXgyC8f29Msk6tNIuA9T9umOWF RPGA== Received: by 10.14.221.9 with SMTP id q9mr4478322eep.3.1355396726957; Thu, 13 Dec 2012 03:05:26 -0800 (PST) Received: from biers.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPS id 6sm2322551eea.3.2012.12.13.03.05.25 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 13 Dec 2012 03:05:26 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 2/2] drm/exynos: reorder framebuffer init sequence Date: Thu, 13 Dec 2012 12:05:19 +0100 Message-Id: <1355396719-25286-2-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355396719-25286-1-git-send-email-daniel.vetter@ffwll.ch> References: <1355317637-16742-17-git-send-email-daniel.vetter@ffwll.ch> <1355396719-25286-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQlpKP8KHn0xnbFZzzc6zFXEOXXeXLfAf8yG2q5uAZDDioYVt1nlCjEYcQghnfghzly9aKYD Cc: Nouveau Dev , Intel Graphics Development , Daniel Vetter X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org For user framebuffers it's easier to just inline the exynos_drm_framebuffer_init helper instead of trying to adjust it - most of the things that helper sets up need to be overwritten anyway again due to the multiple backing storage objects support exynos has, but does not use for the fbdev. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/exynos/exynos_drm_fb.c | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/exynos/exynos_drm_fb.c b/drivers/gpu/drm/exynos/exynos_drm_fb.c index 4ef4cd3..aea6500 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fb.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fb.c @@ -136,15 +136,15 @@ exynos_drm_framebuffer_init(struct drm_device *dev, return ERR_PTR(-ENOMEM); } + drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd); + exynos_fb->exynos_gem_obj[0] = to_exynos_gem_obj(obj); + ret = drm_framebuffer_init(dev, &exynos_fb->fb, &exynos_drm_fb_funcs); if (ret) { DRM_ERROR("failed to initialize framebuffer\n"); return ERR_PTR(ret); } - drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd); - exynos_fb->exynos_gem_obj[0] = to_exynos_gem_obj(obj); - return &exynos_fb->fb; } @@ -190,9 +190,8 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, struct drm_mode_fb_cmd2 *mode_cmd) { struct drm_gem_object *obj; - struct drm_framebuffer *fb; struct exynos_drm_fb *exynos_fb; - int i; + int i, ret; DRM_DEBUG_KMS("%s\n", __FILE__); @@ -202,13 +201,13 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, return ERR_PTR(-ENOENT); } - fb = exynos_drm_framebuffer_init(dev, mode_cmd, obj); - if (IS_ERR(fb)) { - drm_gem_object_unreference_unlocked(obj); - return fb; + exynos_fb = kzalloc(sizeof(*exynos_fb), GFP_KERNEL); + if (!exynos_fb) { + DRM_ERROR("failed to allocate exynos drm framebuffer\n"); + return ERR_PTR(-ENOMEM); } - exynos_fb = to_exynos_fb(fb); + drm_helper_mode_fill_fb_struct(&exynos_fb->fb, mode_cmd); exynos_fb->buf_cnt = exynos_drm_format_num_buffers(mode_cmd); DRM_DEBUG_KMS("buf_cnt = %d\n", exynos_fb->buf_cnt); @@ -218,14 +217,23 @@ exynos_user_fb_create(struct drm_device *dev, struct drm_file *file_priv, mode_cmd->handles[i]); if (!obj) { DRM_ERROR("failed to lookup gem object\n"); - exynos_drm_fb_destroy(fb); + kfree(exynos_fb); return ERR_PTR(-ENOENT); } exynos_fb->exynos_gem_obj[i] = to_exynos_gem_obj(obj); } - return fb; + ret = drm_framebuffer_init(dev, &exynos_fb->fb, &exynos_drm_fb_funcs); + if (ret) { + for (i = 0; i < exynos_fb->buf_cnt; i++) + drm_gem_object_unreference_unlocked(&exynos_fb->exynos_gem_obj[i]->base); + + kfree(exynos_fb); + return ERR_PTR(ret); + } + + return &exynos_fb->fb; } struct exynos_drm_gem_buf *exynos_drm_fb_buffer(struct drm_framebuffer *fb,