From patchwork Tue Jul 2 08:48:31 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 2811161 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 4C3709F3EB for ; Tue, 2 Jul 2013 08:52:18 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 919D020134 for ; Tue, 2 Jul 2013 08:52:13 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id A33E12012E for ; Tue, 2 Jul 2013 08:52:12 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8E6EEE61D0 for ; Tue, 2 Jul 2013 01:52:12 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ee0-f51.google.com (mail-ee0-f51.google.com [74.125.83.51]) by gabe.freedesktop.org (Postfix) with ESMTP id DC421E61CD for ; Tue, 2 Jul 2013 01:51:03 -0700 (PDT) Received: by mail-ee0-f51.google.com with SMTP id e52so2546153eek.24 for ; Tue, 02 Jul 2013 01:51:02 -0700 (PDT) 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=9ZBieQDR/tBJxqQvIq08jpimLoa/dDixazAcOjXg9AA=; b=MvTiUwZ4TTfFsTTIrjrUpOG3+kptRQuz2mgW2Gr6ErZZFXbRXFbh8KzXKslofrfMf+ MPIWvLVB6RxOytxglkVecrC7+IYAGal27keNtHC/ChNCNql56Wlmt5+3Ddn4WjPz7hyR /XJQ+Cn7G/cuSkaC753/D+pwfwIGz9g5xiQ+E= 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=9ZBieQDR/tBJxqQvIq08jpimLoa/dDixazAcOjXg9AA=; b=XXdOqorxKQ0lSRrc0oM6Jk4iqv8rTfEP2Ydc1ogB+hZUFbZ20jeah0yCvOH5bBuKEk m3+r6XQSMdFlkFrwu5kbRDX7t9ToIWeivOMGOzYAcrdB7ShCoRnOKnyGsPaTyi+JB736 EFnBp9a58nbVAyM/cXmAcjHiD7NSmXj7KVvE4Wc4QdYPogiFkMNrZfiuDbY+mqtT4JHG mKj5BXC+KUrooi5LL5kMnM7rMZEeeBMGT1kgMtPhJmARrvNQ4poSa8gXf1gR96M2clod OHop+nkL81LgrGVe1HJpypcAeMLb2+f56ehft/c+owlA6RR37wefowTSWRuECwb7WBh0 b1FQ== X-Received: by 10.15.35.129 with SMTP id g1mr25289730eev.2.1372755062796; Tue, 02 Jul 2013 01:51:02 -0700 (PDT) Received: from gina.ffwll.local (178-83-130-250.dynamic.hispeed.ch. [178.83.130.250]) by mx.google.com with ESMTPSA id bj46sm35078515eeb.13.2013.07.02.01.51.01 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 02 Jul 2013 01:51:01 -0700 (PDT) From: Daniel Vetter To: Intel Graphics Development Subject: [PATCH] drm/i915: Don't try to tear down the stolen drm_mm if it's not there Date: Tue, 2 Jul 2013 10:48:31 +0200 Message-Id: <1372754911-12725-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20130702081334.GE8080@cantiga.alporthouse.com> References: <20130702081334.GE8080@cantiga.alporthouse.com> X-Gm-Message-State: ALoCoQmGzBczqP/gnmHOKpmDvgTR/VdCq+K7j/rWsvHOXD1ohDoj8H0NZs9gHZ1dPCLpv06Gzq8X Cc: Daniel Vetter , DRI Development 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=-4.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, 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 Every other place properly checks whether we've managed to set up the stolen allocator at boot-up properly, with the exception of the cleanup code. Which results in an ugly *ERROR* Memory manager not clean. Delaying takedown at module unload time since the drm_mm isn't initialized at all. v2: While at it check whether the stolen drm_mm is initialized instead of the more obscure stolen_base == 0 check. v3: Fix up the logic. Also we need to keep the stolen_base check in i915_gem_object_create_stolen_for_preallocated since that can be called before stolen memory is fully set up. Spotted by Chris Wilson. v4: Readd the conversion in i915_gem_object_create_stolen_for_preallocated, the check is for the dev_priv->mm.gtt_space drm_mm, the stolen allocatot must already be initialized when calling that function (if we indeed have stolen memory). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65953 Cc: Chris Wilson Tested-by: lu hua (v3) Signed-off-by: Daniel Vetter Reviewed-by: Chris Wilson --- drivers/gpu/drm/i915/i915_gem_stolen.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index 8e02344..0f8cf62 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c @@ -147,7 +147,7 @@ int i915_gem_stolen_setup_compression(struct drm_device *dev, int size) { struct drm_i915_private *dev_priv = dev->dev_private; - if (dev_priv->mm.stolen_base == 0) + if (!drm_mm_initialized(&dev_priv->mm.stolen)) return -ENODEV; if (size < dev_priv->fbc.size) @@ -179,6 +179,9 @@ void i915_gem_cleanup_stolen(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; + if (!drm_mm_initialized(&dev_priv->mm.stolen)) + return; + i915_gem_stolen_cleanup_compression(dev); drm_mm_takedown(&dev_priv->mm.stolen); } @@ -300,7 +303,7 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size) struct drm_i915_gem_object *obj; struct drm_mm_node *stolen; - if (dev_priv->mm.stolen_base == 0) + if (!drm_mm_initialized(&dev_priv->mm.stolen)) return NULL; DRM_DEBUG_KMS("creating stolen object: size=%x\n", size); @@ -331,7 +334,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, struct drm_i915_gem_object *obj; struct drm_mm_node *stolen; - if (dev_priv->mm.stolen_base == 0) + if (!drm_mm_initialized(&dev_priv->mm.stolen)) return NULL; DRM_DEBUG_KMS("creating preallocated stolen object: stolen_offset=%x, gtt_offset=%x, size=%x\n",