diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index dfe9328f2..59f877c3e 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -45,6 +45,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/init NV_REPOSITORY_COMPONENTS += userspace/units/posix/thread NV_REPOSITORY_COMPONENTS += userspace/units/posix/cond NV_REPOSITORY_COMPONENTS += userspace/units/posix/timers +NV_REPOSITORY_COMPONENTS += userspace/units/posix/kmem NV_REPOSITORY_COMPONENTS += userspace/units/interface/bsearch NV_REPOSITORY_COMPONENTS += userspace/units/interface/lock NV_REPOSITORY_COMPONENTS += userspace/units/interface/atomic diff --git a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export index 9c48920b3..8d853b499 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export @@ -258,7 +258,10 @@ nvgpu_init_mm_support nvgpu_inst_block_addr nvgpu_inst_block_ptr nvgpu_is_enabled +nvgpu_big_alloc_impl +nvgpu_big_free nvgpu_kfree_impl +nvgpu_kcalloc_impl nvgpu_kmalloc_impl nvgpu_kmem_cache_alloc nvgpu_kmem_cache_create @@ -266,6 +269,7 @@ nvgpu_kmem_cache_destroy nvgpu_kmem_cache_free nvgpu_kmem_get_fault_injection nvgpu_kzalloc_impl +nvgpu_vmalloc_impl nvgpu_log_msg_impl nvgpu_memset nvgpu_mem_create_from_phys diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources index a0732520d..6bf9d1a5e 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -52,6 +52,7 @@ UNITS := \ $(UNIT_SRC)/posix/thread \ $(UNIT_SRC)/posix/cond \ $(UNIT_SRC)/posix/timers \ + $(UNIT_SRC)/posix/kmem \ $(UNIT_SRC)/pramin \ $(UNIT_SRC)/ptimer \ $(UNIT_SRC)/init \ diff --git a/userspace/units/posix/kmem/Makefile b/userspace/units/posix/kmem/Makefile new file mode 100644 index 000000000..3324137c7 --- /dev/null +++ b/userspace/units/posix/kmem/Makefile @@ -0,0 +1,26 @@ +# 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. + +.SUFFIXES: + +OBJS = posix-kmem.o +MODULE = posix-kmem + +include ../../Makefile.units diff --git a/userspace/units/posix/kmem/Makefile.interface.tmk b/userspace/units/posix/kmem/Makefile.interface.tmk new file mode 100644 index 000000000..e2919210d --- /dev/null +++ b/userspace/units/posix/kmem/Makefile.interface.tmk @@ -0,0 +1,35 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# 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. +# +# tmake for SW Mobile component makefile +# +############################################################################### + +NVGPU_UNIT_NAME=posix-kmem + +include $(NV_COMPONENT_DIR)/../../Makefile.units.common.interface.tmk + +# Local Variables: +# indent-tabs-mode: t +# tab-width: 8 +# End: +# vi: set tabstop=8 noexpandtab: diff --git a/userspace/units/posix/kmem/Makefile.tmk b/userspace/units/posix/kmem/Makefile.tmk new file mode 100644 index 000000000..74ebf93dc --- /dev/null +++ b/userspace/units/posix/kmem/Makefile.tmk @@ -0,0 +1,35 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# 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. +# +# tmake for SW Mobile component makefile +# +############################################################################### + +NVGPU_UNIT_NAME=posix-kmem + +include $(NV_COMPONENT_DIR)/../../Makefile.units.common.tmk + +# Local Variables: +# indent-tabs-mode: t +# tab-width: 8 +# End: +# vi: set tabstop=8 noexpandtab: diff --git a/userspace/units/posix/kmem/posix-kmem.c b/userspace/units/posix/kmem/posix-kmem.c new file mode 100644 index 000000000..ffdb7aaa3 --- /dev/null +++ b/userspace/units/posix/kmem/posix-kmem.c @@ -0,0 +1,257 @@ +/* + * 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. + */ + +#include +#include + +#include +#include + +#include +#include "posix-kmem.h" + +#define KMEM_TEST_CACHE_SIZE 512 +#define KMEM_TEST_ALLOC_SIZE 256 +#define KMEM_TEST_CALLOC_COUNT 4 + +struct nvgpu_kmem_cache { + struct gk20a *g; + size_t size; + char name[128]; +}; + +int test_kmem_cache_create(struct unit_module *m, + struct gk20a *g, void *args) +{ + struct nvgpu_kmem_cache *test_cache; + + test_cache = nvgpu_kmem_cache_create(g, KMEM_TEST_CACHE_SIZE); + + if (test_cache == NULL) { + unit_return_fail(m, "Kmem cache create failed\n"); + } + + if (test_cache->size != KMEM_TEST_CACHE_SIZE) { + nvgpu_kmem_cache_destroy(test_cache); + unit_return_fail(m, "Kmem cache size mismatch\n"); + } else if (test_cache->g != g) { + nvgpu_kmem_cache_destroy(test_cache); + unit_return_fail(m, "Kmem cache g structure mismatch\n"); + } + + nvgpu_kmem_cache_destroy(test_cache); + + return UNIT_SUCCESS; +} + +int test_kmem_cache_alloc(struct unit_module *m, + struct gk20a *g, void *args) +{ + struct nvgpu_kmem_cache *test_cache; + void *test_ptr = NULL; + + test_cache = nvgpu_kmem_cache_create(g, KMEM_TEST_CACHE_SIZE); + + if (test_cache == NULL) { + unit_return_fail(m, "Kmem alloc cache create failed\n"); + } + + if (test_cache->size != KMEM_TEST_CACHE_SIZE) { + nvgpu_kmem_cache_destroy(test_cache); + unit_return_fail(m, "Kmem alloc cache size mismatch\n"); + } else if (test_cache->g != g) { + nvgpu_kmem_cache_destroy(test_cache); + unit_return_fail(m, "Kmem alloc cache g structure mismatch\n"); + } + + test_ptr = nvgpu_kmem_cache_alloc(test_cache); + + if (test_ptr == NULL) { + nvgpu_kmem_cache_destroy(test_cache); + unit_return_fail(m, "Kmem cache alloc failed\n"); + } + + nvgpu_kmem_cache_free(test_cache, test_ptr); + nvgpu_kmem_cache_destroy(test_cache); + + return UNIT_SUCCESS; +} + +int test_kmem_kmalloc(struct unit_module *m, + struct gk20a *g, void *args) +{ + void *test_ptr; + + test_ptr = nvgpu_kmalloc_impl(g, KMEM_TEST_ALLOC_SIZE, NULL); + + if (test_ptr == NULL) { + unit_return_fail(m, "Kmalloc failed\n"); + } + + nvgpu_kfree_impl(g, test_ptr); + + return UNIT_SUCCESS; +} + +int test_kmem_kzalloc(struct unit_module *m, + struct gk20a *g, void *args) +{ + void *test_ptr; + char *check_ptr; + int i; + + test_ptr = nvgpu_kzalloc_impl(g, KMEM_TEST_ALLOC_SIZE, NULL); + + if (test_ptr == NULL) { + unit_return_fail(m, "Kzalloc failed\n"); + } + + check_ptr = (char *)test_ptr; + + for (i = 0; i < KMEM_TEST_ALLOC_SIZE; i++) { + if (*check_ptr != 0) { + nvgpu_kfree_impl(g, (void *)test_ptr); + unit_return_fail(m, "Non zero memory in Kzalloc\n"); + } + + check_ptr++; + } + + nvgpu_kfree_impl(g, test_ptr); + + return UNIT_SUCCESS; +} + +int test_kmem_kcalloc(struct unit_module *m, + struct gk20a *g, void *args) +{ + void *test_ptr; + char *check_ptr; + int i; + + test_ptr = nvgpu_kcalloc_impl(g, KMEM_TEST_ALLOC_SIZE, + KMEM_TEST_CALLOC_COUNT, NULL); + + if (test_ptr == NULL) { + unit_return_fail(m, "Kcalloc failed\n"); + } + + check_ptr = (char *)test_ptr; + + for (i = 0; i < (KMEM_TEST_ALLOC_SIZE * KMEM_TEST_CALLOC_COUNT); i++) { + if (*check_ptr != 0) { + nvgpu_kfree_impl(g, (void *)test_ptr); + unit_return_fail(m, "Non zero memory in Kcalloc\n"); + } + check_ptr++; + } + + nvgpu_kfree_impl(g, test_ptr); + + return UNIT_SUCCESS; +} + +int test_kmem_virtual_alloc(struct unit_module *m, + struct gk20a *g, void *args) +{ + void *test_ptr; + char *check_ptr; + int i; + + test_ptr = nvgpu_vmalloc_impl(g, KMEM_TEST_ALLOC_SIZE, NULL); + + if (test_ptr == NULL) { + unit_return_fail(m, "Vmalloc failed\n"); + } + + nvgpu_vfree_impl(g, test_ptr); + + test_ptr = nvgpu_vzalloc_impl(g, KMEM_TEST_ALLOC_SIZE, NULL); + + if (test_ptr == NULL) { + unit_return_fail(m, "Vzalloc failed\n"); + } + + check_ptr = (char *)test_ptr; + + for (i = 0; i < KMEM_TEST_ALLOC_SIZE; i++) { + if (*check_ptr != 0) { + nvgpu_vfree_impl(g, (void *)test_ptr); + unit_return_fail(m, + "Non Zero entry in vzalloc memory\n"); + } + check_ptr++; + } + + nvgpu_vfree_impl(g, test_ptr); + + return UNIT_SUCCESS; +} + +int test_kmem_big_alloc(struct unit_module *m, + struct gk20a *g, void *args) +{ + void *test_ptr; + char *check_ptr; + int i; + + test_ptr = nvgpu_big_alloc_impl(g, KMEM_TEST_ALLOC_SIZE, false); + + if (test_ptr == NULL) { + unit_return_fail(m, "Big alloc failed\n"); + } + + nvgpu_big_free(g, test_ptr); + + test_ptr = nvgpu_big_alloc_impl(g, KMEM_TEST_ALLOC_SIZE, true); + + if (test_ptr == NULL) { + unit_return_fail(m, "Big clear alloc failed\n"); + } + + check_ptr = (char *)test_ptr; + + for (i = 0; i < KMEM_TEST_ALLOC_SIZE; i++) { + if (*check_ptr != 0) { + nvgpu_big_free(g, (void *)test_ptr); + unit_return_fail(m, + "Non Zero entry in big clear alloc memory\n"); + } + check_ptr++; + } + + nvgpu_big_free(g, test_ptr); + + return UNIT_SUCCESS; +} + +struct unit_module_test posix_kmem_tests[] = { + UNIT_TEST(cache_create, test_kmem_cache_create, NULL, 0), + UNIT_TEST(cache_alloc, test_kmem_cache_alloc, NULL, 0), + UNIT_TEST(kmalloc_test, test_kmem_kmalloc, NULL, 0), + UNIT_TEST(kzalloc_test, test_kmem_kzalloc, NULL, 0), + UNIT_TEST(kcalloc_test, test_kmem_kcalloc, NULL, 0), + UNIT_TEST(virtual_alloc, test_kmem_virtual_alloc, NULL, 0), + UNIT_TEST(big_alloc, test_kmem_big_alloc, NULL, 0), +}; + +UNIT_MODULE(posix_kmem, posix_kmem_tests, UNIT_PRIO_POSIX_TEST); diff --git a/userspace/units/posix/kmem/posix-kmem.h b/userspace/units/posix/kmem/posix-kmem.h new file mode 100644 index 000000000..4345cbb56 --- /dev/null +++ b/userspace/units/posix/kmem/posix-kmem.h @@ -0,0 +1,242 @@ +/* + * 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. + */ + +/** + * @addtogroup SWUTS-posix-kmem + * @{ + * + * Software Unit Test Specification for posix-kmem + */ + +#ifndef __UNIT_POSIX_KMEM_H__ +#define __UNIT_POSIX_KMEM_H__ + +/** + * Test specification for test_kmem_cache_create + * + * Description: Test the creation of kmem cache. + * + * Test Type: Feature based. + * + * Inputs: + * 1) GPU driver struct g. + * 2) Global define for cache size to alloc. + * + * Steps: + * 1) Call nvgpu_kmem_cache_create with cache size as a parameter. + * 2) Check the return value from cache create function. If the return value + * is NULL, return test FAIL. + * 3) Check if the size value of the created cache is equal to the requested + * size, if not destroy the cache and return FAIL. + * 4) Check if the g struct of the created cache is equal to the g struct + * instance passed to the cache creation API, if not destroy the cache and + * return FAIL. + * 5) Destroy the created cache and return PASS. + * + * Output: + * The test returns PASS if the cache is created successfully and the size and + * g struct of the cache matches with the passed arguments. Otherwise the test + * returns FAIL. + * + */ +int test_kmem_cache_create(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for test_kmem_cache_alloc + * + * Description: Test the allocation of memory from kmem cache. + * + * Test Type: Feature based. + * + * Inputs: + * 1) GPU driver struct g. + * 2) Global define for cache size to alloc. + * + * Steps: + * 1) Call nvgpu_kmem_cache_create with cache size as a parameter. + * 2) Check the return value from cache create function. If the return value + * is NULL, return test FAIL. + * 3) Check if the size value of the created cache is equal to the requested + * size, if not destroy the cache and return FAIL. + * 4) Check if the g struct of the created cache is equal to the g struct + * instance passed to the cache creation API, if not destroy the cache and + * return FAIL. + * 5) Call nvgpu_kmem_cache_alloc to alloc memory from the created cache. + * 6) Check the return value from cache alloc function. If the return value + * is NULL, destroy the cache and return test FAIL. + * 7) Free the allocated memory and destroy the cache, and return PASS. + * + * Output: + * The test returns PASS if the cache creation and allocation of memory from + * the cache is successful. Otherwise, return FAIL. + * + */ +int test_kmem_cache_alloc(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for test_kmem_kmalloc + * + * Description: Test the allocation of memory using kmalloc. + * + * Test Type: Feature based. + * + * Inputs: + * 1) GPU driver struct g. + * 2) Global define for size to alloc. + * + * Steps: + * 1) Call nvgpu_kmalloc_impl with size as a parameter. + * 2) Check the return value from nvgpu_kmalloc_impl function. If the return + * value is NULL, return test FAIL. + * 3) Free the allocated memory. + * 4) Return PASS. + * + * Output: + * The test returns PASS if the memory is successfully allocated. Otherwise, + * the test returns FAIL. + */ +int test_kmem_kmalloc(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for test_kmem_kzalloc + * + * Description: Test the allocation of memory using kzalloc. + * + * Test Type: Feature based. + * + * Inputs: + * 1) GPU driver struct g. + * 2) Global define for size to alloc. + * + * Steps: + * 1) Call nvgpu_kzalloc_impl with size as a parameter. + * 2) Check the return value from nvgpu_kmalloc_impl function. If the return + * value is NULL, return test FAIL. + * 3) Check if the allocated chunk of memory is zero initialized. If it is not, + * free the memory and return FAIL. + * 3) Free the allocated memory. + * 4) Return PASS. + * + * Output: + * The test returns PASS if the zero initialized memory is successfully + * allocated. Otherwise, the test returns FAIL. + */ +int test_kmem_kzalloc(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for test_kmem_kcalloc + * + * Description: Test the allocation of memory using kcalloc. + * + * Test Type: Feature based. + * + * Inputs: + * 1) GPU driver struct g. + * 2) Global define for size to alloc. + * 3) Global define for count to alloc. + * + * Steps: + * 1) Call nvgpu_kcalloc_impl with size and count as parameters. + * 2) Check the return value from nvgpu_kmalloc_impl function. If the return + * value is NULL, return test FAIL. + * 3) Check if the allocated chunk of memory is zero initialized. If it is not, + * free the memory and return FAIL. + * 3) Free the allocated memory. + * 4) Return PASS. + * + * Output: + * The test returns PASS if the zero initialized memory is successfully + * allocated. Otherwise, the test returns FAIL. + */ +int test_kmem_kcalloc(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for test_kmem_virtual_alloc + * + * Description: Test the allocation of memory using virtual alloc APIs. + * + * Test Type: Feature based. + * + * Inputs: + * 1) GPU driver struct g. + * 2) Global define for cache size to alloc. + * + * Steps: + * 1) Call nvgpu_vmalloc_impl with size as a parameter. + * 2) Check the return value from nvgpu_vmalloc_impl function. If the return + * value is NULL, return test FAIL. + * 3) Free the memory using nvgpu_vfree_impl. + * 4) Call nvgpu_vzalloc_impl with size as a parameter. + * 5) Check the return value from nvgpu_vzalloc_impl function. If the return + * value is NULL, return test FAIL. + * 6) Check if the allocated chunk of memory is zero initialized. If it is not, + * free the memory and return FAIL. + * 7) Free the memory using nvgpu_vfree_impl. + * 8) Return PASS. + * + * Output: + * The test returns PASS if, + * - The virtual allocation API nvgpu_vmalloc_impl successfully allocates memory. + * - The virtual allocation API nvgpu_vzalloc_impl successfully allocates zero + * initialised memory. + * If any of the above points fail, the test returns FAIL. + */ +int test_kmem_virtual_alloc(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for test_kmem_big_alloc + * + * Description: Test the allocation of memory using big alloc APIs. + * + * Test Type: Feature based. + * + * Inputs: + * 1) GPU driver struct g. + * 2) Global define for cache size to alloc. + * + * Steps: + * 1) Call nvgpu_big_alloc_impl with size as a parameter and clear flag set to + * false. + * 2) Check the return value from nvgpu_big_alloc_impl function. If the return + * value is NULL, return test FAIL. + * 3) Free the memory using nvgpu_big_free. + * 4) Call nvgpu_big_alloc_impl with size as a parameter and clear flag set to + * true. + * 5) Check the return value from nvgpu_big_alloc_impl function. If the return + * value is NULL, return test FAIL. + * 6) Check if the allocated chunk of memory is zero initialized. If it is not, + * free the memory and return FAIL. + * 7) Free the memory using nvgpu_big_free.. + * 8) Return PASS. + * + * Output: + * + */ +int test_kmem_big_alloc(struct unit_module *m, + struct gk20a *g, void *args); +#endif /* __UNIT_POSIX_KMEM_H__ */