diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common/mm/buddy_allocator.c')
-rw-r--r-- | drivers/gpu/nvgpu/common/mm/buddy_allocator.c | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c index e5a9b62b..b986b29f 100644 --- a/drivers/gpu/nvgpu/common/mm/buddy_allocator.c +++ b/drivers/gpu/nvgpu/common/mm/buddy_allocator.c | |||
@@ -128,7 +128,7 @@ static void __balloc_buddy_list_add(struct nvgpu_buddy_allocator *a, | |||
128 | { | 128 | { |
129 | if (buddy_is_in_list(b)) { | 129 | if (buddy_is_in_list(b)) { |
130 | alloc_dbg(balloc_owner(a), | 130 | alloc_dbg(balloc_owner(a), |
131 | "Oops: adding added buddy (%llu:0x%llx)\n", | 131 | "Oops: adding added buddy (%llu:0x%llx)", |
132 | b->order, b->start); | 132 | b->order, b->start); |
133 | BUG(); | 133 | BUG(); |
134 | } | 134 | } |
@@ -152,7 +152,7 @@ static void __balloc_buddy_list_rem(struct nvgpu_buddy_allocator *a, | |||
152 | { | 152 | { |
153 | if (!buddy_is_in_list(b)) { | 153 | if (!buddy_is_in_list(b)) { |
154 | alloc_dbg(balloc_owner(a), | 154 | alloc_dbg(balloc_owner(a), |
155 | "Oops: removing removed buddy (%llu:0x%llx)\n", | 155 | "Oops: removing removed buddy (%llu:0x%llx)", |
156 | b->order, b->start); | 156 | b->order, b->start); |
157 | BUG(); | 157 | BUG(); |
158 | } | 158 | } |
@@ -304,19 +304,19 @@ static void nvgpu_buddy_allocator_destroy(struct nvgpu_allocator *__a) | |||
304 | 304 | ||
305 | if (a->buddy_list_len[i] != 0) { | 305 | if (a->buddy_list_len[i] != 0) { |
306 | nvgpu_info(__a->g, | 306 | nvgpu_info(__a->g, |
307 | "Excess buddies!!! (%d: %llu)\n", | 307 | "Excess buddies!!! (%d: %llu)", |
308 | i, a->buddy_list_len[i]); | 308 | i, a->buddy_list_len[i]); |
309 | BUG(); | 309 | BUG(); |
310 | } | 310 | } |
311 | if (a->buddy_list_split[i] != 0) { | 311 | if (a->buddy_list_split[i] != 0) { |
312 | nvgpu_info(__a->g, | 312 | nvgpu_info(__a->g, |
313 | "Excess split nodes!!! (%d: %llu)\n", | 313 | "Excess split nodes!!! (%d: %llu)", |
314 | i, a->buddy_list_split[i]); | 314 | i, a->buddy_list_split[i]); |
315 | BUG(); | 315 | BUG(); |
316 | } | 316 | } |
317 | if (a->buddy_list_alloced[i] != 0) { | 317 | if (a->buddy_list_alloced[i] != 0) { |
318 | nvgpu_info(__a->g, | 318 | nvgpu_info(__a->g, |
319 | "Excess alloced nodes!!! (%d: %llu)\n", | 319 | "Excess alloced nodes!!! (%d: %llu)", |
320 | i, a->buddy_list_alloced[i]); | 320 | i, a->buddy_list_alloced[i]); |
321 | BUG(); | 321 | BUG(); |
322 | } | 322 | } |
@@ -646,7 +646,7 @@ static struct nvgpu_buddy *__balloc_make_fixed_buddy( | |||
646 | /* Welp, that's the end of that. */ | 646 | /* Welp, that's the end of that. */ |
647 | alloc_dbg(balloc_owner(a), | 647 | alloc_dbg(balloc_owner(a), |
648 | "Fixed buddy PTE " | 648 | "Fixed buddy PTE " |
649 | "size mismatch!\n"); | 649 | "size mismatch!"); |
650 | return NULL; | 650 | return NULL; |
651 | } | 651 | } |
652 | 652 | ||
@@ -663,7 +663,7 @@ static struct nvgpu_buddy *__balloc_make_fixed_buddy( | |||
663 | } | 663 | } |
664 | 664 | ||
665 | if (cur_order > a->max_order) { | 665 | if (cur_order > a->max_order) { |
666 | alloc_dbg(balloc_owner(a), "No buddy for range ???\n"); | 666 | alloc_dbg(balloc_owner(a), "No buddy for range ???"); |
667 | return NULL; | 667 | return NULL; |
668 | } | 668 | } |
669 | 669 | ||
@@ -671,7 +671,7 @@ static struct nvgpu_buddy *__balloc_make_fixed_buddy( | |||
671 | while (bud->start != base || bud->order != order) { | 671 | while (bud->start != base || bud->order != order) { |
672 | if (balloc_split_buddy(a, bud, pte_size)) { | 672 | if (balloc_split_buddy(a, bud, pte_size)) { |
673 | alloc_dbg(balloc_owner(a), | 673 | alloc_dbg(balloc_owner(a), |
674 | "split buddy failed? {0x%llx, %llu}\n", | 674 | "split buddy failed? {0x%llx, %llu}", |
675 | bud->start, bud->order); | 675 | bud->start, bud->order); |
676 | balloc_coalesce(a, bud); | 676 | balloc_coalesce(a, bud); |
677 | return NULL; | 677 | return NULL; |
@@ -704,7 +704,7 @@ static u64 __balloc_do_alloc_fixed(struct nvgpu_buddy_allocator *a, | |||
704 | 704 | ||
705 | if (align_order > a->max_order) { | 705 | if (align_order > a->max_order) { |
706 | alloc_dbg(balloc_owner(a), | 706 | alloc_dbg(balloc_owner(a), |
707 | "Align order too big: %llu > %llu\n", | 707 | "Align order too big: %llu > %llu", |
708 | align_order, a->max_order); | 708 | align_order, a->max_order); |
709 | return 0; | 709 | return 0; |
710 | } | 710 | } |
@@ -723,7 +723,7 @@ static u64 __balloc_do_alloc_fixed(struct nvgpu_buddy_allocator *a, | |||
723 | align_order, pte_size); | 723 | align_order, pte_size); |
724 | if (!bud) { | 724 | if (!bud) { |
725 | alloc_dbg(balloc_owner(a), | 725 | alloc_dbg(balloc_owner(a), |
726 | "Fixed buddy failed: {0x%llx, %llu}!\n", | 726 | "Fixed buddy failed: {0x%llx, %llu}!", |
727 | balloc_base_unshift(a, inc_base), | 727 | balloc_base_unshift(a, inc_base), |
728 | align_order); | 728 | align_order); |
729 | goto err_and_cleanup; | 729 | goto err_and_cleanup; |
@@ -799,7 +799,7 @@ static u64 nvgpu_buddy_balloc(struct nvgpu_allocator *__a, u64 len) | |||
799 | 799 | ||
800 | if (order > a->max_order) { | 800 | if (order > a->max_order) { |
801 | alloc_unlock(__a); | 801 | alloc_unlock(__a); |
802 | alloc_dbg(balloc_owner(a), "Alloc fail\n"); | 802 | alloc_dbg(balloc_owner(a), "Alloc fail"); |
803 | return 0; | 803 | return 0; |
804 | } | 804 | } |
805 | 805 | ||
@@ -814,13 +814,13 @@ static u64 nvgpu_buddy_balloc(struct nvgpu_allocator *__a, u64 len) | |||
814 | a->bytes_alloced += len; | 814 | a->bytes_alloced += len; |
815 | a->bytes_alloced_real += balloc_order_to_len(a, order); | 815 | a->bytes_alloced_real += balloc_order_to_len(a, order); |
816 | alloc_dbg(balloc_owner(a), | 816 | alloc_dbg(balloc_owner(a), |
817 | "Alloc 0x%-10llx %3lld:0x%-10llx pte_size=%s\n", | 817 | "Alloc 0x%-10llx %3lld:0x%-10llx pte_size=%s", |
818 | addr, order, len, | 818 | addr, order, len, |
819 | pte_size == gmmu_page_size_big ? "big" : | 819 | pte_size == gmmu_page_size_big ? "big" : |
820 | pte_size == gmmu_page_size_small ? "small" : | 820 | pte_size == gmmu_page_size_small ? "small" : |
821 | "NA/any"); | 821 | "NA/any"); |
822 | } else { | 822 | } else { |
823 | alloc_dbg(balloc_owner(a), "Alloc failed: no mem!\n"); | 823 | alloc_dbg(balloc_owner(a), "Alloc failed: no mem!"); |
824 | } | 824 | } |
825 | 825 | ||
826 | a->alloc_made = 1; | 826 | a->alloc_made = 1; |
@@ -869,7 +869,7 @@ static u64 __nvgpu_balloc_fixed_buddy(struct nvgpu_allocator *__a, | |||
869 | 869 | ||
870 | if (!balloc_is_range_free(a, base, base + len)) { | 870 | if (!balloc_is_range_free(a, base, base + len)) { |
871 | alloc_dbg(balloc_owner(a), | 871 | alloc_dbg(balloc_owner(a), |
872 | "Range not free: 0x%llx -> 0x%llx\n", | 872 | "Range not free: 0x%llx -> 0x%llx", |
873 | base, base + len); | 873 | base, base + len); |
874 | goto fail_unlock; | 874 | goto fail_unlock; |
875 | } | 875 | } |
@@ -877,7 +877,7 @@ static u64 __nvgpu_balloc_fixed_buddy(struct nvgpu_allocator *__a, | |||
877 | ret = __balloc_do_alloc_fixed(a, falloc, base, len, pte_size); | 877 | ret = __balloc_do_alloc_fixed(a, falloc, base, len, pte_size); |
878 | if (!ret) { | 878 | if (!ret) { |
879 | alloc_dbg(balloc_owner(a), | 879 | alloc_dbg(balloc_owner(a), |
880 | "Alloc-fixed failed ?? 0x%llx -> 0x%llx\n", | 880 | "Alloc-fixed failed ?? 0x%llx -> 0x%llx", |
881 | base, base + len); | 881 | base, base + len); |
882 | goto fail_unlock; | 882 | goto fail_unlock; |
883 | } | 883 | } |
@@ -891,7 +891,7 @@ static u64 __nvgpu_balloc_fixed_buddy(struct nvgpu_allocator *__a, | |||
891 | a->bytes_alloced += len; | 891 | a->bytes_alloced += len; |
892 | a->bytes_alloced_real += real_bytes; | 892 | a->bytes_alloced_real += real_bytes; |
893 | 893 | ||
894 | alloc_dbg(balloc_owner(a), "Alloc (fixed) 0x%llx\n", base); | 894 | alloc_dbg(balloc_owner(a), "Alloc (fixed) 0x%llx", base); |
895 | 895 | ||
896 | return base; | 896 | return base; |
897 | 897 | ||
@@ -962,7 +962,7 @@ static void nvgpu_buddy_bfree(struct nvgpu_allocator *__a, u64 addr) | |||
962 | 962 | ||
963 | done: | 963 | done: |
964 | alloc_unlock(__a); | 964 | alloc_unlock(__a); |
965 | alloc_dbg(balloc_owner(a), "Free 0x%llx\n", addr); | 965 | alloc_dbg(balloc_owner(a), "Free 0x%llx", addr); |
966 | return; | 966 | return; |
967 | } | 967 | } |
968 | 968 | ||
@@ -1018,7 +1018,7 @@ static int nvgpu_buddy_reserve_co(struct nvgpu_allocator *__a, | |||
1018 | if (!addr) { | 1018 | if (!addr) { |
1019 | err = -ENOMEM; | 1019 | err = -ENOMEM; |
1020 | nvgpu_warn(__a->g, | 1020 | nvgpu_warn(__a->g, |
1021 | "%s: Failed to reserve a valid carveout!\n", | 1021 | "%s: Failed to reserve a valid carveout!", |
1022 | __func__); | 1022 | __func__); |
1023 | goto done; | 1023 | goto done; |
1024 | } | 1024 | } |
@@ -1102,32 +1102,32 @@ static void nvgpu_buddy_print_stats(struct nvgpu_allocator *__a, | |||
1102 | struct nvgpu_alloc_carveout *tmp; | 1102 | struct nvgpu_alloc_carveout *tmp; |
1103 | struct nvgpu_buddy_allocator *a = __a->priv; | 1103 | struct nvgpu_buddy_allocator *a = __a->priv; |
1104 | 1104 | ||
1105 | __alloc_pstat(s, __a, "base = %llu, limit = %llu, blk_size = %llu\n", | 1105 | __alloc_pstat(s, __a, "base = %llu, limit = %llu, blk_size = %llu", |
1106 | a->base, a->length, a->blk_size); | 1106 | a->base, a->length, a->blk_size); |
1107 | __alloc_pstat(s, __a, "Internal params:\n"); | 1107 | __alloc_pstat(s, __a, "Internal params:"); |
1108 | __alloc_pstat(s, __a, " start = 0x%llx\n", a->start); | 1108 | __alloc_pstat(s, __a, " start = 0x%llx", a->start); |
1109 | __alloc_pstat(s, __a, " end = 0x%llx\n", a->end); | 1109 | __alloc_pstat(s, __a, " end = 0x%llx", a->end); |
1110 | __alloc_pstat(s, __a, " count = 0x%llx\n", a->count); | 1110 | __alloc_pstat(s, __a, " count = 0x%llx", a->count); |
1111 | __alloc_pstat(s, __a, " blks = 0x%llx\n", a->blks); | 1111 | __alloc_pstat(s, __a, " blks = 0x%llx", a->blks); |
1112 | __alloc_pstat(s, __a, " max_order = %llu\n", a->max_order); | 1112 | __alloc_pstat(s, __a, " max_order = %llu", a->max_order); |
1113 | 1113 | ||
1114 | if (lock) | 1114 | if (lock) |
1115 | alloc_lock(__a); | 1115 | alloc_lock(__a); |
1116 | 1116 | ||
1117 | if (!nvgpu_list_empty(&a->co_list)) { | 1117 | if (!nvgpu_list_empty(&a->co_list)) { |
1118 | __alloc_pstat(s, __a, "\n"); | 1118 | __alloc_pstat(s, __a, ""); |
1119 | __alloc_pstat(s, __a, "Carveouts:\n"); | 1119 | __alloc_pstat(s, __a, "Carveouts:"); |
1120 | nvgpu_list_for_each_entry(tmp, &a->co_list, | 1120 | nvgpu_list_for_each_entry(tmp, &a->co_list, |
1121 | nvgpu_alloc_carveout, co_entry) | 1121 | nvgpu_alloc_carveout, co_entry) |
1122 | __alloc_pstat(s, __a, | 1122 | __alloc_pstat(s, __a, |
1123 | " CO %2d: %-20s 0x%010llx + 0x%llx\n", | 1123 | " CO %2d: %-20s 0x%010llx + 0x%llx", |
1124 | i++, tmp->name, tmp->base, tmp->length); | 1124 | i++, tmp->name, tmp->base, tmp->length); |
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | __alloc_pstat(s, __a, "\n"); | 1127 | __alloc_pstat(s, __a, ""); |
1128 | __alloc_pstat(s, __a, "Buddy blocks:\n"); | 1128 | __alloc_pstat(s, __a, "Buddy blocks:"); |
1129 | __alloc_pstat(s, __a, " Order Free Alloced Split\n"); | 1129 | __alloc_pstat(s, __a, " Order Free Alloced Split"); |
1130 | __alloc_pstat(s, __a, " ----- ---- ------- -----\n"); | 1130 | __alloc_pstat(s, __a, " ----- ---- ------- -----"); |
1131 | 1131 | ||
1132 | for (i = a->max_order; i >= 0; i--) { | 1132 | for (i = a->max_order; i >= 0; i--) { |
1133 | if (a->buddy_list_len[i] == 0 && | 1133 | if (a->buddy_list_len[i] == 0 && |
@@ -1135,31 +1135,31 @@ static void nvgpu_buddy_print_stats(struct nvgpu_allocator *__a, | |||
1135 | a->buddy_list_split[i] == 0) | 1135 | a->buddy_list_split[i] == 0) |
1136 | continue; | 1136 | continue; |
1137 | 1137 | ||
1138 | __alloc_pstat(s, __a, " %3d %-7llu %-9llu %llu\n", i, | 1138 | __alloc_pstat(s, __a, " %3d %-7llu %-9llu %llu", i, |
1139 | a->buddy_list_len[i], | 1139 | a->buddy_list_len[i], |
1140 | a->buddy_list_alloced[i], | 1140 | a->buddy_list_alloced[i], |
1141 | a->buddy_list_split[i]); | 1141 | a->buddy_list_split[i]); |
1142 | } | 1142 | } |
1143 | 1143 | ||
1144 | __alloc_pstat(s, __a, "\n"); | 1144 | __alloc_pstat(s, __a, ""); |
1145 | 1145 | ||
1146 | nvgpu_rbtree_enum_start(0, &node, a->fixed_allocs); | 1146 | nvgpu_rbtree_enum_start(0, &node, a->fixed_allocs); |
1147 | i = 1; | 1147 | i = 1; |
1148 | while (node) { | 1148 | while (node) { |
1149 | falloc = nvgpu_fixed_alloc_from_rbtree_node(node); | 1149 | falloc = nvgpu_fixed_alloc_from_rbtree_node(node); |
1150 | 1150 | ||
1151 | __alloc_pstat(s, __a, "Fixed alloc (%d): [0x%llx -> 0x%llx]\n", | 1151 | __alloc_pstat(s, __a, "Fixed alloc (%d): [0x%llx -> 0x%llx]", |
1152 | i, falloc->start, falloc->end); | 1152 | i, falloc->start, falloc->end); |
1153 | 1153 | ||
1154 | nvgpu_rbtree_enum_next(&node, a->fixed_allocs); | 1154 | nvgpu_rbtree_enum_next(&node, a->fixed_allocs); |
1155 | } | 1155 | } |
1156 | 1156 | ||
1157 | __alloc_pstat(s, __a, "\n"); | 1157 | __alloc_pstat(s, __a, ""); |
1158 | __alloc_pstat(s, __a, "Bytes allocated: %llu\n", | 1158 | __alloc_pstat(s, __a, "Bytes allocated: %llu", |
1159 | a->bytes_alloced); | 1159 | a->bytes_alloced); |
1160 | __alloc_pstat(s, __a, "Bytes allocated (real): %llu\n", | 1160 | __alloc_pstat(s, __a, "Bytes allocated (real): %llu", |
1161 | a->bytes_alloced_real); | 1161 | a->bytes_alloced_real); |
1162 | __alloc_pstat(s, __a, "Bytes freed: %llu\n", | 1162 | __alloc_pstat(s, __a, "Bytes freed: %llu", |
1163 | a->bytes_freed); | 1163 | a->bytes_freed); |
1164 | 1164 | ||
1165 | if (lock) | 1165 | if (lock) |
@@ -1294,16 +1294,16 @@ int __nvgpu_buddy_allocator_init(struct gk20a *g, struct nvgpu_allocator *__a, | |||
1294 | #ifdef CONFIG_DEBUG_FS | 1294 | #ifdef CONFIG_DEBUG_FS |
1295 | nvgpu_init_alloc_debug(g, __a); | 1295 | nvgpu_init_alloc_debug(g, __a); |
1296 | #endif | 1296 | #endif |
1297 | alloc_dbg(__a, "New allocator: type buddy\n"); | 1297 | alloc_dbg(__a, "New allocator: type buddy"); |
1298 | alloc_dbg(__a, " base 0x%llx\n", a->base); | 1298 | alloc_dbg(__a, " base 0x%llx", a->base); |
1299 | alloc_dbg(__a, " size 0x%llx\n", a->length); | 1299 | alloc_dbg(__a, " size 0x%llx", a->length); |
1300 | alloc_dbg(__a, " blk_size 0x%llx\n", a->blk_size); | 1300 | alloc_dbg(__a, " blk_size 0x%llx", a->blk_size); |
1301 | if (flags & GPU_ALLOC_GVA_SPACE) | 1301 | if (flags & GPU_ALLOC_GVA_SPACE) |
1302 | alloc_dbg(balloc_owner(a), | 1302 | alloc_dbg(balloc_owner(a), |
1303 | " pde_size 0x%llx\n", | 1303 | " pde_size 0x%llx", |
1304 | balloc_order_to_len(a, a->pte_blk_order)); | 1304 | balloc_order_to_len(a, a->pte_blk_order)); |
1305 | alloc_dbg(__a, " max_order %llu\n", a->max_order); | 1305 | alloc_dbg(__a, " max_order %llu", a->max_order); |
1306 | alloc_dbg(__a, " flags 0x%llx\n", a->flags); | 1306 | alloc_dbg(__a, " flags 0x%llx", a->flags); |
1307 | 1307 | ||
1308 | return 0; | 1308 | return 0; |
1309 | 1309 | ||