diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index 59f877c3e..a1c47457f 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -69,6 +69,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/netlist NV_REPOSITORY_COMPONENTS += userspace/units/fifo NV_REPOSITORY_COMPONENTS += userspace/units/fifo/channel NV_REPOSITORY_COMPONENTS += userspace/units/fifo/runlist +NV_REPOSITORY_COMPONENTS += userspace/units/fifo/runlist/gv11b NV_REPOSITORY_COMPONENTS += userspace/units/fifo/tsg NV_REPOSITORY_COMPONENTS += userspace/units/fifo/tsg/gv11b NV_REPOSITORY_COMPONENTS += userspace/units/fuse diff --git a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export index 8d853b499..c9e297d24 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export @@ -45,6 +45,9 @@ gv11b_mm_l2_flush gv11b_mm_mmu_fault_disable_hw gv11b_mm_mmu_fault_info_mem_destroy gv11b_mc_is_mmu_fault_pending +gv11b_runlist_entry_size +gv11b_runlist_get_tsg_entry +gv11b_runlist_get_ch_entry gv11b_slcg_bus_gating_prod_size gv11b_slcg_bus_get_gating_prod gv11b_slcg_ce2_gating_prod_size diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources index 6bf9d1a5e..c7ba3f43f 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -80,6 +80,7 @@ UNITS := \ $(UNIT_SRC)/fifo/channel/gm20b \ $(UNIT_SRC)/fifo/channel/gv11b \ $(UNIT_SRC)/fifo/runlist \ + $(UNIT_SRC)/fifo/runlist/gv11b \ $(UNIT_SRC)/fifo/tsg \ $(UNIT_SRC)/fifo/tsg/gv11b \ $(UNIT_SRC)/list \ diff --git a/userspace/SWUTS.h b/userspace/SWUTS.h index 84ece4d14..9809099c0 100644 --- a/userspace/SWUTS.h +++ b/userspace/SWUTS.h @@ -39,6 +39,7 @@ * - @ref SWUTS-fifo * - @ref SWUTS-fifo-channel * - @ref SWUTS-fifo-runlist + * - @ref SWUTS-fifo-runlist-gv11b * - @ref SWUTS-fifo-tsg * - @ref SWUTS-fifo-tsg-gv11b * - @ref SWUTS-init diff --git a/userspace/SWUTS.sources b/userspace/SWUTS.sources index 94a3aaa86..835542148 100644 --- a/userspace/SWUTS.sources +++ b/userspace/SWUTS.sources @@ -12,6 +12,7 @@ INPUT += ../../../userspace/units/fifo/channel/nvgpu-channel-gk20a.h INPUT += ../../../userspace/units/fifo/channel/nvgpu-channel-gm20b.h INPUT += ../../../userspace/units/fifo/channel/nvgpu-channel-gv11b.h INPUT += ../../../userspace/units/fifo/runlist/nvgpu-runlist.h +INPUT += ../../../userspace/units/fifo/runlist/nvgpu-runlist-gv11b.h INPUT += ../../../userspace/units/fifo/tsg/nvgpu-tsg.h INPUT += ../../../userspace/units/fifo/tsg/gv11b/nvgpu-tsg-gv11b.h INPUT += ../../../userspace/units/fuse/nvgpu-fuse.h diff --git a/userspace/units/fifo/runlist/gv11b/Makefile b/userspace/units/fifo/runlist/gv11b/Makefile new file mode 100644 index 000000000..0167a587e --- /dev/null +++ b/userspace/units/fifo/runlist/gv11b/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-runlist-gv11b.o +MODULE = nvgpu-runlist-gv11b + +LIB_PATHS += -lnvgpu-fifo +include ../../../Makefile.units + +lib$(MODULE).so: fifo + +fifo: + $(MAKE) -C ../.. diff --git a/userspace/units/fifo/runlist/gv11b/Makefile.interface.tmk b/userspace/units/fifo/runlist/gv11b/Makefile.interface.tmk new file mode 100644 index 000000000..0dddca302 --- /dev/null +++ b/userspace/units/fifo/runlist/gv11b/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-runlist-gv11b + +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/runlist/gv11b/Makefile.tmk b/userspace/units/fifo/runlist/gv11b/Makefile.tmk new file mode 100644 index 000000000..eb96ed284 --- /dev/null +++ b/userspace/units/fifo/runlist/gv11b/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-runlist-gv11b +NVGPU_UNIT_SRCS = nvgpu-runlist-gv11b.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/runlist/gv11b/nvgpu-runlist-gv11b.c b/userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.c new file mode 100644 index 000000000..a61279331 --- /dev/null +++ b/userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.c @@ -0,0 +1,159 @@ +/* + * 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 + +#include "common/gr/ctx_priv.h" +#include + +#include "hal/fifo/runlist_ram_gv11b.h" + +#include + + +#include "../../nvgpu-fifo.h" +#include "nvgpu-runlist-gv11b.h" + +#define RUNLIST_GV11B_UNIT_DEBUG +#ifdef RUNLIST_GV11B_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) + +int test_gv11b_runlist_entry_size(struct unit_module *m, + struct gk20a *g, void *args) +{ + int ret = UNIT_FAIL; + + assert(gv11b_runlist_entry_size(g) == ram_rl_entry_size_v()); + ret = UNIT_SUCCESS; +done: + return ret; +} + +#define RL_MAX_TIMESLICE_TIMEOUT ram_rl_entry_tsg_timeslice_timeout_v(U32_MAX) +#define RL_MAX_TIMESLICE_SCALE ram_rl_entry_tsg_timeslice_scale_v(U32_MAX) + +int test_gv11b_runlist_get_tsg_entry(struct unit_module *m, + struct gk20a *g, void *args) +{ + struct nvgpu_tsg *tsg = NULL; + int ret = UNIT_FAIL; + u32 timeslice; + u32 runlist[4]; + + tsg = nvgpu_tsg_open(g, getpid()); + assert(tsg != NULL); + + /* no scaling */ + timeslice = RL_MAX_TIMESLICE_TIMEOUT / 2; + gv11b_runlist_get_tsg_entry(tsg, runlist, timeslice); + assert(ram_rl_entry_tsg_timeslice_timeout_v(runlist[0]) == timeslice); + assert(ram_rl_entry_tsg_timeslice_scale_v(runlist[0]) == 0U); + assert(runlist[1] == ram_rl_entry_tsg_length_f(tsg->num_active_channels)); + assert(runlist[2] == ram_rl_entry_tsg_tsgid_f(tsg->tsgid)); + + /* scaling */ + timeslice = RL_MAX_TIMESLICE_TIMEOUT + 1; + gv11b_runlist_get_tsg_entry(tsg, runlist, timeslice); + assert(ram_rl_entry_tsg_timeslice_timeout_v(runlist[0]) == (timeslice >> 1U)); + assert(ram_rl_entry_tsg_timeslice_scale_v(runlist[0]) == 1U); + + /* oversize */ + timeslice = U32_MAX; + gv11b_runlist_get_tsg_entry(tsg, runlist, timeslice); + assert(ram_rl_entry_tsg_timeslice_timeout_v(runlist[0]) == RL_MAX_TIMESLICE_TIMEOUT); + assert(ram_rl_entry_tsg_timeslice_scale_v(runlist[0]) == RL_MAX_TIMESLICE_SCALE); + + ret = UNIT_SUCCESS; + +done: + if (tsg != NULL) { + nvgpu_ref_put(&tsg->refcount, nvgpu_tsg_release); + } + return ret; +} + +int test_gv11b_runlist_get_ch_entry(struct unit_module *m, + struct gk20a *g, void *args) +{ + struct nvgpu_channel *ch = NULL; + int ret = UNIT_FAIL; + u32 runlist[4]; + struct nvgpu_mem mem; + + ch = nvgpu_channel_open_new(g, NVGPU_INVALID_RUNLIST_ID, + false, getpid(), getpid()); + assert(ch); + + ch->userd_mem = &mem; + mem.aperture = APERTURE_SYSMEM; + ch->userd_iova = 0x1000beef; + + gv11b_runlist_get_ch_entry(ch, runlist); + assert(runlist[1] == u64_hi32(ch->userd_iova)); + assert(ram_rl_entry_chid_f(runlist[2]) == ch->chid); + assert(runlist[3] == u64_hi32(nvgpu_inst_block_addr(g, &ch->inst_block))); + + ch->userd_mem = NULL; + + ret = UNIT_SUCCESS; + +done: + if (ch != NULL) { + nvgpu_channel_close(ch); + } + return ret; +} + +struct unit_module_test nvgpu_runlist_gv11b_tests[] = { + UNIT_TEST(init_support, test_fifo_init_support, NULL, 0), + UNIT_TEST(entry_size, test_gv11b_runlist_entry_size, NULL, 0), + UNIT_TEST(get_tsg_entry, test_gv11b_runlist_get_tsg_entry, NULL, 0), + UNIT_TEST(get_ch_entry, test_gv11b_runlist_get_ch_entry, NULL, 0), + UNIT_TEST(remove_support, test_fifo_remove_support, NULL, 0), +}; + +UNIT_MODULE(nvgpu_runlist_gv11b, nvgpu_runlist_gv11b_tests, UNIT_PRIO_NVGPU_TEST); diff --git a/userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.h b/userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.h new file mode 100644 index 000000000..631a785d0 --- /dev/null +++ b/userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.h @@ -0,0 +1,98 @@ +/* + * 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_RUNLIST_GV11B_H +#define UNIT_NVGPU_RUNLIST_GV11B_H + +#include + +struct unit_module; +struct gk20a; + +/** @addtogroup SWUTS-fifo-runlist-gv11b + * @{ + * + * Software Unit Test Specification for fifo/runlist/gv11b + */ + +/** + * Test specification for: test_gv11b_runlist_entry_size + * + * Description: Branch coverage for gv11b_runlist_entry_size + * + * Test Type: Feature based + * + * Input: test_fifo_init_support() run for this GPU + * + * Steps: + * - Check that runlist entry size matches the H/W manuals + * + * Output: Returns PASS if all branches gave expected results. FAIL otherwise. + */ +int test_gv11b_runlist_entry_size(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for: test_gv11b_runlist_get_tsg_entry + * + * Description: Branch coverage for gv11b_runlist_get_tsg_entry + * + * Test Type: Feature based + * + * Input: test_fifo_init_support() run for this GPU + * + * Steps: + * - Allocate TSG. + * - Get runlist entry with timeslice that does not need scaling + * - Check timeout and scale in returned runlist entry + * - Check length and tsgid as well + * - Get runlist entry with a timeslice that needs scaling + * - Get runlist entry with an oversize timeslice + * + * Output: Returns PASS if all branches gave expected results. FAIL otherwise. + */ +int test_gv11b_runlist_get_tsg_entry(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * Test specification for: test_gv11b_runlist_get_ch_entry + * + * Description: Branch coverage for gv11b_runlist_get_ch_entry + * + * Test Type: Feature based + * + * Input: test_fifo_init_support() run for this GPU + * + * Steps: + * - Allocate channel. + * - Get runlist entry for the channel. + * - Check userd and inst block addr in returned runlist entry. + * + * Output: Returns PASS if all branches gave expected results. FAIL otherwise. + */ +int test_gv11b_runlist_get_ch_entry(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * @} + */ + +#endif /* UNIT_NVGPU_RUNLIST_GV11B_H */