gpu: nvgpu: unit: fifo: fifo unit test

This unit test covers most of the nvgpu.common.fifo.fifo module lines
and almost all branches.

Jira NVGPU-3697

Change-Id: I5722277a3e1630a902f63b707eb3de1c4e1876b0
Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2237796
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Vedashree Vidwans
2019-11-12 14:03:01 -08:00
committed by Alex Waterman
parent 917fb2e2df
commit 0ca906a6ad
69 changed files with 701 additions and 66 deletions

View File

@@ -91,6 +91,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/fifo/engine/gm20b
NV_REPOSITORY_COMPONENTS += userspace/units/fifo/engine/gp10b
NV_REPOSITORY_COMPONENTS += userspace/units/fifo/engine/gv100
NV_REPOSITORY_COMPONENTS += userspace/units/fifo/engine/gv11b
NV_REPOSITORY_COMPONENTS += userspace/units/fifo/fifo
NV_REPOSITORY_COMPONENTS += userspace/units/fifo/fifo/gk20a
NV_REPOSITORY_COMPONENTS += userspace/units/fifo/fifo/gv11b
NV_REPOSITORY_COMPONENTS += userspace/units/fifo/pbdma

View File

@@ -368,7 +368,11 @@ nvgpu_fbp_init_support
nvgpu_fbp_get_max_fbps_count
nvgpu_fbp_get_fbp_en_mask
nvgpu_fbp_remove_support
nvgpu_fifo_cleanup_sw_common
nvgpu_fifo_decode_pbdma_ch_eng_status
nvgpu_fifo_init_support
nvgpu_fifo_suspend
nvgpu_fifo_sw_quiesce
nvgpu_finalize_poweron
nvgpu_free
nvgpu_free_enabled_flags

View File

@@ -102,6 +102,7 @@ UNITS := \
$(UNIT_SRC)/fifo/engine/gp10b \
$(UNIT_SRC)/fifo/engine/gv100 \
$(UNIT_SRC)/fifo/engine/gv11b \
$(UNIT_SRC)/fifo/fifo \
$(UNIT_SRC)/fifo/pbdma \
$(UNIT_SRC)/fifo/pbdma/gm20b \
$(UNIT_SRC)/fifo/pbdma/gp10b \

View File

@@ -47,6 +47,7 @@
* - @ref SWUTS-fifo-engine-gp10b
* - @ref SWUTS-fifo-engine-gv100
* - @ref SWUTS-fifo-engine-gv11b
* - @ref SWUTS-fifo-fifo
* - @ref SWUTS-fifo-fifo-gk20a
* - @ref SWUTS-fifo-fifo-gv11b
* - @ref SWUTS-fifo-pbdma

View File

@@ -9,6 +9,7 @@ INPUT += ../../../userspace/units/falcon/falcon_tests/nvgpu-falcon.h
INPUT += ../../../userspace/units/netlist/nvgpu-netlist.h
INPUT += ../../../userspace/units/fbp/nvgpu-fbp.h
INPUT += ../../../userspace/units/fb/fb_fusa.h
INPUT += ../../../userspace/units/fifo/nvgpu-fifo-common.h
INPUT += ../../../userspace/units/fifo/channel/nvgpu-channel.h
INPUT += ../../../userspace/units/fifo/channel/gk20a/nvgpu-channel-gk20a.h
INPUT += ../../../userspace/units/fifo/channel/gm20b/nvgpu-channel-gm20b.h
@@ -18,6 +19,7 @@ INPUT += ../../../userspace/units/fifo/engine/gm20b/nvgpu-engine-gm20b.h
INPUT += ../../../userspace/units/fifo/engine/gp10b/nvgpu-engine-gp10b.h
INPUT += ../../../userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.h
INPUT += ../../../userspace/units/fifo/engine/gv11b/nvgpu-engine-gv11b.h
INPUT += ../../../userspace/units/fifo/fifo/nvgpu-fifo.h
INPUT += ../../../userspace/units/fifo/fifo/gk20a/nvgpu-fifo-gk20a.h
INPUT += ../../../userspace/units/fifo/fifo/gk20a/nvgpu-fifo-intr-gk20a.h
INPUT += ../../../userspace/units/fifo/fifo/gv11b/nvgpu-fifo-gv11b.h

