From ac8afda036b0c46f64b0e260e4646655355fb6cc Mon Sep 17 00:00:00 2001 From: vinodg Date: Mon, 26 Aug 2019 21:47:11 -0700 Subject: [PATCH] gpu: nvgpu: unit: add gr_prepare tests Add support gr_prepare for sw and hw. Add needed registers using nvgpu_posix_io_add_reg_space calls. Add unit tests covering following functions nvgpu_gr_prepare_sw nvgpu_gr_enable_hw Copy the falcon ucode binaries under userspace/firmware directory install-unit.sh modified to copy the firmware binaries under nvgpu-unnit/firmware directory Jira NVGPU-3582 Change-Id: If2131d2c48e828251208da86688b0594e62de82e Signed-off-by: vinodg Reviewed-on: https://git-master.nvidia.com/r/2184293 Reviewed-by: Deepak Nibade GVS: Gerrit_Virtual_Submit Reviewed-by: mobile promotions Tested-by: mobile promotions --- Makefile.umbrella.tmk | 1 + drivers/gpu/nvgpu/libnvgpu-drv_safe.export | 2 + userspace/Makefile.sources | 7 +- userspace/firmware/NETD_img.bin | Bin 0 -> 78184 bytes userspace/firmware/fecs.bin | Bin 0 -> 528 bytes userspace/firmware/gpccs.bin | Bin 0 -> 528 bytes userspace/install-unit.sh | 2 + userspace/required_tests.json | 35 ++++++--- userspace/units/gr/init/Makefile | 33 +++++++++ .../units/gr/init/Makefile.interface.tmk | 35 +++++++++ userspace/units/gr/init/Makefile.tmk | 40 ++++++++++ userspace/units/gr/init/nvgpu-gr-init.c | 43 +++++++++++ userspace/units/gr/libnvgpu-gr.export | 1 + userspace/units/gr/nvgpu-gr-gv11b.c | 70 +++++++++++++++++- userspace/units/gr/nvgpu-gr.c | 22 ++++++ userspace/units/gr/nvgpu-gr.h | 3 +- 16 files changed, 279 insertions(+), 15 deletions(-) create mode 100755 userspace/firmware/NETD_img.bin create mode 100644 userspace/firmware/fecs.bin create mode 100644 userspace/firmware/gpccs.bin create mode 100644 userspace/units/gr/init/Makefile create mode 100644 userspace/units/gr/init/Makefile.interface.tmk create mode 100644 userspace/units/gr/init/Makefile.tmk create mode 100644 userspace/units/gr/init/nvgpu-gr-init.c diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index a63cc4e40..a19dea61c 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -71,6 +71,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/falcon/falcon_tests NV_REPOSITORY_COMPONENTS += userspace/units/pmu NV_REPOSITORY_COMPONENTS += userspace/units/gr NV_REPOSITORY_COMPONENTS += userspace/units/gr/config +NV_REPOSITORY_COMPONENTS += userspace/units/gr/init endif # Local Variables: diff --git a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export index fd6775816..9b2342b9e 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export @@ -91,6 +91,8 @@ nvgpu_gr_config_get_sm_info_sm_index nvgpu_gr_config_set_gpc_tpc_mask nvgpu_gr_config_get_gpc_tpc_mask nvgpu_can_busy +nvgpu_gr_prepare_sw +nvgpu_gr_enable_hw nvgpu_channel_alloc_inst nvgpu_channel_cleanup_sw nvgpu_channel_close diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources index 975f2ecec..2b04e7930 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -71,11 +71,12 @@ UNITS := \ $(UNIT_SRC)/fifo/tsg \ $(UNIT_SRC)/list \ $(UNIT_SRC)/enabled \ - $(UNIT_SRC)/gr \ - $(UNIT_SRC)/gr/config \ $(UNIT_SRC)/falcon \ $(UNIT_SRC)/falcon/falcon_tests \ - $(UNIT_SRC)/pmu + $(UNIT_SRC)/pmu \ + $(UNIT_SRC)/gr \ + $(UNIT_SRC)/gr/config \ + $(UNIT_SRC)/gr/init ifeq ($(CONFIG_NVGPU_HAL_NON_FUSA),1) UNITS += $(UNIT_SRC)/fuse diff --git a/userspace/firmware/NETD_img.bin b/userspace/firmware/NETD_img.bin new file mode 100755 index 0000000000000000000000000000000000000000..f80194cab46f75d16e8b1dc5b69cc5dce529eeaa GIT binary patch literal 78184 zcmeIuF#!Mo0K%a4Pwiz3h(KY$fB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM z7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b* z1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd z0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwA zz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEj zFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r z3>YwAz<>b*1`HT5V8DO@0|pEjFkrxd0RsjM7%*VKfB^#r3>YwAz<>b*1`K>)F?Rp~ literal 0 HcmV?d00001 diff --git a/userspace/firmware/fecs.bin b/userspace/firmware/fecs.bin new file mode 100644 index 0000000000000000000000000000000000000000..2e3e996bb70b55be8594e2847f4344d46c7e22c4 GIT binary patch literal 528 PcmZQz7zLvtfCvEq0uTTJ literal 0 HcmV?d00001 diff --git a/userspace/firmware/gpccs.bin b/userspace/firmware/gpccs.bin new file mode 100644 index 0000000000000000000000000000000000000000..2e3e996bb70b55be8594e2847f4344d46c7e22c4 GIT binary patch literal 528 PcmZQz7zLvtfCvEq0uTTJ literal 0 HcmV?d00001 diff --git a/userspace/install-unit.sh b/userspace/install-unit.sh index 6a28b889f..be2a59b8c 100755 --- a/userspace/install-unit.sh +++ b/userspace/install-unit.sh @@ -103,6 +103,7 @@ fi # Building the necessary directory structure. It may not be present # first time this is run. ssh $target mkdir -p nvgpu_unit/units +ssh $target mkdir -p nvgpu_unit/firmware ssh $target mkdir -p $TOP/kernel if [ $? != 0 ]; then echo @@ -121,6 +122,7 @@ jcp $TOP/kernel/nvgpu/userspace/gcov.sh nvgpu_unit/gcov.sh jcp $TOP/kernel/nvgpu/userspace/testlist.py nvgpu_unit/testlist.py jcp $TOP/kernel/nvgpu/userspace/required_tests.json \ nvgpu_unit/required_tests.json +jcp $TOP/kernel/nvgpu/userspace/firmware/ nvgpu_unit/firmware/ find $nvgpu_bins/userspace/units -name "*.so" -not -path "*unit.so" \ -not -path "*drv.so" -exec ls {} \; | while read unit_so ; do diff --git a/userspace/required_tests.json b/userspace/required_tests.json index 77750908a..9a24bff92 100644 --- a/userspace/required_tests.json +++ b/userspace/required_tests.json @@ -1373,16 +1373,6 @@ "test_level": 0, "unit": "nvgpu-pmu" }, - { - "test": "init_support", - "test_level": 0, - "unit": "nvgpu_gr_config" - }, - { - "test": "config_init", - "test_level": 0, - "unit": "nvgpu_gr_config" - }, { "test": "config_check_init", "test_level": 0, @@ -1398,9 +1388,34 @@ "test_level": 0, "unit": "nvgpu_gr_config" }, + { + "test": "config_init", + "test_level": 0, + "unit": "nvgpu_gr_config" + }, + { + "test": "init_support", + "test_level": 0, + "unit": "nvgpu_gr_config" + }, { "test": "remove_support", "test_level": 0, "unit": "nvgpu_gr_config" + }, + { + "test": "init_prepare", + "test_level": 0, + "unit": "nvgpu_gr_init" + }, + { + "test": "init_support", + "test_level": 0, + "unit": "nvgpu_gr_init" + }, + { + "test": "remove_support", + "test_level": 0, + "unit": "nvgpu_gr_init" } ] diff --git a/userspace/units/gr/init/Makefile b/userspace/units/gr/init/Makefile new file mode 100644 index 000000000..060c352ea --- /dev/null +++ b/userspace/units/gr/init/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-init.o +MODULE = nvgpu-gr-init + +LIB_PATHS += -lnvgpu-gr +include ../../Makefile.units + +lib$(MODULE).so: nvgpu-gr + +nvgpu-gr: + $(MAKE) -C .. + diff --git a/userspace/units/gr/init/Makefile.interface.tmk b/userspace/units/gr/init/Makefile.interface.tmk new file mode 100644 index 000000000..a7a204f46 --- /dev/null +++ b/userspace/units/gr/init/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-init + +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/init/Makefile.tmk b/userspace/units/gr/init/Makefile.tmk new file mode 100644 index 000000000..21366ed6d --- /dev/null +++ b/userspace/units/gr/init/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-init +NVGPU_UNIT_SRCS = nvgpu-gr-init.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/init/nvgpu-gr-init.c b/userspace/units/gr/init/nvgpu-gr-init.c new file mode 100644 index 000000000..358e79906 --- /dev/null +++ b/userspace/units/gr/init/nvgpu-gr-init.c @@ -0,0 +1,43 @@ +/* + * 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 "common/gr/gr_priv.h" + +#include "../nvgpu-gr.h" + +struct unit_module_test nvgpu_gr_init_tests[] = { + UNIT_TEST(init_support, test_gr_init_support, NULL, 0), + UNIT_TEST(init_prepare, test_gr_init_prepare, NULL, 0), + UNIT_TEST(remove_support, test_gr_remove_support, NULL, 0), +}; + +UNIT_MODULE(nvgpu_gr_init, nvgpu_gr_init_tests, UNIT_PRIO_NVGPU_TEST); diff --git a/userspace/units/gr/libnvgpu-gr.export b/userspace/units/gr/libnvgpu-gr.export index aed6e7b85..f11302967 100644 --- a/userspace/units/gr/libnvgpu-gr.export +++ b/userspace/units/gr/libnvgpu-gr.export @@ -22,4 +22,5 @@ test_gr_init_support test_gr_remove_support +test_gr_init_prepare diff --git a/userspace/units/gr/nvgpu-gr-gv11b.c b/userspace/units/gr/nvgpu-gr-gv11b.c index df042b633..1dd77fe1b 100644 --- a/userspace/units/gr/nvgpu-gr-gv11b.c +++ b/userspace/units/gr/nvgpu-gr-gv11b.c @@ -39,6 +39,7 @@ #include "nvgpu-gr-gv11b.h" #include "nvgpu-gr-gv11b-regs.h" +#define NV_PBB_FBHUB_REGSPACE 0x100B00 /* * Mock I/O */ @@ -132,6 +133,56 @@ int test_gr_setup_gv11b_reg_space(struct unit_module *m, struct gk20a *g) goto clean_up_pes_tpc_mask; } + /* + * GPCS_SWDX reg space + * + */ + if (nvgpu_posix_io_add_reg_space(g, + gr_gpcs_swdx_dss_zbc_color_r_r(0), 0xEFF) != 0) { + unit_err(m, "Add gpcs swdx reg space failed!\n"); + goto clean_up_fs_space; + } + + /* + * PRI_GPCS_GCC reg space + * + */ + if (nvgpu_posix_io_add_reg_space(g, + gr_pri_gpcs_gcc_dbg_r(), 0x60) != 0) { + unit_err(m, "Add gpcs swdx reg space failed!\n"); + goto clean_up_swdx_space; + } + + /* + * PRI_GPCS_TPCS reg space + * + */ + if (nvgpu_posix_io_add_reg_space(g, + gr_gpcs_tpcs_pe_vaf_r(), 0x7FF) != 0) { + unit_err(m, "Add gpcs swdx reg space failed!\n"); + goto clean_up_gcc_space; + } + + /* + * PRI_GPCS_PPCS reg space + * + */ + if (nvgpu_posix_io_add_reg_space(g, + gr_gpcs_tpcs_pes_vsc_vpc_r(), 0x1FF) != 0) { + unit_err(m, "Add gpcs swdx reg space failed!\n"); + goto clean_up_gcc_tpcs_space; + } + + /* + * FB partition reg space + * + */ + if (nvgpu_posix_io_add_reg_space(g, + NV_PBB_FBHUB_REGSPACE, 0x1FF) != 0) { + unit_err(m, "Add gpcs swdx reg space failed!\n"); + goto clean_up_gcc_ppcs_space; + } + /* * MC register mc_enable_r() is set during gr_init_prepare_hw hence * add it to reg space @@ -139,13 +190,25 @@ int test_gr_setup_gv11b_reg_space(struct unit_module *m, struct gk20a *g) if (nvgpu_posix_io_add_reg_space(g, mc_enable_r(), 0x4) != 0) { unit_err(m, "Add mc enable reg space failed!\n"); - goto clean_up_priv_ring; + goto clean_up_fbhub_space; } (void)nvgpu_posix_register_io(g, &gr_test_reg_callbacks); return 0; +clean_up_fbhub_space: + nvgpu_posix_io_delete_reg_space(g, NV_PBB_FBHUB_REGSPACE); +clean_up_gcc_ppcs_space: + nvgpu_posix_io_delete_reg_space(g, gr_gpcs_tpcs_pes_vsc_vpc_r()); +clean_up_gcc_tpcs_space: + nvgpu_posix_io_delete_reg_space(g, gr_gpcs_tpcs_pe_vaf_r()); +clean_up_gcc_space: + nvgpu_posix_io_delete_reg_space(g, gr_pri_gpcs_gcc_dbg_r()); +clean_up_swdx_space: + nvgpu_posix_io_delete_reg_space(g, gr_gpcs_swdx_dss_zbc_color_r_r(0)); +clean_up_fs_space: + nvgpu_posix_io_unregister_reg_space(g, &gv11b_gr_fs_reg_space); clean_up_pes_tpc_mask: nvgpu_posix_io_unregister_reg_space(g, &gv11b_gr_pes_tpc_mask_reg_space); clean_up_priv_ring: @@ -164,6 +227,11 @@ clean_up_master: void test_gr_cleanup_gv11b_reg_space(struct unit_module *m, struct gk20a *g) { + nvgpu_posix_io_delete_reg_space(g, NV_PBB_FBHUB_REGSPACE); + nvgpu_posix_io_delete_reg_space(g, gr_gpcs_tpcs_pes_vsc_vpc_r()); + nvgpu_posix_io_delete_reg_space(g, gr_gpcs_tpcs_pe_vaf_r()); + nvgpu_posix_io_delete_reg_space(g, gr_pri_gpcs_gcc_dbg_r()); + nvgpu_posix_io_delete_reg_space(g, gr_gpcs_swdx_dss_zbc_color_r_r(0)); nvgpu_posix_io_unregister_reg_space(g, &gv11b_top_reg_space); nvgpu_posix_io_unregister_reg_space(g, &gv11b_master_reg_space); nvgpu_posix_io_unregister_reg_space(g, &gv11b_fuse_reg_space); diff --git a/userspace/units/gr/nvgpu-gr.c b/userspace/units/gr/nvgpu-gr.c index 44bc97365..cdc444d8f 100644 --- a/userspace/units/gr/nvgpu-gr.c +++ b/userspace/units/gr/nvgpu-gr.c @@ -61,9 +61,31 @@ fail: return UNIT_FAIL; } +int test_gr_init_prepare(struct unit_module *m, struct gk20a *g, void *args) +{ + int err; + + err = nvgpu_gr_prepare_sw(g); + if (err) { + goto prep_fail; + } + + err = nvgpu_gr_enable_hw(g); + if (err) { + goto prep_fail; + } + + return UNIT_SUCCESS; + +prep_fail: + return UNIT_FAIL; + +} + int test_gr_remove_support(struct unit_module *m, struct gk20a *g, void *args) { + test_gr_cleanup_gv11b_reg_space(m, g); nvgpu_gr_free(g); return UNIT_SUCCESS; diff --git a/userspace/units/gr/nvgpu-gr.h b/userspace/units/gr/nvgpu-gr.h index ab14a134f..965494a3b 100644 --- a/userspace/units/gr/nvgpu-gr.h +++ b/userspace/units/gr/nvgpu-gr.h @@ -39,5 +39,6 @@ int test_gr_init_support(struct unit_module *m, struct gk20a *g, void *args); int test_gr_remove_support(struct unit_module *m, struct gk20a *g, void *args); - +int test_gr_init_prepare(struct unit_module *m, + struct gk20a *g, void *args); #endif /* UNIT_NVGPU_GR_H */