From patchwork Tue Dec 18 21:25:07 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 1893661 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 485BDDF2F6 for ; Tue, 18 Dec 2012 21:29:48 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3A766E60C1 for ; Tue, 18 Dec 2012 13:29:48 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ea0-f171.google.com (mail-ea0-f171.google.com [209.85.215.171]) by gabe.freedesktop.org (Postfix) with ESMTP id 57A04E5ED7 for ; Tue, 18 Dec 2012 13:25:27 -0800 (PST) Received: by mail-ea0-f171.google.com with SMTP id n10so485560eaa.30 for ; Tue, 18 Dec 2012 13:25:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=gaiz2zCSBM0AUSuxEgYoA10VQvJ95SWAwHuIhZxiFFQ=; b=JlFRdwsnYMHCvOC3IMh+CQohC2RLYIdVAhHPeYV43PY75OHkT0krT/EUJJRDzaW3O1 rCakhxYwNDr22KPfk+NTM9fGqs0vXX+XeBsAC+q7nH8IAP1X7tRalB8ISNwlFEgKxw+o DQimlHJEWpR1ewiI+8bhvDZvXYrYcU/DVNFNs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=gaiz2zCSBM0AUSuxEgYoA10VQvJ95SWAwHuIhZxiFFQ=; b=Ww10zNmK3A+p/ZO4cRqbUUOn+LCnllQpGSJIJTkefpOsYrumkiNOf+tkh/hlmm2RvH 5+Bx/aRasGtuoreGUO37FHxp+N/u1LFojshhtD1qwMj5yjeA2CzjWHRDzxp2pIqaU5gf 2kRIcHXiMdrQee6ISE6GSTcH9nJrgDJxpiwrYy6rVPwZQJ9zwuYCNOm4n8DQNh1WiEAx v89WHGTRmPfopl7bmodwdpAdcxFdLJdKJw3U1TI8Vc5YbiJc+6rFf5hJEO3rJrek352D zLRwSYXDDQxUzFE7nET24/i/CODnXlGGdH+mz9rWCXahi7YygWIGMFuONLIirBQcxflC o1lg== X-Received: by 10.14.176.66 with SMTP id a42mr8834015eem.34.1355865926451; Tue, 18 Dec 2012 13:25: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 w3sm5549337eel.17.2012.12.18.13.25.25 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 18 Dec 2012 13:25:25 -0800 (PST) From: Daniel Vetter To: DRI Development Subject: [PATCH 04/10] drm/vmwgfx: reorder framebuffer init sequence Date: Tue, 18 Dec 2012 22:25:07 +0100 Message-Id: <1355865913-14858-5-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1355865913-14858-1-git-send-email-daniel.vetter@ffwll.ch> References: <1355865913-14858-1-git-send-email-daniel.vetter@ffwll.ch> X-Gm-Message-State: ALoCoQmG1a9KG6WvECZA3Ohe16WAxIXGYP94pkJIqV9ve+yOx1UyUxDBp8JOxV+eK8woIxM48UH7 Cc: 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 vmwgfx has an oddity, when failing to reference the surface it'll return 0, since that's what the successfull drm_framebuffer_init will leave behind in ret. Fix this up by returning -EINVAL. Split out from all the other driver updates due to the above tiny semantic change. Shouldn't matter though since the reference grabbing seemingly can't fail. Signed-off-by: Daniel Vetter --- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c index 5474394..edc9792 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_kms.c @@ -681,14 +681,10 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv, goto out_err1; } - ret = drm_framebuffer_init(dev, &vfbs->base.base, - &vmw_framebuffer_surface_funcs); - if (ret) - goto out_err2; - if (!vmw_surface_reference(surface)) { DRM_ERROR("failed to reference surface %p\n", surface); - goto out_err3; + ret = -EINVAL; + goto out_err2; } /* XXX get the first 3 from the surface info */ @@ -707,10 +703,15 @@ static int vmw_kms_new_framebuffer_surface(struct vmw_private *dev_priv, *out = &vfbs->base; + ret = drm_framebuffer_init(dev, &vfbs->base.base, + &vmw_framebuffer_surface_funcs); + if (ret) + goto out_err3; + return 0; out_err3: - drm_framebuffer_cleanup(&vfbs->base.base); + vmw_surface_unreference(&surface); out_err2: kfree(vfbs); out_err1: @@ -1053,14 +1054,10 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv, goto out_err1; } - ret = drm_framebuffer_init(dev, &vfbd->base.base, - &vmw_framebuffer_dmabuf_funcs); - if (ret) - goto out_err2; - if (!vmw_dmabuf_reference(dmabuf)) { DRM_ERROR("failed to reference dmabuf %p\n", dmabuf); - goto out_err3; + ret = -EINVAL; + goto out_err2; } vfbd->base.base.bits_per_pixel = mode_cmd->bpp; @@ -1077,10 +1074,15 @@ static int vmw_kms_new_framebuffer_dmabuf(struct vmw_private *dev_priv, vfbd->base.user_handle = mode_cmd->handle; *out = &vfbd->base; + ret = drm_framebuffer_init(dev, &vfbd->base.base, + &vmw_framebuffer_dmabuf_funcs); + if (ret) + goto out_err3; + return 0; out_err3: - drm_framebuffer_cleanup(&vfbd->base.base); + vmw_dmabuf_unreference(&dmabuf); out_err2: kfree(vfbd); out_err1: