From 63de725df9bc24bf51fb7bf201f89bcfa9735f00 Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Tue, 3 Dec 2019 14:46:57 -0500 Subject: [PATCH] gpu: nvgpu: unit: add tests for usermode gv11b HAL Add unit tests for the following usermode HALs: - gv11b_usermode_base - gv11b_usermode_bus_base - gv11b_usermode_doorbell_token - gv11b_usermode_ring_doorbell Jira NVGPU-4389 Change-Id: I7fdad23b0482c1437d309e8eeab239aad1fb5c99 Signed-off-by: Thomas Fleury Reviewed-on: https://git-master.nvidia.com/r/2254548 Reviewed-by: mobile promotions Tested-by: mobile promotions --- Makefile.umbrella.tmk | 1 + drivers/gpu/nvgpu/libnvgpu-drv_safe.export | 4 + userspace/Makefile.sources | 1 + userspace/SWUTS.h | 1 + userspace/SWUTS.sources | 1 + userspace/required_tests.json | 18 +++ userspace/units/fifo/usermode/gv11b/Makefile | 32 ++++++ .../usermode/gv11b/Makefile.interface.tmk | 35 ++++++ .../units/fifo/usermode/gv11b/Makefile.tmk | 40 +++++++ .../usermode/gv11b/nvgpu-usermode-gv11b.c | 103 ++++++++++++++++++ .../usermode/gv11b/nvgpu-usermode-gv11b.h | 61 +++++++++++ 11 files changed, 297 insertions(+) create mode 100644 userspace/units/fifo/usermode/gv11b/Makefile create mode 100644 userspace/units/fifo/usermode/gv11b/Makefile.interface.tmk create mode 100644 userspace/units/fifo/usermode/gv11b/Makefile.tmk create mode 100644 userspace/units/fifo/usermode/gv11b/nvgpu-usermode-gv11b.c create mode 100644 userspace/units/fifo/usermode/gv11b/nvgpu-usermode-gv11b.h diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index 51c2764bb..73065a342 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -86,6 +86,7 @@ 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/fifo/userd/gk20a +NV_REPOSITORY_COMPONENTS += userspace/units/fifo/usermode/gv11b NV_REPOSITORY_COMPONENTS += userspace/units/fuse NV_REPOSITORY_COMPONENTS += userspace/units/list NV_REPOSITORY_COMPONENTS += userspace/units/ltc diff --git a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export index 010264cb1..13baad4de 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export @@ -88,6 +88,10 @@ gv11b_mc_is_mmu_fault_pending gv11b_runlist_entry_size gv11b_runlist_get_tsg_entry gv11b_runlist_get_ch_entry +gv11b_usermode_base +gv11b_usermode_bus_base +gv11b_usermode_doorbell_token +gv11b_usermode_ring_doorbell gv11b_class_is_valid_compute gv11b_class_is_valid gv11b_slcg_bus_gating_prod_size diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources index e2465835b..c8934ad58 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -94,6 +94,7 @@ UNITS := \ $(UNIT_SRC)/fifo/tsg \ $(UNIT_SRC)/fifo/tsg/gv11b \ $(UNIT_SRC)/fifo/userd/gk20a \ + $(UNIT_SRC)/fifo/usermode/gv11b \ $(UNIT_SRC)/list \ $(UNIT_SRC)/ltc \ $(UNIT_SRC)/enabled \ diff --git a/userspace/SWUTS.h b/userspace/SWUTS.h index f1bfeab3a..28671dd8d 100644 --- a/userspace/SWUTS.h +++ b/userspace/SWUTS.h @@ -53,6 +53,7 @@ * - @ref SWUTS-fifo-tsg * - @ref SWUTS-fifo-tsg-gv11b * - @ref SWUTS-fifo-userd-gk20a + * - @ref SWUTS-fifo-usermode-gv11b * - @ref SWUTS-init * - @ref SWUTS-interface-atomic * - @ref SWUTS-ltc diff --git a/userspace/SWUTS.sources b/userspace/SWUTS.sources index 22e900191..7bc6b1d72 100644 --- a/userspace/SWUTS.sources +++ b/userspace/SWUTS.sources @@ -23,6 +23,7 @@ INPUT += ../../../userspace/units/fifo/runlist/gv11b/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/fifo/userd/gk20a/nvgpu-userd-gk20a.h +INPUT += ../../../userspace/units/fifo/userd/gv11b/nvgpu-usermode-gv11b.h INPUT += ../../../userspace/units/fuse/nvgpu-fuse.h INPUT += ../../../userspace/units/fuse/nvgpu-fuse-gm20b.h INPUT += ../../../userspace/units/fuse/nvgpu-fuse-gp10b.h diff --git a/userspace/required_tests.json b/userspace/required_tests.json index c04ff1477..19413e881 100644 --- a/userspace/required_tests.json +++ b/userspace/required_tests.json @@ -2111,6 +2111,24 @@ "unit": "nvgpu_userd_gk20a", "test_level": 0 }, + { + "test": "test_fifo_init_support", + "case": "init_support", + "unit": "nvgpu_usermode_gv11b", + "test_level": 0 + }, + { + "test": "test_fifo_remove_support", + "case": "remove_support", + "unit": "nvgpu_usermode_gv11b", + "test_level": 0 + }, + { + "test": "test_gv11b_usermode", + "case": "usermode", + "unit": "nvgpu_usermode_gv11b", + "test_level": 0 + }, { "test": "test_nvgpu_gmmu_clean", "case": "gmmu_clean", diff --git a/userspace/units/fifo/usermode/gv11b/Makefile b/userspace/units/fifo/usermode/gv11b/Makefile new file mode 100644 index 000000000..3ab647621 --- /dev/null +++ b/userspace/units/fifo/usermode/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-usermode-gv11b.o +MODULE = nvgpu-usermode-gv11b + +LIB_PATHS += -lnvgpu-fifo +include ../../../Makefile.units + +lib$(MODULE).so: fifo + +fifo: + $(MAKE) -C ../.. diff --git a/userspace/units/fifo/usermode/gv11b/Makefile.interface.tmk b/userspace/units/fifo/usermode/gv11b/Makefile.interface.tmk new file mode 100644 index 000000000..6b74e453f --- /dev/null +++ b/userspace/units/fifo/usermode/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-usermode-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/usermode/gv11b/Makefile.tmk b/userspace/units/fifo/usermode/gv11b/Makefile.tmk new file mode 100644 index 000000000..46fc7d1c3 --- /dev/null +++ b/userspace/units/fifo/usermode/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-usermode-gv11b +NVGPU_UNIT_SRCS = nvgpu-usermode-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/usermode/gv11b/nvgpu-usermode-gv11b.c b/userspace/units/fifo/usermode/gv11b/nvgpu-usermode-gv11b.c new file mode 100644 index 000000000..af345796c --- /dev/null +++ b/userspace/units/fifo/usermode/gv11b/nvgpu-usermode-gv11b.c @@ -0,0 +1,103 @@ +/* + * 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 "hal/fifo/usermode_gv11b.h" + +#include + +#include "../../nvgpu-fifo.h" +#include "nvgpu-usermode-gv11b.h" + +#ifdef USERMODE_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) +#define branches_str test_fifo_flags_str + +int test_gv11b_usermode(struct unit_module *m, + struct gk20a *g, void *args) +{ + int ret = UNIT_FAIL; + u64 base = gv11b_usermode_base(g); + u64 bus_base = gv11b_usermode_bus_base(g); + struct nvgpu_channel *ch = NULL; + struct nvgpu_fifo *f = &g->fifo; + u32 runlist_id = NVGPU_INVALID_RUNLIST_ID; + bool privileged = false; + u32 hw_chid; + u32 token; + u32 val; + + assert(base == usermode_cfg0_r()); + assert(bus_base == usermode_cfg0_r()); + + ch = nvgpu_channel_open_new(g, runlist_id, + privileged, getpid(), getpid()); + assert(ch != NULL); + hw_chid = f->channel_base + ch->chid; + + token = gv11b_usermode_doorbell_token(ch); + assert(token == usermode_notify_channel_pending_id_f(hw_chid)); + + nvgpu_usermode_writel(g, usermode_notify_channel_pending_r(), 0); + gv11b_usermode_ring_doorbell(ch); + val = nvgpu_readl(g, usermode_notify_channel_pending_r()); + assert(val == token); + + ret = UNIT_SUCCESS; +done: + if (ch != NULL) { + nvgpu_channel_close(ch); + } + return ret; +} + +struct unit_module_test nvgpu_usermode_gv11b_tests[] = { + UNIT_TEST(init_support, test_fifo_init_support, NULL, 0), + UNIT_TEST(usermode, test_gv11b_usermode, NULL, 0), + UNIT_TEST(remove_support, test_fifo_remove_support, NULL, 0), +}; + +UNIT_MODULE(nvgpu_usermode_gv11b, nvgpu_usermode_gv11b_tests, UNIT_PRIO_NVGPU_TEST); diff --git a/userspace/units/fifo/usermode/gv11b/nvgpu-usermode-gv11b.h b/userspace/units/fifo/usermode/gv11b/nvgpu-usermode-gv11b.h new file mode 100644 index 000000000..8be5c2047 --- /dev/null +++ b/userspace/units/fifo/usermode/gv11b/nvgpu-usermode-gv11b.h @@ -0,0 +1,61 @@ +/* + * 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_USERMODE_GV11B_H +#define UNIT_NVGPU_USERMODE_GV11B_H + +#include + +struct unit_module; +struct gk20a; + +/** @addtogroup SWUTS-fifo-usermode-gv11b + * @{ + * + * Software Unit Test Specification for fifo/usermode/gv11b + */ + +/** + * Test specification for: test_gv11b_usermode + * + * Description: Usermode gv11b HALs + * + * Test Type: Feature based + * + * Targets: gv11b_usermode_base, gv11b_usermode_bus_base, + * gv11b_usermode_doorbell_token, gv11b_usermode_ring_doorbell + * + * Input: test_fifo_init_support() run for this GPU + * + * Steps: + * - Get USERD entry size in bytes by calling gk20a_userd_entry_size. + * - Check that it is consistent with definitions in HW manuals. + * + * Output: Returns PASS if all branches gave expected results. FAIL otherwise. + */ +int test_gv11b_usermode(struct unit_module *m, + struct gk20a *g, void *args); + +/** + * @} + */ + +#endif /* UNIT_NVGPU_USERMODE_GV11B_H */