mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-23 18:16:01 +03:00
Open source GPL/LGPL release
This commit is contained in:
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:
|
||||
155
userspace/units/class/nvgpu-class.c
Normal file
155
userspace/units/class/nvgpu-class.c
Normal file
@@ -0,0 +1,155 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2021, 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, /* BVEC test value */
|
||||
0xB000U, /* BVEC test value */
|
||||
0xC3BFU, /* BVEC test value */
|
||||
0xC3C1U, /* BVEC test value */
|
||||
0xD000U, /* BVEC test value */
|
||||
0xFFFFFFFFU, /* BVEC test value */
|
||||
};
|
||||
|
||||
u32 valid_classes[] = {
|
||||
0xC36FU, /* VOLTA_CHANNEL_GPFIFO_A */
|
||||
0xC397U, /* VOLTA_A */
|
||||
0xC3B5U, /* VOLTA_DMA_COPY_A */
|
||||
0xC3C0U, /* VOLTA_COMPUTE_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 */
|
||||
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 */
|
||||
0x76543210U, /* random value */
|
||||
0x0000U, /* BVEC test value */
|
||||
0xB000U, /* BVEC test value */
|
||||
0xC36EU, /* BVEC test value */
|
||||
0xC370U, /* BVEC test value */
|
||||
0xC396U, /* BVEC test value */
|
||||
0xC398U, /* BVEC test value */
|
||||
0xC3B4U, /* BVEC test value */
|
||||
0xC3B6U, /* BVEC test value */
|
||||
0xC3BFU, /* BVEC test value */
|
||||
0xC3C1U, /* BVEC test value */
|
||||
0xD000U, /* BVEC test value */
|
||||
0xFFFFFFFFU, /* BVEC test 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);
|
||||
82
userspace/units/class/nvgpu-class.h
Normal file
82
userspace/units/class/nvgpu-class.h
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2021, 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, Boundary Values
|
||||
*
|
||||
* Targets: gops_class.is_valid, gv11b_class_is_valid
|
||||
* Equivalence classes:
|
||||
* Variable: class_num
|
||||
* - Valid : { 0xC3C0U }, { 0xC3B5U }, { 0xC36FU }, { 0xC397U }
|
||||
*
|
||||
* Targets: gops_class.is_valid_compute, gv11b_class_is_valid_compute,
|
||||
* Equivalence classes:
|
||||
* Variable: class_num
|
||||
* - Valid : { 0xC3C0U }
|
||||
*
|
||||
* 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