diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index ceb9cebb0..88165154d 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -70,6 +70,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/fifo/tsg NV_REPOSITORY_COMPONENTS += userspace/units/fifo/tsg/gv11b NV_REPOSITORY_COMPONENTS += userspace/units/fuse NV_REPOSITORY_COMPONENTS += userspace/units/list +NV_REPOSITORY_COMPONENTS += userspace/units/ltc NV_REPOSITORY_COMPONENTS += userspace/units/enabled NV_REPOSITORY_COMPONENTS += userspace/units/falcon NV_REPOSITORY_COMPONENTS += userspace/units/falcon/falcon_tests diff --git a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export index 2fb2d7942..ebf18ad97 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export @@ -171,6 +171,12 @@ nvgpu_gr_config_get_sm_info_sm_index nvgpu_gr_config_set_gpc_tpc_mask nvgpu_gr_config_get_gpc_tpc_mask nvgpu_hr_timestamp +nvgpu_init_ltc_support +nvgpu_ltc_get_cacheline_size +nvgpu_ltc_get_ltc_count +nvgpu_ltc_get_slices_per_ltc +nvgpu_ltc_remove_support +nvgpu_ltc_sync_enabled nvgpu_can_busy nvgpu_channel_alloc_inst nvgpu_channel_cleanup_sw diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources index b6677f618..b583c59da 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -77,6 +77,7 @@ UNITS := \ $(UNIT_SRC)/fifo/tsg \ $(UNIT_SRC)/fifo/tsg/gv11b \ $(UNIT_SRC)/list \ + $(UNIT_SRC)/ltc \ $(UNIT_SRC)/enabled \ $(UNIT_SRC)/falcon \ $(UNIT_SRC)/falcon/falcon_tests \ diff --git a/userspace/SWUTS.h b/userspace/SWUTS.h index 25205f638..f92412400 100644 --- a/userspace/SWUTS.h +++ b/userspace/SWUTS.h @@ -43,6 +43,7 @@ * - @ref SWUTS-fifo-tsg-gv11b * - @ref SWUTS-init * - @ref SWUTS-interface-atomic + * - @ref SWUTS-ltc * - @ref SWUTS-mm-allocators-bitmap-allocator * - @ref SWUTS-mm-allocators-buddy-allocator * - @ref SWUTS-mm-as diff --git a/userspace/SWUTS.sources b/userspace/SWUTS.sources index 86c201816..b409c4915 100644 --- a/userspace/SWUTS.sources +++ b/userspace/SWUTS.sources @@ -16,6 +16,7 @@ INPUT += ../../../userspace/units/fuse/nvgpu-fuse-gm20b.h INPUT += ../../../userspace/units/fuse/nvgpu-fuse-gp10b.h INPUT += ../../../userspace/units/init/nvgpu-init.h INPUT += ../../../userspace/units/interface/atomic/atomic.h +INPUT += ../../../userspace/units/ltc/nvgpu-ltc.h INPUT += ../../../userspace/units/mm/allocators/bitmap_allocator/bitmap_allocator.h INPUT += ../../../userspace/units/mm/allocators/buddy_allocator/buddy_allocator.h INPUT += ../../../userspace/units/mm/as/as.h diff --git a/userspace/required_tests.json b/userspace/required_tests.json index bd86b2e6b..1fba39103 100644 --- a/userspace/required_tests.json +++ b/userspace/required_tests.json @@ -1673,6 +1673,26 @@ "test_level": 0, "unit": "nvgpu_gr_intr" }, + { + "test": "ltc_init_support", + "test_level": 0, + "unit": "nvgpu-ltc" + }, + { + "test": "ltc_functionality_tests", + "test_level": 0, + "unit": "nvgpu-ltc" + }, + { + "test": "ltc_negative_tests", + "test_level": 0, + "unit": "nvgpu-ltc" + }, + { + "test": "ltc_remove_support", + "test_level": 0, + "unit": "nvgpu-ltc" + }, { "test": "acr_init", "test_level": 0, diff --git a/userspace/units/ltc/Makefile b/userspace/units/ltc/Makefile new file mode 100644 index 000000000..f35d53197 --- /dev/null +++ b/userspace/units/ltc/Makefile @@ -0,0 +1,27 @@ +# 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 = nvgpu-ltc.o + +MODULE = nvgpu-ltc + +include ../Makefile.units diff --git a/userspace/units/ltc/Makefile.interface.tmk b/userspace/units/ltc/Makefile.interface.tmk new file mode 100644 index 000000000..0dc3a435e --- /dev/null +++ b/userspace/units/ltc/Makefile.interface.tmk @@ -0,0 +1,29 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2019, NVIDIA CORPORATION. All Rights Reserved. +# +# NVIDIA CORPORATION and its licensors retain all intellectual property +# and proprietary rights in and to this software, related documentation +# and any modifications thereto. Any use, reproduction, disclosure or +# distribution of this software and related documentation without an express +# license agreement from NVIDIA CORPORATION is strictly prohibited. +# +# tmake for SW Mobile component makefile +# +# libnvgpu-fifo interface makefile fragment +# +############################################################################### + +ifdef NV_INTERFACE_FLAG_SHARED_LIBRARY_SECTION + +NV_INTERFACE_NAME := nvgpu-ltc + +include $(NV_COMPONENT_DIR)/../Makefile.units.common.interface.tmk + +endif + +# Local Variables: +# indent-tabs-mode: t +# tab-width: 8 +# End: +# vi: set tabstop=8 noexpandtab: diff --git a/userspace/units/ltc/Makefile.tmk b/userspace/units/ltc/Makefile.tmk new file mode 100644 index 000000000..4aed0391e --- /dev/null +++ b/userspace/units/ltc/Makefile.tmk @@ -0,0 +1,25 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2019 NVIDIA CORPORATION. All Rights Reserved. +# +# NVIDIA CORPORATION and its licensors retain all intellectual property +# and proprietary rights in and to this software, related documentation +# and any modifications thereto. Any use, reproduction, disclosure or +# distribution of this software and related documentation without an express +# license agreement from NVIDIA CORPORATION is strictly prohibited. +# +# tmake for SW Mobile component makefile +# +# Component makefile for compiling nvgpu-fifo common tests. +# +############################################################################### + +NVGPU_UNIT_NAME = nvgpu-ltc + +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/ltc/nvgpu-ltc.c b/userspace/units/ltc/nvgpu-ltc.c new file mode 100644 index 000000000..28fc44d88 --- /dev/null +++ b/userspace/units/ltc/nvgpu-ltc.c @@ -0,0 +1,175 @@ +/* + * 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 +#include +#include +#include +#include +#include +#include + +#include "nvgpu-ltc.h" + +#define NV_PMC_BOOT_0_ARCHITECTURE_GV110 (0x00000015 << \ + NVGPU_GPU_ARCHITECTURE_SHIFT) +#define NV_PMC_BOOT_0_IMPLEMENTATION_B 0xB + +/* + * Mock I/O + */ + +/* + * Write callback. Forward the write access to the mock IO framework. + */ +static void writel_access_reg_fn(struct gk20a *g, + struct nvgpu_reg_access *access) +{ + nvgpu_posix_io_writel_reg_space(g, access->addr, access->value); +} + +/* + * Read callback. Get the register value from the mock IO framework. + */ +static void readl_access_reg_fn(struct gk20a *g, + struct nvgpu_reg_access *access) +{ + access->value = nvgpu_posix_io_readl_reg_space(g, access->addr); +} + +static struct nvgpu_posix_io_callbacks netlist_test_reg_callbacks = { + .writel = writel_access_reg_fn, + .writel_check = writel_access_reg_fn, + .bar1_writel = writel_access_reg_fn, + .usermode_writel = writel_access_reg_fn, + .__readl = readl_access_reg_fn, + .readl = readl_access_reg_fn, + .bar1_readl = readl_access_reg_fn, +}; + + +int test_ltc_init_support(struct unit_module *m, + struct gk20a *g, void *args) +{ + + int err = 0; + + nvgpu_posix_io_init_reg_space(g); + if (nvgpu_posix_io_add_reg_space(g, mc_boot_0_r(), 0xfff) != 0) { + unit_err(m, "%s: failed to create register space\n", __func__); + return UNIT_FAIL; + } + + (void)nvgpu_posix_register_io(g, &netlist_test_reg_callbacks); + + /* + * HAL init parameters for gv11b + */ + g->params.gpu_arch = NV_PMC_BOOT_0_ARCHITECTURE_GV110; + g->params.gpu_impl = NV_PMC_BOOT_0_IMPLEMENTATION_B; + + /* + * HAL init required for getting + * the falcon ops initialized. + */ + err = nvgpu_init_hal(g); + if (err != 0) { + unit_return_fail(m, "nvgpu_init_hal failed\n"); + } + + err = nvgpu_init_ltc_support(g); + if (err != 0) { + unit_return_fail(m, "nvgpu_init_ltc_support failed\n"); + } + + return UNIT_SUCCESS; + +} + +int test_ltc_functionality_tests(struct unit_module *m, + struct gk20a *g, void *args) +{ + u32 ltc_count; + u32 slice_per_ltc; + u32 cacheline_size; + + g->mm.ltc_enabled_current = false; + nvgpu_ltc_sync_enabled(g); + + ltc_count = nvgpu_ltc_get_ltc_count(g); + if (ltc_count != 0) { + unit_return_fail(m, "nvgpu_ltc_get_ltc_count failed\n"); + } + slice_per_ltc = nvgpu_ltc_get_slices_per_ltc(g); + if (slice_per_ltc != 0) { + unit_return_fail(m, "nvgpu_ltc_get_slices_per_ltc failed\n"); + } + cacheline_size = nvgpu_ltc_get_cacheline_size(g); + if (cacheline_size == 0) { + unit_return_fail(m, "nvgpu_ltc_get_cacheline_size failed\n"); + } + + return UNIT_SUCCESS; +} + +int test_ltc_negative_tests(struct unit_module *m, + struct gk20a *g, void *args) +{ + int err = 0; + + g->ops.ltc.set_enabled = NULL; + nvgpu_ltc_sync_enabled(g); + nvgpu_ltc_remove_support(g); + nvgpu_ltc_remove_support(g); + err = nvgpu_init_ltc_support(g); + if (err != 0) { + unit_return_fail(m, "nvgpu_init_ltc_support failed\n"); + } + + return UNIT_SUCCESS; +} + +int test_ltc_remove_support(struct unit_module *m, + struct gk20a *g, void *args) +{ + nvgpu_ltc_remove_support(g); + + return UNIT_SUCCESS; +} + +struct unit_module_test nvgpu_ltc_tests[] = { + UNIT_TEST(ltc_init_support, test_ltc_init_support, NULL, 0), + UNIT_TEST(ltc_functionality_tests, test_ltc_functionality_tests, + NULL, 0), + UNIT_TEST(ltc_negative_tests, test_ltc_negative_tests, NULL, 0), + UNIT_TEST(ltc_remove_support, test_ltc_remove_support, NULL, 0), +}; + +UNIT_MODULE(nvgpu-ltc, nvgpu_ltc_tests, UNIT_PRIO_NVGPU_TEST); + + diff --git a/userspace/units/ltc/nvgpu-ltc.h b/userspace/units/ltc/nvgpu-ltc.h new file mode 100644 index 000000000..f96342470 --- /dev/null +++ b/userspace/units/ltc/nvgpu-ltc.h @@ -0,0 +1,117 @@ +/* + * 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_NVGPU_LTC_H +#define UNIT_NVGPU_LTC_H + +#include + +/** @addtogroup SWUTS-ltc + * @{ + * + * Software Unit Test Specification for ltc + */ + +/** + * Test specification for: test_ltc_init_support + * + * Description: The ltc unit get initilized + * + * Test Type: Feature based + * + * Input: None + * + * Steps: + * - Initialize the test environment for ltc unit testing: + * - Setup gv11b register spaces for hals to read emulated values. + * - Register read/write IO callbacks. + * - Setup init parameters to setup gv11b arch. + * - Initialize hal to setup the hal functions. + * - Call nvgpu_init_ltc_support to initilize ltc unit. + * + * Output: Returns PASS if the steps above were executed successfully. FAIL + * otherwise. + */ +int test_ltc_init_support(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for: test_ltc_functionality_tests + * + * Description: This test test ltc sync enabled and queries data + * related to different ltc data. + * Checks whether valid data is retured or not. + * + * Test Type: Feature based + * + * Input: None + * + * Steps: + * - Set ltc_enabled_current to false and then call + * nvgpu_ltc_sync_enabled. + * - Call nvgpu_ltc_get_ltc_count + * - Call nvgpu_ltc_get_slices_per_ltc + * - Call nvgpu_ltc_get_cacheline_size + * Checked called functions returns correct data. + * + * Output: Returns PASS if returned data is valid. FAIL otherwise. + */ + +int test_ltc_functionality_tests(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for: test_ltc_negative_tests + * + * Description: This test covers negative paths in ltc unit. + * + * Test Type: Feature based + * + * Input: None + * + * Steps: + * - Set ltc.set_enabled to NULL and then call nvgpu_ltc_sync_enabled + * - Call nvgpu_ltc_remove_support twice + * - Call nvgpu_init_ltc_support + * + * Output: Returns PASS if expected result is met, FAIL otherwise. + */ +int test_ltc_negative_tests(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for: test_ltc_remove_support + * + * Description: The ltc unit removes all populated ltc info. + * + * Test Type: Feature based + * + * Input: None + * + * Steps: + * - Call nvgpu_ltc_remove_support + * + * Output: Returns PASS + */ +int test_ltc_remove_support(struct unit_module *m, + struct gk20a *g, void *args); + +#endif /* UNIT_NVGPU_LTC_H */