From 0ca906a6ad05fd4e8fb55ef1cb2cbde3a6af2434 Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Tue, 12 Nov 2019 14:03:01 -0800 Subject: [PATCH] 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 Reviewed-on: https://git-master.nvidia.com/r/2237796 Reviewed-by: mobile promotions Tested-by: mobile promotions --- Makefile.umbrella.tmk | 1 + drivers/gpu/nvgpu/libnvgpu-drv_safe.export | 4 + userspace/Makefile.sources | 1 + userspace/SWUTS.h | 1 + userspace/SWUTS.sources | 2 + userspace/required_tests.json | 24 ++ userspace/units/cg/Makefile | 2 +- userspace/units/cg/nvgpu-cg.c | 2 +- userspace/units/fifo/Makefile | 4 +- userspace/units/fifo/Makefile.interface.tmk | 2 +- userspace/units/fifo/Makefile.tmk | 4 +- userspace/units/fifo/channel/Makefile | 2 +- userspace/units/fifo/channel/gk20a/Makefile | 2 +- .../fifo/channel/gk20a/nvgpu-channel-gk20a.c | 2 +- userspace/units/fifo/channel/gm20b/Makefile | 2 +- .../fifo/channel/gm20b/nvgpu-channel-gm20b.c | 2 +- userspace/units/fifo/channel/gv11b/Makefile | 2 +- .../fifo/channel/gv11b/nvgpu-channel-gv11b.c | 2 +- userspace/units/fifo/channel/nvgpu-channel.c | 2 +- userspace/units/fifo/engine/Makefile | 2 +- userspace/units/fifo/engine/gm20b/Makefile | 2 +- .../fifo/engine/gm20b/nvgpu-engine-gm20b.c | 2 +- userspace/units/fifo/engine/gp10b/Makefile | 2 +- .../fifo/engine/gp10b/nvgpu-engine-gp10b.c | 2 +- userspace/units/fifo/engine/gv100/Makefile | 2 +- .../fifo/engine/gv100/nvgpu-engine-gv100.c | 2 +- userspace/units/fifo/engine/gv11b/Makefile | 2 +- .../fifo/engine/gv11b/nvgpu-engine-gv11b.c | 2 +- userspace/units/fifo/engine/nvgpu-engine.c | 2 +- userspace/units/fifo/fifo/Makefile | 32 ++ .../units/fifo/fifo/Makefile.interface.tmk | 35 ++ userspace/units/fifo/fifo/Makefile.tmk | 40 ++ userspace/units/fifo/fifo/gk20a/Makefile | 2 +- .../units/fifo/fifo/gk20a/nvgpu-fifo-gk20a.c | 2 +- .../fifo/fifo/gk20a/nvgpu-fifo-intr-gk20a.c | 2 +- userspace/units/fifo/fifo/gv11b/Makefile | 2 +- .../units/fifo/fifo/gv11b/nvgpu-fifo-gv11b.c | 2 +- .../fifo/fifo/gv11b/nvgpu-fifo-intr-gv11b.c | 2 +- userspace/units/fifo/fifo/nvgpu-fifo.c | 346 ++++++++++++++++++ userspace/units/fifo/fifo/nvgpu-fifo.h | 117 ++++++ ...ifo.export => libnvgpu-fifo-common.export} | 1 + .../{nvgpu-fifo.c => nvgpu-fifo-common.c} | 33 +- .../{nvgpu-fifo.h => nvgpu-fifo-common.h} | 14 +- userspace/units/fifo/pbdma/Makefile | 2 +- userspace/units/fifo/pbdma/gm20b/Makefile | 2 +- .../fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.c | 2 +- userspace/units/fifo/pbdma/gp10b/Makefile | 2 +- .../fifo/pbdma/gp10b/nvgpu-pbdma-gp10b.c | 2 +- userspace/units/fifo/pbdma/gv11b/Makefile | 2 +- .../fifo/pbdma/gv11b/nvgpu-pbdma-gv11b.c | 2 +- userspace/units/fifo/pbdma/nvgpu-pbdma.c | 2 +- userspace/units/fifo/preempt/Makefile | 2 +- userspace/units/fifo/preempt/nvgpu-preempt.c | 4 +- userspace/units/fifo/runlist/Makefile | 2 +- userspace/units/fifo/runlist/gk20a/Makefile | 2 +- .../fifo/runlist/gk20a/nvgpu-runlist-gk20a.c | 2 +- userspace/units/fifo/runlist/gv11b/Makefile | 2 +- .../fifo/runlist/gv11b/nvgpu-runlist-gv11b.c | 2 +- userspace/units/fifo/runlist/nvgpu-runlist.c | 2 +- userspace/units/fifo/tsg/Makefile | 2 +- userspace/units/fifo/tsg/gv11b/Makefile | 2 +- .../units/fifo/tsg/gv11b/nvgpu-tsg-gv11b.c | 2 +- userspace/units/fifo/tsg/nvgpu-tsg.c | 2 +- userspace/units/fifo/userd/gk20a/Makefile | 2 +- .../fifo/userd/gk20a/nvgpu-userd-gk20a.c | 2 +- userspace/units/fifo/usermode/gv11b/Makefile | 2 +- .../usermode/gv11b/nvgpu-usermode-gv11b.c | 2 +- userspace/units/sync/Makefile | 2 +- userspace/units/sync/nvgpu-sync.c | 2 +- 69 files changed, 701 insertions(+), 66 deletions(-) create mode 100644 userspace/units/fifo/fifo/Makefile create mode 100644 userspace/units/fifo/fifo/Makefile.interface.tmk create mode 100644 userspace/units/fifo/fifo/Makefile.tmk create mode 100644 userspace/units/fifo/fifo/nvgpu-fifo.c create mode 100644 userspace/units/fifo/fifo/nvgpu-fifo.h rename userspace/units/fifo/{libnvgpu-fifo.export => libnvgpu-fifo-common.export} (98%) rename userspace/units/fifo/{nvgpu-fifo.c => nvgpu-fifo-common.c} (83%) rename userspace/units/fifo/{nvgpu-fifo.h => nvgpu-fifo-common.h} (93%) diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index d911bf496..54fa2a552 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -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 diff --git a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export index cf7a53382..c61407032 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export @@ -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 diff --git a/userspace/Makefile.sources b/userspace/Makefile.sources index 52cded16a..c1bf16205 100644 --- a/userspace/Makefile.sources +++ b/userspace/Makefile.sources @@ -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 \ diff --git a/userspace/SWUTS.h b/userspace/SWUTS.h index 36b85b415..6031495f3 100644 --- a/userspace/SWUTS.h +++ b/userspace/SWUTS.h @@ -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 diff --git a/userspace/SWUTS.sources b/userspace/SWUTS.sources index 3e516e74a..79b5ac9d8 100644 --- a/userspace/SWUTS.sources +++ b/userspace/SWUTS.sources @@ -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 diff --git a/userspace/required_tests.json b/userspace/required_tests.json index 63bb5852c..4dc4b9d44 100644 --- a/userspace/required_tests.json +++ b/userspace/required_tests.json @@ -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", diff --git a/userspace/units/cg/Makefile b/userspace/units/cg/Makefile index 0f71163cb..838b07f52 100644 --- a/userspace/units/cg/Makefile +++ b/userspace/units/cg/Makefile @@ -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 diff --git a/userspace/units/cg/nvgpu-cg.c b/userspace/units/cg/nvgpu-cg.c index a820d7296..b9cce6b39 100644 --- a/userspace/units/cg/nvgpu-cg.c +++ b/userspace/units/cg/nvgpu-cg.c @@ -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" diff --git a/userspace/units/fifo/Makefile b/userspace/units/fifo/Makefile index 2bb9b8da5..5c3bcb933 100644 --- a/userspace/units/fifo/Makefile +++ b/userspace/units/fifo/Makefile @@ -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 diff --git a/userspace/units/fifo/Makefile.interface.tmk b/userspace/units/fifo/Makefile.interface.tmk index c9a8a3345..763a9490f 100644 --- a/userspace/units/fifo/Makefile.interface.tmk +++ b/userspace/units/fifo/Makefile.interface.tmk @@ -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 diff --git a/userspace/units/fifo/Makefile.tmk b/userspace/units/fifo/Makefile.tmk index 86ed3013d..f78dd8883 100644 --- a/userspace/units/fifo/Makefile.tmk +++ b/userspace/units/fifo/Makefile.tmk @@ -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 diff --git a/userspace/units/fifo/channel/Makefile b/userspace/units/fifo/channel/Makefile index d1a46e80b..7fd45dd26 100644 --- a/userspace/units/fifo/channel/Makefile +++ b/userspace/units/fifo/channel/Makefile @@ -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 diff --git a/userspace/units/fifo/channel/gk20a/Makefile b/userspace/units/fifo/channel/gk20a/Makefile index 405c4f42d..b7481f065 100644 --- a/userspace/units/fifo/channel/gk20a/Makefile +++ b/userspace/units/fifo/channel/gk20a/Makefile @@ -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 diff --git a/userspace/units/fifo/channel/gk20a/nvgpu-channel-gk20a.c b/userspace/units/fifo/channel/gk20a/nvgpu-channel-gk20a.c index 3b155d3e0..599394c73 100644 --- a/userspace/units/fifo/channel/gk20a/nvgpu-channel-gk20a.c +++ b/userspace/units/fifo/channel/gk20a/nvgpu-channel-gk20a.c @@ -39,7 +39,7 @@ #include "hal/fifo/channel_gk20a.h" #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-channel-gk20a.h" #ifdef CHANNEL_GK20A_UNIT_DEBUG diff --git a/userspace/units/fifo/channel/gm20b/Makefile b/userspace/units/fifo/channel/gm20b/Makefile index 63b893d53..e53835a61 100644 --- a/userspace/units/fifo/channel/gm20b/Makefile +++ b/userspace/units/fifo/channel/gm20b/Makefile @@ -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 diff --git a/userspace/units/fifo/channel/gm20b/nvgpu-channel-gm20b.c b/userspace/units/fifo/channel/gm20b/nvgpu-channel-gm20b.c index 16033f983..035f2f6a7 100644 --- a/userspace/units/fifo/channel/gm20b/nvgpu-channel-gm20b.c +++ b/userspace/units/fifo/channel/gm20b/nvgpu-channel-gm20b.c @@ -39,7 +39,7 @@ #include "hal/fifo/channel_gm20b.h" #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-channel-gm20b.h" #ifdef CHANNEL_GM20B_UNIT_DEBUG diff --git a/userspace/units/fifo/channel/gv11b/Makefile b/userspace/units/fifo/channel/gv11b/Makefile index 4564423b3..50b367aed 100644 --- a/userspace/units/fifo/channel/gv11b/Makefile +++ b/userspace/units/fifo/channel/gv11b/Makefile @@ -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 diff --git a/userspace/units/fifo/channel/gv11b/nvgpu-channel-gv11b.c b/userspace/units/fifo/channel/gv11b/nvgpu-channel-gv11b.c index cef5ad8ad..d43613874 100644 --- a/userspace/units/fifo/channel/gv11b/nvgpu-channel-gv11b.c +++ b/userspace/units/fifo/channel/gv11b/nvgpu-channel-gv11b.c @@ -44,7 +44,7 @@ #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-channel-gv11b.h" #ifdef CHANNEL_GV11B_UNIT_DEBUG diff --git a/userspace/units/fifo/channel/nvgpu-channel.c b/userspace/units/fifo/channel/nvgpu-channel.c index dfccde43e..83158e3ae 100644 --- a/userspace/units/fifo/channel/nvgpu-channel.c +++ b/userspace/units/fifo/channel/nvgpu-channel.c @@ -39,7 +39,7 @@ #include -#include "../nvgpu-fifo.h" +#include "../nvgpu-fifo-common.h" #include "nvgpu-channel.h" #define MAX_STUB 2 diff --git a/userspace/units/fifo/engine/Makefile b/userspace/units/fifo/engine/Makefile index 71e2c58d1..a39774534 100644 --- a/userspace/units/fifo/engine/Makefile +++ b/userspace/units/fifo/engine/Makefile @@ -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 diff --git a/userspace/units/fifo/engine/gm20b/Makefile b/userspace/units/fifo/engine/gm20b/Makefile index 432d737f0..54dfc424c 100644 --- a/userspace/units/fifo/engine/gm20b/Makefile +++ b/userspace/units/fifo/engine/gm20b/Makefile @@ -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 diff --git a/userspace/units/fifo/engine/gm20b/nvgpu-engine-gm20b.c b/userspace/units/fifo/engine/gm20b/nvgpu-engine-gm20b.c index 94efa193b..2b95604ed 100644 --- a/userspace/units/fifo/engine/gm20b/nvgpu-engine-gm20b.c +++ b/userspace/units/fifo/engine/gm20b/nvgpu-engine-gm20b.c @@ -38,7 +38,7 @@ #include #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-engine-gm20b.h" #ifdef ENGINE_GM20B_UNIT_DEBUG diff --git a/userspace/units/fifo/engine/gp10b/Makefile b/userspace/units/fifo/engine/gp10b/Makefile index 951497543..e6c6f8e34 100644 --- a/userspace/units/fifo/engine/gp10b/Makefile +++ b/userspace/units/fifo/engine/gp10b/Makefile @@ -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 diff --git a/userspace/units/fifo/engine/gp10b/nvgpu-engine-gp10b.c b/userspace/units/fifo/engine/gp10b/nvgpu-engine-gp10b.c index 72719306c..645a0c108 100644 --- a/userspace/units/fifo/engine/gp10b/nvgpu-engine-gp10b.c +++ b/userspace/units/fifo/engine/gp10b/nvgpu-engine-gp10b.c @@ -40,7 +40,7 @@ #include #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-engine-gp10b.h" #ifdef ENGINE_GP10B_UNIT_DEBUG diff --git a/userspace/units/fifo/engine/gv100/Makefile b/userspace/units/fifo/engine/gv100/Makefile index 02154bade..d545b50cb 100644 --- a/userspace/units/fifo/engine/gv100/Makefile +++ b/userspace/units/fifo/engine/gv100/Makefile @@ -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 diff --git a/userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.c b/userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.c index be08880ba..8c4b4e3fc 100644 --- a/userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.c +++ b/userspace/units/fifo/engine/gv100/nvgpu-engine-gv100.c @@ -38,7 +38,7 @@ #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-engine-gv100.h" //#define ENGINE_GV100_UNIT_DEBUG diff --git a/userspace/units/fifo/engine/gv11b/Makefile b/userspace/units/fifo/engine/gv11b/Makefile index aae65bb35..e403532d1 100644 --- a/userspace/units/fifo/engine/gv11b/Makefile +++ b/userspace/units/fifo/engine/gv11b/Makefile @@ -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 diff --git a/userspace/units/fifo/engine/gv11b/nvgpu-engine-gv11b.c b/userspace/units/fifo/engine/gv11b/nvgpu-engine-gv11b.c index 88d81f62b..106d5ab12 100644 --- a/userspace/units/fifo/engine/gv11b/nvgpu-engine-gv11b.c +++ b/userspace/units/fifo/engine/gv11b/nvgpu-engine-gv11b.c @@ -37,7 +37,7 @@ #include #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-engine-gv11b.h" #ifdef ENGINE_GV11B_UNIT_DEBUG diff --git a/userspace/units/fifo/engine/nvgpu-engine.c b/userspace/units/fifo/engine/nvgpu-engine.c index 1f1ef144c..ab7953ab9 100644 --- a/userspace/units/fifo/engine/nvgpu-engine.c +++ b/userspace/units/fifo/engine/nvgpu-engine.c @@ -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" diff --git a/userspace/units/fifo/fifo/Makefile b/userspace/units/fifo/fifo/Makefile new file mode 100644 index 000000000..a47f3af14 --- /dev/null +++ b/userspace/units/fifo/fifo/Makefile @@ -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 .. \ No newline at end of file diff --git a/userspace/units/fifo/fifo/Makefile.interface.tmk b/userspace/units/fifo/fifo/Makefile.interface.tmk new file mode 100644 index 000000000..4362e20ac --- /dev/null +++ b/userspace/units/fifo/fifo/Makefile.interface.tmk @@ -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: diff --git a/userspace/units/fifo/fifo/Makefile.tmk b/userspace/units/fifo/fifo/Makefile.tmk new file mode 100644 index 000000000..6141469a4 --- /dev/null +++ b/userspace/units/fifo/fifo/Makefile.tmk @@ -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: diff --git a/userspace/units/fifo/fifo/gk20a/Makefile b/userspace/units/fifo/fifo/gk20a/Makefile index aa19a310d..6c931da6f 100644 --- a/userspace/units/fifo/fifo/gk20a/Makefile +++ b/userspace/units/fifo/fifo/gk20a/Makefile @@ -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 diff --git a/userspace/units/fifo/fifo/gk20a/nvgpu-fifo-gk20a.c b/userspace/units/fifo/fifo/gk20a/nvgpu-fifo-gk20a.c index 3447211b9..faa4893dc 100644 --- a/userspace/units/fifo/fifo/gk20a/nvgpu-fifo-gk20a.c +++ b/userspace/units/fifo/fifo/gk20a/nvgpu-fifo-gk20a.c @@ -39,7 +39,7 @@ #include "hal/fifo/fifo_gk20a.h" #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-fifo-gk20a.h" #include "nvgpu-fifo-intr-gk20a.h" diff --git a/userspace/units/fifo/fifo/gk20a/nvgpu-fifo-intr-gk20a.c b/userspace/units/fifo/fifo/gk20a/nvgpu-fifo-intr-gk20a.c index 4e02ce6f5..7780acac0 100644 --- a/userspace/units/fifo/fifo/gk20a/nvgpu-fifo-intr-gk20a.c +++ b/userspace/units/fifo/fifo/gk20a/nvgpu-fifo-intr-gk20a.c @@ -41,7 +41,7 @@ #include "hal/fifo/fifo_intr_gk20a.h" #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-fifo-intr-gk20a.h" #ifdef FIFO_GK20A_INTR_UNIT_DEBUG diff --git a/userspace/units/fifo/fifo/gv11b/Makefile b/userspace/units/fifo/fifo/gv11b/Makefile index 8fd4286d0..13c4fead3 100644 --- a/userspace/units/fifo/fifo/gv11b/Makefile +++ b/userspace/units/fifo/fifo/gv11b/Makefile @@ -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 diff --git a/userspace/units/fifo/fifo/gv11b/nvgpu-fifo-gv11b.c b/userspace/units/fifo/fifo/gv11b/nvgpu-fifo-gv11b.c index dce2e7828..fb2c0367e 100644 --- a/userspace/units/fifo/fifo/gv11b/nvgpu-fifo-gv11b.c +++ b/userspace/units/fifo/fifo/gv11b/nvgpu-fifo-gv11b.c @@ -41,7 +41,7 @@ #include "hal/fifo/fifo_gv11b.h" #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-fifo-gv11b.h" #include "nvgpu-fifo-intr-gv11b.h" diff --git a/userspace/units/fifo/fifo/gv11b/nvgpu-fifo-intr-gv11b.c b/userspace/units/fifo/fifo/gv11b/nvgpu-fifo-intr-gv11b.c index 74a514ce9..0c080c50d 100644 --- a/userspace/units/fifo/fifo/gv11b/nvgpu-fifo-intr-gv11b.c +++ b/userspace/units/fifo/fifo/gv11b/nvgpu-fifo-intr-gv11b.c @@ -44,7 +44,7 @@ #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-fifo-intr-gv11b.h" #define FIFO_GV11B_INTR_UNIT_DEBUG diff --git a/userspace/units/fifo/fifo/nvgpu-fifo.c b/userspace/units/fifo/fifo/nvgpu-fifo.c new file mode 100644 index 000000000..0acfcdab7 --- /dev/null +++ b/userspace/units/fifo/fifo/nvgpu-fifo.c @@ -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 +#include +#include + +#include +#include +#include +#include + +#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); diff --git a/userspace/units/fifo/fifo/nvgpu-fifo.h b/userspace/units/fifo/fifo/nvgpu-fifo.h new file mode 100644 index 000000000..d1c4a2630 --- /dev/null +++ b/userspace/units/fifo/fifo/nvgpu-fifo.h @@ -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 + +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 */ diff --git a/userspace/units/fifo/libnvgpu-fifo.export b/userspace/units/fifo/libnvgpu-fifo-common.export similarity index 98% rename from userspace/units/fifo/libnvgpu-fifo.export rename to userspace/units/fifo/libnvgpu-fifo-common.export index ae4074567..dc2d3d6a2 100644 --- a/userspace/units/fifo/libnvgpu-fifo.export +++ b/userspace/units/fifo/libnvgpu-fifo-common.export @@ -21,6 +21,7 @@ # test_fifo_init_support +test_fifo_get_log2 test_fifo_remove_support test_fifo_subtest_pruned test_fifo_flags_str diff --git a/userspace/units/fifo/nvgpu-fifo.c b/userspace/units/fifo/nvgpu-fifo-common.c similarity index 83% rename from userspace/units/fifo/nvgpu-fifo.c rename to userspace/units/fifo/nvgpu-fifo-common.c index a1a602bea..0f11b2d74 100644 --- a/userspace/units/fifo/nvgpu-fifo.c +++ b/userspace/units/fifo/nvgpu-fifo-common.c @@ -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; diff --git a/userspace/units/fifo/nvgpu-fifo.h b/userspace/units/fifo/nvgpu-fifo-common.h similarity index 93% rename from userspace/units/fifo/nvgpu-fifo.h rename to userspace/units/fifo/nvgpu-fifo-common.h index cca69598c..a92a7cbf9 100644 --- a/userspace/units/fifo/nvgpu-fifo.h +++ b/userspace/units/fifo/nvgpu-fifo-common.h @@ -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 @@ -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 */ diff --git a/userspace/units/fifo/pbdma/Makefile b/userspace/units/fifo/pbdma/Makefile index 1d282d28e..726b36a32 100644 --- a/userspace/units/fifo/pbdma/Makefile +++ b/userspace/units/fifo/pbdma/Makefile @@ -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 diff --git a/userspace/units/fifo/pbdma/gm20b/Makefile b/userspace/units/fifo/pbdma/gm20b/Makefile index d7265ee71..525ac186b 100644 --- a/userspace/units/fifo/pbdma/gm20b/Makefile +++ b/userspace/units/fifo/pbdma/gm20b/Makefile @@ -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 diff --git a/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.c b/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.c index 88cd7c08b..f2ab332f4 100644 --- a/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.c +++ b/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.c @@ -40,7 +40,7 @@ #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "../../nvgpu-fifo-gv11b.h" #include "nvgpu-pbdma-gm20b.h" diff --git a/userspace/units/fifo/pbdma/gp10b/Makefile b/userspace/units/fifo/pbdma/gp10b/Makefile index 31cc33f5a..a3b0b75ad 100644 --- a/userspace/units/fifo/pbdma/gp10b/Makefile +++ b/userspace/units/fifo/pbdma/gp10b/Makefile @@ -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 diff --git a/userspace/units/fifo/pbdma/gp10b/nvgpu-pbdma-gp10b.c b/userspace/units/fifo/pbdma/gp10b/nvgpu-pbdma-gp10b.c index 4155e9429..f5805e715 100644 --- a/userspace/units/fifo/pbdma/gp10b/nvgpu-pbdma-gp10b.c +++ b/userspace/units/fifo/pbdma/gp10b/nvgpu-pbdma-gp10b.c @@ -41,7 +41,7 @@ #include #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "../../nvgpu-fifo-gv11b.h" #include "nvgpu-pbdma-gp10b.h" diff --git a/userspace/units/fifo/pbdma/gv11b/Makefile b/userspace/units/fifo/pbdma/gv11b/Makefile index bf57d598d..9ac1a4dcb 100644 --- a/userspace/units/fifo/pbdma/gv11b/Makefile +++ b/userspace/units/fifo/pbdma/gv11b/Makefile @@ -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 diff --git a/userspace/units/fifo/pbdma/gv11b/nvgpu-pbdma-gv11b.c b/userspace/units/fifo/pbdma/gv11b/nvgpu-pbdma-gv11b.c index 75d4b94a9..64cebaf7d 100644 --- a/userspace/units/fifo/pbdma/gv11b/nvgpu-pbdma-gv11b.c +++ b/userspace/units/fifo/pbdma/gv11b/nvgpu-pbdma-gv11b.c @@ -41,7 +41,7 @@ #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "../../nvgpu-fifo-gv11b.h" #include "nvgpu-pbdma-gv11b.h" diff --git a/userspace/units/fifo/pbdma/nvgpu-pbdma.c b/userspace/units/fifo/pbdma/nvgpu-pbdma.c index c661f86f1..cc8ecc440 100644 --- a/userspace/units/fifo/pbdma/nvgpu-pbdma.c +++ b/userspace/units/fifo/pbdma/nvgpu-pbdma.c @@ -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" diff --git a/userspace/units/fifo/preempt/Makefile b/userspace/units/fifo/preempt/Makefile index e81c874a0..6a7bd8f51 100644 --- a/userspace/units/fifo/preempt/Makefile +++ b/userspace/units/fifo/preempt/Makefile @@ -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 diff --git a/userspace/units/fifo/preempt/nvgpu-preempt.c b/userspace/units/fifo/preempt/nvgpu-preempt.c index cd411e2b6..1db8dfef6 100644 --- a/userspace/units/fifo/preempt/nvgpu-preempt.c +++ b/userspace/units/fifo/preempt/nvgpu-preempt.c @@ -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 diff --git a/userspace/units/fifo/runlist/Makefile b/userspace/units/fifo/runlist/Makefile index a4c3bc703..b399d04ce 100644 --- a/userspace/units/fifo/runlist/Makefile +++ b/userspace/units/fifo/runlist/Makefile @@ -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 diff --git a/userspace/units/fifo/runlist/gk20a/Makefile b/userspace/units/fifo/runlist/gk20a/Makefile index cac15b94a..67f5a4961 100644 --- a/userspace/units/fifo/runlist/gk20a/Makefile +++ b/userspace/units/fifo/runlist/gk20a/Makefile @@ -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 diff --git a/userspace/units/fifo/runlist/gk20a/nvgpu-runlist-gk20a.c b/userspace/units/fifo/runlist/gk20a/nvgpu-runlist-gk20a.c index 53d36fe05..49b68075f 100644 --- a/userspace/units/fifo/runlist/gk20a/nvgpu-runlist-gk20a.c +++ b/userspace/units/fifo/runlist/gk20a/nvgpu-runlist-gk20a.c @@ -44,7 +44,7 @@ #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-runlist-gk20a.h" #ifdef RUNLIST_GK20A_UNIT_DEBUG diff --git a/userspace/units/fifo/runlist/gv11b/Makefile b/userspace/units/fifo/runlist/gv11b/Makefile index 0167a587e..fcabf9701 100644 --- a/userspace/units/fifo/runlist/gv11b/Makefile +++ b/userspace/units/fifo/runlist/gv11b/Makefile @@ -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 diff --git a/userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.c b/userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.c index a61279331..636243fbb 100644 --- a/userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.c +++ b/userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.c @@ -44,7 +44,7 @@ #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-runlist-gv11b.h" #define RUNLIST_GV11B_UNIT_DEBUG diff --git a/userspace/units/fifo/runlist/nvgpu-runlist.c b/userspace/units/fifo/runlist/nvgpu-runlist.c index 8043441cd..0f337c411 100644 --- a/userspace/units/fifo/runlist/nvgpu-runlist.c +++ b/userspace/units/fifo/runlist/nvgpu-runlist.c @@ -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 diff --git a/userspace/units/fifo/tsg/Makefile b/userspace/units/fifo/tsg/Makefile index 096232cc2..3785f4a0c 100644 --- a/userspace/units/fifo/tsg/Makefile +++ b/userspace/units/fifo/tsg/Makefile @@ -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 diff --git a/userspace/units/fifo/tsg/gv11b/Makefile b/userspace/units/fifo/tsg/gv11b/Makefile index 6878e1c40..252d1f8e0 100644 --- a/userspace/units/fifo/tsg/gv11b/Makefile +++ b/userspace/units/fifo/tsg/gv11b/Makefile @@ -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 diff --git a/userspace/units/fifo/tsg/gv11b/nvgpu-tsg-gv11b.c b/userspace/units/fifo/tsg/gv11b/nvgpu-tsg-gv11b.c index d6755f6ff..113bb4873 100644 --- a/userspace/units/fifo/tsg/gv11b/nvgpu-tsg-gv11b.c +++ b/userspace/units/fifo/tsg/gv11b/nvgpu-tsg-gv11b.c @@ -46,7 +46,7 @@ #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-tsg-gv11b.h" #ifdef TSG_GV11B_UNIT_DEBUG diff --git a/userspace/units/fifo/tsg/nvgpu-tsg.c b/userspace/units/fifo/tsg/nvgpu-tsg.c index 202d901ff..7b398dee5 100644 --- a/userspace/units/fifo/tsg/nvgpu-tsg.c +++ b/userspace/units/fifo/tsg/nvgpu-tsg.c @@ -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 diff --git a/userspace/units/fifo/userd/gk20a/Makefile b/userspace/units/fifo/userd/gk20a/Makefile index eeaf3c1a7..2809dab57 100644 --- a/userspace/units/fifo/userd/gk20a/Makefile +++ b/userspace/units/fifo/userd/gk20a/Makefile @@ -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 diff --git a/userspace/units/fifo/userd/gk20a/nvgpu-userd-gk20a.c b/userspace/units/fifo/userd/gk20a/nvgpu-userd-gk20a.c index 84e1e2e5a..b40e9d862 100644 --- a/userspace/units/fifo/userd/gk20a/nvgpu-userd-gk20a.c +++ b/userspace/units/fifo/userd/gk20a/nvgpu-userd-gk20a.c @@ -40,7 +40,7 @@ #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-userd-gk20a.h" #ifdef USERD_GK20A_UNIT_DEBUG diff --git a/userspace/units/fifo/usermode/gv11b/Makefile b/userspace/units/fifo/usermode/gv11b/Makefile index 3ab647621..cb0dd0afd 100644 --- a/userspace/units/fifo/usermode/gv11b/Makefile +++ b/userspace/units/fifo/usermode/gv11b/Makefile @@ -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 diff --git a/userspace/units/fifo/usermode/gv11b/nvgpu-usermode-gv11b.c b/userspace/units/fifo/usermode/gv11b/nvgpu-usermode-gv11b.c index af345796c..7e185fdad 100644 --- a/userspace/units/fifo/usermode/gv11b/nvgpu-usermode-gv11b.c +++ b/userspace/units/fifo/usermode/gv11b/nvgpu-usermode-gv11b.c @@ -38,7 +38,7 @@ #include -#include "../../nvgpu-fifo.h" +#include "../../nvgpu-fifo-common.h" #include "nvgpu-usermode-gv11b.h" #ifdef USERMODE_GV11B_UNIT_DEBUG diff --git a/userspace/units/sync/Makefile b/userspace/units/sync/Makefile index 00d01b2d4..80dcda954 100644 --- a/userspace/units/sync/Makefile +++ b/userspace/units/sync/Makefile @@ -23,7 +23,7 @@ OBJS = nvgpu-sync.o MODULE = nvgpu-sync -LIB_PATHS += -lnvgpu-fifo +LIB_PATHS += -lnvgpu-fifo-common include ../Makefile.units diff --git a/userspace/units/sync/nvgpu-sync.c b/userspace/units/sync/nvgpu-sync.c index 152ff71cc..0645b744c 100644 --- a/userspace/units/sync/nvgpu-sync.c +++ b/userspace/units/sync/nvgpu-sync.c @@ -34,7 +34,7 @@ #include #include -#include "../fifo/nvgpu-fifo.h" +#include "../fifo/nvgpu-fifo-common.h" #include "../fifo/nvgpu-fifo-gv11b.h" #include "nvgpu-sync.h"