diff --git a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export index 10846c711..362a56aa5 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export @@ -58,6 +58,8 @@ gp10b_get_device_info gp10b_is_engine_ce gp10b_priv_ring_isr gp10b_priv_ring_decode_error_code +gv100_dump_engine_status +gv100_read_engine_status_info gv11b_channel_count gv11b_channel_debug_dump gv11b_channel_read_state diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources index eb850d3ab..71739e79d 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -82,8 +82,9 @@ UNITS := \ $(UNIT_SRC)/fifo/channel/gk20a \ $(UNIT_SRC)/fifo/channel/gm20b \ $(UNIT_SRC)/fifo/channel/gv11b \ - $(UNIT_SRC)/fifo/engine \ $(UNIT_SRC)/fifo/pbdma \ + $(UNIT_SRC)/fifo/engine \ + $(UNIT_SRC)/fifo/engine/gv100 \ $(UNIT_SRC)/fifo/runlist \ $(UNIT_SRC)/fifo/runlist/gk20a \ $(UNIT_SRC)/fifo/runlist/gv11b \ diff --git a/userspace/SWUTS.h b/userspace/SWUTS.h index 7ee065120..fdf03f984 100644 --- a/userspace/SWUTS.h +++ b/userspace/SWUTS.h @@ -42,6 +42,7 @@ * - @ref SWUTS-fifo-channel-gm20b * - @ref SWUTS-fifo-channel-gv11b * - @ref SWUTS-fifo-engine + * - @ref SWUTS-fifo-engine-gv100 * - @ref SWUTS-fifo-pbdma * - @ref SWUTS-fifo-runlist * - @ref SWUTS-fifo-runlist-gk20a diff --git a/userspace/SWUTS.sources b/userspace/SWUTS.sources index a121997c2..cf5bd7f7c 100644 --- a/userspace/SWUTS.sources +++ b/userspace/SWUTS.sources @@ -12,6 +12,7 @@ INPUT += ../../../userspace/units/fifo/channel/gk20a/nvgpu-channel-gk20a.h INPUT += ../../../userspace/units/fifo/channel/gm20b/nvgpu-channel-gm20b.h INPUT += ../../../userspace/units/fifo/channel/gv11b/nvgpu-channel-gv11b.h INPUT += ../../../userspace/units/fifo/engine/nvgpu-engine.h +INPUT += ../../../userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.h INPUT += ../../../userspace/units/fifo/pbdma/nvgpu-pbdma.h INPUT += ../../../userspace/units/fifo/runlist/nvgpu-runlist.h INPUT += ../../../userspace/units/fifo/runlist/gk20a/nvgpu-runlist-gk20a.h diff --git a/userspace/units/fifo/engine/gv100/Makefile b/userspace/units/fifo/engine/gv100/Makefile new file mode 100644 index 000000000..02154bade --- /dev/null +++ b/userspace/units/fifo/engine/gv100/Makefile @@ -0,0 +1,32 @@ +# 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-engine-gv100.o +MODULE = nvgpu-engine-gv100 + +LIB_PATHS += -lnvgpu-fifo +include ../../../Makefile.units + +lib$(MODULE).so: fifo + +fifo: + $(MAKE) -C ../.. diff --git a/userspace/units/fifo/engine/gv100/Makefile.interface.tmk b/userspace/units/fifo/engine/gv100/Makefile.interface.tmk new file mode 100644 index 000000000..62add3403 --- /dev/null +++ b/userspace/units/fifo/engine/gv100/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-engine-gv100 + +include $(NV_SOURCE)/kernel/nvgpu/userspace/units/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/fifo/engine/gv100/Makefile.tmk b/userspace/units/fifo/engine/gv100/Makefile.tmk new file mode 100644 index 000000000..d9fca818d --- /dev/null +++ b/userspace/units/fifo/engine/gv100/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-engine-gv100 +NVGPU_UNIT_SRCS = nvgpu-engine-gv100.c + +NVGPU_UNIT_INTERFACE_DIRS := \ + $(NV_SOURCE)/kernel/nvgpu/userspace/units/fifo \ + $(NV_SOURCE)/kernel/nvgpu/drivers/gpu/nvgpu + +include $(NV_SOURCE)/kernel/nvgpu/userspace/units/Makefile.units.common.tmk + +# Local Variables: +# indent-tabs-mode: t +# tab-width: 8 +# End: +# vi: set tabstop=8 noexpandtab: diff --git a/userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.c b/userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.c new file mode 100644 index 000000000..4b8db8321 --- /dev/null +++ b/userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.c @@ -0,0 +1,167 @@ +/* + * 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 "hal/fifo/engine_status_gv100.h" + +#include + +#include "../../nvgpu-fifo.h" +#include "nvgpu-engine-gv100.h" + +//#define ENGINE_GV100_UNIT_DEBUG +#ifdef ENGINE_GV100_UNIT_DEBUG +#undef unit_verbose +#define unit_verbose unit_info +#else +#define unit_verbose(unit, msg, ...) \ + do { \ + if (0) { \ + unit_info(unit, msg, ##__VA_ARGS__); \ + } \ + } while (0) +#endif + +#define assert(cond) unit_assert(cond, goto done) + +#define branches_str test_fifo_flags_str +#define pruned test_fifo_subtest_pruned + +struct unit_ctx { + struct unit_module *m; + u32 engine_id; +}; + +struct unit_ctx unit_ctx; + +int test_gv100_read_engine_status_info(struct unit_module *m, + struct gk20a *g, void *args) +{ + u32 engine_id = nvgpu_engine_get_gr_id(g); + struct nvgpu_engine_status_info status; + int ret = UNIT_FAIL; + + /* gm20b_read_engine_status_info covered separately */ + + nvgpu_writel(g, fifo_engine_status_r(engine_id), 0); + gv100_read_engine_status_info(g, engine_id, &status); + assert(status.in_reload_status == false); + + nvgpu_writel(g, fifo_engine_status_r(engine_id), BIT(29)); + gv100_read_engine_status_info(g, engine_id, &status); + assert(status.in_reload_status == true); + + ret = UNIT_SUCCESS; +done: + return ret; +} + +#define F_ENGINE_DUMP_CTX_IS_TSG BIT(0) +#define F_ENGINE_DUMP_NEXT_CTX_IS_TSG BIT(1) +#define F_ENGINE_DUMP_IN_RELOAD_STATUS BIT(2) +#define F_ENGINE_DUMP_IS_FAULTED BIT(3) +#define F_ENGINE_DUMP_IS_BUSY BIT(4) +#define F_ENGINE_DUMP_LAST BIT(5) + +static u32 stub_get_litter_value(struct gk20a *g, int value) +{ + /* + * Pretend there are as many engines as possible branches. + * Each engine_id will cover one combination of branches. + */ + return F_ENGINE_DUMP_LAST; +} + +static void stub_read_engine_status_info(struct gk20a *g, u32 engine_id, + struct nvgpu_engine_status_info *status) +{ + u32 branches = engine_id; + + unit_verbose(unit_ctx.m, "engine_id=%u\n", engine_id); + + memset(status, 0, sizeof(*status)); + + status->ctx_id_type = branches & F_ENGINE_DUMP_CTX_IS_TSG ? + ENGINE_STATUS_CTX_ID_TYPE_TSGID : ENGINE_STATUS_CTX_ID_TYPE_CHID; + + status->ctx_next_id_type = branches & F_ENGINE_DUMP_NEXT_CTX_IS_TSG ? + ENGINE_STATUS_CTX_NEXT_ID_TYPE_TSGID : ENGINE_STATUS_CTX_NEXT_ID_TYPE_CHID; + + status->in_reload_status = branches & F_ENGINE_DUMP_IN_RELOAD_STATUS ? + true : false; + + status->is_faulted = branches & F_ENGINE_DUMP_IS_FAULTED ? + true : false; + + status->is_busy = branches & F_ENGINE_DUMP_IS_BUSY ? + true : false; + + unit_ctx.engine_id = engine_id; +} + +int test_gv100_dump_engine_status(struct unit_module *m, + struct gk20a *g, void *args) +{ + struct gpu_ops gops = g->ops; + struct nvgpu_debug_context o; + int ret = UNIT_FAIL; + u32 num_engines; + + unit_ctx.m = m; + + g->ops.get_litter_value = stub_get_litter_value; + num_engines = g->ops.get_litter_value(g, GPU_LIT_HOST_NUM_ENGINES); + unit_verbose(unit_ctx.m, "num_engines=%u\n", num_engines); + + g->ops.engine_status.read_engine_status_info = stub_read_engine_status_info; + + unit_ctx.engine_id = 0; + gv100_dump_engine_status(g, &o); + assert(unit_ctx.engine_id == (num_engines - 1)); + + ret = UNIT_SUCCESS; +done: + g->ops = gops; + return ret; +} + +struct unit_module_test nvgpu_engine_gv100_tests[] = { + UNIT_TEST(init_support, test_fifo_init_support, NULL, 0), + UNIT_TEST(read_engine_status_info, test_gv100_read_engine_status_info, NULL, 0), + UNIT_TEST(dump_engine_status_info, test_gv100_dump_engine_status, NULL, 0), + UNIT_TEST(remove_support, test_fifo_remove_support, NULL, 0), +}; + +UNIT_MODULE(nvgpu_engine_gv100, nvgpu_engine_gv100_tests, UNIT_PRIO_NVGPU_TEST); diff --git a/userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.h b/userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.h new file mode 100644 index 000000000..8d7849ab5 --- /dev/null +++ b/userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.h @@ -0,0 +1,82 @@ +/* + * 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_ENGINE_GV100_H +#define UNIT_NVGPU_ENGINE_GV100_H + +#include + +struct unit_module; +struct gk20a; + +/** @addtogroup SWUTS-fifo-engine-gv100 + * @{ + * + * Software Unit Test Specification for fifo/engine/gv100 + */ + +/** + * Test specification for: test_gv100_read_engine_status_info + * + * Description: Branch coverage for gv100_read_engine_status_info + * + * Test Type: Feature based + * + * Input: test_fifo_init_support() run for this GPU + * + * Steps: + * - Check that status.in_reload_status field is consistent with + * fifo_engine_status_eng_reload_f bit of fifo_engine_status_r H/W register. + * - Other bits tested in a separate test for gm20b_read_engine_status_info. + * + * Output: Returns PASS if all branches gave expected results. FAIL otherwise. + */ +int test_gv100_read_engine_status_info(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for: test_gv100_dump_engine_status + * + * Description: Branch coverage for gv100_dump_engine_status + * + * Test Type: Feature based + * + * Input: test_fifo_init_support() run for this GPU + * + * Steps: + * - Check dumping of engine status, with combinations of: + * - ctx_id_type is TSG/channel. + * - ctx_next_id_tupe is TSG/channel. + * - in_reload_status is true/false. + * - is_faulted is true/false. + * - is_busy is true/false. + * Check number that read_engine_status_info was (num_engines - 1) times. + * + * Output: Returns PASS if all branches gave expected results. FAIL otherwise. + */ +int test_gv100_dump_engine_status(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * @} + */ + +#endif /* UNIT_NVGPU_ENGINE_GV100_H */