All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Herrmann <dh.herrmann@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	Martin Peres <martin.peres@labri.fr>,
	Dave Airlie <airlied@redhat.com>
Subject: [RFC v2 06/20] drm/ttm: replace drm_mm_pre_get() by direct alloc
Date: Sun,  7 Jul 2013 19:17:22 +0200	[thread overview]
Message-ID: <1373217456-32282-7-git-send-email-dh.herrmann@gmail.com> (raw)
In-Reply-To: <1373217456-32282-1-git-send-email-dh.herrmann@gmail.com>

Instead of calling drm_mm_pre_get() in a row, we now preallocate the node
and then use the atomic insertion functions. This has the exact same
semantics and there is no reason to use the racy pre-allocations.

Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
---
 drivers/gpu/drm/ttm/ttm_bo_manager.c | 40 +++++++++++++++++-------------------
 1 file changed, 19 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_manager.c b/drivers/gpu/drm/ttm/ttm_bo_manager.c
index e4367f9..cbd2ec7 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_manager.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_manager.c
@@ -61,28 +61,24 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
 	lpfn = placement->lpfn;
 	if (!lpfn)
 		lpfn = man->size;
-	do {
-		ret = drm_mm_pre_get(mm);
-		if (unlikely(ret))
-			return ret;
 
-		spin_lock(&rman->lock);
-		node = drm_mm_search_free_in_range(mm,
-					mem->num_pages, mem->page_alignment,
-					placement->fpfn, lpfn, 1);
-		if (unlikely(node == NULL)) {
-			spin_unlock(&rman->lock);
-			return 0;
-		}
-		node = drm_mm_get_block_atomic_range(node, mem->num_pages,
-						     mem->page_alignment,
-						     placement->fpfn,
-						     lpfn);
-		spin_unlock(&rman->lock);
-	} while (node == NULL);
+	node = kzalloc(sizeof(*node), GFP_KERNEL);
+	if (!node)
+		return -ENOMEM;
+
+	spin_lock(&rman->lock);
+	ret = drm_mm_insert_node_in_range(mm, node, mem->num_pages,
+					  mem->page_alignment,
+					  placement->fpfn, lpfn, true);
+	spin_unlock(&rman->lock);
+
+	if (unlikely(ret)) {
+		kfree(node);
+	} else {
+		mem->mm_node = node;
+		mem->start = node->start;
+	}
 
-	mem->mm_node = node;
-	mem->start = node->start;
 	return 0;
 }
 
@@ -93,8 +89,10 @@ static void ttm_bo_man_put_node(struct ttm_mem_type_manager *man,
 
 	if (mem->mm_node) {
 		spin_lock(&rman->lock);
-		drm_mm_put_block(mem->mm_node);
+		drm_mm_remove_node(mem->mm_node);
 		spin_unlock(&rman->lock);
+
+		kfree(mem->mm_node);
 		mem->mm_node = NULL;
 	}
 }
-- 
1.8.3.2

  parent reply	other threads:[~2013-07-07 17:17 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-07 17:17 [PATCH v2 00/20] Unified VMA Offset Manager v2 (+Render Node RFC) David Herrmann
2013-07-07 17:17 ` [PATCH v2 01/20] drm: add unified vma offset manager David Herrmann
2013-07-07 17:17 ` [PATCH v2 02/20] drm/gem: convert to new unified vma manager David Herrmann
2013-07-11 10:33   ` David Herrmann
2013-07-07 17:17 ` [PATCH v2 03/20] drm/ttm: convert to unified vma offset manager David Herrmann
2013-07-07 17:17 ` [PATCH v2 04/20] drm/vma: provide drm_vma_node_unmap() helper David Herrmann
2013-07-07 17:17 ` [RFC v2 05/20] drm/mm: add "best_match" to drm_mm_insert_node() David Herrmann
2013-07-07 17:17 ` David Herrmann [this message]
2013-07-07 17:17 ` [RFC v2 07/20] drm/i915: pre-alloc instead of drm_mm search/get_block David Herrmann
2013-07-07 17:17 ` [RFC v2 08/20] drm/mm: remove unused API David Herrmann
2013-07-07 17:17 ` [PATCH v2 09/20] drm/vma: add access management helpers David Herrmann
2013-07-07 17:17 ` [PATCH v2 10/20] drm/ast: implement mmap access managament David Herrmann
2013-07-07 17:17 ` [PATCH v2 11/20] drm/cirrus: " David Herrmann
2013-07-07 17:17 ` [PATCH v2 12/20] drm/mgag200: " David Herrmann
2013-07-07 17:17 ` [PATCH v2 13/20] drm/nouveau: " David Herrmann
2013-07-07 17:17 ` [PATCH v2 14/20] drm/radeon: " David Herrmann
2013-07-07 17:17 ` [PATCH v2 15/20] drm/qxl: " David Herrmann
2013-07-07 17:17 ` [PATCH v2 16/20] drm/vmwgfx: " David Herrmann
2013-07-07 17:17 ` [PATCH v2 17/20] drm/ttm: prevent mmap access to unauthorized users David Herrmann
2013-07-07 17:17 ` [PATCH v2 18/20] drm/gem: implement mmap access management David Herrmann
2013-07-07 17:17 ` [PATCH v2 19/20] drm: fix minor number range calculation David Herrmann
2013-07-07 17:17 ` [PATCH v2 20/20] drm: implement render nodes David Herrmann
2013-07-11 11:12 ` [PATCH v2 00/20] Unified VMA Offset Manager v2 (+Render Node RFC) Martin Peres
2013-07-11 11:21   ` David Herrmann
2013-07-11 11:55     ` Martin Peres

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1373217456-32282-7-git-send-email-dh.herrmann@gmail.com \
    --to=dh.herrmann@gmail.com \
    --cc=airlied@redhat.com \
    --cc=daniel.vetter@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=martin.peres@labri.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.