From patchwork Wed Jul 1 20:15:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paulo Zanoni X-Patchwork-Id: 6706381 Return-Path: X-Original-To: patchwork-intel-gfx@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8D7C19F38C for ; Wed, 1 Jul 2015 20:16:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 857EB20796 for ; Wed, 1 Jul 2015 20:16:10 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 6CDD920793 for ; Wed, 1 Jul 2015 20:16:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D7FB56E1F5; Wed, 1 Jul 2015 13:16:08 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qk0-f179.google.com (mail-qk0-f179.google.com [209.85.220.179]) by gabe.freedesktop.org (Postfix) with ESMTPS id 392306E1E5 for ; Wed, 1 Jul 2015 13:16:05 -0700 (PDT) Received: by qkei195 with SMTP id i195so37998179qke.3 for ; Wed, 01 Jul 2015 13:16:04 -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:in-reply-to:references; bh=sWXWycKtRL17oUSVq6OmHLl/lL3GRM/yBmitVR0PkEg=; b=gSaM7i4lekPt2B1/kxL4wR9P/QtzmZ40sXCPx5i7DH9J//lnqUM7k98vZ2PEFZEgae d8O1vckPRlN0pFrDMLaA199bsYCE7I3GFM9hoS06MnaDBbgGrEpWTNQ6OE8lZoz/b94V js12UrmnOvfvwesSC9GDngXKBNRBoOn9SnGgARRHsBfVRrCSNlYNLSqCGvPT9k/1yeaA xB1lpJua5mmrvD/+5PfBOWhmJzGINqcFJQX1bu37oeOQrcI57hDoZ6ECtrQ2EY1hw2ph jLUFmMMC0zZKI31OA2R5GFvuavCCm0o2saHWF7uI1gg1SF3olqyJ4LDluFdPzi44cpr4 0Mng== X-Received: by 10.140.152.201 with SMTP id 192mr39136812qhy.26.1435781764371; Wed, 01 Jul 2015 13:16:04 -0700 (PDT) Received: from localhost.localdomain (r130-pw-tresbarras.ibys.com.br. [189.76.1.243]) by mx.google.com with ESMTPSA id h3sm1589670qgh.22.2015.07.01.13.16.03 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Jul 2015 13:16:03 -0700 (PDT) From: Paulo Zanoni To: intel-gfx@lists.freedesktop.org Date: Wed, 1 Jul 2015 17:15:20 -0300 Message-Id: <1435781726-7282-2-git-send-email-przanoni@gmail.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1435781726-7282-1-git-send-email-przanoni@gmail.com> References: <1435781726-7282-1-git-send-email-przanoni@gmail.com> Cc: Paulo Zanoni Subject: [Intel-gfx] [PATCH 1/7] drm/i915: add simple wrappers for stolen node insertion/removal X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Spam-Status: No, score=-4.7 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 From: Paulo Zanoni We want to move the FBC code out of i915_gem_stolen.c, but that code directly adds/removes stolen memory nodes. Let's create this abstraction, so i915_gme_stolen.c is still in control of all the stolen memory handling. These abstractions will also allow us to add locking assertions later. Requested-by: Chris Wilson Signed-off-by: Paulo Zanoni --- drivers/gpu/drm/i915/i915_drv.h | 4 ++++ drivers/gpu/drm/i915/i915_gem_stolen.c | 44 +++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h index 1dbd957..b9de374 100644 --- a/drivers/gpu/drm/i915/i915_drv.h +++ b/drivers/gpu/drm/i915/i915_drv.h @@ -3109,6 +3109,10 @@ static inline void i915_gem_chipset_flush(struct drm_device *dev) } /* i915_gem_stolen.c */ +int i915_gem_stolen_insert_node(struct drm_i915_private *dev_priv, + struct drm_mm_node *node, u64 size, + unsigned alignment); +void i915_gem_stolen_remove_node(struct drm_mm_node *node); int i915_gem_init_stolen(struct drm_device *dev); int i915_gem_stolen_setup_compression(struct drm_device *dev, int size, int fb_cpp); void i915_gem_stolen_cleanup_compression(struct drm_device *dev); diff --git a/drivers/gpu/drm/i915/i915_gem_stolen.c b/drivers/gpu/drm/i915/i915_gem_stolen.c index 348ed5a..6b43234 100644 --- a/drivers/gpu/drm/i915/i915_gem_stolen.c +++ b/drivers/gpu/drm/i915/i915_gem_stolen.c @@ -42,6 +42,22 @@ * for is a boon. */ +int i915_gem_stolen_insert_node(struct drm_i915_private *dev_priv, + struct drm_mm_node *node, u64 size, + unsigned alignment) +{ + if (!drm_mm_initialized(&dev_priv->mm.stolen)) + return -ENODEV; + + return drm_mm_insert_node(&dev_priv->mm.stolen, node, size, alignment, + DRM_MM_SEARCH_DEFAULT); +} + +void i915_gem_stolen_remove_node(struct drm_mm_node *node) +{ + drm_mm_remove_node(node); +} + static unsigned long i915_stolen_to_physical(struct drm_device *dev) { struct drm_i915_private *dev_priv = dev->dev_private; @@ -168,8 +184,7 @@ static int find_compression_threshold(struct drm_device *dev, */ /* Try to over-allocate to reduce reallocations and fragmentation. */ - ret = drm_mm_insert_node(&dev_priv->mm.stolen, node, - size <<= 1, 4096, DRM_MM_SEARCH_DEFAULT); + ret = i915_gem_stolen_insert_node(dev_priv, node, size <<= 1, 4096); if (ret == 0) return compression_threshold; @@ -179,9 +194,7 @@ again: (fb_cpp == 2 && compression_threshold == 2)) return 0; - ret = drm_mm_insert_node(&dev_priv->mm.stolen, node, - size >>= 1, 4096, - DRM_MM_SEARCH_DEFAULT); + ret = i915_gem_stolen_insert_node(dev_priv, node, size >>= 1, 4096); if (ret && INTEL_INFO(dev)->gen <= 4) { return 0; } else if (ret) { @@ -218,8 +231,8 @@ static int i915_setup_compression(struct drm_device *dev, int size, int fb_cpp) if (!compressed_llb) goto err_fb; - ret = drm_mm_insert_node(&dev_priv->mm.stolen, compressed_llb, - 4096, 4096, DRM_MM_SEARCH_DEFAULT); + ret = i915_gem_stolen_insert_node(dev_priv, compressed_llb, + 4096, 4096); if (ret) goto err_fb; @@ -240,7 +253,7 @@ static int i915_setup_compression(struct drm_device *dev, int size, int fb_cpp) err_fb: kfree(compressed_llb); - drm_mm_remove_node(&dev_priv->fbc.compressed_fb); + i915_gem_stolen_remove_node(&dev_priv->fbc.compressed_fb); err_llb: pr_info_once("drm: not enough stolen space for compressed buffer (need %d more bytes), disabling. Hint: you may be able to increase stolen memory size in the BIOS to avoid this.\n", size); return -ENOSPC; @@ -269,10 +282,10 @@ void i915_gem_stolen_cleanup_compression(struct drm_device *dev) if (dev_priv->fbc.uncompressed_size == 0) return; - drm_mm_remove_node(&dev_priv->fbc.compressed_fb); + i915_gem_stolen_remove_node(&dev_priv->fbc.compressed_fb); if (dev_priv->fbc.compressed_llb) { - drm_mm_remove_node(dev_priv->fbc.compressed_llb); + i915_gem_stolen_remove_node(dev_priv->fbc.compressed_llb); kfree(dev_priv->fbc.compressed_llb); } @@ -387,7 +400,7 @@ static void i915_gem_object_release_stolen(struct drm_i915_gem_object *obj) { if (obj->stolen) { - drm_mm_remove_node(obj->stolen); + i915_gem_stolen_remove_node(obj->stolen); kfree(obj->stolen); obj->stolen = NULL; } @@ -449,8 +462,7 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size) if (!stolen) return NULL; - ret = drm_mm_insert_node(&dev_priv->mm.stolen, stolen, size, - 4096, DRM_MM_SEARCH_DEFAULT); + ret = i915_gem_stolen_insert_node(dev_priv, stolen, size, 4096); if (ret) { kfree(stolen); return NULL; @@ -460,7 +472,7 @@ i915_gem_object_create_stolen(struct drm_device *dev, u32 size) if (obj) return obj; - drm_mm_remove_node(stolen); + i915_gem_stolen_remove_node(stolen); kfree(stolen); return NULL; } @@ -505,7 +517,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, obj = _i915_gem_object_create_stolen(dev, stolen); if (obj == NULL) { DRM_DEBUG_KMS("failed to allocate stolen object\n"); - drm_mm_remove_node(stolen); + i915_gem_stolen_remove_node(stolen); kfree(stolen); return NULL; } @@ -546,7 +558,7 @@ i915_gem_object_create_stolen_for_preallocated(struct drm_device *dev, err_vma: i915_gem_vma_destroy(vma); err_out: - drm_mm_remove_node(stolen); + i915_gem_stolen_remove_node(stolen); kfree(stolen); drm_gem_object_unreference(&obj->base); return NULL;