mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 02:22:34 +03:00
gpu: nvgpu: unit: add tests for gv11b runlist HAL
Add unit tests for the following HALs: - gv11b_runlist_entry_size - gv11b_runlist_get_tsg_entry - gv11b_runlist_get_ch_entry Jira NVGPU-3793 Change-Id: If4c574efacc316e6c410b3f2872fd41b1470011b Signed-off-by: Thomas Fleury <tfleury@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2239477 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
a717ba1a50
commit
0130ebd349
32
userspace/units/fifo/runlist/gv11b/Makefile
Normal file
32
userspace/units/fifo/runlist/gv11b/Makefile
Normal 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-runlist-gv11b.o
|
||||
MODULE = nvgpu-runlist-gv11b
|
||||
|
||||
LIB_PATHS += -lnvgpu-fifo
|
||||
include ../../../Makefile.units
|
||||
|
||||
lib$(MODULE).so: fifo
|
||||
|
||||
fifo:
|
||||
$(MAKE) -C ../..
|
||||
35
userspace/units/fifo/runlist/gv11b/Makefile.interface.tmk
Normal file
35
userspace/units/fifo/runlist/gv11b/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-runlist-gv11b
|
||||
|
||||
include $(NV_SOURCE)/kernel/nvgpu/userspace/units/Makefile.units.common.interface.tmk
|
||||
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: t
|
||||
# tab-width: 8
|
||||
# End:
|
||||
# vi: set tabstop=8 noexpandtab:
|
||||
40
userspace/units/fifo/runlist/gv11b/Makefile.tmk
Normal file
40
userspace/units/fifo/runlist/gv11b/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-runlist-gv11b
|
||||
NVGPU_UNIT_SRCS = nvgpu-runlist-gv11b.c
|
||||
|
||||
NVGPU_UNIT_INTERFACE_DIRS := \
|
||||
$(NV_SOURCE)/kernel/nvgpu/userspace/units/fifo \
|
||||
$(NV_SOURCE)/kernel/nvgpu/drivers/gpu/nvgpu
|
||||
|
||||
include $(NV_SOURCE)/kernel/nvgpu/userspace/units/Makefile.units.common.tmk
|
||||
|
||||
# Local Variables:
|
||||
# indent-tabs-mode: t
|
||||
# tab-width: 8
|
||||
# End:
|
||||
# vi: set tabstop=8 noexpandtab:
|
||||
159
userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.c
Normal file
159
userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.c
Normal file
@@ -0,0 +1,159 @@
|
||||
/*
|
||||
* 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 <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <unit/io.h>
|
||||
#include <unit/unit.h>
|
||||
|
||||
#include <nvgpu/channel.h>
|
||||
#include <nvgpu/tsg.h>
|
||||
#include <nvgpu/gk20a.h>
|
||||
#include <nvgpu/engines.h>
|
||||
#include <nvgpu/runlist.h>
|
||||
#include <nvgpu/fuse.h>
|
||||
#include <nvgpu/dma.h>
|
||||
#include <nvgpu/gr/ctx.h>
|
||||
|
||||
#include "common/gr/ctx_priv.h"
|
||||
#include <nvgpu/posix/posix-fault-injection.h>
|
||||
|
||||
#include "hal/fifo/runlist_ram_gv11b.h"
|
||||
|
||||
#include <nvgpu/hw/gv11b/hw_ram_gv11b.h>
|
||||
|
||||
|
||||
#include "../../nvgpu-fifo.h"
|
||||
#include "nvgpu-runlist-gv11b.h"
|
||||
|
||||
#define RUNLIST_GV11B_UNIT_DEBUG
|
||||
#ifdef RUNLIST_GV11B_UNIT_DEBUG
|
||||
#undef unit_verbose
|
||||
#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)
|
||||
|
||||
int test_gv11b_runlist_entry_size(struct unit_module *m,
|
||||
struct gk20a *g, void *args)
|
||||
{
|
||||
int ret = UNIT_FAIL;
|
||||
|
||||
assert(gv11b_runlist_entry_size(g) == ram_rl_entry_size_v());
|
||||
ret = UNIT_SUCCESS;
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define RL_MAX_TIMESLICE_TIMEOUT ram_rl_entry_tsg_timeslice_timeout_v(U32_MAX)
|
||||
#define RL_MAX_TIMESLICE_SCALE ram_rl_entry_tsg_timeslice_scale_v(U32_MAX)
|
||||
|
||||
int test_gv11b_runlist_get_tsg_entry(struct unit_module *m,
|
||||
struct gk20a *g, void *args)
|
||||
{
|
||||
struct nvgpu_tsg *tsg = NULL;
|
||||
int ret = UNIT_FAIL;
|
||||
u32 timeslice;
|
||||
u32 runlist[4];
|
||||
|
||||
tsg = nvgpu_tsg_open(g, getpid());
|
||||
assert(tsg != NULL);
|
||||
|
||||
/* no scaling */
|
||||
timeslice = RL_MAX_TIMESLICE_TIMEOUT / 2;
|
||||
gv11b_runlist_get_tsg_entry(tsg, runlist, timeslice);
|
||||
assert(ram_rl_entry_tsg_timeslice_timeout_v(runlist[0]) == timeslice);
|
||||
assert(ram_rl_entry_tsg_timeslice_scale_v(runlist[0]) == 0U);
|
||||
assert(runlist[1] == ram_rl_entry_tsg_length_f(tsg->num_active_channels));
|
||||
assert(runlist[2] == ram_rl_entry_tsg_tsgid_f(tsg->tsgid));
|
||||
|
||||
/* scaling */
|
||||
timeslice = RL_MAX_TIMESLICE_TIMEOUT + 1;
|
||||
gv11b_runlist_get_tsg_entry(tsg, runlist, timeslice);
|
||||
assert(ram_rl_entry_tsg_timeslice_timeout_v(runlist[0]) == (timeslice >> 1U));
|
||||
assert(ram_rl_entry_tsg_timeslice_scale_v(runlist[0]) == 1U);
|
||||
|
||||
/* oversize */
|
||||
timeslice = U32_MAX;
|
||||
gv11b_runlist_get_tsg_entry(tsg, runlist, timeslice);
|
||||
assert(ram_rl_entry_tsg_timeslice_timeout_v(runlist[0]) == RL_MAX_TIMESLICE_TIMEOUT);
|
||||
assert(ram_rl_entry_tsg_timeslice_scale_v(runlist[0]) == RL_MAX_TIMESLICE_SCALE);
|
||||
|
||||
ret = UNIT_SUCCESS;
|
||||
|
||||
done:
|
||||
if (tsg != NULL) {
|
||||
nvgpu_ref_put(&tsg->refcount, nvgpu_tsg_release);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
int test_gv11b_runlist_get_ch_entry(struct unit_module *m,
|
||||
struct gk20a *g, void *args)
|
||||
{
|
||||
struct nvgpu_channel *ch = NULL;
|
||||
int ret = UNIT_FAIL;
|
||||
u32 runlist[4];
|
||||
struct nvgpu_mem mem;
|
||||
|
||||
ch = nvgpu_channel_open_new(g, NVGPU_INVALID_RUNLIST_ID,
|
||||
false, getpid(), getpid());
|
||||
assert(ch);
|
||||
|
||||
ch->userd_mem = &mem;
|
||||
mem.aperture = APERTURE_SYSMEM;
|
||||
ch->userd_iova = 0x1000beef;
|
||||
|
||||
gv11b_runlist_get_ch_entry(ch, runlist);
|
||||
assert(runlist[1] == u64_hi32(ch->userd_iova));
|
||||
assert(ram_rl_entry_chid_f(runlist[2]) == ch->chid);
|
||||
assert(runlist[3] == u64_hi32(nvgpu_inst_block_addr(g, &ch->inst_block)));
|
||||
|
||||
ch->userd_mem = NULL;
|
||||
|
||||
ret = UNIT_SUCCESS;
|
||||
|
||||
done:
|
||||
if (ch != NULL) {
|
||||
nvgpu_channel_close(ch);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
struct unit_module_test nvgpu_runlist_gv11b_tests[] = {
|
||||
UNIT_TEST(init_support, test_fifo_init_support, NULL, 0),
|
||||
UNIT_TEST(entry_size, test_gv11b_runlist_entry_size, NULL, 0),
|
||||
UNIT_TEST(get_tsg_entry, test_gv11b_runlist_get_tsg_entry, NULL, 0),
|
||||
UNIT_TEST(get_ch_entry, test_gv11b_runlist_get_ch_entry, NULL, 0),
|
||||
UNIT_TEST(remove_support, test_fifo_remove_support, NULL, 0),
|
||||
};
|
||||
|
||||
UNIT_MODULE(nvgpu_runlist_gv11b, nvgpu_runlist_gv11b_tests, UNIT_PRIO_NVGPU_TEST);
|
||||
98
userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.h
Normal file
98
userspace/units/fifo/runlist/gv11b/nvgpu-runlist-gv11b.h
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* 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_RUNLIST_GV11B_H
|
||||
#define UNIT_NVGPU_RUNLIST_GV11B_H
|
||||
|
||||
#include <nvgpu/types.h>
|
||||
|
||||
struct unit_module;
|
||||
struct gk20a;
|
||||
|
||||
/** @addtogroup SWUTS-fifo-runlist-gv11b
|
||||
* @{
|
||||
*
|
||||
* Software Unit Test Specification for fifo/runlist/gv11b
|
||||
*/
|
||||
|
||||
/**
|
||||
* Test specification for: test_gv11b_runlist_entry_size
|
||||
*
|
||||
* Description: Branch coverage for gv11b_runlist_entry_size
|
||||
*
|
||||
* Test Type: Feature based
|
||||
*
|
||||
* Input: test_fifo_init_support() run for this GPU
|
||||
*
|
||||
* Steps:
|
||||
* - Check that runlist entry size matches the H/W manuals
|
||||
*
|
||||
* Output: Returns PASS if all branches gave expected results. FAIL otherwise.
|
||||
*/
|
||||
int test_gv11b_runlist_entry_size(struct unit_module *m,
|
||||
struct gk20a *g, void *args);
|
||||
|
||||
/**
|
||||
* Test specification for: test_gv11b_runlist_get_tsg_entry
|
||||
*
|
||||
* Description: Branch coverage for gv11b_runlist_get_tsg_entry
|
||||
*
|
||||
* Test Type: Feature based
|
||||
*
|
||||
* Input: test_fifo_init_support() run for this GPU
|
||||
*
|
||||
* Steps:
|
||||
* - Allocate TSG.
|
||||
* - Get runlist entry with timeslice that does not need scaling
|
||||
* - Check timeout and scale in returned runlist entry
|
||||
* - Check length and tsgid as well
|
||||
* - Get runlist entry with a timeslice that needs scaling
|
||||
* - Get runlist entry with an oversize timeslice
|
||||
*
|
||||
* Output: Returns PASS if all branches gave expected results. FAIL otherwise.
|
||||
*/
|
||||
int test_gv11b_runlist_get_tsg_entry(struct unit_module *m,
|
||||
struct gk20a *g, void *args);
|
||||
|
||||
/**
|
||||
* Test specification for: test_gv11b_runlist_get_ch_entry
|
||||
*
|
||||
* Description: Branch coverage for gv11b_runlist_get_ch_entry
|
||||
*
|
||||
* Test Type: Feature based
|
||||
*
|
||||
* Input: test_fifo_init_support() run for this GPU
|
||||
*
|
||||
* Steps:
|
||||
* - Allocate channel.
|
||||
* - Get runlist entry for the channel.
|
||||
* - Check userd and inst block addr in returned runlist entry.
|
||||
*
|
||||
* Output: Returns PASS if all branches gave expected results. FAIL otherwise.
|
||||
*/
|
||||
int test_gv11b_runlist_get_ch_entry(struct unit_module *m,
|
||||
struct gk20a *g, void *args);
|
||||
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
||||
#endif /* UNIT_NVGPU_RUNLIST_GV11B_H */
|
||||
Reference in New Issue
Block a user