Open source GPL/LGPL release

This commit is contained in:
svcmobrel-release
2025-12-19 15:25:44 -08:00
commit 9fc87a7ec7
2261 changed files with 576825 additions and 0 deletions

View 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-enabled.o
MODULE = nvgpu-enabled
include ../Makefile.units

View File

@@ -0,0 +1,35 @@
################################### tell Emacs this is a -*- makefile-gmake -*-
#
# 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.
#
# tmake for SW Mobile component makefile
#
###############################################################################
NVGPU_UNIT_NAME=nvgpu-enabled
include $(NV_COMPONENT_DIR)/../Makefile.units.common.interface.tmk
# Local Variables:
# indent-tabs-mode: t
# tab-width: 8
# End:
# vi: set tabstop=8 noexpandtab:

View File

@@ -0,0 +1,35 @@
################################### tell Emacs this is a -*- makefile-gmake -*-
#
# 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.
#
# tmake for SW Mobile component makefile
#
###############################################################################
NVGPU_UNIT_NAME=nvgpu-enabled
include $(NV_COMPONENT_DIR)/../Makefile.units.common.tmk
# Local Variables:
# indent-tabs-mode: t
# tab-width: 8
# End:
# vi: set tabstop=8 noexpandtab:

View File

@@ -0,0 +1,131 @@
/*
* 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 <stdlib.h>
#include <unit/io.h>
#include <unit/unit.h>
#include <nvgpu/enabled.h>
#include <nvgpu/gk20a.h>
#include <nvgpu/posix/posix-fault-injection.h>
#include "nvgpu-enabled.h"
static unsigned long *original_enabled_flags;
int test_nvgpu_init_enabled_flags(struct unit_module *m,
struct gk20a *g, void *args)
{
int err;
struct nvgpu_posix_fault_inj *kmem_fi =
nvgpu_kmem_get_fault_injection();
original_enabled_flags = g->enabled_flags;
/*
* Test 1 - Enable SW fault injection and check that init function
* fails with -ENOMEM.
*/
nvgpu_posix_enable_fault_injection(kmem_fi, true, 0);
err = nvgpu_init_enabled_flags(g);
if (err != -ENOMEM) {
g->enabled_flags = original_enabled_flags;
unit_return_fail(m,
"enabled_flags init didn't fail as expected\n");
}
nvgpu_posix_enable_fault_injection(kmem_fi, false, 0);
/*
* Test 2 - Check that enabled_flags are inited successfully
* Use these flags (allocated memory) for next tests in module.
*/
err = nvgpu_init_enabled_flags(g);
if (err != 0) {
g->enabled_flags = original_enabled_flags;
unit_return_fail(m, "enabled_flags init failed\n");
}
return UNIT_SUCCESS;
}
int test_nvgpu_enabled_flags_false_check(struct unit_module *m,
struct gk20a *g, void *args)
{
u32 i;
u32 n = NVGPU_MAX_ENABLED_BITS;
for (i = 1U; i < n; i++) { /* First flag is index 1 */
if (nvgpu_is_enabled(g, i)) {
g->enabled_flags = original_enabled_flags;
unit_return_fail(m,
"enabled_flag %u inited to non-zero value\n", i);
}
}
return UNIT_SUCCESS;
}
int test_nvgpu_set_enabled(struct unit_module *m,
struct gk20a *g, void *args)
{
u32 i;
u32 n = NVGPU_MAX_ENABLED_BITS;
for (i = 1U; i < n; i++) { /* First flag is index 1 */
nvgpu_set_enabled(g, i, true);
if (!nvgpu_is_enabled(g, i)) {
g->enabled_flags = original_enabled_flags;
unit_return_fail(m,
"enabled_flag %u could not be enabled\n", i);
}
nvgpu_set_enabled(g, i, false);
if (nvgpu_is_enabled(g, i)) {
g->enabled_flags = original_enabled_flags;
unit_return_fail(m,
"enabled_flag %u could not be disabled\n", i);
}
}
return UNIT_SUCCESS;
}
int test_nvgpu_free_enabled_flags(struct unit_module *m,
struct gk20a *g, void *args)
{
nvgpu_free_enabled_flags(g);
g->enabled_flags = original_enabled_flags;
return UNIT_SUCCESS;
}
struct unit_module_test enabled_tests[] = {
/*
* Init test should run first in order to use newly allocated memory.
*/
UNIT_TEST(init, test_nvgpu_init_enabled_flags, NULL, 0),
UNIT_TEST(enabled_flags_false_check, test_nvgpu_enabled_flags_false_check, NULL, 0),
UNIT_TEST(set_enabled, test_nvgpu_set_enabled, NULL, 0),
UNIT_TEST(free, test_nvgpu_free_enabled_flags, NULL, 0),
};
UNIT_MODULE(enabled, enabled_tests, UNIT_PRIO_NVGPU_TEST);

View File

@@ -0,0 +1,125 @@
/*
* Copyright (c) 2019-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.
*/
#ifndef UNIT_NVGPU_ENABLED_H
#define UNIT_NVGPU_ENABLED_H
struct gk20a;
struct unit_module;
/** @addtogroup SWUTS-enabled
* @{
*
* Software Unit Test Specification for enabled
*/
/**
* Test specification for: test_nvgpu_init_enabled_flags
*
* Description: Initialize GPU enabled_flags
*
* Test Type: Feature, Error guessing
*
* Targets: nvgpu_init_enabled_flags
*
* Input: None
*
* Steps:
* - GPU structure contains enabled_flags initialized at boot
* - Store already created enabled_flags pointer in a global variable
* - Initialize enabled_flags for this unit test
* - New created enabled_flags are set to false
* - Check if return value indicates success
*
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
* otherwise.
*/
int test_nvgpu_init_enabled_flags(struct unit_module *m, struct gk20a *g,
void *args);
/**
* Test specification for: test_nvgpu_enabled_flags_false_check
*
* Description: Check if enabled_flags are set to false.
*
* Test Type: Feature
*
* Targets: nvgpu_is_enabled
*
* Input: test_nvgpu_init_enabled_flags
*
* Steps:
* - Check flag value
* - As flags are allocated for unit test, flag value is expected to be false
* - Iterate over each flag and check if flag value is false
*
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
* otherwise.
*/
int test_nvgpu_enabled_flags_false_check(struct unit_module *m,
struct gk20a *g, void *args);
/**
* Test specification for: test_nvgpu_set_enabled
*
* Description: Set and reset enabled_flags
*
* Test Type: Feature
*
* Targets: nvgpu_is_enabled, nvgpu_set_enabled
*
* Input: test_nvgpu_init_enabled_flags
*
* Steps:
* - Set and reset each flag
* - Iterate over a flag 'i' and set it to true
* - Check if flag 'i' value is true
* - Reset value of flag 'i' to false
* - Check if flag 'i' value is false
*
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
* otherwise.
*/
int test_nvgpu_set_enabled(struct unit_module *m, struct gk20a *g, void *args);
/**
* Test specification for: test_nvgpu_free_enabled_flags
*
* Description: Free enabled_flags
*
* Test Type: Feature
*
* Targets: nvgpu_free_enabled_flags
*
* Input: test_nvgpu_init_enabled_flags
*
* Steps:
* - Free enabled_flag memory
* - Free enabled_flags allocated for this unit test
* - Restore originally created enabled_flags pointer
*
* Output: Returns SUCCESS if the steps above were executed successfully. FAIL
* otherwise.
*/
int test_nvgpu_free_enabled_flags(struct unit_module *m,
struct gk20a *g, void *args);
#endif /* UNIT_NVGPU_ENABLED_H */