From: "Christian König" <deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH 1/6] drm/ttm: cleanup and optimize ttm_bo_mem_compat v2
Date: Fri, 31 Mar 2017 11:47:27 +0200 [thread overview]
Message-ID: <1490953652-3703-1-git-send-email-deathsimple@vodafone.de> (raw)
From: Christian König <christian.koenig@amd.com>
No need to implement the same logic twice. Also check if the busy placements
are identical to the already scanned placements before checking them.
v2: improve check even more as suggested by Michel.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/ttm/ttm_bo.c | 45 ++++++++++++++++++++++++--------------------
1 file changed, 25 insertions(+), 20 deletions(-)
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 989b98b..348b17e 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1046,29 +1046,17 @@ static int ttm_bo_move_buffer(struct ttm_buffer_object *bo,
return ret;
}
-bool ttm_bo_mem_compat(struct ttm_placement *placement,
- struct ttm_mem_reg *mem,
- uint32_t *new_flags)
+static bool ttm_bo_places_compat(const struct ttm_place *places,
+ unsigned num_placement,
+ struct ttm_mem_reg *mem,
+ uint32_t *new_flags)
{
- int i;
+ unsigned i;
- for (i = 0; i < placement->num_placement; i++) {
- const struct ttm_place *heap = &placement->placement[i];
- if (mem->mm_node &&
- (mem->start < heap->fpfn ||
- (heap->lpfn != 0 && (mem->start + mem->num_pages) > heap->lpfn)))
- continue;
+ for (i = 0; i < num_placement; i++) {
+ const struct ttm_place *heap = &places[i];
- *new_flags = heap->flags;
- if ((*new_flags & mem->placement & TTM_PL_MASK_CACHING) &&
- (*new_flags & mem->placement & TTM_PL_MASK_MEM))
- return true;
- }
-
- for (i = 0; i < placement->num_busy_placement; i++) {
- const struct ttm_place *heap = &placement->busy_placement[i];
- if (mem->mm_node &&
- (mem->start < heap->fpfn ||
+ if (mem->mm_node && (mem->start < heap->fpfn ||
(heap->lpfn != 0 && (mem->start + mem->num_pages) > heap->lpfn)))
continue;
@@ -1077,6 +1065,23 @@ bool ttm_bo_mem_compat(struct ttm_placement *placement,
(*new_flags & mem->placement & TTM_PL_MASK_MEM))
return true;
}
+ return false;
+}
+
+bool ttm_bo_mem_compat(struct ttm_placement *placement,
+ struct ttm_mem_reg *mem,
+ uint32_t *new_flags)
+{
+ if (ttm_bo_places_compat(placement->placement, placement->num_placement,
+ mem, new_flags))
+ return true;
+
+ if ((placement->busy_placement != placement->placement ||
+ placement->num_busy_placement > placement->num_placement) &&
+ ttm_bo_places_compat(placement->busy_placement,
+ placement->num_busy_placement,
+ mem, new_flags))
+ return true;
return false;
}
--
2.5.0
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next reply other threads:[~2017-03-31 9:47 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-31 9:47 Christian König [this message]
2017-03-31 9:47 ` [PATCH 2/6] drm/ttm: add io_mem_pfn callback Christian König
[not found] ` <1490953652-3703-1-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-03-31 9:47 ` [PATCH 3/6] drm/ttm: add TTM_PL_FLAG_CONTIGUOUS v2 Christian König
2017-04-03 16:27 ` Nicolai Hähnle
2017-03-31 9:47 ` [PATCH 5/6] drm/amdgpu: use TTM_PL_FLAG_CONTIGUOUS Christian König
[not found] ` <1490953652-3703-5-git-send-email-deathsimple-ANTagKRnAhcb1SvskN2V4Q@public.gmane.org>
2017-04-03 16:22 ` Nicolai Hähnle
[not found] ` <425dfa9e-c86b-6958-f7ff-31b91a0f9e21-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2017-04-04 11:33 ` Christian König
2017-04-04 14:24 ` Nicolai Hähnle
2017-03-31 9:47 ` [PATCH 6/6] drm/amdgpu: handle CPU access for split VRAM buffers Christian König
2017-04-03 16:25 ` Nicolai Hähnle
2017-04-04 11:30 ` Christian König
2017-04-03 12:37 ` [PATCH 1/6] drm/ttm: cleanup and optimize ttm_bo_mem_compat v2 Christian König
2017-03-31 9:47 ` [PATCH 4/6] drm/amdgpu: drop alpha support Christian König
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=1490953652-3703-1-git-send-email-deathsimple@vodafone.de \
--to=deathsimple-antagkrnahcb1svskn2v4q@public.gmane.org \
--cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
--cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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