diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index 82e76e575..a86250bba 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -163,6 +163,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/rc NV_REPOSITORY_COMPONENTS += userspace/units/sync NV_REPOSITORY_COMPONENTS += userspace/units/mock-iospace NV_REPOSITORY_COMPONENTS += userspace/units/ecc +NV_REPOSITORY_COMPONENTS += userspace/units/io endif endif diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources index 29eac8c3f..def5aa7df 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -159,4 +159,5 @@ UNITS := \ $(UNIT_SRC)/cg \ $(UNIT_SRC)/rc \ $(UNIT_SRC)/sync \ - $(UNIT_SRC)/ecc + $(UNIT_SRC)/ecc \ + $(UNIT_SRC)/io diff --git a/userspace/SWUTS.h b/userspace/SWUTS.h index ef17ff634..abb23bd79 100644 --- a/userspace/SWUTS.h +++ b/userspace/SWUTS.h @@ -152,5 +152,7 @@ * - @ref SWUTS-ecc * - @ref SWUTS-channel_devctl_qnx * - @ref SWUTS-pmu + * - @ref SWUTS-io + * */ diff --git a/userspace/SWUTS.sources b/userspace/SWUTS.sources index 020036fc7..ea7ab0d57 100644 --- a/userspace/SWUTS.sources +++ b/userspace/SWUTS.sources @@ -123,3 +123,4 @@ INPUT += ../../../userspace/units/gr/obj_ctx/nvgpu-gr-obj-ctx.h INPUT += ../../../userspace/units/gr/config/nvgpu-gr-config.h INPUT += ../../../userspace/units/ecc/nvgpu-ecc.h INPUT += ../../../userspace/units/ecc/nvgpu-pmu.h +INPUT += ../../../userspace/units/io/common_io.h diff --git a/userspace/required_tests.json b/userspace/required_tests.json index 2eb8c7905..d4b3e80c3 100644 --- a/userspace/required_tests.json +++ b/userspace/required_tests.json @@ -4969,5 +4969,11 @@ "case": "sync_fail", "unit": "nvgpu-sync", "test_level": 0 + }, + { + "test": "test_writel_check", + "case": "writel_check", + "unit": "io", + "test_level": 0 } ] diff --git a/userspace/units/io/Makefile b/userspace/units/io/Makefile new file mode 100644 index 000000000..c9c5adfe3 --- /dev/null +++ b/userspace/units/io/Makefile @@ -0,0 +1,26 @@ +# Copyright (c) 2020, 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 = common_io.o +MODULE = common_io + +include ../Makefile.units diff --git a/userspace/units/io/Makefile.interface.tmk b/userspace/units/io/Makefile.interface.tmk new file mode 100644 index 000000000..1c1c7acd4 --- /dev/null +++ b/userspace/units/io/Makefile.interface.tmk @@ -0,0 +1,35 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2020, 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=common_io + +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/io/Makefile.tmk b/userspace/units/io/Makefile.tmk new file mode 100644 index 000000000..4cc50c1d1 --- /dev/null +++ b/userspace/units/io/Makefile.tmk @@ -0,0 +1,35 @@ +################################### tell Emacs this is a -*- makefile-gmake -*- +# +# Copyright (c) 2020, 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=common_io + +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/io/common_io.c b/userspace/units/io/common_io.c new file mode 100644 index 000000000..df4eaa986 --- /dev/null +++ b/userspace/units/io/common_io.c @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2020, 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 "common_io.h" + +#define USER_MODE_BASE (0x00810000U) +#define NVGPU_READ_VAL (0xD007U) + +static void readl_access_reg_fn(struct gk20a *g, + struct nvgpu_reg_access *access) +{ + access->value = NVGPU_READ_VAL; +} + +static void writel_access_reg_fn(struct gk20a *g, + struct nvgpu_reg_access *access) +{ + +} + +static struct nvgpu_posix_io_callbacks ut_common_io_reg_callbacks = { + .readl = readl_access_reg_fn, + .writel = writel_access_reg_fn, +}; + +int test_writel_check(struct unit_module *m, struct gk20a *g, void *args) +{ + nvgpu_posix_io_init_reg_space(g); + nvgpu_posix_register_io(g, &ut_common_io_reg_callbacks); + + /* Value 0 will force to fail readback call as read API returns + * NVGPU_READ_VAL. */ + nvgpu_writel_check(g, USER_MODE_BASE, 0); + + /* Value NVGPU_READ_VAL will pass the readback call as read API returns + * NVGPU_READ_VAL. */ + nvgpu_writel_check(g, USER_MODE_BASE, NVGPU_READ_VAL); + + return UNIT_SUCCESS; +} + +struct unit_module_test io_tests[] = { + UNIT_TEST(writel_check, test_writel_check, NULL, 0), +}; + +UNIT_MODULE(io, io_tests, UNIT_PRIO_NVGPU_TEST); diff --git a/userspace/units/io/common_io.h b/userspace/units/io/common_io.h new file mode 100644 index 000000000..a03c15417 --- /dev/null +++ b/userspace/units/io/common_io.h @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2020, 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. + */ + +/** + * @addtogroup SWUTS-io + * @{ + * + * Software Unit Test Specification for common_io + */ + +#ifndef __UNIT_COMMON_IO_H__ +#define __UNIT_COMMON_IO_H__ + +/** + * Test specification for test_writel_check + * + * Description: Write value v to reg and read it back. + * + * Test Type: Feature + * + * Targets: nvgpu_writel_check + * + * Inputs: None + * + * Steps: + * Initialize address space and register io callbacks. + * Call nvgpu_writel_check with value 0. Here read and write value will be + * different as read callback always returns NVGPU_READ_VAL. + * Call nvgpu_writel_check with value NVGPU_READ_VAL. Here read and write value + * will be same as read callback always returns NVGPU_READ_VAL. + * + * Output: + * The test returns PASS only as target nvgpu_writel_check() always returns + * void. + * + */ +int test_writel_check(struct unit_module *m, struct gk20a *g, void *args); + +#endif /* __UNIT_COMMON_IO_H__ */