From patchwork Wed May 1 08:52:43 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 2507271 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id A4B2BDF230 for ; Wed, 1 May 2013 08:59:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C1A0BE61B3 for ; Wed, 1 May 2013 01:59:58 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-we0-f179.google.com (mail-we0-f179.google.com [74.125.82.179]) by gabe.freedesktop.org (Postfix) with ESMTP id 0D3C4E5F4B for ; Wed, 1 May 2013 01:53:04 -0700 (PDT) Received: by mail-we0-f179.google.com with SMTP id u7so1106470wey.10 for ; Wed, 01 May 2013 01:53:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=rE8YNd7sz4ADlmVz5C3tHRjlcH9zduHpi90EvlXNxs4=; b=uGv8qhtHayXYqVL1pvIOJXWFZkVe4pw5f/aA0aMOBbUtHMoW731fcgnVLXDAF9d6cu R0hlDim+IRvYSmcvsvMW6TspwIlNaOgvHQ93rnoMjBDY0pqyqMknvzEp3w70UjD+byle BuOv1AiKd7Uth2BnOW4W5JXMoNvCJmIUhBqZpPohDY9oyuH/A0E03dAjqNc46GtKMBtT Y3kSPBUtzfvZbxyPKQE+QdLg8XX3hXS8jhpv9iHq93Tj8tk6FKHKyXZJPBAGUMbWbLBn FM/vBi8K07N9eeiCzZVKjZYF+tToTop15ar5Hyc8yMklf5lb6a9OQFEq4vsk++a8C5HL OkWQ== X-Received: by 10.194.78.204 with SMTP id d12mr1795955wjx.42.1367398384153; Wed, 01 May 2013 01:53:04 -0700 (PDT) Received: from localhost (5ED49945.cm-7-5c.dynamic.ziggo.nl. [94.212.153.69]) by mx.google.com with ESMTPSA id ge7sm30863803wic.0.2013.05.01.01.53.02 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 01 May 2013 01:53:03 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Wed, 01 May 2013 10:53:01 +0200 From: Maarten Lankhorst To: dri-devel@lists.freedesktop.org Subject: [PATCH 6/7] drm/nouveau: fixup fbcon failure paths Date: Wed, 1 May 2013 10:52:43 +0200 Message-Id: <1367398364-28997-6-git-send-email-maarten.lankhorst@canonical.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1367398364-28997-1-git-send-email-maarten.lankhorst@canonical.com> References: <1367398364-28997-1-git-send-email-maarten.lankhorst@canonical.com> 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 Add missing calls, and fix a leak from forgetting to call the unpin function. Signed-off-by: Maarten Lankhorst --- drivers/gpu/drm/nouveau/nouveau_fbcon.c | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c index b035317..ecbfe69 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c @@ -289,16 +289,13 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, ret = nouveau_bo_pin(nvbo, TTM_PL_FLAG_VRAM); if (ret) { NV_ERROR(drm, "failed to pin fb: %d\n", ret); - nouveau_bo_ref(NULL, &nvbo); - goto out; + goto out_unref; } ret = nouveau_bo_map(nvbo); if (ret) { NV_ERROR(drm, "failed to map fb: %d\n", ret); - nouveau_bo_unpin(nvbo); - nouveau_bo_ref(NULL, &nvbo); - goto out; + goto out_unpin; } chan = nouveau_nofbaccel ? NULL : drm->channel; @@ -316,13 +313,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, info = framebuffer_alloc(0, &pdev->dev); if (!info) { ret = -ENOMEM; - goto out_unref; + goto out_unlock; } ret = fb_alloc_cmap(&info->cmap, 256, 0); if (ret) { ret = -ENOMEM; - goto out_unref; + framebuffer_release(info); + goto out_unlock; } info->par = fbcon; @@ -337,7 +335,7 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, fbcon->helper.fbdev = info; strcpy(info->fix.id, "nouveaufb"); - if (nouveau_nofbaccel) + if (!chan) info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_DISABLED; else info->flags = FBINFO_DEFAULT | FBINFO_HWACCEL_COPYAREA | @@ -383,8 +381,14 @@ nouveau_fbcon_create(struct drm_fb_helper *helper, vga_switcheroo_client_fb_set(dev->pdev, info); return 0; -out_unref: +out_unlock: mutex_unlock(&dev->struct_mutex); + if (chan) + nouveau_bo_vma_del(nvbo, &fbcon->nouveau_fb.vma); +out_unpin: + nouveau_bo_unpin(nvbo); +out_unref: + nouveau_bo_ref(NULL, &nvbo); out: return ret; } @@ -413,6 +417,7 @@ nouveau_fbcon_destroy(struct drm_device *dev, struct nouveau_fbdev *fbcon) if (nouveau_fb->nvbo) { nouveau_bo_unmap(nouveau_fb->nvbo); nouveau_bo_vma_del(nouveau_fb->nvbo, &nouveau_fb->vma); + nouveau_bo_unpin(nouveau_fb->nvbo); drm_gem_object_unreference_unlocked(nouveau_fb->nvbo->gem); nouveau_fb->nvbo = NULL; }