From patchwork Mon Jul 1 20:34:30 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Vetter X-Patchwork-Id: 2810001 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 EA4BD9F3C3 for ; Mon, 1 Jul 2013 20:37:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 03070201E4 for ; Mon, 1 Jul 2013 20:37:39 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 29D54201E3 for ; Mon, 1 Jul 2013 20:37:38 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id F2E12E60CD for ; Mon, 1 Jul 2013 13:37:37 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ee0-f53.google.com (mail-ee0-f53.google.com [74.125.83.53]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E801E5FF0 for ; Mon, 1 Jul 2013 13:37:02 -0700 (PDT) Received: by mail-ee0-f53.google.com with SMTP id c41so2305138eek.26 for ; Mon, 01 Jul 2013 13:37:01 -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=qOOH63jRuEutl1O1ABm5dx4u8LzoiCj9aMsx0K0D7ok=; b=EQH5EJbGxCGY+DSy3zI4DJJ65FNuVWoHP118hhTOeSg/OlAWM1atH1OEQCa9lNdIgw HibR0TKT2fovvi0QzTuRG00dGotolCho4vpsQsWmA7zue3sPWMgPAGt1kggVL4vdT+r+ W/hgBqiEoPNo7r74RWPrUNNTK3FpCNws5X3wU= 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=qOOH63jRuEutl1O1ABm5dx4u8LzoiCj9aMsx0K0D7ok=; b=DjLCeWXElzqeC54BA+Wmfv08wMIXj+fAhJLXtJfpQAOxhFW6LEcodIZNt5fu2AE3o1 qS9vzSJ3d/tsOJyJmHiVpxCU7ntwOGU1fCfZtQ0BdHJBAJIDVWuxCpwd+pZKYdmIruoA wNFQTJDSncWjyD9wg7U1FzQs6HirgkgPlA6R7DQDh7VZuJvmHUTwaINce9bs9+0PEOBc +KwLu9yg/JPWcCIuL+IFadIQ/zcx+3IN+OTzneGnACwbSo5z5eXjRY0OiqWcy9TUwkEJ 3+9Hqz0zCq34c/CMAWl5m2ZnbLuOhNANwt8uyJisR+jkWUZoOqV+f0Tc9zIBgLOqHLMY 93yw== X-Received: by 10.15.65.8 with SMTP id p8mr17981296eex.110.1372711021349; Mon, 01 Jul 2013 13:37:01 -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 m1sm32126467eex.17.2013.07.01.13.36.59 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Jul 2013 13:37:00 -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: Mon, 1 Jul 2013 22:34:30 +0200 Message-Id: <1372710870-4329-1-git-send-email-daniel.vetter@ffwll.ch> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <20130701201329.GA8080@cantiga.alporthouse.com> References: <20130701201329.GA8080@cantiga.alporthouse.com> X-Gm-Message-State: ALoCoQlSWepNpTCXg4lIs/5+YvsgJUotnS+GjIF8Z6Nn4cY5rKqXt7e2/upACd8HHODLQ/fElLOA 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. Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=65953 Cc: Chris Wilson Signed-off-by: Daniel Vetter Tested-by: lu hua --- drivers/gpu/drm/i915/i915_gem_stolen.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index 8e02344..fbfc2c7 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);