summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a_allocator_buddy.c14
1 files changed, 14 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
1093static 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