mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 01:50:07 +03:00
gpu: nvgpu: unit: add common.class unit tests
Add unit tests for API exposed by common.class unit Jira NVGPU-4373 Change-Id: Id72df78c5a3c8a85ac71dd3b559d19c296c87b5f Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2246808 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Alex Waterman
parent
84a24c9593
commit
df5924cf57
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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 \
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1828,6 +1828,11 @@
|
||||
"test_level": 0,
|
||||
"unit": "top"
|
||||
},
|
||||
{
|
||||
"test": "class_validate",
|
||||
"test_level": 0,
|
||||
"unit": "class"
|
||||
},
|
||||
{
|
||||
"test": "gr_falcon_init",
|
||||
"test_level": 0,
|
||||
|
||||
26
userspace/units/class/Makefile
Normal file
26
userspace/units/class/Makefile
Normal file
@@ -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
|
||||
23
userspace/units/class/Makefile.interface.tmk
Normal file
23
userspace/units/class/Makefile.interface.tmk
Normal file
@@ -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:
|
||||
24
userspace/units/class/Makefile.tmk
Normal file
24
userspace/units/class/Makefile.tmk
Normal file
@@ -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:
|
||||
141
userspace/units/class/nvgpu-class.c
Normal file
141
userspace/units/class/nvgpu-class.c
Normal file
@@ -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 <unit/unit.h>
|
||||
#include <unit/io.h>
|
||||
|
||||
#include <nvgpu/gk20a.h>
|
||||
#include <nvgpu/class.h>
|
||||
|
||||
#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);
|
||||
75
userspace/units/class/nvgpu-class.h
Normal file
75
userspace/units/class/nvgpu-class.h
Normal file
@@ -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 */
|
||||
Reference in New Issue
Block a user