From: David Herrmann <dh.herrmann@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Dave Airlie <airlied@redhat.com>, Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 2/4] drm/ttm: replace drm_mm_pre_get() by direct alloc
Date: Thu, 25 Jul 2013 15:56:00 +0200 [thread overview]
Message-ID: <1374760562-6096-3-git-send-email-dh.herrmann@gmail.com> (raw)
In-Reply-To: <1374760562-6096-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.
Note that ttm_bo_man_get_node() does not run in atomic context. Nouveau already
uses GFP_KERNEL alloc in nouveau/nouveau_ttm.c in nouveau_gart_manager_new(). So
we can do the same in ttm_bo_man_get_node().
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.3
next prev parent reply other threads:[~2013-07-25 13:56 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-07-25 13:55 [PATCH 0/4] DRM: Remove MM "Pre-Alloc" David Herrmann
2013-07-25 13:55 ` [PATCH 1/4] drm/mm: add "best_match" to drm_mm_insert_node() David Herrmann
2013-07-25 14:15 ` Daniel Vetter
2013-07-27 11:36 ` [PATCH 1/4] drm/mm: add "best_match" flag " David Herrmann
2013-08-05 7:46 ` Daniel Vetter
2013-08-06 9:39 ` David Herrmann
2013-08-06 11:03 ` Daniel Vetter
2013-07-25 13:56 ` David Herrmann [this message]
2013-07-25 14:25 ` [PATCH 2/4] drm/ttm: replace drm_mm_pre_get() by direct alloc Daniel Vetter
2013-07-27 11:37 ` [PATCH v2 " David Herrmann
2013-07-25 13:56 ` [PATCH 3/4] drm/i915: pre-alloc instead of drm_mm search/get_block David Herrmann
2013-07-25 14:14 ` Chris Wilson
2013-07-27 11:38 ` [PATCH v2 " David Herrmann
2013-07-27 13:06 ` Chris Wilson
2013-07-27 13:09 ` David Herrmann
2013-07-27 13:15 ` Chris Wilson
2013-07-27 14:21 ` [PATCH v3 " David Herrmann
2013-08-05 7:49 ` Daniel Vetter
2013-07-25 13:56 ` [PATCH 4/4] drm/mm: remove unused API David Herrmann
2013-07-25 14:27 ` Daniel Vetter
2013-07-27 11:39 ` [PATCH v2 " David Herrmann
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=1374760562-6096-3-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 \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).