gpu: nvgpu: construct initial utf for sync unit.

This patch constructs the initial setup for sync unit.
There are three simple tests currently. The first test inits the
environment necessary such as regspace init, hal init. The second
step simply fails the creation of the sync and the last test is meant
as a deinit step.

JIRA NVGPU-913

Change-Id: I1db72d9833c3c4bc3c3903a7d81cce06e9983509
Signed-off-by: Debarshi Dutta <ddutta@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2248493
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Debarshi Dutta
2019-11-27 10:49:49 +05:30
committed by Alex Waterman
parent bb942331e8
commit 4cc1fa1a0b
12 changed files with 379 additions and 76 deletions

View File

@@ -97,6 +97,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/gr/setup
NV_REPOSITORY_COMPONENTS += userspace/units/gr/intr NV_REPOSITORY_COMPONENTS += userspace/units/gr/intr
NV_REPOSITORY_COMPONENTS += userspace/units/acr NV_REPOSITORY_COMPONENTS += userspace/units/acr
NV_REPOSITORY_COMPONENTS += userspace/units/cg NV_REPOSITORY_COMPONENTS += userspace/units/cg
NV_REPOSITORY_COMPONENTS += userspace/units/sync
endif endif
# Local Variables: # Local Variables:

View File

@@ -53,7 +53,8 @@ headers:
include/nvgpu/posix/soc_fuse.h, include/nvgpu/posix/soc_fuse.h,
include/nvgpu/posix/vm.h, include/nvgpu/posix/vm.h,
include/nvgpu/posix/posix_vidmem.h, include/nvgpu/posix/posix_vidmem.h,
include/nvgpu/posix/queue.h ] include/nvgpu/posix/queue.h,
include/nvgpu/posix/posix-nvhost.h ]
sort: sort:
safe: yes safe: yes

View File

