diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index 501cdfb6c..ee1377499 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -86,6 +86,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/falcon NV_REPOSITORY_COMPONENTS += userspace/units/falcon/falcon_tests NV_REPOSITORY_COMPONENTS += userspace/units/pmu NV_REPOSITORY_COMPONENTS += userspace/units/top +NV_REPOSITORY_COMPONENTS += userspace/units/class NV_REPOSITORY_COMPONENTS += userspace/units/gr NV_REPOSITORY_COMPONENTS += userspace/units/gr/falcon NV_REPOSITORY_COMPONENTS += userspace/units/gr/config diff --git a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export index dbc274532..370268b70 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export @@ -74,6 +74,8 @@ gv11b_mc_is_mmu_fault_pending gv11b_runlist_entry_size gv11b_runlist_get_tsg_entry gv11b_runlist_get_ch_entry +gv11b_class_is_valid_compute +gv11b_class_is_valid 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 71e984982..c0d8133ba 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -95,6 +95,7 @@ UNITS := \ $(UNIT_SRC)/fuse \ $(UNIT_SRC)/pmu \ $(UNIT_SRC)/top \ + $(UNIT_SRC)/class \ $(UNIT_SRC)/gr \ $(UNIT_SRC)/gr/falcon \ $(UNIT_SRC)/gr/config \ diff --git a/userspace/SWUTS.h b/userspace/SWUTS.h index e2b1a3585..5ceb38933 100644 --- a/userspace/SWUTS.h +++ b/userspace/SWUTS.h @@ -73,6 +73,7 @@ * - @ref SWUTS-init_test * - @ref SWUTS-channel_os * - @ref SWUTS-top + * - @ref SWUTS-class * - @ref SWUTS-gr * - @ref SWUTS-gr-setup * - @ref SWUTS-gr-intr diff --git a/userspace/SWUTS.sources b/userspace/SWUTS.sources index a3f229685..0b036faf5 100644 --- a/userspace/SWUTS.sources +++ b/userspace/SWUTS.sources @@ -42,6 +42,7 @@ INPUT += ../../../userspace/units/posix/timers/posix-timers.h INPUT += ../../../userspace/units/ptimer/nvgpu-ptimer.h INPUT += ../../../userspace/units/acr/nvgpu-acr.h INPUT += ../../../userspace/units/top/nvgpu-top.h +INPUT += ../../../userspace/units/class/nvgpu-class.h 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 diff --git a/userspace/required_tests.json b/userspace/required_tests.json index 487649d81..dc1c4c56d 100644 --- a/userspace/required_tests.json +++ b/userspace/required_tests.json @@ -1828,6 +1828,11 @@ "test_level": 0, "unit": "top" }, + { + "test": "class_validate", + "test_level": 0, + "unit": "class" + }, { "test": "gr_falcon_init", "test_level": 0, diff --git a/userspace/units/class/Makefile b/userspace/units/class/Makefile new file mode 100644 index 000000000..835edbb43 --- /dev/null +++ b/userspace/units/class/Makefile @@ -0,0 +1,26 @@ +# 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-class.o +MODULE = class + +include ../Makefile.units diff --git a/userspace/units/class/Makefile.interface.tmk b/userspace/units/class/Makefile.interface.tmk new file mode 100644 index 000000000..e9bc2b953 --- /dev/null +++ b/userspace/units/class/Makefile.interface.tmk @@ -0,0 +1,23 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2019, NVIDIA CORPORATION. All Rights Reserved. +# +# NVIDIA CORPORATION and its licensors retain all intellectual property +# and proprietary rights in and to this software, related documentation +# and any modifications thereto. Any use, reproduction, disclosure or +# distribution of this software and related documentation without an express +# license agreement from NVIDIA CORPORATION is strictly prohibited. +# +# tmake for SW Mobile component makefile +# +############################################################################### + +NVGPU_UNIT_NAME=class + +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/class/Makefile.tmk b/userspace/units/class/Makefile.tmk new file mode 100644 index 000000000..2d03516d1 --- /dev/null +++ b/userspace/units/class/Makefile.tmk @@ -0,0 +1,24 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2019, NVIDIA CORPORATION. All Rights Reserved. +# +# NVIDIA CORPORATION and its licensors retain all intellectual property +# and proprietary rights in and to this software, related documentation +# and any modifications thereto. Any use, reproduction, disclosure or +# distribution of this software and related documentation without an express +# license agreement from NVIDIA CORPORATION is strictly prohibited. +# +# tmake for SW Mobile component makefile +# +############################################################################### + +NVGPU_UNIT_NAME=class +NVGPU_UNIT_SRCS=nvgpu-class.c + +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/class/nvgpu-class.c b/userspace/units/class/nvgpu-class.c new file mode 100644 index 000000000..574608305 --- /dev/null +++ b/userspace/units/class/nvgpu-class.c @@ -0,0 +1,141 @@ +/* + * 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 "hal/class/class_gv11b.h" + +#include "nvgpu-class.h" + +u32 valid_compute_classes[] = { + 0xC3C0U, /* VOLTA_COMPUTE_A */ +}; + +u32 invalid_compute_classes[] = { + 0xC397U, /* VOLTA_A */ + 0xC3B5U, /* VOLTA_DMA_COPY_A */ + 0xC36FU, /* VOLTA_CHANNEL_GPFIFO_A */ + 0xC0B5U, /* PASCAL_DMA_COPY_A */ + 0xC06FU, /* PASCAL_CHANNEL_GPFIFO_A */ + 0xB06FU, /* MAXWELL_CHANNEL_GPFIFO_A */ + 0xB0B5U, /* MAXWELL_DMA_COPY_A */ + 0xA140U, /* KEPLER_INLINE_TO_MEMORY_B */ + 0xA0B5U, /* KEPLER_DMA_COPY_A */ + 0xC097U, /* PASCAL_A */ + 0xC0C0U, /* PASCAL_COMPUTE_A */ + 0xB1C0U, /* MAXWELL_COMPUTE_B */ + 0xB197U, /* MAXWELL_B */ + 0x902DU, /* FERMI_TWOD_A */ + 0x1234U, /* random value */ + 0x76543210U, /* random value */ + 0x0000U, /* random value */ + 0xC000U, /* random value */ +}; + +u32 valid_classes[] = { + 0xC3C0U, /* VOLTA_COMPUTE_A */ + 0xC397U, /* VOLTA_A */ + 0xC3B5U, /* VOLTA_DMA_COPY_A */ + 0xC36FU, /* VOLTA_CHANNEL_GPFIFO_A */ + 0xC0B5U, /* PASCAL_DMA_COPY_A */ + 0xC06FU, /* PASCAL_CHANNEL_GPFIFO_A */ + 0xB06FU, /* MAXWELL_CHANNEL_GPFIFO_A */ + 0xB0B5U, /* MAXWELL_DMA_COPY_A */ + 0xA140U, /* KEPLER_INLINE_TO_MEMORY_B */ + 0xA0B5U, /* KEPLER_DMA_COPY_A */ +}; + +u32 invalid_classes[] = { + 0x1234U, /* random value */ + 0xC097U, /* PASCAL_A */ + 0xC0C0U, /* PASCAL_COMPUTE_A */ + 0xB1C0U, /* MAXWELL_COMPUTE_B */ + 0xB197U, /* MAXWELL_B */ + 0x902DU, /* FERMI_TWOD_A */ + 0x76543210U, /* random value */ + 0x0000U, /* random value */ + 0xC000U, /* random value */ +}; + +int class_validate_setup(struct unit_module *m, struct gk20a *g, void *args) +{ + bool valid = false; + u32 i; + + /* Init HAL */ + g->ops.gpu_class.is_valid_compute = gv11b_class_is_valid_compute; + g->ops.gpu_class.is_valid = gv11b_class_is_valid; + + for (i = 0; + i < sizeof(valid_compute_classes)/sizeof(u32); + i++) { + valid = g->ops.gpu_class.is_valid_compute( + valid_compute_classes[i]); + if (!valid) { + goto fail; + } + } + + for (i = 0; + i < sizeof(invalid_compute_classes)/sizeof(u32); + i++) { + valid = g->ops.gpu_class.is_valid_compute( + invalid_compute_classes[i]); + if (valid) { + goto fail; + } + } + + for (i = 0; + i < sizeof(valid_classes)/sizeof(u32); + i++) { + valid = g->ops.gpu_class.is_valid(valid_classes[i]); + if (!valid) { + goto fail; + } + } + + for (i = 0; + i < sizeof(invalid_classes)/sizeof(u32); + i++) { + valid = g->ops.gpu_class.is_valid(invalid_classes[i]); + if (valid) { + goto fail; + } + } + + return UNIT_SUCCESS; + +fail: + unit_err(m, "%s: failed to validate class API\n", __func__); + return UNIT_FAIL; +} + +struct unit_module_test class_tests[] = { + UNIT_TEST(class_validate, class_validate_setup, NULL, 0), +}; + +UNIT_MODULE(class, class_tests, UNIT_PRIO_NVGPU_TEST); diff --git a/userspace/units/class/nvgpu-class.h b/userspace/units/class/nvgpu-class.h new file mode 100644 index 000000000..c5bb0b859 --- /dev/null +++ b/userspace/units/class/nvgpu-class.h @@ -0,0 +1,75 @@ +/* + * 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_CLASS_H +#define UNIT_NVGPU_CLASS_H + +struct gk20a; +struct unit_module; + +/** @addtogroup SWUTS-class + * @{ + * + * Software Unit Test Specification for nvgpu.common.class + */ + +/** + * Test specification for: class_validate + * + * Description: Validate common.class unit API. + * + * Test Type: Feature based. + * + * Targets: #gv11b_class_is_valid_compute, + * #gv11b_class_is_valid. + * + * Input: None + * + * Steps: + * - Initialize common.class HAL function pointers. + * - Validate common.class unit API with below positive/negative data + * sets. + * + * - g->ops.gpu_class.is_valid_compute() + * Pass data set of supported compute classes and ensure API + * returns success in each case. + * + * - g->ops.gpu_class.is_valid_compute() + * Pass data set of unsupported compute classes and ensure API + * returns failure in each case. + * + * - g->ops.gpu_class.is_valid() + * Pass data set of all supported classes and ensure API + * returns success in each case. + * + * - g->ops.gpu_class.is_valid() + * Pass data set of unsupported classes and ensure API + * returns failure in each case. + * + * Output: + * Returns PASS if above validation was performed successfully. FAIL + * otherwise. + */ +int class_validate_setup(struct unit_module *m, struct gk20a *g, void *args); + + +#endif /* UNIT_NVGPU_CLASS_H */