diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2016-09-20 06:32:45 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2016-10-14 11:12:27 -0400 |
commit | 4d07572c8279f199c220e7c606cc9ffb73216d83 (patch) | |
tree | 78464a1176273b15de005b61ab758d97a111f1ec /drivers/gpu/nvgpu | |
parent | 6fb5481a6b64530474bb378f3a7b1e2b5516fc2c (diff) |
gpu: nvgpu: add space query in page and buddy allocs
Amount of free space in the buddy allocator is computed from the
complete capacity minus currently used bytes.
The page allocator just queries its underlying allocator.
Bug 1787771
Bug 200233138
Change-Id: I9b6f5ef90119236a13de14e14cd0a3ee72144a11
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/1223761
(cherry picked from commit 0b324a60ebdf67e793ade869c252a8ddd56c04f8)
Reviewed-on: http://git-master/r/1235979
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c | 14 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_allocator_page.c | 8 |
2 files changed, 22 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c index f9fb48b5..a8a031be 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c | |||
@@ -1090,6 +1090,19 @@ static u64 gk20a_buddy_alloc_end(struct gk20a_allocator *a) | |||
1090 | return ba->end; | 1090 | return ba->end; |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | static u64 gk20a_buddy_alloc_space(struct gk20a_allocator *a) | ||
1094 | { | ||
1095 | struct gk20a_buddy_allocator *ba = a->priv; | ||
1096 | u64 space; | ||
1097 | |||
1098 | alloc_lock(a); | ||
1099 | space = ba->end - ba->start - | ||
1100 | (ba->bytes_alloced_real - ba->bytes_freed); | ||
1101 | alloc_unlock(a); | ||
1102 | |||
1103 | return space; | ||
1104 | } | ||
1105 | |||
1093 | /* | 1106 | /* |
1094 | * Print the buddy allocator top level stats. If you pass @s as NULL then the | 1107 | * Print the buddy allocator top level stats. If you pass @s as NULL then the |
1095 | * stats are printed to the kernel log. This lets this code be used for | 1108 | * stats are printed to the kernel log. This lets this code be used for |
@@ -1180,6 +1193,7 @@ static const struct gk20a_allocator_ops buddy_ops = { | |||
1180 | .length = gk20a_buddy_alloc_length, | 1193 | .length = gk20a_buddy_alloc_length, |
1181 | .end = gk20a_buddy_alloc_end, | 1194 | .end = gk20a_buddy_alloc_end, |
1182 | .inited = gk20a_buddy_alloc_inited, | 1195 | .inited = gk20a_buddy_alloc_inited, |
1196 | .space = gk20a_buddy_alloc_space, | ||
1183 | 1197 | ||
1184 | .fini = gk20a_buddy_allocator_destroy, | 1198 | .fini = gk20a_buddy_allocator_destroy, |
1185 | 1199 | ||
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_page.c b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_page.c index 42eb9a14..2e5d46b9 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator_page.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator_page.c | |||
@@ -57,6 +57,13 @@ static u64 gk20a_page_alloc_end(struct gk20a_allocator *a) | |||
57 | return gk20a_alloc_end(&va->source_allocator); | 57 | return gk20a_alloc_end(&va->source_allocator); |
58 | } | 58 | } |
59 | 59 | ||
60 | static u64 gk20a_page_alloc_space(struct gk20a_allocator *a) | ||
61 | { | ||
62 | struct gk20a_page_allocator *va = a->priv; | ||
63 | |||
64 | return gk20a_alloc_space(&va->source_allocator); | ||
65 | } | ||
66 | |||
60 | static int gk20a_page_reserve_co(struct gk20a_allocator *a, | 67 | static int gk20a_page_reserve_co(struct gk20a_allocator *a, |
61 | struct gk20a_alloc_carveout *co) | 68 | struct gk20a_alloc_carveout *co) |
62 | { | 69 | { |
@@ -492,6 +499,7 @@ static const struct gk20a_allocator_ops page_ops = { | |||
492 | .length = gk20a_page_alloc_length, | 499 | .length = gk20a_page_alloc_length, |
493 | .end = gk20a_page_alloc_end, | 500 | .end = gk20a_page_alloc_end, |
494 | .inited = gk20a_page_alloc_inited, | 501 | .inited = gk20a_page_alloc_inited, |
502 | .space = gk20a_page_alloc_space, | ||
495 | 503 | ||
496 | .fini = gk20a_page_allocator_destroy, | 504 | .fini = gk20a_page_allocator_destroy, |
497 | 505 | ||