@@ -0,0 +1,57 @@
/*
* 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 NVGPU_POSIX_NVHOST_H
#define NVGPU_POSIX_NVHOST_H
#include <nvgpu/types.h>
struct gk20a;
struct nvgpu_nvhost_dev {
u32 host1x_sp_base;
u32 host1x_sp_size;
u32 nb_hw_pts;
};
void nvgpu_free_nvhost_dev(struct gk20a *g);
int nvgpu_get_nvhost_dev(struct gk20a *g);
int nvgpu_nvhost_syncpt_unit_interface_get_aperture(
struct nvgpu_nvhost_dev *nvgpu_syncpt_dev,
u64 *base, size_t *size);
u32 nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(u32 syncpt_id);
void nvgpu_nvhost_syncpt_set_min_eq_max_ext(
struct nvgpu_nvhost_dev *nvhost_dev, u32 id);
void nvgpu_nvhost_syncpt_put_ref_ext(
struct nvgpu_nvhost_dev *nvhost_dev, u32 id);
u32 nvgpu_nvhost_get_syncpt_client_managed(
struct nvgpu_nvhost_dev *nvhost_dev,
const char *syncpt_name);
void nvgpu_nvhost_syncpt_set_safe_state(
struct nvgpu_nvhost_dev *nvhost_dev, u32 id);
#endif

View File

@@ -498,4 +498,5 @@ nvgpu_test_bit
nvgpu_test_and_clear_bit nvgpu_test_and_clear_bit
nvgpu_test_and_set_bit nvgpu_test_and_set_bit
vm_aspace_id vm_aspace_id
nvgpu_get_nvhost_dev
nvgpu_free_nvhost_dev

View File

@@ -22,27 +22,72 @@
#include <nvgpu/gk20a.h> #include <nvgpu/gk20a.h>
#include <nvgpu/bug.h> #include <nvgpu/bug.h>
#include <nvgpu/nvhost.h> #include <nvgpu/posix/posix-nvhost.h>
static inline u32 nvgpu_nvhost_syncpt_nb_hw_pts(
struct nvgpu_nvhost_dev *nvgpu_syncpt_dev)
{
return nvgpu_syncpt_dev->nb_hw_pts;
}
void nvgpu_free_nvhost_dev(struct gk20a *g) {
if (g->nvhost_dev != NULL) {
nvgpu_kfree(g, g->nvhost_dev);
g->nvhost_dev = NULL;
}
}
int nvgpu_get_nvhost_dev(struct gk20a *g) int nvgpu_get_nvhost_dev(struct gk20a *g)
{ {
BUG(); int ret = 0;
g->nvhost_dev = nvgpu_kzalloc(g, sizeof(struct nvgpu_nvhost_dev));
if (g->nvhost_dev == NULL) {
return -ENOMEM;
}
g->nvhost_dev->host1x_sp_base = 0x60000000;
g->nvhost_dev->host1x_sp_size = 0x400000;
g->nvhost_dev->nb_hw_pts = 704U;
ret = nvgpu_nvhost_syncpt_unit_interface_get_aperture(
g->nvhost_dev, &g->syncpt_unit_base,
&g->syncpt_unit_size);
if (ret != 0) {
nvgpu_err(g, "Failed to get syncpt interface");
goto fail_nvgpu_get_nvhost_dev;
}
g->syncpt_size =
nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(1);
return 0; return 0;
fail_nvgpu_get_nvhost_dev:
nvgpu_free_nvhost_dev(g);
return ret;
} }
void nvgpu_free_nvhost_dev(struct gk20a *g) int nvgpu_nvhost_syncpt_unit_interface_get_aperture(
struct nvgpu_nvhost_dev *nvgpu_syncpt_dev,
u64 *base, size_t *size)
{ {
BUG(); if (nvgpu_syncpt_dev == NULL || base == NULL || size == NULL) {
return -ENOSYS;
} }
bool nvgpu_nvhost_syncpt_is_valid_pt_ext( *base = (u64)nvgpu_syncpt_dev->host1x_sp_base;
struct nvgpu_nvhost_dev *nvhost_dev, u32 id) *size = nvgpu_syncpt_dev->host1x_sp_size;
return 0;
}
u32 nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(u32 syncpt_id)
{ {
BUG(); return nvgpu_safe_mult_u32(syncpt_id, 0x1000U);
return false;
} }
void nvgpu_nvhost_syncpt_set_min_eq_max_ext( void nvgpu_nvhost_syncpt_set_min_eq_max_ext(
struct nvgpu_nvhost_dev *nvhost_dev, u32 id) struct nvgpu_nvhost_dev *nvhost_dev, u32 id)
{ {
@@ -59,14 +104,6 @@ u32 nvgpu_nvhost_get_syncpt_client_managed(
struct nvgpu_nvhost_dev *nvhost_dev, struct nvgpu_nvhost_dev *nvhost_dev,
const char *syncpt_name) const char *syncpt_name)
{ {
BUG();
return 0U;
}
u32 nvgpu_nvhost_syncpt_read_maxval(
struct nvgpu_nvhost_dev *nvhost_dev, u32 id)
{
BUG();
return 0U; return 0U;
} }
@@ -75,58 +112,3 @@ void nvgpu_nvhost_syncpt_set_safe_state(
{ {
BUG(); BUG();
} }
#ifdef CONFIG_SYNC
u32 nvgpu_nvhost_sync_pt_id(struct sync_pt *pt)
{
BUG();
return 0U;
}
u32 nvgpu_nvhost_sync_pt_thresh(struct sync_pt *pt)
{
BUG();
return 0U;
}
struct sync_fence *nvgpu_nvhost_sync_fdget(int fd)
{
BUG();
return NULL;
}
int nvgpu_nvhost_sync_num_pts(struct sync_fence *fence)
{
BUG();
return 0;
}
struct sync_fence *nvgpu_nvhost_sync_create_fence(
struct nvgpu_nvhost_dev *nvhost_dev,
u32 id, u32 thresh, const char *name)
{
BUG();
return NULL;
}
#endif /* CONFIG_SYNC */
#ifdef CONFIG_TEGRA_T19X_GRHOST
int nvgpu_nvhost_syncpt_unit_interface_get_aperture(
struct nvgpu_nvhost_dev *nvhost_dev,
u64 *base, size_t *size)
{
BUG();
return 0;
}
u32 nvgpu_nvhost_syncpt_unit_interface_get_byte_offset(u32 syncpt_id)
{
BUG();
return 0U;
}
int nvgpu_nvhost_syncpt_init(struct gk20a *g)
{
return -ENOSYS;
}
#endif

View File

@@ -105,4 +105,5 @@ UNITS := \
$(UNIT_SRC)/gr/intr \ $(UNIT_SRC)/gr/intr \
$(UNIT_SRC)/gr/setup \ $(UNIT_SRC)/gr/setup \
$(UNIT_SRC)/acr \ $(UNIT_SRC)/acr \
$(UNIT_SRC)/cg $(UNIT_SRC)/cg \
$(UNIT_SRC)/sync

View File

@@ -25,4 +25,4 @@ test_fifo_remove_support
test_fifo_subtest_pruned test_fifo_subtest_pruned
test_fifo_flags_str test_fifo_flags_str
test_fifo_setup_gv11b_reg_space test_fifo_setup_gv11b_reg_space
test_fifo_cleanup_gv11b_reg_space

