mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
gpu: nvgpu: unit test for common-io
This patch covers unit test for nvgpu_writel_check(). Jira NVGPU-4810 Change-Id: I173afd59a9e8fe9e647f260a70012f2c7c2d02f9 Signed-off-by: Prateek sethi <prsethi@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2293538 Reviewed-by: Rajesh Devaraj <rdevaraj@nvidia.com> Reviewed-by: Ankur Kishore <ankkishore@nvidia.com> Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com> GVS: Gerrit_Virtual_Submit
This commit is contained in:
committed by
Alex Waterman
parent
406913dc42
commit
a9f3890ad6
@@ -159,4 +159,5 @@ UNITS := \
|
||||
$(UNIT_SRC)/cg \
|
||||
$(UNIT_SRC)/rc \
|
||||
$(UNIT_SRC)/sync \
|
||||
$(UNIT_SRC)/ecc
|
||||
$(UNIT_SRC)/ecc \
|
||||
$(UNIT_SRC)/io
|
||||
|
||||
@@ -152,5 +152,7 @@
|
||||
* - @ref SWUTS-ecc
|
||||
* - @ref SWUTS-channel_devctl_qnx
|
||||
* - @ref SWUTS-pmu
|
||||
* - @ref SWUTS-io
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
]
|
||||
|
||||
26
userspace/units/io/Makefile
Normal file
26
userspace/units/io/Makefile
Normal file
@@ -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
|
||||
35
userspace/units/io/Makefile.interface.tmk
Normal file
35
userspace/units/io/Makefile.interface.tmk
Normal file
@@ -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:
|
||||
35
userspace/units/io/Makefile.tmk
Normal file
35
userspace/units/io/Makefile.tmk
Normal file
@@ -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:
|
||||
72
userspace/units/io/common_io.c
Normal file
72
userspace/units/io/common_io.c
Normal file
@@ -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 <unit/io.h>
|
||||
#include <unit/unit.h>
|
||||
|
||||
#include <include/nvgpu/posix/io.h>
|
||||
#include <nvgpu/types.h>
|
||||
#include <nvgpu/io.h>
|
||||
|
||||
#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);
|
||||
58
userspace/units/io/common_io.h
Normal file
58
userspace/units/io/common_io.h
Normal file
@@ -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__ */
|
||||
Reference in New Issue
Block a user