View File

@@ -2351,6 +2351,30 @@
"unit": "nvgpu_engine_gv11b",
"test_level": 0
},
{
"test": "test_fifo_suspend",
"case": "fifo_suspend",
"unit": "nvgpu_fifo",
"test_level": 0
},
{
"test": "test_fifo_sw_quiesce",
"case": "fifo_sw_quiesce",
"unit": "nvgpu_fifo",
"test_level": 0
},
{
"test": "test_init_support",
"case": "init",
"unit": "nvgpu_fifo",
"test_level": 0
},
{
"test": "test_decode_pbdma_ch_eng_status",
"case": "pbdma_ch_eng_status",
"unit": "nvgpu_fifo",
"test_level": 0
},
{
"test": "test_gk20a_get_timeslices",
"case": "get_timeslices",

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-cg.o
MODULE = nvgpu-cg
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -34,7 +34,7 @@
#include "hal/init/hal_gv11b.h"
#include "hal/power_features/cg/gating_reglist.h"
#include "hal/power_features/cg/gv11b_gating_reglist.h"
#include "../fifo/nvgpu-fifo.h"
#include "../fifo/nvgpu-fifo-common.h"
#include "nvgpu-cg.h"

View File

@@ -20,9 +20,9 @@
.SUFFIXES:
OBJS = nvgpu-fifo.o nvgpu-fifo-gv11b.o
OBJS = nvgpu-fifo-common.o nvgpu-fifo-gv11b.o
MODULE = nvgpu-fifo
MODULE = nvgpu-fifo-common
LIB_PATHS += -lmock-iospace
include ../Makefile.units

View File

@@ -16,7 +16,7 @@
ifdef NV_INTERFACE_FLAG_SHARED_LIBRARY_SECTION
NV_INTERFACE_NAME := nvgpu-fifo
NV_INTERFACE_NAME := nvgpu-fifo-common
NV_INTERFACE_EXPORTS := lib$(NV_INTERFACE_NAME)
NV_INTERFACE_SONAME := lib$(NV_INTERFACE_NAME).so

View File

@@ -14,8 +14,8 @@
#
###############################################################################
NVGPU_UNIT_NAME = nvgpu-fifo
NVGPU_UNIT_SRCS = nvgpu-fifo.c nvgpu-fifo-gv11b.c
NVGPU_UNIT_NAME = nvgpu-fifo-common
NVGPU_UNIT_SRCS = nvgpu-fifo-common.c nvgpu-fifo-gv11b.c
NVGPU_UNIT_INTERFACE_DIRS := \
$(NV_SOURCE)/kernel/nvgpu/userspace/units/mock-iospace

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-channel.o
MODULE = nvgpu-channel
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-channel-gk20a.o
MODULE = nvgpu-channel-gk20a
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -39,7 +39,7 @@
#include "hal/fifo/channel_gk20a.h"
#include <nvgpu/hw/gk20a/hw_ccsr_gk20a.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-channel-gk20a.h"
#ifdef CHANNEL_GK20A_UNIT_DEBUG

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-channel-gm20b.o
MODULE = nvgpu-channel-gm20b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -39,7 +39,7 @@
#include "hal/fifo/channel_gm20b.h"
#include <nvgpu/hw/gm20b/hw_ccsr_gm20b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-channel-gm20b.h"
#ifdef CHANNEL_GM20B_UNIT_DEBUG

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-channel-gv11b.o
MODULE = nvgpu-channel-gv11b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -44,7 +44,7 @@
#include <nvgpu/hw/gv11b/hw_ccsr_gv11b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-channel-gv11b.h"
#ifdef CHANNEL_GV11B_UNIT_DEBUG

View File

@@ -39,7 +39,7 @@
#include <nvgpu/posix/posix-fault-injection.h>
#include "../nvgpu-fifo.h"
#include "../nvgpu-fifo-common.h"
#include "nvgpu-channel.h"
#define MAX_STUB 2

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-engine.o
MODULE = nvgpu-engine
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-engine-gm20b.o
MODULE = nvgpu-engine-gm20b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -38,7 +38,7 @@
#include <nvgpu/hw/gm20b/hw_fifo_gm20b.h>
#include <nvgpu/hw/gm20b/hw_top_gm20b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-engine-gm20b.h"
#ifdef ENGINE_GM20B_UNIT_DEBUG

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-engine-gp10b.o
MODULE = nvgpu-engine-gp10b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -40,7 +40,7 @@
#include <nvgpu/hw/gp10b/hw_fifo_gp10b.h>
#include <nvgpu/hw/gp10b/hw_top_gp10b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-engine-gp10b.h"
#ifdef ENGINE_GP10B_UNIT_DEBUG

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-engine-gv100.o
MODULE = nvgpu-engine-gv100
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -38,7 +38,7 @@
#include <nvgpu/hw/gv100/hw_fifo_gv100.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-engine-gv100.h"
//#define ENGINE_GV100_UNIT_DEBUG

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-engine-gv11b.o
MODULE = nvgpu-engine-gv11b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -37,7 +37,7 @@
#include <nvgpu/hw/gv11b/hw_fifo_gv11b.h>
#include <nvgpu/hw/gv11b/hw_gmmu_gv11b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-engine-gv11b.h"
#ifdef ENGINE_GV11B_UNIT_DEBUG

View File

@@ -40,7 +40,7 @@
#include "nvgpu/hw/gv11b/hw_top_gv11b.h"
#include "../nvgpu-fifo.h"
#include "../nvgpu-fifo-common.h"
#include "../nvgpu-fifo-gv11b.h"
#include "nvgpu-engine.h"

View File

@@ -0,0 +1,32 @@
# 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-fifo.o
MODULE = nvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../Makefile.units
lib$(MODULE).so: fifo
fifo:
$(MAKE) -C ..

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-fifo
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,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-fifo
NVGPU_UNIT_SRCS = nvgpu-fifo.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:

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-fifo-gk20a.o nvgpu-fifo-intr-gk20a.o
MODULE = nvgpu-fifo-gk20a
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -39,7 +39,7 @@
#include "hal/fifo/fifo_gk20a.h"
#include <nvgpu/hw/gk20a/hw_fifo_gk20a.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-fifo-gk20a.h"
#include "nvgpu-fifo-intr-gk20a.h"

View File

@@ -41,7 +41,7 @@
#include "hal/fifo/fifo_intr_gk20a.h"
#include <nvgpu/hw/gk20a/hw_fifo_gk20a.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-fifo-intr-gk20a.h"
#ifdef FIFO_GK20A_INTR_UNIT_DEBUG

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-fifo-gv11b.o nvgpu-fifo-intr-gv11b.o
MODULE = nvgpu-fifo-gv11b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -41,7 +41,7 @@
#include "hal/fifo/fifo_gv11b.h"
#include <nvgpu/hw/gv11b/hw_fifo_gv11b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-fifo-gv11b.h"
#include "nvgpu-fifo-intr-gv11b.h"

View File

@@ -44,7 +44,7 @@
#include <nvgpu/hw/gv11b/hw_fifo_gv11b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-fifo-intr-gv11b.h"
#define FIFO_GV11B_INTR_UNIT_DEBUG

View File

@@ -0,0 +1,346 @@
/*
* 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/gk20a.h>
#include <nvgpu/posix/posix-fault-injection.h>
#include <nvgpu/posix/dma.h>
#include <nvgpu/io.h>
#include "hal/init/hal_gv11b.h"
#include "nvgpu/hw/gk20a/hw_fifo_gk20a.h"
#include "../nvgpu-fifo-gv11b.h"
#include "../nvgpu-fifo-common.h"
#include "nvgpu-fifo.h"
#ifdef FIFO_UNIT_DEBUG
#define unit_verbose unit_info
#else
#define unit_verbose(unit, msg, ...) \
do { \
if (0) { \
unit_info(unit, msg, ##__VA_ARGS__); \
} \
} while (0)
#endif
#define assert(cond) unit_assert(cond, goto done)
#define pruned test_fifo_subtest_pruned
#define branches_str test_fifo_flags_str
#define get_log2 test_fifo_get_log2
static const char *f_fifo_decode_status[] = {
"invalid",
"valid",
"NA",
"NA",
"NA",
"load",
"save",
"switch",
"NOT FOUND",
};
int test_decode_pbdma_ch_eng_status(struct unit_module *m, struct gk20a *g,
void *args)
{
const char *pbdma_ch_eng_status = NULL;
u32 index;
u32 max_index = ARRAY_SIZE(f_fifo_decode_status);
int ret = UNIT_FAIL;
for (index = 0U; index < max_index; index++) {
pbdma_ch_eng_status =
nvgpu_fifo_decode_pbdma_ch_eng_status(index);
assert(strcmp(pbdma_ch_eng_status,
f_fifo_decode_status[index]) == 0);
}
ret = UNIT_SUCCESS;
done:
if (ret != UNIT_SUCCESS) {
unit_err(m, "%s index=%u\n", __func__, index);
}
return ret;
}
#define F_FIFO_SUSPEND_BAR1_SUPPORTED BIT(0)
#define F_FIFO_SUSPEND_LAST BIT(1)
static const char *f_fifo_suspend[] = {
"fifo suspend bar1 not supported",
"fifo suspend bar1 supported",
};
static void stub_fifo_bar1_snooping_disable(struct gk20a *g)
{
}
static bool stub_mm_is_bar1_supported(struct gk20a *g)
{
return true;
}
int test_fifo_suspend(struct unit_module *m, struct gk20a *g, void *args)
{
struct gpu_ops gops;
u32 reg0_val, reg1_val;
u32 branches = 0U;
int ret = UNIT_FAIL;
int err = 0U;
u32 prune = F_FIFO_SUSPEND_BAR1_SUPPORTED;
err = test_fifo_setup_gv11b_reg_space(m, g);
assert(err == 0);
gv11b_init_hal(g);
gops = g->ops;
g->ops.fifo.bar1_snooping_disable = stub_fifo_bar1_snooping_disable;
err = nvgpu_fifo_init_support(g);
assert(err == 0);
for (branches = 0U; branches < F_FIFO_SUSPEND_LAST; branches++) {
if (pruned(branches, prune)) {
unit_verbose(m, "%s branches=%u (pruned)\n", __func__,
branches);
continue;
}
unit_verbose(m, "%s branches=%u\n", __func__, branches);
g->ops.mm.is_bar1_supported =
(branches & F_FIFO_SUSPEND_BAR1_SUPPORTED) ?
stub_mm_is_bar1_supported :
gops.mm.is_bar1_supported;
err = nvgpu_fifo_suspend(g);
reg0_val = nvgpu_readl(g, fifo_intr_en_0_r());
reg1_val = nvgpu_readl(g, fifo_intr_en_1_r());
assert(reg0_val == 0U);
assert(reg1_val == 0U);
}
ret = UNIT_SUCCESS;
done:
if (ret != UNIT_SUCCESS) {
unit_err(m, "%s branches=%s\n", __func__,
branches_str(branches, f_fifo_suspend));
}
nvgpu_fifo_cleanup_sw_common(g);
g->ops = gops;
return ret;
}
int test_fifo_sw_quiesce(struct unit_module *m, struct gk20a *g, void *args)
{
struct gpu_ops gops;
u32 reg_val;
int ret = UNIT_FAIL;
int err;
err = test_fifo_setup_gv11b_reg_space(m, g);
assert(err == 0);
gv11b_init_hal(g);
gops = g->ops;
err = nvgpu_fifo_init_support(g);
assert(err == 0);
#ifndef CONFIG_NVGPU_RECOVERY
nvgpu_fifo_sw_quiesce(g);
reg_val = nvgpu_readl(g, fifo_sched_disable_r());
assert(reg_val == 3U);
#endif
ret = UNIT_SUCCESS;
done:
if (ret != UNIT_SUCCESS) {
unit_err(m, "%s failed\n", __func__);
}
nvgpu_fifo_cleanup_sw_common(g);
g->ops = gops;
return ret;
}
#define F_FIFO_SETUP_SW_READY BIT(0)
#define F_FIFO_SETUP_SW_COMMON_CH_FAIL BIT(1)
#define F_FIFO_SETUP_SW_COMMON_TSG_FAIL BIT(2)
#define F_FIFO_SETUP_SW_COMMON_PBDMA_FAIL BIT(3)
#define F_FIFO_SETUP_SW_COMMON_ENGINE_FAIL BIT(4)
/*
* NOTE: nvgpu_engine_setup_sw() consists of 2 memory allocations.
* Selecting branch for nvgpu_runlist_setup_sw() fail case accordingly.
*/
#define F_FIFO_SETUP_SW_COMMON_RUNLIST_FAIL BIT(6)
#define F_FIFO_SETUP_SW_PBDMA_NULL BIT(7)
#define F_FIFO_CLEANUP_SW_PBDMA_NULL BIT(8)
#define F_FIFO_SETUP_HW_PASS BIT(9)
#define F_FIFO_SETUP_HW_FAIL BIT(10)
#define F_FIFO_INIT_LAST BIT(11)
static const char *f_fifo_init[] = {
"fifo init support",
"fifo init sw ready",
"channel setup sw fail",
"tsg setup sw fail",
"pbdma setup sw fail",
"engine setup sw fail",
"",
"runlist setup sw fail",
"pbdma setup sw NULL",
"pbdma cleanup sw NULL",
"fifo setup hw pass",
"fifo setup hw fail",
};
static int stub_nvgpu_engine_init_info(struct nvgpu_fifo *f)
{
return 0;
}
static int stub_init_fifo_setup_hw_fail(struct gk20a *g)
{
return -1;
}
static int stub_init_fifo_setup_hw_pass(struct gk20a *g)
{
return 0;
}
int test_init_support(struct unit_module *m, struct gk20a *g, void *args)
{
struct nvgpu_posix_fault_inj *kmem_fi;
struct gpu_ops gops;
u32 branches = 0U;
int ret = UNIT_FAIL;
int err = 0U;
u32 alloc_fail = F_FIFO_SETUP_SW_COMMON_CH_FAIL |
F_FIFO_SETUP_SW_COMMON_TSG_FAIL |
F_FIFO_SETUP_SW_COMMON_PBDMA_FAIL |
F_FIFO_SETUP_SW_COMMON_ENGINE_FAIL |
F_FIFO_SETUP_SW_COMMON_RUNLIST_FAIL |
F_FIFO_CLEANUP_SW_PBDMA_NULL;
u32 fail = F_FIFO_SETUP_HW_FAIL | alloc_fail;
u32 prune = F_FIFO_SETUP_SW_READY | F_FIFO_SETUP_SW_PBDMA_NULL |
F_FIFO_SETUP_HW_PASS | fail;
kmem_fi = nvgpu_kmem_get_fault_injection();
err = test_fifo_setup_gv11b_reg_space(m, g);
assert(err == 0);
gv11b_init_hal(g);
gops = g->ops;
for (branches = 0U; branches < F_FIFO_INIT_LAST; branches++) {
if (pruned(branches, prune)) {
unit_verbose(m, "%s branches=%u (pruned)\n", __func__,
branches);
continue;
}
unit_verbose(m, "%s branches=%u\n", __func__, branches);
if (branches & alloc_fail) {
nvgpu_posix_enable_fault_injection(kmem_fi, true,
(get_log2(branches) - 1U));
}
if (branches & F_FIFO_SETUP_SW_READY) {
err = nvgpu_fifo_init_support(g);
assert(err == 0);
}
g->ops.fifo.init_fifo_setup_hw =
(branches & F_FIFO_SETUP_HW_FAIL) ?
stub_init_fifo_setup_hw_fail :
(branches & F_FIFO_SETUP_HW_PASS) ?
stub_init_fifo_setup_hw_pass : NULL;
g->ops.pbdma.setup_sw =
(branches & F_FIFO_SETUP_SW_PBDMA_NULL) ?
NULL : gops.pbdma.setup_sw;
/*
* Replace engine init_info with stub when
* PBDMA setup_sw is NULL
*/
g->ops.engine.init_info =
(branches & F_FIFO_SETUP_SW_PBDMA_NULL) ?
stub_nvgpu_engine_init_info :
gops.engine.init_info;
g->ops.pbdma.cleanup_sw =
(branches & (F_FIFO_CLEANUP_SW_PBDMA_NULL |
F_FIFO_SETUP_SW_PBDMA_NULL)) ?
NULL : gops.pbdma.cleanup_sw;
err = nvgpu_fifo_init_support(g);
if (branches & fail) {
nvgpu_posix_enable_fault_injection(kmem_fi, false, 0);
if (branches & F_FIFO_CLEANUP_SW_PBDMA_NULL) {
gops.pbdma.cleanup_sw(g);
}
assert(err != 0);
} else {
assert(err == 0);
nvgpu_fifo_cleanup_sw_common(g);
}
}
ret = UNIT_SUCCESS;
done:
if (ret != UNIT_SUCCESS) {
unit_err(m, "%s branches=%s\n", __func__,
branches_str(branches, f_fifo_init));
}
g->ops = gops;
return ret;
}
struct unit_module_test nvgpu_fifo_tests[] = {
UNIT_TEST(init, test_init_support, NULL, 0),
UNIT_TEST(pbdma_ch_eng_status, test_decode_pbdma_ch_eng_status, NULL, 0),
UNIT_TEST(fifo_suspend, test_fifo_suspend, NULL, 0),
UNIT_TEST(fifo_sw_quiesce, test_fifo_sw_quiesce, NULL, 0),
};
UNIT_MODULE(nvgpu_fifo, nvgpu_fifo_tests, UNIT_PRIO_NVGPU_TEST);

View File

@@ -0,0 +1,117 @@
/*
* 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_FIFO_H
#define UNIT_NVGPU_FIFO_H
#include <nvgpu/types.h>
struct unit_module;
struct gk20a;
/** @addtogroup SWUTS-fifo-fifo
* @{
*
* Software Unit Test Specification for fifo/fifo */
/**
* Test specification for: test_init_support
*
* Description: Test fifo software context init.
*
* Test Type: Feature based
*
* Targets: nvgpu_fifo_init_support, nvgpu_fifo_setup_sw,
* nvgpu_fifo_setup_sw_common, nvgpu_fifo_cleanup_sw,
* nvgpu_fifo_cleanup_sw_common
*
* Input: None
*
* Steps:
* - Initialize FIFO software with nvgpu_fifo_setup_sw_common(). If successful,
* initialize FIFO hardware setup.
* - Test FIFO software and hardware setup with following cases:
* - FIFO software is already initialized.
* - Channel, TSG, PBDMA, engine or runlist setup fail.
* - PBDMA setup_sw and/or cleanup_sw is NULL.
* - FIFO hardware setup failure.
*
* Output: Returns PASS if all branches gave expected results. FAIL otherwise.
*/
int test_init_support(struct unit_module *m, struct gk20a *g, void *args);
/**
* Test specification for: test_decode_pbdma_ch_eng_status
*
* Description: Test decoding of PBDMA channel/engine status.
*
* Test Type: Feature based
*
* Targets: nvgpu_fifo_decode_pbdma_ch_eng_status
*
* Input: None
*
* Steps:
* - Test decode string returned for each possible index.
*
* Output: Returns PASS if all branches gave expected results. FAIL otherwise.
*/
int test_decode_pbdma_ch_eng_status(struct unit_module *m, struct gk20a *g,
void *args);
/**
* Test specification for: test_fifo_suspend
*
* Description: Test FIFO suspend
*
* Test Type: Feature based
*
* Targets: nvgpu_fifo_suspend
*
* Input: None
*
* Steps:
* - Execute FIFO suspend and check if interrupt 0 and 1 are set to false.
*
* Output: Returns PASS if all branches gave expected results. FAIL otherwise.
*/
int test_fifo_suspend(struct unit_module *m, struct gk20a *g, void *args);
/**
* Test specification for: test_fifo_sw_quiesce
*
* Description: Test FIFO quiescing
*
* Test Type: Feature based
*
* Targets: nvgpu_fifo_sw_quiesce
*
* Input: None
*
* Steps:
* - Execute fifo sw quiesce and check runlist state.
*
* Output: Returns PASS if all branches gave expected results. FAIL otherwise.
*/
int test_fifo_sw_quiesce(struct unit_module *m, struct gk20a *g, void *args);
#endif /* UNIT_NVGPU_FIFO_H */

View File

@@ -21,6 +21,7 @@
#
test_fifo_init_support
test_fifo_get_log2
test_fifo_remove_support
test_fifo_subtest_pruned
test_fifo_flags_str

View File

@@ -34,11 +34,27 @@
#include "hal/init/hal_gv11b.h"
#include "nvgpu-fifo.h"
#include "nvgpu-fifo-common.h"
#include "nvgpu-fifo-gv11b.h"
static struct unit_module *global_m;
/*
* If taken, some branches are final, e.g. the function exits.
* There is no need to test subsequent branches combinations,
* if one final branch is taken.
*
* We want to skip the subtest if:
* - it has at least one final branch
* - it is supposed to test some branches after this final branch
*
* Parameters:
* branches bitmask of branches to be taken for one subtest
* final_branches bitmask of final branches
*
* Note: the assumption is that branches are numbered in their
* order of appearance in the function to be tested.
*/
bool test_fifo_subtest_pruned(u32 branches, u32 final_branches)
{
u32 match = branches & final_branches;
@@ -80,6 +96,20 @@ char *test_fifo_flags_str(u32 flags, const char *labels[])
return buf;
}
u32 test_fifo_get_log2(u32 num)
{
u32 res = 0;
if (num == 0) {
return 0;
}
while (num > 0) {
res++;
num >>= 1;
}
return res - 1U;
}
static u32 stub_gv11b_gr_init_get_no_of_sm(struct gk20a *g)
{
return 8;
@@ -89,6 +119,7 @@ static u32 stub_gv11b_gr_init_get_no_of_sm(struct gk20a *g)
static int stub_userd_setup_sw(struct gk20a *g)
{
int err = nvgpu_userd_init_slabs(g);
if (err != 0) {
unit_err(global_m, "failed to init userd support");
return err;

View File

@@ -19,8 +19,8 @@
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef UNIT_NVGPU_FIFO_H
#define UNIT_NVGPU_FIFO_H
#ifndef UNIT_NVGPU_FIFO_COMMON_H
#define UNIT_NVGPU_FIFO_COMMON_H
#include <nvgpu/types.h>
@@ -29,13 +29,13 @@
#else
#define unit_verbose(unit, msg, ...) \
do { \
if (0) \
{ unit_info(unit, msg, ##__VA_ARGS__); \
if (0) {\
unit_info(unit, msg, ##__VA_ARGS__); \
} \
} while (0)
#endif
/** @addtogroup SWUTS-fifo
/** @addtogroup SWUTS-fifo-common
* @{
*
* Software Unit Test Specification for fifo
@@ -96,5 +96,5 @@ int test_fifo_remove_support(struct unit_module *m,
bool test_fifo_subtest_pruned(u32 branches, u32 final_branches);
char *test_fifo_flags_str(u32 flags, const char *labels[]);
#endif /* UNIT_NVGPU_FIFO_H */
u32 test_fifo_get_log2(u32 num);
#endif /* UNIT_NVGPU_FIFO_COMMON_H */

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-pbdma.o
MODULE = nvgpu-pbdma
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-pbdma-gm20b.o
MODULE = nvgpu-pbdma-gm20b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -40,7 +40,7 @@
#include <nvgpu/hw/gm20b/hw_pbdma_gm20b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "../../nvgpu-fifo-gv11b.h"
#include "nvgpu-pbdma-gm20b.h"

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-pbdma-gp10b.o
MODULE = nvgpu-pbdma-gp10b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -41,7 +41,7 @@
#include <nvgpu/hw/gp10b/hw_pbdma_gp10b.h>
#include <nvgpu/hw/gp10b/hw_ram_gp10b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "../../nvgpu-fifo-gv11b.h"
#include "nvgpu-pbdma-gp10b.h"

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-pbdma-gv11b.o
MODULE = nvgpu-pbdma-gv11b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -41,7 +41,7 @@
#include <nvgpu/hw/gv11b/hw_pbdma_gv11b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "../../nvgpu-fifo-gv11b.h"
#include "nvgpu-pbdma-gv11b.h"

View File

@@ -39,7 +39,7 @@
#include "hal/init/hal_gv11b.h"
#include "../nvgpu-fifo.h"
#include "../nvgpu-fifo-common.h"
#include "../nvgpu-fifo-gv11b.h"
#include "nvgpu-pbdma.h"

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-preempt.o
MODULE = nvgpu-preempt
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -40,11 +40,11 @@
#include "nvgpu-preempt.h"
#include "nvgpu/hw/gk20a/hw_fifo_gk20a.h"
#include "../nvgpu-fifo-common.h"
#define RL_MAX_TIMESLICE_TIMEOUT ram_rl_entry_timeslice_timeout_v(U32_MAX)
#define RL_MAX_TIMESLICE_SCALE ram_rl_entry_timeslice_scale_v(U32_MAX)
#include "../nvgpu-fifo.h"
#ifdef PREEMPT_UNIT_DEBUG
#define unit_verbose unit_info
#else

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-runlist.o
MODULE = nvgpu-runlist
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-runlist-gk20a.o
MODULE = nvgpu-runlist-gk20a
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -44,7 +44,7 @@
#include <nvgpu/hw/gk20a/hw_fifo_gk20a.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-runlist-gk20a.h"
#ifdef RUNLIST_GK20A_UNIT_DEBUG

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-runlist-gv11b.o
MODULE = nvgpu-runlist-gv11b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -44,7 +44,7 @@
#include <nvgpu/hw/gv11b/hw_ram_gv11b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-runlist-gv11b.h"
#define RUNLIST_GV11B_UNIT_DEBUG

View File

@@ -43,7 +43,7 @@
#define RL_MAX_TIMESLICE_TIMEOUT ram_rl_entry_timeslice_timeout_v(U32_MAX)
#define RL_MAX_TIMESLICE_SCALE ram_rl_entry_timeslice_scale_v(U32_MAX)
#include "../nvgpu-fifo.h"
#include "../nvgpu-fifo-common.h"
#ifdef RUNLIST_UNIT_DEBUG
#define unit_verbose unit_info

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-tsg.o
MODULE = nvgpu-tsg
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-tsg-gv11b.o
MODULE = nvgpu-tsg-gv11b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -46,7 +46,7 @@
#include <nvgpu/hw/gv11b/hw_ram_gv11b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-tsg-gv11b.h"
#ifdef TSG_GV11B_UNIT_DEBUG

View File

@@ -45,7 +45,7 @@
#include "hal/init/hal_gv11b.h"
#include "../nvgpu-fifo.h"
#include "../nvgpu-fifo-common.h"
#include "nvgpu-tsg.h"
#ifdef TSG_UNIT_DEBUG

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-userd-gk20a.o
MODULE = nvgpu-userd-gk20a
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -40,7 +40,7 @@
#include <nvgpu/hw/gk20a/hw_ram_gk20a.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-userd-gk20a.h"
#ifdef USERD_GK20A_UNIT_DEBUG

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-usermode-gv11b.o
MODULE = nvgpu-usermode-gv11b
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../../../Makefile.units
lib$(MODULE).so: fifo

View File

@@ -38,7 +38,7 @@
#include <nvgpu/hw/gv11b/hw_usermode_gv11b.h>
#include "../../nvgpu-fifo.h"
#include "../../nvgpu-fifo-common.h"
#include "nvgpu-usermode-gv11b.h"
#ifdef USERMODE_GV11B_UNIT_DEBUG

View File

@@ -23,7 +23,7 @@
OBJS = nvgpu-sync.o
MODULE = nvgpu-sync
LIB_PATHS += -lnvgpu-fifo
LIB_PATHS += -lnvgpu-fifo-common
include ../Makefile.units

View File

@@ -34,7 +34,7 @@
#include <nvgpu/channel_sync.h>
#include <nvgpu/channel_sync_syncpt.h>
#include "../fifo/nvgpu-fifo.h"
#include "../fifo/nvgpu-fifo-common.h"
#include "../fifo/nvgpu-fifo-gv11b.h"
#include "nvgpu-sync.h"