diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index ef1f3b2a9..70c8e32b3 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -94,6 +94,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/gr/falcon NV_REPOSITORY_COMPONENTS += userspace/units/gr/config NV_REPOSITORY_COMPONENTS += userspace/units/gr/init NV_REPOSITORY_COMPONENTS += userspace/units/gr/setup +NV_REPOSITORY_COMPONENTS += userspace/units/gr/fs_state NV_REPOSITORY_COMPONENTS += userspace/units/gr/intr NV_REPOSITORY_COMPONENTS += userspace/units/acr NV_REPOSITORY_COMPONENTS += userspace/units/cg diff --git a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export index fb3bb72d5..10846c711 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export @@ -223,6 +223,8 @@ nvgpu_gr_config_set_gpc_tpc_mask nvgpu_gr_config_get_gpc_tpc_mask nvgpu_gr_obj_ctx_is_golden_image_ready nvgpu_gr_ctx_get_tsgid +nvgpu_gr_get_config_ptr +nvgpu_gr_fs_state_init nvgpu_hr_timestamp nvgpu_init_ltc_support nvgpu_ltc_ecc_free diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources index eff14ed07..eb850d3ab 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -102,6 +102,7 @@ UNITS := \ $(UNIT_SRC)/gr/falcon \ $(UNIT_SRC)/gr/config \ $(UNIT_SRC)/gr/init \ + $(UNIT_SRC)/gr/fs_state \ $(UNIT_SRC)/gr/intr \ $(UNIT_SRC)/gr/setup \ $(UNIT_SRC)/acr \ diff --git a/userspace/SWUTS.h b/userspace/SWUTS.h index 5c5ca12ce..7ee065120 100644 --- a/userspace/SWUTS.h +++ b/userspace/SWUTS.h @@ -82,6 +82,7 @@ * - @ref SWUTS-gr-setup * - @ref SWUTS-gr-intr * - @ref SWUTS-gr-falcon + * - @ref SWUTS-gr-fs-state * - @ref SWUTS-gr-config * */ diff --git a/userspace/SWUTS.sources b/userspace/SWUTS.sources index 2adbde9c9..a121997c2 100644 --- a/userspace/SWUTS.sources +++ b/userspace/SWUTS.sources @@ -51,4 +51,5 @@ INPUT += ../../../userspace/units/gr/nvgpu-gr.h INPUT += ../../../userspace/units/gr/setup/nvgpu-gr-setup.h INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-intr.h INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-falcon.h +INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-fs-state.h INPUT += ../../../userspace/units/gr/config/nvgpu-gr-config.h diff --git a/userspace/required_tests.json b/userspace/required_tests.json index dfe501635..a1e324b02 100644 --- a/userspace/required_tests.json +++ b/userspace/required_tests.json @@ -1577,6 +1577,24 @@ "unit": "nvgpu_gr_setup", "test_level": 0 }, + { + "test": "test_gr_init_setup_ready", + "case": "gr_fs_state_setup", + "unit": "nvgpu_gr_fs_state", + "test_level": 0 + }, + { + "test": "test_gr_fs_state_error_injection", + "case": "gr_fs_state_error_injection", + "unit": "nvgpu_gr_fs_state", + "test_level": 0 + }, + { + "test": "test_gr_init_setup_cleanup", + "case": "gr_fs_state_cleanup", + "unit": "nvgpu_gr_fs_state", + "test_level": 0 + }, { "test": "test_nvgpu_mem_create_from_phys", "case": "mem_create_from_phys", diff --git a/userspace/units/gr/fs_state/Makefile b/userspace/units/gr/fs_state/Makefile new file mode 100644 index 000000000..88fd8f59f --- /dev/null +++ b/userspace/units/gr/fs_state/Makefile @@ -0,0 +1,33 @@ +# 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-gr-fs-state.o +MODULE = nvgpu-gr-fs-state + +LIB_PATHS += -lnvgpu-gr +include ../../Makefile.units + +lib$(MODULE).so: nvgpu-gr + +nvgpu-gr: + $(MAKE) -C .. + diff --git a/userspace/units/gr/fs_state/Makefile.interface.tmk b/userspace/units/gr/fs_state/Makefile.interface.tmk new file mode 100644 index 000000000..ed9f935d5 --- /dev/null +++ b/userspace/units/gr/fs_state/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=nvgpu-gr-fs-state + +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/gr/fs_state/Makefile.tmk b/userspace/units/gr/fs_state/Makefile.tmk new file mode 100644 index 000000000..52c9d2377 --- /dev/null +++ b/userspace/units/gr/fs_state/Makefile.tmk @@ -0,0 +1,40 @@ +################################### 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 = nvgpu-gr-fs-state +NVGPU_UNIT_SRCS = nvgpu-gr-fs-state.c + +NVGPU_UNIT_INTERFACE_DIRS := \ + $(NV_COMPONENT_DIR)/.. \ + $(NV_SOURCE)/kernel/nvgpu/drivers/gpu/nvgpu + +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/gr/fs_state/nvgpu-gr-fs-state.c b/userspace/units/gr/fs_state/nvgpu-gr-fs-state.c new file mode 100644 index 000000000..63310f433 --- /dev/null +++ b/userspace/units/gr/fs_state/nvgpu-gr-fs-state.c @@ -0,0 +1,81 @@ +/* + * 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 "common/gr/gr_priv.h" + +#include "../nvgpu-gr.h" +#include "nvgpu-gr-fs-state.h" + +int test_gr_fs_state_error_injection(struct unit_module *m, + struct gk20a *g, void *args) +{ + int err; + struct nvgpu_gr_config *config = nvgpu_gr_get_config_ptr(g); + struct nvgpu_posix_fault_inj *kmem_fi = + nvgpu_kmem_get_fault_injection(); + + /* Fail g->ops.gr.config.init_sm_id_table() */ + nvgpu_posix_enable_fault_injection(kmem_fi, true, 1); + err = nvgpu_gr_fs_state_init(g, config); + if (err == 0) { + return UNIT_FAIL; + } + + /* Fail gr_load_sm_id_config() */ + nvgpu_posix_enable_fault_injection(kmem_fi, true, 13); + err = nvgpu_gr_fs_state_init(g, config); + if (err == 0) { + return UNIT_FAIL; + } + + /* Passing case */ + nvgpu_posix_enable_fault_injection(kmem_fi, false, 0); + err = nvgpu_gr_fs_state_init(g, config); + if (err != 0) { + return UNIT_FAIL; + } + + return UNIT_SUCCESS; +} + +struct unit_module_test nvgpu_gr_fs_state_tests[] = { + UNIT_TEST(gr_fs_state_setup, test_gr_init_setup_ready, NULL, 0), + UNIT_TEST(gr_fs_state_error_injection, test_gr_fs_state_error_injection, NULL, 0), + UNIT_TEST(gr_fs_state_cleanup, test_gr_init_setup_cleanup, NULL, 0), +}; + +UNIT_MODULE(nvgpu_gr_fs_state, nvgpu_gr_fs_state_tests, UNIT_PRIO_NVGPU_TEST); diff --git a/userspace/units/gr/fs_state/nvgpu-gr-fs-state.h b/userspace/units/gr/fs_state/nvgpu-gr-fs-state.h new file mode 100644 index 000000000..e4573f6b4 --- /dev/null +++ b/userspace/units/gr/fs_state/nvgpu-gr-fs-state.h @@ -0,0 +1,70 @@ +/* + * 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_GR_FS_STATE_H +#define UNIT_NVGPU_GR_FS_STATE_H + +#include + +struct gk20a; +struct unit_module; + +/** @addtogroup SWUTS-gr-fs-state + * @{ + * + * Software Unit Test Specification for common.gr.fs_state + */ + +/** + * Test specification for: test_gr_fs_state_error_injection. + * + * Description: Verify error handling in #nvgpu_gr_fs_state_init() + * + * Test Type: Feature based, Error guessing. + * + * Targets: #nvgpu_gr_fs_state_init. + * + * Input: gr_fs_state_setup must have been executed successfully. + * + * Steps: + * - Negative tests. + * - Inject faults to trigger memory allocation failures in various + * functions called from #nvgpu_gr_fs_state_init. + * - Call #nvgpu_gr_fs_state_init and ensure that function returns + * error. + * + * - Positive test. + * - Disable all fault injections. + * - Call #nvgpu_gr_fs_state_init and ensure that function returns + * success. + * + * Output: Returns PASS if the steps above were executed successfully. FAIL + * otherwise. + */ +int test_gr_fs_state_error_injection(struct unit_module *m, + struct gk20a *g, void *args); + +#endif /* UNIT_NVGPU_GR_FS_STATE_H */ + +/** + * @} + */ +