From patchwork Thu Jun 27 11:38:21 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maarten Lankhorst X-Patchwork-Id: 2791901 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 05A4B9F3A0 for ; Thu, 27 Jun 2013 11:42:51 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D567B20274 for ; Thu, 27 Jun 2013 11:42:49 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6D45F20278 for ; Thu, 27 Jun 2013 11:42:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 68D77E6476 for ; Thu, 27 Jun 2013 04:42:48 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-we0-f175.google.com (mail-we0-f175.google.com [74.125.82.175]) by gabe.freedesktop.org (Postfix) with ESMTP id AAA6AE5F3B for ; Thu, 27 Jun 2013 04:39:03 -0700 (PDT) Received: by mail-we0-f175.google.com with SMTP id t59so460052wes.6 for ; Thu, 27 Jun 2013 04:39:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=3AAhOnyoOcJmrhOarHXHmHd0HoqidaMPu/Dx5bU6xeM=; b=sb5ulwGgaFIy4bSenxs9J0lyFBr4gghbgxAsOnb3krn8K65ayVV18l3Cmk+kvf/2Sr txbJ+EmtP6WJHGKsdHvTp9B0jGtvB0Yc8I5OENTquvpj3bULLtZImtoDyS4Ugq8dUusJ 1jpALXJcYjjbw/eZoKzsFu4fzU5lo5cHIYP6GK8pPm72Ar4TCF49zf9YKZsBxheeqapi YhAz487s/Q1r6uW/5ocL7p9Lmkj2AU6k+sTqLretaLq8ptO/3FGOHnr5fK+kcUp5jBeN gQt0SFcfOPnkos+RDZmSJzsg7OH5MCh0QV9ekahU3ztBSTe4fgaioPQ1K0Eh/aCdVFVM C4sQ== X-Received: by 10.180.76.103 with SMTP id j7mr5710058wiw.21.1372333142889; Thu, 27 Jun 2013 04:39:02 -0700 (PDT) Received: from localhost (5ED49945.cm-7-5c.dynamic.ziggo.nl. [94.212.153.69]) by mx.google.com with ESMTPSA id o14sm16828367wiv.3.2013.06.27.04.39.00 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 27 Jun 2013 04:39:01 -0700 (PDT) Received: by localhost (sSMTP sendmail emulation); Thu, 27 Jun 2013 13:38:59 +0200 From: Maarten Lankhorst To: Dave Airlie Subject: [PATCH 4/9] drm/nouveau: fixup fbcon failure paths Date: Thu, 27 Jun 2013 13:38:21 +0200 Message-Id: <1372333106-28910-4-git-send-email-maarten.lankhorst@canonical.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1372333106-28910-1-git-send-email-maarten.lankhorst@canonical.com> References: <1372333106-28910-1-git-send-email-maarten.lankhorst@canonical.com> Cc: dri-devel@lists.freedesktop.org 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 X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 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; }