mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
gpu: nvgpu: unit: add negative tests for common.gr.ctx
Add negative tests that inject memory allocation failures and verify error handling path in common.gr.ctx unit. Update common.gr.global_ctx unit test to check if global context buffers are ready after allocation call. Jira NVGPU-4373 Change-Id: Ia373441819257890f9f10667e6e2e363081a6757 Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2259074 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
7003a9bb8b
commit
80f408632a
@@ -109,6 +109,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/gr/init
|
|||||||
NV_REPOSITORY_COMPONENTS += userspace/units/gr/setup
|
NV_REPOSITORY_COMPONENTS += userspace/units/gr/setup
|
||||||
NV_REPOSITORY_COMPONENTS += userspace/units/gr/fs_state
|
NV_REPOSITORY_COMPONENTS += userspace/units/gr/fs_state
|
||||||
NV_REPOSITORY_COMPONENTS += userspace/units/gr/global_ctx
|
NV_REPOSITORY_COMPONENTS += userspace/units/gr/global_ctx
|
||||||
|
NV_REPOSITORY_COMPONENTS += userspace/units/gr/ctx
|
||||||
NV_REPOSITORY_COMPONENTS += userspace/units/gr/intr
|
NV_REPOSITORY_COMPONENTS += userspace/units/gr/intr
|
||||||
NV_REPOSITORY_COMPONENTS += userspace/units/acr
|
NV_REPOSITORY_COMPONENTS += userspace/units/acr
|
||||||
NV_REPOSITORY_COMPONENTS += userspace/units/ce
|
NV_REPOSITORY_COMPONENTS += userspace/units/ce
|
||||||
|
|||||||
@@ -305,6 +305,19 @@ nvgpu_gr_global_ctx_init_local_golden_image
|
|||||||
nvgpu_gr_global_ctx_load_local_golden_image
|
nvgpu_gr_global_ctx_load_local_golden_image
|
||||||
nvgpu_gr_global_ctx_compare_golden_images
|
nvgpu_gr_global_ctx_compare_golden_images
|
||||||
nvgpu_gr_global_ctx_deinit_local_golden_image
|
nvgpu_gr_global_ctx_deinit_local_golden_image
|
||||||
|
nvgpu_gr_ctx_desc_alloc
|
||||||
|
nvgpu_gr_ctx_desc_free
|
||||||
|
nvgpu_alloc_gr_ctx_struct
|
||||||
|
nvgpu_free_gr_ctx_struct
|
||||||
|
nvgpu_gr_ctx_alloc
|
||||||
|
nvgpu_gr_ctx_free
|
||||||
|
nvgpu_gr_ctx_set_size
|
||||||
|
nvgpu_gr_ctx_alloc_patch_ctx
|
||||||
|
nvgpu_gr_ctx_free_patch_ctx
|
||||||
|
nvgpu_gr_ctx_map_global_ctx_buffers
|
||||||
|
nvgpu_gr_ctx_patch_write_begin
|
||||||
|
nvgpu_gr_ctx_patch_write
|
||||||
|
nvgpu_gr_ctx_patch_write_end
|
||||||
nvgpu_hr_timestamp
|
nvgpu_hr_timestamp
|
||||||
nvgpu_init_ltc_support
|
nvgpu_init_ltc_support
|
||||||
nvgpu_ltc_ecc_free
|
nvgpu_ltc_ecc_free
|
||||||
@@ -385,7 +398,6 @@ nvgpu_finalize_poweron
|
|||||||
nvgpu_free
|
nvgpu_free
|
||||||
nvgpu_free_enabled_flags
|
nvgpu_free_enabled_flags
|
||||||
nvgpu_free_fixed
|
nvgpu_free_fixed
|
||||||
nvgpu_free_gr_ctx_struct
|
|
||||||
nvgpu_get_pte
|
nvgpu_get_pte
|
||||||
nvgpu_gmmu_init_page_table
|
nvgpu_gmmu_init_page_table
|
||||||
nvgpu_gmmu_map
|
nvgpu_gmmu_map
|
||||||
|
|||||||
@@ -116,6 +116,7 @@ UNITS := \
|
|||||||
$(UNIT_SRC)/gr/init \
|
$(UNIT_SRC)/gr/init \
|
||||||
$(UNIT_SRC)/gr/fs_state \
|
$(UNIT_SRC)/gr/fs_state \
|
||||||
$(UNIT_SRC)/gr/global_ctx \
|
$(UNIT_SRC)/gr/global_ctx \
|
||||||
|
$(UNIT_SRC)/gr/ctx \
|
||||||
$(UNIT_SRC)/gr/intr \
|
$(UNIT_SRC)/gr/intr \
|
||||||
$(UNIT_SRC)/gr/setup \
|
$(UNIT_SRC)/gr/setup \
|
||||||
$(UNIT_SRC)/acr \
|
$(UNIT_SRC)/acr \
|
||||||
|
|||||||
@@ -96,6 +96,7 @@
|
|||||||
* - @ref SWUTS-gr-falcon
|
* - @ref SWUTS-gr-falcon
|
||||||
* - @ref SWUTS-gr-fs-state
|
* - @ref SWUTS-gr-fs-state
|
||||||
* - @ref SWUTS-gr-global-ctx
|
* - @ref SWUTS-gr-global-ctx
|
||||||
|
* - @ref SWUTS-gr-ctx
|
||||||
* - @ref SWUTS-gr-config
|
* - @ref SWUTS-gr-config
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -67,4 +67,5 @@ INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-intr.h
|
|||||||
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-falcon.h
|
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-falcon.h
|
||||||
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-fs-state.h
|
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-fs-state.h
|
||||||
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-global-ctx.h
|
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-global-ctx.h
|
||||||
|
INPUT += ../../../userspace/units/gr/intr/nvgpu-gr-ctx.h
|
||||||
INPUT += ../../../userspace/units/gr/config/nvgpu-gr-config.h
|
INPUT += ../../../userspace/units/gr/config/nvgpu-gr-config.h
|
||||||
|
|||||||
@@ -2027,6 +2027,24 @@
|
|||||||
"unit": "nvgpu_gr_global_ctx",
|
"unit": "nvgpu_gr_global_ctx",
|
||||||
"test_level": 0
|
"test_level": 0
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"test": "test_gr_init_setup",
|
||||||
|
"case": "gr_ctx_setup",
|
||||||
|
"unit": "nvgpu_gr_ctx",
|
||||||
|
"test_level": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "test_gr_ctx_error_injection",
|
||||||
|
"case": "gr_ctx_alloc_errors",
|
||||||
|
"unit": "nvgpu_gr_ctx",
|
||||||
|
"test_level": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"test": "test_gr_remove_setup",
|
||||||
|
"case": "gr_ctx_cleanup",
|
||||||
|
"unit": "nvgpu_gr_ctx",
|
||||||
|
"test_level": 0
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"test": "test_nvgpu_mem_create_from_phys",
|
"test": "test_nvgpu_mem_create_from_phys",
|
||||||
"case": "mem_create_from_phys",
|
"case": "mem_create_from_phys",
|
||||||
|
|||||||
33
userspace/units/gr/ctx/Makefile
Normal file
33
userspace/units/gr/ctx/Makefile
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
# 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-gr-ctx.o
|
||||||
|
MODULE = nvgpu-gr-ctx
|
||||||
|
|
||||||
|
LIB_PATHS += -lnvgpu-gr
|
||||||
|
include ../../Makefile.units
|
||||||
|
|
||||||
|
lib$(MODULE).so: nvgpu-gr
|
||||||
|
|
||||||
|
nvgpu-gr:
|
||||||
|
$(MAKE) -C ..
|
||||||
|
|
||||||
35
userspace/units/gr/ctx/Makefile.interface.tmk
Normal file
35
userspace/units/gr/ctx/Makefile.interface.tmk
Normal 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-gr-ctx
|
||||||
|
|
||||||
|
include $(NV_COMPONENT_DIR)/../../Makefile.units.common.interface.tmk
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# indent-tabs-mode: t
|
||||||
|
# tab-width: 8
|
||||||
|
# End:
|
||||||
|
# vi: set tabstop=8 noexpandtab:
|
||||||
40
userspace/units/gr/ctx/Makefile.tmk
Normal file
40
userspace/units/gr/ctx/Makefile.tmk
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
################################### 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-gr-ctx
|
||||||
|
NVGPU_UNIT_SRCS = nvgpu-gr-ctx.c
|
||||||
|
|
||||||
|
NVGPU_UNIT_INTERFACE_DIRS := \
|
||||||
|
$(NV_COMPONENT_DIR)/.. \
|
||||||
|
$(NV_SOURCE)/kernel/nvgpu/drivers/gpu/nvgpu
|
||||||
|
|
||||||
|
include $(NV_COMPONENT_DIR)/../../Makefile.units.common.tmk
|
||||||
|
|
||||||
|
# Local Variables:
|
||||||
|
# indent-tabs-mode: t
|
||||||
|
# tab-width: 8
|
||||||
|
# End:
|
||||||
|
# vi: set tabstop=8 noexpandtab:
|
||||||
217
userspace/units/gr/ctx/nvgpu-gr-ctx.c
Normal file
217
userspace/units/gr/ctx/nvgpu-gr-ctx.c
Normal file
@@ -0,0 +1,217 @@
|
|||||||
|
/*
|
||||||
|
* 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/unit.h>
|
||||||
|
#include <unit/io.h>
|
||||||
|
|
||||||
|
#include <nvgpu/posix/io.h>
|
||||||
|
#include <nvgpu/gk20a.h>
|
||||||
|
#include <nvgpu/dma.h>
|
||||||
|
#include <nvgpu/gr/gr.h>
|
||||||
|
#include <nvgpu/gr/ctx.h>
|
||||||
|
|
||||||
|
#include <nvgpu/posix/posix-fault-injection.h>
|
||||||
|
#include <nvgpu/posix/dma.h>
|
||||||
|
|
||||||
|
#include "common/gr/gr_priv.h"
|
||||||
|
#include "common/gr/ctx_priv.h"
|
||||||
|
|
||||||
|
#include "../nvgpu-gr.h"
|
||||||
|
#include "nvgpu-gr-ctx.h"
|
||||||
|
|
||||||
|
#define DUMMY_SIZE 0xF0U
|
||||||
|
|
||||||
|
int test_gr_ctx_error_injection(struct unit_module *m,
|
||||||
|
struct gk20a *g, void *args)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
struct vm_gk20a *vm;
|
||||||
|
struct nvgpu_gr_ctx_desc *desc;
|
||||||
|
struct nvgpu_gr_global_ctx_buffer_desc *global_desc;
|
||||||
|
struct nvgpu_gr_ctx *gr_ctx = NULL;
|
||||||
|
struct nvgpu_posix_fault_inj *dma_fi =
|
||||||
|
nvgpu_dma_alloc_get_fault_injection();
|
||||||
|
struct nvgpu_posix_fault_inj *kmem_fi =
|
||||||
|
nvgpu_kmem_get_fault_injection();
|
||||||
|
|
||||||
|
desc = nvgpu_gr_ctx_desc_alloc(g);
|
||||||
|
if (!desc) {
|
||||||
|
unit_return_fail(m, "failed to allocate memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
vm = nvgpu_vm_init(g, SZ_4K, SZ_4K << 10, (1ULL << 32),
|
||||||
|
(1ULL << 32) + (1ULL << 37), false, false, false,
|
||||||
|
"dummy");
|
||||||
|
if (!vm) {
|
||||||
|
unit_return_fail(m, "failed to allocate VM");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to free gr_ctx before it is allocated. */
|
||||||
|
nvgpu_gr_ctx_free(g, gr_ctx, NULL, NULL);
|
||||||
|
|
||||||
|
gr_ctx = nvgpu_alloc_gr_ctx_struct(g);
|
||||||
|
if (!gr_ctx) {
|
||||||
|
unit_return_fail(m, "failed to allocate memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Context size is not set, so should fail. */
|
||||||
|
err = nvgpu_gr_ctx_alloc(g, gr_ctx, desc, vm);
|
||||||
|
if (err == 0) {
|
||||||
|
unit_return_fail(m, "unexpected success");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Set the size now, but inject dma allocation failures. */
|
||||||
|
nvgpu_gr_ctx_set_size(desc, NVGPU_GR_CTX_CTX, DUMMY_SIZE);
|
||||||
|
nvgpu_posix_enable_fault_injection(dma_fi, true, 0);
|
||||||
|
err = nvgpu_gr_ctx_alloc(g, gr_ctx, desc, vm);
|
||||||
|
if (err == 0) {
|
||||||
|
unit_return_fail(m, "unexpected success");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Inject kmem alloc failures to trigger mapping failures */
|
||||||
|
nvgpu_posix_enable_fault_injection(dma_fi, false, 0);
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, true, 1);
|
||||||
|
err = nvgpu_gr_ctx_alloc(g, gr_ctx, desc, vm);
|
||||||
|
if (err == 0) {
|
||||||
|
unit_return_fail(m, "unexpected success");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Successful allocation */
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, false, 0);
|
||||||
|
err = nvgpu_gr_ctx_alloc(g, gr_ctx, desc, vm);
|
||||||
|
if (err != 0) {
|
||||||
|
unit_return_fail(m, "failed to allocate context");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Try to free patch context before it is allocated. */
|
||||||
|
nvgpu_gr_ctx_free_patch_ctx(g, vm, gr_ctx);
|
||||||
|
|
||||||
|
/* Inject allocation error and allocate patch context */
|
||||||
|
nvgpu_gr_ctx_set_size(desc, NVGPU_GR_CTX_PATCH_CTX, DUMMY_SIZE);
|
||||||
|
nvgpu_posix_enable_fault_injection(dma_fi, true, 0);
|
||||||
|
err = nvgpu_gr_ctx_alloc_patch_ctx(g, gr_ctx, desc, vm);
|
||||||
|
if (err == 0) {
|
||||||
|
unit_return_fail(m, "unexpected success");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Successful allocation */
|
||||||
|
nvgpu_posix_enable_fault_injection(dma_fi, false, 0);
|
||||||
|
err = nvgpu_gr_ctx_alloc_patch_ctx(g, gr_ctx, desc, vm);
|
||||||
|
if (err != 0) {
|
||||||
|
unit_return_fail(m, "failed to allocate patch context");
|
||||||
|
}
|
||||||
|
|
||||||
|
global_desc = nvgpu_gr_global_ctx_desc_alloc(g);
|
||||||
|
if (!global_desc) {
|
||||||
|
unit_return_fail(m, "failed to allocate desc");
|
||||||
|
}
|
||||||
|
|
||||||
|
err = nvgpu_gr_ctx_map_global_ctx_buffers(g, gr_ctx, global_desc,
|
||||||
|
vm, false);
|
||||||
|
if (err == 0) {
|
||||||
|
unit_return_fail(m, "unexpected success");
|
||||||
|
}
|
||||||
|
|
||||||
|
nvgpu_gr_global_ctx_set_size(global_desc, NVGPU_GR_GLOBAL_CTX_CIRCULAR,
|
||||||
|
DUMMY_SIZE);
|
||||||
|
nvgpu_gr_global_ctx_set_size(global_desc, NVGPU_GR_GLOBAL_CTX_PAGEPOOL,
|
||||||
|
DUMMY_SIZE);
|
||||||
|
nvgpu_gr_global_ctx_set_size(global_desc, NVGPU_GR_GLOBAL_CTX_ATTRIBUTE,
|
||||||
|
DUMMY_SIZE);
|
||||||
|
nvgpu_gr_global_ctx_set_size(global_desc, NVGPU_GR_GLOBAL_CTX_PRIV_ACCESS_MAP,
|
||||||
|
DUMMY_SIZE);
|
||||||
|
|
||||||
|
err = nvgpu_gr_global_ctx_buffer_alloc(g, global_desc);
|
||||||
|
if (err != 0) {
|
||||||
|
unit_return_fail(m, "failed to allocate global buffers");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fail global circular buffer mapping */
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, true, 0);
|
||||||
|
err = nvgpu_gr_ctx_map_global_ctx_buffers(g, gr_ctx, global_desc,
|
||||||
|
vm, false);
|
||||||
|
if (err == 0) {
|
||||||
|
unit_return_fail(m, "unexpected success");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fail global attribute buffer mapping */
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, true, 4);
|
||||||
|
err = nvgpu_gr_ctx_map_global_ctx_buffers(g, gr_ctx, global_desc,
|
||||||
|
vm, false);
|
||||||
|
if (err == 0) {
|
||||||
|
unit_return_fail(m, "unexpected success");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fail global pagepool buffer mapping */
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, true, 8);
|
||||||
|
err = nvgpu_gr_ctx_map_global_ctx_buffers(g, gr_ctx, global_desc,
|
||||||
|
vm, false);
|
||||||
|
if (err == 0) {
|
||||||
|
unit_return_fail(m, "unexpected success");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Fail global access map buffer mapping */
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, true, 12);
|
||||||
|
err = nvgpu_gr_ctx_map_global_ctx_buffers(g, gr_ctx, global_desc,
|
||||||
|
vm, false);
|
||||||
|
if (err == 0) {
|
||||||
|
unit_return_fail(m, "unexpected success");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Successful mapping */
|
||||||
|
nvgpu_posix_enable_fault_injection(kmem_fi, false, 0);
|
||||||
|
err = nvgpu_gr_ctx_map_global_ctx_buffers(g, gr_ctx, global_desc,
|
||||||
|
vm, false);
|
||||||
|
if (err != 0) {
|
||||||
|
unit_return_fail(m, "failed to map global buffers");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update the patch buffer */
|
||||||
|
nvgpu_gr_ctx_patch_write_begin(g, gr_ctx, true);
|
||||||
|
/* Increase data count so that patch write fails */
|
||||||
|
gr_ctx->patch_ctx.data_count = 1000;
|
||||||
|
nvgpu_gr_ctx_patch_write(g, gr_ctx, 0, 0, true);
|
||||||
|
/* Restore data count so that patch write passes */
|
||||||
|
gr_ctx->patch_ctx.data_count = 0;
|
||||||
|
nvgpu_gr_ctx_patch_write(g, gr_ctx, 0, 0, true);
|
||||||
|
nvgpu_gr_ctx_patch_write_end(g, gr_ctx, true);
|
||||||
|
|
||||||
|
/* cleanup */
|
||||||
|
nvgpu_gr_ctx_free_patch_ctx(g, vm, gr_ctx);
|
||||||
|
nvgpu_gr_ctx_free(g, gr_ctx, global_desc, vm);
|
||||||
|
nvgpu_free_gr_ctx_struct(g, gr_ctx);
|
||||||
|
nvgpu_gr_ctx_desc_free(g, desc);
|
||||||
|
nvgpu_vm_put(vm);
|
||||||
|
|
||||||
|
return UNIT_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
struct unit_module_test nvgpu_gr_ctx_tests[] = {
|
||||||
|
UNIT_TEST(gr_ctx_setup, test_gr_init_setup, NULL, 0),
|
||||||
|
UNIT_TEST(gr_ctx_alloc_errors, test_gr_ctx_error_injection, NULL, 0),
|
||||||
|
UNIT_TEST(gr_ctx_cleanup, test_gr_remove_setup, NULL, 0),
|
||||||
|
};
|
||||||
|
|
||||||
|
UNIT_MODULE(nvgpu_gr_ctx, nvgpu_gr_ctx_tests, UNIT_PRIO_NVGPU_TEST);
|
||||||
88
userspace/units/gr/ctx/nvgpu-gr-ctx.h
Normal file
88
userspace/units/gr/ctx/nvgpu-gr-ctx.h
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
/*
|
||||||
|
* 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_GR_CTX_H
|
||||||
|
#define UNIT_NVGPU_GR_CTX_H
|
||||||
|
|
||||||
|
#include <nvgpu/types.h>
|
||||||
|
|
||||||
|
struct gk20a;
|
||||||
|
struct unit_module;
|
||||||
|
|
||||||
|
/** @addtogroup SWUTS-gr-ctx
|
||||||
|
* @{
|
||||||
|
*
|
||||||
|
* Software Unit Test Specification for common.gr.ctx
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Test specification for: test_gr_ctx_error_injection.
|
||||||
|
*
|
||||||
|
* Description: Verify error handling in context allocation and mapping path.
|
||||||
|
*
|
||||||
|
* Test Type: Feature based, Error guessing.
|
||||||
|
*
|
||||||
|
* Targets: #nvgpu_gr_ctx_alloc,
|
||||||
|
* #nvgpu_gr_ctx_free,
|
||||||
|
* #nvgpu_gr_ctx_desc_alloc,
|
||||||
|
* #nvgpu_gr_ctx_desc_free,
|
||||||
|
* #nvgpu_alloc_gr_ctx_struct,
|
||||||
|
* #nvgpu_free_gr_ctx_struct,
|
||||||
|
* #nvgpu_gr_ctx_set_size,
|
||||||
|
* #nvgpu_gr_ctx_alloc_patch_ctx,
|
||||||
|
* #nvgpu_gr_ctx_free_patch_ctx,
|
||||||
|
* #nvgpu_gr_ctx_map_global_ctx_buffers,
|
||||||
|
* #nvgpu_gr_ctx_patch_write_begin,
|
||||||
|
* #nvgpu_gr_ctx_patch_write,
|
||||||
|
* #nvgpu_gr_ctx_patch_write_end.
|
||||||
|
*
|
||||||
|
* Input: gr_ctx_setup must have been executed successfully.
|
||||||
|
*
|
||||||
|
* Steps:
|
||||||
|
* - Allocate context descriptor struct.
|
||||||
|
* - Try to free gr_ctx before it is allocated, should fail.
|
||||||
|
* - Try to allocate gr_ctx before size is set, should fail.
|
||||||
|
* - Inject dma allocation failure and try to allocate gr_ctx, should fail.
|
||||||
|
* - Inject kmem allocation failure and try to allocate gr_ctx, should fail.
|
||||||
|
* - Disable error injection and allocate gr_ctx, should pass.
|
||||||
|
* - Try to free patch_ctx before it is allocated, should fail.
|
||||||
|
* - Inject dma allocation failure and try to allocate patch_ctx, should fail.
|
||||||
|
* - Disable error injection and allocate patch_ctx, should pass.
|
||||||
|
* - Setup all the global context buffers.
|
||||||
|
* - Inject kmem allocation failures for each global context buffer mappping,
|
||||||
|
* should fail.
|
||||||
|
* - Disable error injection and map, should pass.
|
||||||
|
* - Increase data count in patch context beyond max, write should fail.
|
||||||
|
* - Set data count to 0, write should pass.
|
||||||
|
* - Cleanup all the local resources.
|
||||||
|
*
|
||||||
|
* Output: Returns PASS if the steps above were executed successfully. FAIL
|
||||||
|
* otherwise.
|
||||||
|
*/
|
||||||
|
int test_gr_ctx_error_injection(struct unit_module *m,
|
||||||
|
struct gk20a *g, void *args);
|
||||||
|
|
||||||
|
#endif /* UNIT_NVGPU_GR_CTX_H */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @}
|
||||||
|
*/
|
||||||
|
|
||||||
Reference in New Issue
Block a user