diff --git a/drivers/gpu/nvgpu/libnvgpu-drv.export b/drivers/gpu/nvgpu/libnvgpu-drv.export index 41e9a5ab1..3cc689d2e 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv.export @@ -70,12 +70,11 @@ nvgpu_alloc_pte nvgpu_alloc_release_carveout nvgpu_alloc_reserve_carveout nvgpu_alloc_space +nvgpu_allocator_init nvgpu_aperture_mask nvgpu_bar1_readl nvgpu_bar1_writel -nvgpu_bitmap_allocator_init nvgpu_bsearch -nvgpu_buddy_allocator_init nvgpu_dma_alloc nvgpu_dma_alloc_get_fault_injection nvgpu_dma_alloc_vid_at diff --git a/userspace/units/mm/allocators/bitmap_allocator/bitmap_allocator.c b/userspace/units/mm/allocators/bitmap_allocator/bitmap_allocator.c index 3ee1c1128..bc82f2bae 100644 --- a/userspace/units/mm/allocators/bitmap_allocator/bitmap_allocator.c +++ b/userspace/units/mm/allocators/bitmap_allocator/bitmap_allocator.c @@ -63,8 +63,8 @@ static int test_nvgpu_bitmap_allocator_critical(struct unit_module *m, * Initialize bitmap allocator * This ba will be used in this test. */ - if (nvgpu_bitmap_allocator_init(g, na, "test_bitmap", base, - length, blk_size, flags) != 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", base, length, + blk_size, 0ULL, flags, BITMAP_ALLOCATOR) != 0) { nvgpu_kfree(g, na); unit_return_fail(m, "bitmap_allocator init failed\n"); } @@ -303,8 +303,8 @@ static int test_nvgpu_bitmap_allocator_init(struct unit_module *m, } /* base = 0, length = 0, blk_size = 0 */ - if (nvgpu_bitmap_allocator_init(g, na, "test_bitmap", 0ULL, - 0ULL, 0ULL, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", 0ULL, 0ULL, 0ULL, + 0ULL, flags, BITMAP_ALLOCATOR) == 0) { na->ops->fini(na); unit_return_fail(m, "bitmap inited despite blk_size = base = length = 0\n"); @@ -314,32 +314,32 @@ static int test_nvgpu_bitmap_allocator_init(struct unit_module *m, * blk_size = 0 * Since base and length are not aligned with 0, init fails */ - if (nvgpu_bitmap_allocator_init(g, na, "test_bitmap", base, - length, 0ULL, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", base, length, + 0ULL, 0ULL, flags, BITMAP_ALLOCATOR) == 0) { unit_return_fail(m, "bitmap init failed for blk_size=0\n"); } /* Odd blk_size */ - if (!EXPECT_BUG(nvgpu_bitmap_allocator_init(g, na, "test_bitmap", base, - length, 3ULL, flags))) { + if (!EXPECT_BUG(nvgpu_allocator_init(g, na, NULL, "test_bitmap", base, + length, 3ULL, 0ULL, flags, BITMAP_ALLOCATOR))) { unit_return_fail(m, "bitmap inited despite odd blk_size\n"); } /* length unaligned */ - if (nvgpu_bitmap_allocator_init(g, na, "test_bitmap", base, - 0x0010, blk_size, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", base, 0x0010, + blk_size, 0ULL, flags, BITMAP_ALLOCATOR) == 0) { unit_return_fail(m, "bitmap init despite unaligned length\n"); } /* base unaligned */ - if (nvgpu_bitmap_allocator_init(g, na, "test_bitmap", 0x0100, - length, blk_size, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", 0x0100, length, + blk_size, 0ULL, flags, BITMAP_ALLOCATOR) == 0) { unit_return_fail(m, "bitmap init despite unaligned base\n"); } /* base = 0 */ - if (nvgpu_bitmap_allocator_init(g, na, "test_bitmap", 0ULL, - length, blk_size, flags) != 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", 0ULL, length, + blk_size, 0ULL, flags, BITMAP_ALLOCATOR) != 0) { unit_return_fail(m, "bitmap init failed with base = 0\n"); } else { ba = na->priv; @@ -353,15 +353,15 @@ static int test_nvgpu_bitmap_allocator_init(struct unit_module *m, } /* length = 0 */ - if (nvgpu_bitmap_allocator_init(g, na, "test_bitmap", 0ULL, - 0ULL, blk_size, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", 0ULL, 0ULL, + blk_size, 0ULL, flags, BITMAP_ALLOCATOR) == 0) { unit_return_fail(m, "bitmap inited with length = 0\n"); } /* Fault injection at nvgpu_bitmap_allocator alloc */ nvgpu_posix_enable_fault_injection(kmem_fi, true, 0); - if (nvgpu_bitmap_allocator_init(g, na, "test_bitmap", base, - length, blk_size, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", base, length, + blk_size, 0ULL, flags, BITMAP_ALLOCATOR) == 0) { unit_return_fail(m, "bitmap inited despite " "fault injection at nvgpu_bitmap_allocator alloc\n"); } @@ -369,8 +369,8 @@ static int test_nvgpu_bitmap_allocator_init(struct unit_module *m, /* Fault injection at meta_data_cache create */ nvgpu_posix_enable_fault_injection(kmem_fi, true, 1); - if (nvgpu_bitmap_allocator_init(g, na, "test_bitmap", base, - length, blk_size, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", base, length, + blk_size, 0ULL, flags, BITMAP_ALLOCATOR) == 0) { unit_return_fail(m, "bitmap inited despite " "fault injection at meta_data_cache\n"); } @@ -378,8 +378,8 @@ static int test_nvgpu_bitmap_allocator_init(struct unit_module *m, /* Fault injection at bitmap create */ nvgpu_posix_enable_fault_injection(kmem_fi, true, 2); - if (nvgpu_bitmap_allocator_init(g, na, "test_bitmap", base, - length, blk_size, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", base, length, + blk_size, 0ULL, flags, BITMAP_ALLOCATOR) == 0) { unit_return_fail(m, "bitmap inited despite " "fault injection at bitmap create\n"); } @@ -389,8 +389,8 @@ static int test_nvgpu_bitmap_allocator_init(struct unit_module *m, * Initialize bitmap allocator * This ba will be used for further tests. */ - if (nvgpu_bitmap_allocator_init(g, na, "test_bitmap", base, - length, blk_size, flags) != 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", base, length, + blk_size, 0ULL, flags, BITMAP_ALLOCATOR) != 0) { unit_return_fail(m, "bitmap_allocator init failed\n"); } diff --git a/userspace/units/mm/allocators/buddy_allocator/buddy_allocator.c b/userspace/units/mm/allocators/buddy_allocator/buddy_allocator.c index 62b5be1d8..b438169f0 100644 --- a/userspace/units/mm/allocators/buddy_allocator/buddy_allocator.c +++ b/userspace/units/mm/allocators/buddy_allocator/buddy_allocator.c @@ -138,8 +138,8 @@ static int test_buddy_allocator_with_big_pages(struct unit_module *m, * Initialize buddy allocator, base not pde aligned * Expect to fail */ - if (nvgpu_buddy_allocator_init(g, na, vm_big_pages, "test", SZ_1K, - size, blk_size, max_order, flags) == 0) { + if (nvgpu_allocator_init(g, na, vm_big_pages, "test", SZ_1K, size, + blk_size, max_order, flags, BUDDY_ALLOCATOR) == 0) { free_vm_env(m, g, vm_big_pages); unit_return_fail(m, "ba inited with unaligned pde\n"); } @@ -148,16 +148,16 @@ static int test_buddy_allocator_with_big_pages(struct unit_module *m, * Initialize buddy allocator, base = 0 and blk_size not pde aligned * Expect to fail */ - if (nvgpu_buddy_allocator_init(g, na, vm_big_pages, "test", 0ULL, - size, blk_size, max_order, flags) == 0) { + if (nvgpu_allocator_init(g, na, vm_big_pages, "test", 0ULL, size, + blk_size, max_order, flags, BUDDY_ALLOCATOR) == 0) { free_vm_env(m, g, vm_big_pages); unit_return_fail(m, "ba_big_pages inited " "despite base=0, blk_size not pde aligned\n"); } /* Initialize buddy allocator with big pages for this test */ - if (nvgpu_buddy_allocator_init(g, na, vm_big_pages, "test", base, - size, blk_size, max_order, flags) != 0) { + if (nvgpu_allocator_init(g, na, vm_big_pages, "test", base, size, + blk_size, max_order, flags, BUDDY_ALLOCATOR) != 0) { free_vm_env(m, g, vm_big_pages); unit_return_fail(m, "ba_big_pages init failed\n"); } @@ -286,8 +286,8 @@ static int test_buddy_allocator_with_small_pages(struct unit_module *m, /* Initialize buddy allocator with big page disabled for this test */ - if (nvgpu_buddy_allocator_init(g, na, vm_small_pages, "test", base, - size, blk_size, max_order, flags) != 0) { + if (nvgpu_allocator_init(g, na, vm_small_pages, "test", base, size, + blk_size, max_order, flags, BUDDY_ALLOCATOR) != 0) { free_vm_env(m, g, vm_small_pages); unit_return_fail(m, "ba small pages init failed\n"); } @@ -438,8 +438,8 @@ static int test_nvgpu_buddy_allocator_alloc(struct unit_module *m, } /* Initialize buddy allocator for this test */ - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_alloc", base, - size, blk_size, max_order, flags) != 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_alloc", base, size, + blk_size, max_order, flags, BUDDY_ALLOCATOR) != 0) { nvgpu_kfree(g, na); unit_return_fail(m, "ba init for alloc failed\n"); } @@ -834,27 +834,27 @@ static int test_nvgpu_buddy_allocator_init(struct unit_module *m, } /* blk_size = 0 */ - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_ba", base, - size, 0ULL, max_order, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_ba", base, size, 0ULL, + max_order, flags, BUDDY_ALLOCATOR) == 0) { unit_return_fail(m, "ba inited despite blk_size=0\n"); } /* Odd blk_size */ - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_ba", base, - size, 3ULL, max_order, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_ba", base, size, 3ULL, + max_order, flags, BUDDY_ALLOCATOR) == 0) { unit_return_fail(m, "ba inited despite odd blk_size value\n"); } /* max_order > (u64)GPU_BALLOC_MAX_ORDER */ - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_ba", base, - size, blk_size, (u64)GPU_BALLOC_MAX_ORDER + 1, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_ba", base, size, blk_size, + (u64)GPU_BALLOC_MAX_ORDER + 1, flags, BUDDY_ALLOCATOR) == 0) { unit_return_fail(m, "ba inited despite max_order > GPU_BALLOC_MAX_ORDER\n"); } /* size = 0 */ - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_ba", base, - 0ULL, blk_size, max_order, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_ba", base, 0ULL, blk_size, + max_order, flags, BUDDY_ALLOCATOR) == 0) { /* If buddy allocator was created, check length */ ba = buddy_allocator(na); if (ba->length == 0ULL) { @@ -865,8 +865,8 @@ static int test_nvgpu_buddy_allocator_init(struct unit_module *m, } /* base = 0 */ - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_ba", 0ULL, - size, blk_size, max_order, flags) != 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_ba", 0ULL, size, blk_size, + max_order, flags, BUDDY_ALLOCATOR) != 0) { unit_return_fail(m, "ba init with base=0 failed\n"); } else { /* If buddy allocator was created, check base */ @@ -883,24 +883,24 @@ static int test_nvgpu_buddy_allocator_init(struct unit_module *m, * base = 0x0101 (unaligned), GVA_space is disabled * adds base as offset */ - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_ba", 0x0101, - size, blk_size, max_order, flags) != 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_ba", 0x0101, size, + blk_size, max_order, flags, BUDDY_ALLOCATOR) != 0) { unit_return_fail(m, "ba init with unaligned base failed\n"); } else { na->ops->fini(na); } /* ba init - GVA_space enabled, no vm */ - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_ba", base, - size, blk_size, max_order, GPU_ALLOC_GVA_SPACE) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_ba", base, size, blk_size, + max_order, GPU_ALLOC_GVA_SPACE, BUDDY_ALLOCATOR) == 0) { unit_return_fail(m, "ba inited " "with GPU_ALLOC_GVA_SPACE & vm=NULL\n"); } /* Fault injection at nvgpu_buddy_allocator alloc */ nvgpu_posix_enable_fault_injection(kmem_fi, true, 0); - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_ba", base, - size, blk_size, max_order, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_ba", base, size, blk_size, + max_order, flags, BUDDY_ALLOCATOR) == 0) { unit_return_fail(m, "ba inited despite fault injection\n"); } @@ -908,8 +908,8 @@ static int test_nvgpu_buddy_allocator_init(struct unit_module *m, /* Fault injection at buddy_cache create */ nvgpu_posix_enable_fault_injection(kmem_fi, true, 1); - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_ba", base, - size, blk_size, max_order, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_ba", base, size, blk_size, + max_order, flags, BUDDY_ALLOCATOR) == 0) { unit_return_fail(m, "ba inited despite fault injection\n"); } @@ -917,8 +917,8 @@ static int test_nvgpu_buddy_allocator_init(struct unit_module *m, /* Fault injection at balloc_new_buddy */ nvgpu_posix_enable_fault_injection(kmem_fi, true, 5); - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_ba", 0ULL, - size, blk_size, max_order, flags) == 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_ba", 0ULL, size, blk_size, + max_order, flags, BUDDY_ALLOCATOR) == 0) { unit_return_fail(m, "buddy_allocator inited despite fault injection\n"); } @@ -929,8 +929,8 @@ static int test_nvgpu_buddy_allocator_init(struct unit_module *m, * vm un-initialized, * This doesn't complain as GPU_ALLOC_GVA_SPACE is disabled */ - if (nvgpu_buddy_allocator_init(g, na, &vm1, "test_ba", base, - 0x40000, blk_size, max_order, flags) != 0) { + if (nvgpu_allocator_init(g, na, &vm1, "test_ba", base, 0x40000, + blk_size, max_order, flags, BUDDY_ALLOCATOR) != 0) { unit_return_fail(m, "buddy_allocator_init failed\n"); } else { na->ops->fini(na); @@ -940,8 +940,8 @@ static int test_nvgpu_buddy_allocator_init(struct unit_module *m, * Initialize buddy allocator * This ba will be used for further tests. */ - if (nvgpu_buddy_allocator_init(g, na, NULL, "test_ba", base, - size, blk_size, max_order, flags) != 0) { + if (nvgpu_allocator_init(g, na, NULL, "test_ba", base, size, blk_size, + max_order, flags, BUDDY_ALLOCATOR) != 0) { unit_return_fail(m, "buddy_allocator_init failed\n"); }