From patchwork Wed Oct 30 23:12:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: wang yanqing X-Patchwork-Id: 3118021 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 DB0A19F3E2 for ; Wed, 30 Oct 2013 23:13:09 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 59190203E9 for ; Wed, 30 Oct 2013 23:13:04 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id CF8902039F for ; Wed, 30 Oct 2013 23:12:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B0A1EF0D3; Wed, 30 Oct 2013 16:12:57 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f45.google.com (mail-pa0-f45.google.com [209.85.220.45]) by gabe.freedesktop.org (Postfix) with ESMTP id 8C528EF0D3 for ; Wed, 30 Oct 2013 16:12:55 -0700 (PDT) Received: by mail-pa0-f45.google.com with SMTP id kp14so1653854pab.32 for ; Wed, 30 Oct 2013 16:12:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:mail-followup-to:mime-version :content-type:content-disposition:user-agent; bh=9uVSI228fsWLeQRizMgiup+fYcYpNcxBC8vpGDMtXyk=; b=vegCr9NGVcosQTGdKe0PGMKPQvbU0of/B1V4b7ylL+vF2d0/oQc2PwgLA3oqe3iDcE Af4Lx+Zn4F1iXXUUoYaKbLyMIs2dCYAJqRYVpKrokYG5dB0cRPBCss3+QKCLGyJBePxO Ud/4Va3OJfwHDocX/ubxPgU80kQbCokcLxyuXIFZ972hrqbrBOhdB6JM+uqCcDYY/Xut DT+PcDYfiMXPqHj8XWHPqSRuYU/5AbBYD8WzyjkJfIjJOOfcpa6PBsCUs7AcLmt6Remj biSSPtpygZ1rNNNCfyFofpyXiZ4B3g8JdXSe2M4V7qU6AfgLScDNNTYFk8jb2Nz2mDsk D8Og== X-Received: by 10.68.59.202 with SMTP id b10mr233649pbr.78.1383174775390; Wed, 30 Oct 2013 16:12:55 -0700 (PDT) Received: from udknight.localhost ([120.42.56.66]) by mx.google.com with ESMTPSA id at4sm340803pbc.30.2013.10.30.16.12.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 30 Oct 2013 16:12:54 -0700 (PDT) Received: from udknight.localhost (udknight.localhost [127.0.0.1]) by udknight.localhost (8.14.4/8.14.4) with ESMTP id r9UNCVR9005764; Thu, 31 Oct 2013 07:12:31 +0800 Received: (from root@localhost) by udknight.localhost (8.14.4/8.14.4/Submit) id r9UNCVMT005761; Thu, 31 Oct 2013 07:12:31 +0800 Date: Thu, 31 Oct 2013 07:12:31 +0800 From: Wang YanQing To: airlied@linux.ie Subject: [PATCH 5/5] drm:drm_stub: rewrite error handle code for drm_fill_in_dev Message-ID: <20131030231228.GC5719@udknight> Mail-Followup-To: Wang YanQing , airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) Cc: linux-kernel@vger.kernel.org, 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: , Sender: dri-devel-bounces@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org X-Spam-Status: No, score=-4.6 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 Rewrite error handle code in a more rational and normal way, it bring us benefit that we could drop call to drm_lastclose which do "too much" cleanup work for drm_fill_in_dev. Signed-off-by: Wang YanQing --- drivers/gpu/drm/drm_stub.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_stub.c b/drivers/gpu/drm/drm_stub.c index 3f3b167..6c5f65f 100644 --- a/drivers/gpu/drm/drm_stub.c +++ b/drivers/gpu/drm/drm_stub.c @@ -316,7 +316,7 @@ int drm_fill_in_dev(struct drm_device *dev, if (dev->driver->bus->agp_init) { retcode = dev->driver->bus->agp_init(dev); if (retcode) - goto error_out_unreg; + goto err_g1; } @@ -324,7 +324,7 @@ int drm_fill_in_dev(struct drm_device *dev, retcode = drm_ctxbitmap_init(dev); if (retcode) { DRM_ERROR("Cannot allocate memory for context bitmap.\n"); - goto error_out_unreg; + goto err_g2; } if (driver->driver_features & DRIVER_GEM) { @@ -332,14 +332,30 @@ int drm_fill_in_dev(struct drm_device *dev, if (retcode) { DRM_ERROR("Cannot initialize graphics execution " "manager (GEM)\n"); - goto error_out_unreg; + goto err_g3; } } return 0; - error_out_unreg: - drm_lastclose(dev); +err_g3: + drm_ctxbitmap_cleanup(dev); +err_g2: + if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && + dev->agp && dev->agp->agp_mtrr >= 0) { + int retval; + retval = mtrr_del(dev->agp->agp_mtrr, + dev->agp->agp_info.aper_base, + dev->agp->agp_info.aper_size * 1024 * 1024); + DRM_DEBUG("mtrr_del=%d\n", retval); + } + + if (drm_core_has_AGP(dev) && dev->agp) { + kfree(dev->agp); + dev->agp = NULL; + } +err_g1: + drm_ht_remove(&dev->map_hash); return retcode; } EXPORT_SYMBOL(drm_fill_in_dev);