mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
gpu: nvgpu: unit: SWUTS for mm.allocator.bitmap
Add bitmap_allocator.h header that contains SWUTS for the unit. Jira NVGPU-3943 Change-Id: I13bd00f306bf66079556d775b2de83fd50760201 Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2191878 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Alex Waterman
parent
3b1f679526
commit
64ecb8fb60
@@ -33,6 +33,7 @@
|
|||||||
* - @ref SWUTS-enabled
|
* - @ref SWUTS-enabled
|
||||||
* - @ref SWUTS-init
|
* - @ref SWUTS-init
|
||||||
* - @ref SWUTS-interface-atomic
|
* - @ref SWUTS-interface-atomic
|
||||||
|
* - @ref SWUTS-mm-allocators-bitmap-allocator
|
||||||
* - @ref SWUTS-mm-nvgpu-mem
|
* - @ref SWUTS-mm-nvgpu-mem
|
||||||
* - @ref SWUTS-mm-vm
|
* - @ref SWUTS-mm-vm
|
||||||
* - @ref SWUTS-fuse
|
* - @ref SWUTS-fuse
|
||||||
|
|||||||
@@ -5,5 +5,6 @@ INPUT += ../../../userspace/units/fuse/nvgpu-fuse-gm20b.h
|
|||||||
INPUT += ../../../userspace/units/fuse/nvgpu-fuse-gp10b.h
|
INPUT += ../../../userspace/units/fuse/nvgpu-fuse-gp10b.h
|
||||||
INPUT += ../../../userspace/units/init/nvgpu-init.h
|
INPUT += ../../../userspace/units/init/nvgpu-init.h
|
||||||
INPUT += ../../../userspace/units/interface/atomic/atomic.h
|
INPUT += ../../../userspace/units/interface/atomic/atomic.h
|
||||||
|
INPUT += ../../../userspace/units/mm/allocators/bitmap_allocator/bitmap_allocator.h
|
||||||
INPUT += ../../../userspace/units/mm/nvgpu_mem/nvgpu_mem.h
|
INPUT += ../../../userspace/units/mm/nvgpu_mem/nvgpu_mem.h
|
||||||
INPUT += ../../../userspace/units/mm/vm/vm.h
|
INPUT += ../../../userspace/units/mm/vm/vm.h
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
#include <nvgpu/posix/posix-fault-injection.h>
|
#include <nvgpu/posix/posix-fault-injection.h>
|
||||||
|
|
||||||
#include "common/mm/allocators/bitmap_allocator_priv.h"
|
#include "common/mm/allocators/bitmap_allocator_priv.h"
|
||||||
|
#include "bitmap_allocator.h"
|
||||||
|
|
||||||
#define BA_DEFAULT_BASE SZ_1K
|
#define BA_DEFAULT_BASE SZ_1K
|
||||||
#define BA_DEFAULT_LENGTH (SZ_64K << 1)
|
#define BA_DEFAULT_LENGTH (SZ_64K << 1)
|
||||||
@@ -41,10 +42,7 @@
|
|||||||
|
|
||||||
static struct nvgpu_allocator *na;
|
static struct nvgpu_allocator *na;
|
||||||
|
|
||||||
/*
|
int test_nvgpu_bitmap_allocator_critical(struct unit_module *m,
|
||||||
* Test bitmap_allocator with GPU_ALLOC_NO_ALLOC_PAGE enabled
|
|
||||||
*/
|
|
||||||
static int test_nvgpu_bitmap_allocator_critical(struct unit_module *m,
|
|
||||||
struct gk20a *g, void *args)
|
struct gk20a *g, void *args)
|
||||||
{
|
{
|
||||||
u64 base = BA_DEFAULT_BASE;
|
u64 base = BA_DEFAULT_BASE;
|
||||||
@@ -59,10 +57,6 @@ static int test_nvgpu_bitmap_allocator_critical(struct unit_module *m,
|
|||||||
unit_return_fail(m, "Could not allocate nvgpu_allocator\n");
|
unit_return_fail(m, "Could not allocate nvgpu_allocator\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* Initialize bitmap allocator
|
|
||||||
* This ba will be used in this test.
|
|
||||||
*/
|
|
||||||
if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", base, length,
|
if (nvgpu_allocator_init(g, na, NULL, "test_bitmap", base, length,
|
||||||
blk_size, 0ULL, flags, BITMAP_ALLOCATOR) != 0) {
|
blk_size, 0ULL, flags, BITMAP_ALLOCATOR) != 0) {
|
||||||
nvgpu_kfree(g, na);
|
nvgpu_kfree(g, na);
|
||||||
@@ -118,10 +112,7 @@ fail:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int test_nvgpu_bitmap_allocator_alloc(struct unit_module *m,
|
||||||
* Test bitmap_allocator allocs
|
|
||||||
*/
|
|
||||||
static int test_nvgpu_bitmap_allocator_alloc(struct unit_module *m,
|
|
||||||
struct gk20a *g, void *args)
|
struct gk20a *g, void *args)
|
||||||
{
|
{
|
||||||
u64 alloc0, alloc3k, alloc4k, alloc_at64, addr, addr_fail;
|
u64 alloc0, alloc3k, alloc4k, alloc_at64, addr, addr_fail;
|
||||||
@@ -238,11 +229,7 @@ static int test_nvgpu_bitmap_allocator_alloc(struct unit_module *m,
|
|||||||
return UNIT_SUCCESS;
|
return UNIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int test_nvgpu_bitmap_allocator_ops(struct unit_module *m,
|
||||||
* Tests bitmap_allocator basic ops
|
|
||||||
* Bitmap attributes are set corresponding to default init values
|
|
||||||
*/
|
|
||||||
static int test_nvgpu_bitmap_allocator_ops(struct unit_module *m,
|
|
||||||
struct gk20a *g, void *args)
|
struct gk20a *g, void *args)
|
||||||
{
|
{
|
||||||
u64 addr;
|
u64 addr;
|
||||||
@@ -269,10 +256,7 @@ static int test_nvgpu_bitmap_allocator_ops(struct unit_module *m,
|
|||||||
return UNIT_SUCCESS;
|
return UNIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int test_nvgpu_bitmap_allocator_destroy(struct unit_module *m,
|
||||||
* De-initialize bitmap allocator
|
|
||||||
*/
|
|
||||||
static int test_nvgpu_bitmap_allocator_destroy(struct unit_module *m,
|
|
||||||
struct gk20a *g, void *args)
|
struct gk20a *g, void *args)
|
||||||
{
|
{
|
||||||
na->ops->fini(na);
|
na->ops->fini(na);
|
||||||
@@ -281,11 +265,7 @@ static int test_nvgpu_bitmap_allocator_destroy(struct unit_module *m,
|
|||||||
return UNIT_SUCCESS;
|
return UNIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
int test_nvgpu_bitmap_allocator_init(struct unit_module *m,
|
||||||
* Tests nvgpu_bitmap_allocator_init()
|
|
||||||
* This test considers multiple conditions to initialize bitmap allocator
|
|
||||||
*/
|
|
||||||
static int test_nvgpu_bitmap_allocator_init(struct unit_module *m,
|
|
||||||
struct gk20a *g, void *args)
|
struct gk20a *g, void *args)
|
||||||
{
|
{
|
||||||
u64 base = BA_DEFAULT_BASE;
|
u64 base = BA_DEFAULT_BASE;
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
|
||||||
|
*
|
||||||
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||||
|
* copy of this software and associated documentation files (the "Software"),
|
||||||
|
* to deal in the Software without restriction, including without limitation
|
||||||
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||||
|
* and/or sell copies of the Software, and to permit persons to whom the
|
||||||
|
* Software is furnished to do so, subject to the following conditions:
|
||||||
|
*
|
||||||
|
* The above copyright notice and this permission notice shall be included in
|
||||||
|
* all copies or substantial portions of the Software.
|
||||||
|
*
|
||||||
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||||
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||||
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
|
* DEALINGS IN THE SOFTWARE.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef UNIT_BITMAP_ALLOCATOR_H
|
||||||
|
#define UNIT_BITMAP_ALLOCATOR_H
|
||||||
|
|
||||||
|
struct gk20a;
|
||||||
|
struct unit_module;
|
||||||
|
|
||||||
|
/** @addtogroup SWUTS-mm-allocators-bitmap-allocator
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* Software Unit Test Specification for mm.allocators.bitmap_allocator
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test specification for: test_nvgpu_bitmap_allocator_init
|
||||||
|
*
|
||||||
|
* Description: Initialize bitmap allocator.
|
||||||
|
*
|
||||||
|
* Test Type: Feature based
|
||||||
|
*
|
||||||
|
* Input: None
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* - Initialize bitmap allocator with following characteristics.
|
||||||
|
* - 1K memory base address.
|
||||||
|
* - 128K length of memory.
|
||||||
|
* - 1K block size.
|
||||||
|
* - Use this bitmap allocator for rest of the tests.
|
||||||
|
*
|
||||||
|
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
int test_nvgpu_bitmap_allocator_init(struct unit_module *m,
|
||||||
|
struct gk20a *g, void *args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test specification for: test_nvgpu_bitmap_allocator_ops
|
||||||
|
*
|
||||||
|
* Description: Check bitmap_allocator attribute values using allocator ops.
|
||||||
|
*
|
||||||
|
* Test Type: Feature based
|
||||||
|
*
|
||||||
|
* Input: test_nvgpu_bitmap_allocator_init
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* - Check bitmap_allocator attributes using allocator ops.
|
||||||
|
* - Execute allocator ops to read attibute value.
|
||||||
|
* - Confirm that value is equal to the default values set during
|
||||||
|
* initialization.
|
||||||
|
*
|
||||||
|
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
int test_nvgpu_bitmap_allocator_ops(struct unit_module *m,
|
||||||
|
struct gk20a *g, void *args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test specification for: test_nvgpu_bitmap_allocator_alloc
|
||||||
|
*
|
||||||
|
* Description: Allocate various sizes of memory to test different scenarios.
|
||||||
|
*
|
||||||
|
* Test Type: Feature based
|
||||||
|
*
|
||||||
|
* Input: test_nvgpu_bitmap_allocator_init
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* - Allocate 3k memory using allocation functions.
|
||||||
|
* - Confirm that allocation is successful.
|
||||||
|
* - Allocate 2M which is more than available memory.
|
||||||
|
* - Allocation is expected to fail.
|
||||||
|
* - Allocate 4K, 8K, 16K and 32K memory segments.
|
||||||
|
* - Confirm all allocations are successful.
|
||||||
|
* - Allocate various memory segments using fixed allocation functions.
|
||||||
|
* - Confirm aloocations are successful as expected.
|
||||||
|
* - Free allocations.
|
||||||
|
* - Confirm allocations are freed.
|
||||||
|
*
|
||||||
|
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
int test_nvgpu_bitmap_allocator_alloc(struct unit_module *m,
|
||||||
|
struct gk20a *g, void *args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test specification for: test_nvgpu_bitmap_allocator_destroy
|
||||||
|
*
|
||||||
|
* Description: Free memory used for bitmap allocator.
|
||||||
|
*
|
||||||
|
* Test Type: Other (clean up)
|
||||||
|
*
|
||||||
|
* Input: test_nvgpu_bitmap_allocator_init
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* - Free bitmap_allocator allocated for this unit test.
|
||||||
|
*
|
||||||
|
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
int test_nvgpu_bitmap_allocator_destroy(struct unit_module *m,
|
||||||
|
struct gk20a *g, void *args);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test specification for: test_nvgpu_bitmap_allocator_critical
|
||||||
|
*
|
||||||
|
* Description: Test allocator functions for bitmap allocator in latency
|
||||||
|
* critical path.
|
||||||
|
*
|
||||||
|
* Test Type: Feature based
|
||||||
|
*
|
||||||
|
* Input: None
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* - Initialize allocator with following characteristics.
|
||||||
|
* - 1K memory base address.
|
||||||
|
* - 128K memory length.
|
||||||
|
* - 1K block size.
|
||||||
|
* - GPU_ALLOC_NO_ALLOC_PAGE flag value.
|
||||||
|
* - Allocate memory segments using allocation functions.
|
||||||
|
* - Confirm allocations are successful.
|
||||||
|
* - Free allocated memory segments.
|
||||||
|
* - Free bitmap allocator used for this test.
|
||||||
|
*
|
||||||
|
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
int test_nvgpu_bitmap_allocator_critical(struct unit_module *m,
|
||||||
|
struct gk20a *g, void *args);
|
||||||
|
|
||||||
|
#endif /* UNIT_BITMAP_ALLOCATOR_H */
|
||||||
Reference in New Issue
Block a user