diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a_allocator.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/gk20a_allocator.c | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c index 56fb22df..badfcd9f 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a_allocator.c | |||
@@ -573,7 +573,8 @@ static struct gk20a_buddy *__balloc_find_buddy(struct gk20a_allocator *a, | |||
573 | { | 573 | { |
574 | struct gk20a_buddy *bud; | 574 | struct gk20a_buddy *bud; |
575 | 575 | ||
576 | if (list_empty(balloc_get_order_list(a, order))) | 576 | if (order > a->max_order || |
577 | list_empty(balloc_get_order_list(a, order))) | ||
577 | return NULL; | 578 | return NULL; |
578 | 579 | ||
579 | if (a->flags & GPU_BALLOC_GVA_SPACE && | 580 | if (a->flags & GPU_BALLOC_GVA_SPACE && |
@@ -609,6 +610,10 @@ static u64 __balloc_do_alloc(struct gk20a_allocator *a, u64 order, int pte_size) | |||
609 | while (!(bud = __balloc_find_buddy(a, split_order, pte_size))) | 610 | while (!(bud = __balloc_find_buddy(a, split_order, pte_size))) |
610 | split_order++; | 611 | split_order++; |
611 | 612 | ||
613 | /* Out of memory! */ | ||
614 | if (!bud) | ||
615 | return 0; | ||
616 | |||
612 | while (bud->order != order) { | 617 | while (bud->order != order) { |
613 | if (balloc_split_buddy(a, bud, pte_size)) | 618 | if (balloc_split_buddy(a, bud, pte_size)) |
614 | return 0; /* No mem... */ | 619 | return 0; /* No mem... */ |
@@ -658,15 +663,19 @@ u64 gk20a_balloc(struct gk20a_allocator *a, u64 len) | |||
658 | 663 | ||
659 | addr = __balloc_do_alloc(a, order, pte_size); | 664 | addr = __balloc_do_alloc(a, order, pte_size); |
660 | 665 | ||
661 | a->bytes_alloced += len; | 666 | if (addr) { |
662 | a->bytes_alloced_real += balloc_order_to_len(a, order); | 667 | a->bytes_alloced += len; |
668 | a->bytes_alloced_real += balloc_order_to_len(a, order); | ||
669 | balloc_dbg(a, "Alloc 0x%-10llx %3lld:0x%-10llx pte_size=%s\n", | ||
670 | addr, order, len, | ||
671 | pte_size == gmmu_page_size_big ? "big" : | ||
672 | pte_size == gmmu_page_size_small ? "small" : | ||
673 | "NA/any"); | ||
674 | } else { | ||
675 | balloc_dbg(a, "Alloc failed: no mem!\n"); | ||
676 | } | ||
663 | 677 | ||
664 | balloc_unlock(a); | 678 | balloc_unlock(a); |
665 | balloc_dbg(a, "Alloc 0x%-10llx %3lld:0x%-10llx pte_size=%s\n", | ||
666 | addr, order, len, | ||
667 | pte_size == gmmu_page_size_big ? "big" : | ||
668 | pte_size == gmmu_page_size_small ? "small" : | ||
669 | "NA/any"); | ||
670 | 679 | ||
671 | balloc_trace_func_done(); | 680 | balloc_trace_func_done(); |
672 | return addr; | 681 | return addr; |
@@ -1071,11 +1080,11 @@ static void balloc_print_stats(struct gk20a_allocator *a, struct seq_file *s, | |||
1071 | __balloc_pstat(s, "base = %llu, limit = %llu, blk_size = %llu\n", | 1080 | __balloc_pstat(s, "base = %llu, limit = %llu, blk_size = %llu\n", |
1072 | a->base, a->length, a->blk_size); | 1081 | a->base, a->length, a->blk_size); |
1073 | __balloc_pstat(s, "Internal params:\n"); | 1082 | __balloc_pstat(s, "Internal params:\n"); |
1074 | __balloc_pstat(s, " start = %llu\n", a->start); | 1083 | __balloc_pstat(s, " start = 0x%llx\n", a->start); |
1075 | __balloc_pstat(s, " end = %llu\n", a->end); | 1084 | __balloc_pstat(s, " end = 0x%llx\n", a->end); |
1076 | __balloc_pstat(s, " count = %llu\n", a->count); | 1085 | __balloc_pstat(s, " count = 0x%llx\n", a->count); |
1077 | __balloc_pstat(s, " blks = %llu\n", a->blks); | 1086 | __balloc_pstat(s, " blks = 0x%llx\n", a->blks); |
1078 | __balloc_pstat(s, " max_order = %llu\n", a->max_order); | 1087 | __balloc_pstat(s, " max_order = %llu\n", a->max_order); |
1079 | 1088 | ||
1080 | __balloc_pstat(s, "Buddy blocks:\n"); | 1089 | __balloc_pstat(s, "Buddy blocks:\n"); |
1081 | __balloc_pstat(s, " Order Free Alloced Split\n"); | 1090 | __balloc_pstat(s, " Order Free Alloced Split\n"); |