View File

@@ -0,0 +1,33 @@
# Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a
# copy of this software and associated documentation files (the "Software"),
# to deal in the Software without restriction, including without limitation
# the rights to use, copy, modify, merge, publish, distribute, sublicense,
# and/or sell copies of the Software, and to permit persons to whom the
# Software is furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
# DEALINGS IN THE SOFTWARE.
.SUFFIXES:
OBJS = nvgpu-sync.o
MODULE = nvgpu-sync
LIB_PATHS += -lnvgpu-fifo
include ../Makefile.units
lib$(MODULE).so: nvgpu-fifo
nvgpu-fifo:
$(MAKE) -C ../fifo

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-sync
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,41 @@
################################## 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-sync
NVGPU_UNIT_SRCS=nvgpu-sync.c
NVGPU_UNIT_INTERFACE_DIRS := \
$(NV_COMPONENT_DIR)/../fifo \
$(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

@@ -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.
*/
#include <stdlib.h>
#include <unit/unit.h>
#include <unit/io.h>
#include <nvgpu/types.h>
#include <nvgpu/gk20a.h>
#include <nvgpu/hal_init.h>
#include <nvgpu/posix/io.h>
#include <nvgpu/posix/posix-fault-injection.h>
#include <nvgpu/posix/posix-nvhost.h>
#include <nvgpu/channel.h>
#include <nvgpu/channel_sync.h>
#include "../fifo/nvgpu-fifo-gv11b.h"
#include "nvgpu-sync.h"
#define NV_PMC_BOOT_0_ARCHITECTURE_GV110 (0x00000015 << \
NVGPU_GPU_ARCHITECTURE_SHIFT)
#define NV_PMC_BOOT_0_IMPLEMENTATION_B 0xB
static struct nvgpu_channel *ch;
int test_sync_init(struct unit_module *m, struct gk20a *g, void *args)
{
int ret = 0;
test_fifo_setup_gv11b_reg_space(m, g);
nvgpu_set_enabled(g, NVGPU_HAS_SYNCPOINTS, true);
/*
* HAL init parameters for gv11b
*/
g->params.gpu_arch = NV_PMC_BOOT_0_ARCHITECTURE_GV110;
g->params.gpu_impl = NV_PMC_BOOT_0_IMPLEMENTATION_B;
/*
* HAL init required for getting
* the sync ops initialized.
*/
ret = nvgpu_init_hal(g);
if (ret != 0) {
return -ENODEV;
}
ret = nvgpu_get_nvhost_dev(g);
if (ret != 0) {
unit_return_fail(m, "nvgpu_sync_early_init failed\n");
}
ch = nvgpu_kzalloc(g, sizeof(struct nvgpu_channel));
if (ch == NULL) {
unit_return_fail(m, "sync channel creation failure");
}
ch->g = g;
return UNIT_SUCCESS;
}
int test_sync_create_sync(struct unit_module *m, struct gk20a *g, void *args)
{
struct nvgpu_channel_sync *sync = NULL;
sync = nvgpu_channel_sync_create(ch, true);
if (sync != NULL) {
unit_return_fail(m, "expected failure in creating sync points");
}
return UNIT_SUCCESS;
}
int test_sync_deinit(struct unit_module *m, struct gk20a *g, void *args)
{
if (ch != NULL) {
nvgpu_kfree(g, ch);
}
if (g->nvhost_dev == NULL) {
unit_return_fail(m ,"no valid nvhost device exists\n");
}
nvgpu_free_nvhost_dev(g);
test_fifo_cleanup_gv11b_reg_space(m, g);
return UNIT_SUCCESS;
}
struct unit_module_test nvgpu_sync_tests[] = {
UNIT_TEST(sync_init, test_sync_init, NULL, 0),
UNIT_TEST(sync_deinit, test_sync_create_sync, NULL, 0),
UNIT_TEST(sync_deinit, test_sync_deinit, NULL, 0),
};
UNIT_MODULE(nvgpu-sync, nvgpu_sync_tests, UNIT_PRIO_NVGPU_TEST);

View File

@@ -0,0 +1,34 @@
/*
* 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_SYNC_H
#define UNIT_NVGPU_SYNC_H
#include <nvgpu/types.h>
struct gk20a;
struct unit_module;
int test_sync_init(struct unit_module *m, struct gk20a *g, void *args);
int test_sync_deinit(struct unit_module *m, struct gk20a *g, void *args);
int test_sync_create_sync(struct unit_module *m, struct gk20a *g, void *args);
#endif /* UNIT_NVGPU_SYNC_H */