diff --git a/Makefile.umbrella.tmk b/Makefile.umbrella.tmk index 14b1bfd9e..39305545c 100644 --- a/Makefile.umbrella.tmk +++ b/Makefile.umbrella.tmk @@ -56,6 +56,7 @@ NV_REPOSITORY_COMPONENTS += userspace/units/mm/page_table_faults NV_REPOSITORY_COMPONENTS += userspace/units/mm/vm NV_REPOSITORY_COMPONENTS += userspace/units/fifo/channel NV_REPOSITORY_COMPONENTS += userspace/units/fifo/runlist +NV_REPOSITORY_COMPONENTS += userspace/units/fifo/tsg NV_REPOSITORY_COMPONENTS += userspace/units/fuse NV_REPOSITORY_COMPONENTS += userspace/units/list NV_REPOSITORY_COMPONENTS += userspace/units/enabled diff --git a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export index b5b56e5aa..551d8a703 100644 --- a/drivers/gpu/nvgpu/libnvgpu-drv_safe.export +++ b/drivers/gpu/nvgpu/libnvgpu-drv_safe.export @@ -20,6 +20,7 @@ nvgpu_gmmu_map_locked nvgpu_gmmu_unmap_locked gk20a_ramin_alloc_size gk20a_mm_fb_flush +gk20a_open_new_channel gm20b_fb_tlb_invalidate gm20b_fuse_status_opt_gpc gm20b_ramin_set_big_page_size @@ -62,6 +63,7 @@ nvgpu_aperture_mask nvgpu_bar1_readl nvgpu_bar1_writel nvgpu_bsearch +nvgpu_channel_close nvgpu_dma_alloc nvgpu_dma_alloc_get_fault_injection nvgpu_dma_alloc_vid_at @@ -70,6 +72,7 @@ nvgpu_fifo_init_support nvgpu_free nvgpu_free_enabled_flags nvgpu_free_fixed +nvgpu_free_gr_ctx_struct nvgpu_get_pte nvgpu_gmmu_init_page_table nvgpu_gmmu_map @@ -160,7 +163,14 @@ nvgpu_readl nvgpu_readl_impl nvgpu_runlist_construct_locked nvgpu_rwsem_init +nvgpu_tsg_bind_channel +nvgpu_tsg_check_and_get_from_id nvgpu_tsg_default_timeslice_us +nvgpu_tsg_open +nvgpu_tsg_release +nvgpu_tsg_unbind_channel +nvgpu_tsg_unbind_channel_check_hw_state +nvgpu_tsg_unbind_channel_check_ctx_reload nvgpu_set_enabled nvgpu_set_pte nvgpu_sgt_alignment diff --git a/userspace/required_tests.json b/userspace/required_tests.json index 720da6524..562928a44 100644 --- a/userspace/required_tests.json +++ b/userspace/required_tests.json @@ -749,6 +749,26 @@ "test_level": 0, "unit": "nvgpu_sgt" }, + { + "test": "init_support", + "test_level": 0, + "unit": "nvgpu_tsg" + }, + { + "test": "open", + "test_level": 0, + "unit": "nvgpu_tsg" + }, + { + "test": "release", + "test_level": 0, + "unit": "nvgpu_tsg" + }, + { + "test": "remove_support", + "test_level": 0, + "unit": "nvgpu_tsg" + }, { "test": "add_empty_slab", "test_level": 0, diff --git a/userspace/units/fifo/tsg/Makefile b/userspace/units/fifo/tsg/Makefile index e127217ed..e7d093bdf 100644 --- a/userspace/units/fifo/tsg/Makefile +++ b/userspace/units/fifo/tsg/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved. +# 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"), @@ -20,7 +20,7 @@ .SUFFIXES: -OBJS = nvgpu-tsg.o ../nvgpu-fifo-gv11b.o +OBJS = nvgpu-tsg.o ../nvgpu-fifo.o ../nvgpu-fifo-gv11b.o MODULE = nvgpu-tsg include ../../Makefile.units diff --git a/userspace/units/fifo/tsg/Makefile.tmk b/userspace/units/fifo/tsg/Makefile.tmk index eb4fc4566..521c9c82f 100644 --- a/userspace/units/fifo/tsg/Makefile.tmk +++ b/userspace/units/fifo/tsg/Makefile.tmk @@ -24,7 +24,11 @@ # ############################################################################### -NVGPU_UNIT_NAME=nvgpu-tsg +NVGPU_UNIT_NAME = nvgpu-tsg +NVGPU_UNIT_SRCS = \ + nvgpu-tsg.c \ + ../nvgpu-fifo.c \ + ../nvgpu-fifo-gv11b.c include $(NV_COMPONENT_DIR)/../../Makefile.units.common.tmk diff --git a/userspace/units/fifo/tsg/nvgpu-tsg.c b/userspace/units/fifo/tsg/nvgpu-tsg.c index c90fbebf9..eaed682d9 100644 --- a/userspace/units/fifo/tsg/nvgpu-tsg.c +++ b/userspace/units/fifo/tsg/nvgpu-tsg.c @@ -42,7 +42,7 @@ #include "hal/init/hal_gv11b.h" -#include "../nvgpu-fifo-gv11b.h" +#include "../nvgpu-fifo.h" #ifdef TSG_UNIT_DEBUG #define unit_verbose unit_info @@ -144,81 +144,11 @@ static bool pruned(u32 branches, u32 final_branches) return (branches > BIT(bit)); } -/* test implementations of some hals */ -static u32 stub_gv11b_gr_init_get_no_of_sm(struct gk20a *g) -{ - return 8; -} - -#ifdef NVGPU_USERD -static int stub_userd_setup_sw(struct gk20a *g) -{ - struct nvgpu_fifo *f = &g->fifo; - int err; - - f->userd_entry_size = g->ops.userd.entry_size(g); - - err = nvgpu_userd_init_slabs(g); - if (err != 0) { - nvgpu_err(g, "failed to init userd support"); - return err; - } - - return 0; -} -#endif - -static int test_fifo_init_support(struct unit_module *m, - struct gk20a *g, void *args) -{ - struct test_tsg_args *t = args; - int err; - - if (t->init_done) { - unit_return_fail(m, "init already done"); - } - - err = test_fifo_setup_gv11b_reg_space(m, g); - if (err != 0) { - goto fail; - } - - gv11b_init_hal(g); - g->ops.fifo.init_fifo_setup_hw = NULL; - g->ops.gr.init.get_no_of_sm = stub_gv11b_gr_init_get_no_of_sm; - g->ops.tsg.init_eng_method_buffers = NULL; - -#ifdef NVGPU_USERD - /* - * Regular USERD init requires bar1.vm to be initialized - * Use a stub in unit tests, since it will be disabled in - * safety build anyway. - */ - g->ops.userd.setup_sw = stub_userd_setup_sw; -#endif - - err = nvgpu_fifo_init_support(g); - if (err != 0) { - test_fifo_cleanup_gv11b_reg_space(m, g); - goto fail; - } - - /* Do not allocate from vidmem */ - nvgpu_set_enabled(g, NVGPU_MM_UNIFIED_MEMORY, true); - - t->init_done = true; - - return UNIT_SUCCESS; - -fail: - return UNIT_FAIL; -} - #define F_TSG_OPEN_ACQUIRE_CH_FAIL BIT(0) #define F_TSG_OPEN_SM_FAIL BIT(1) #define F_TSG_OPEN_LAST BIT(2) -static const char const *f_tsg_open[] = { +static const char *f_tsg_open[] = { "acquire_ch_fail", "sm_fail", }; @@ -234,8 +164,8 @@ static int test_tsg_open(struct unit_module *m, struct nvgpu_fifo *f = &g->fifo; struct gpu_ops gops = g->ops; u32 num_channels = f->num_channels; - struct nvgpu_tsg *tsg; - u32 branches; + struct nvgpu_tsg *tsg = NULL; + u32 branches = 0U; int rc = UNIT_FAIL; u32 fail = F_TSG_OPEN_ACQUIRE_CH_FAIL | F_TSG_OPEN_SM_FAIL; @@ -291,7 +221,7 @@ done: #define F_TSG_BIND_CHANNEL_ENG_METHOD_BUFFER BIT(3) #define F_TSG_BIND_CHANNEL_LAST BIT(4) -static const char const *f_tsg_bind[] = { +static const char *f_tsg_bind[] = { "ch_bound", "rl_mismatch", "active", @@ -305,9 +235,11 @@ static int test_tsg_bind_channel(struct unit_module *m, struct nvgpu_fifo *f = &g->fifo; struct gpu_ops gops = g->ops; struct nvgpu_tsg *tsg, tsg_save; - struct nvgpu_channel *chA, *chB, *ch; + struct nvgpu_channel *chA = NULL; + struct nvgpu_channel *chB = NULL; + struct nvgpu_channel *ch = NULL; struct nvgpu_runlist_info *runlist; - u32 branches; + u32 branches = 0U; int rc = UNIT_FAIL; int err; u32 prune = F_TSG_BIND_CHANNEL_CH_BOUND | @@ -420,7 +352,7 @@ done: #define F_TSG_UNBIND_CHANNEL_UNBIND_HAL BIT(4) #define F_TSG_UNBIND_CHANNEL_LAST BIT(5) -static const char const *f_tsg_unbind[] = { +static const char *f_tsg_unbind[] = { "ch_timedout", "preempt_tsg_fail", "check_hw_state_fail", @@ -460,17 +392,14 @@ static int test_tsg_unbind_channel(struct unit_module *m, struct gk20a *g, void *args) { struct gpu_ops gops = g->ops; - struct nvgpu_tsg *tsg; - struct nvgpu_channel *chA, *chB; - u32 f, branches; + struct nvgpu_tsg *tsg = NULL; + struct nvgpu_channel *chA = NULL; + struct nvgpu_channel *chB = NULL; + u32 branches = 0U; int rc = UNIT_FAIL; u32 prune = F_TSG_UNBIND_CHANNEL_PREEMPT_TSG_FAIL; - for (f = 0U; f < F_TSG_BIND_CHANNEL_LAST; f++) { - - reset_stub_rc(); - - branches = f; + for (branches = 0U; branches < F_TSG_BIND_CHANNEL_LAST; branches++) { if (pruned(branches, prune) || /* hw_state is not checked if ch is unserviceable */ @@ -480,6 +409,7 @@ static int test_tsg_unbind_channel(struct unit_module *m, branches_str(branches, f_tsg_unbind)); continue; } + reset_stub_rc(); /* * tsg unbind tears down TSG in case of failure: @@ -577,7 +507,7 @@ done: #define F_TSG_RELEASE_SM_ERR_STATES BIT(5) #define F_TSG_RELEASE_LAST BIT(6) -static const char const *f_tsg_release[] = { +static const char *f_tsg_release[] = { "gr_ctx", "mem", "vm", @@ -605,10 +535,10 @@ static int test_tsg_release(struct unit_module *m, { struct nvgpu_fifo *f = &g->fifo; struct gpu_ops gops = g->ops; - struct nvgpu_tsg *tsg; + struct nvgpu_tsg *tsg = NULL; struct nvgpu_list_node ev1, ev2; struct vm_gk20a vm; - u32 branches; + u32 branches = 0U; int rc = UNIT_FAIL; struct nvgpu_mem mem; u32 free_gr_ctx_mask = @@ -733,7 +663,7 @@ done: #define F_TSG_UNBIND_CHANNEL_CHECK_HW_ENG_FAULTED BIT(2) #define F_TSG_UNBIND_CHANNEL_CHECK_HW_LAST BIT(3) -static const char const *f_tsg_unbind_channel_check_hw[] = { +static const char *f_tsg_unbind_channel_check_hw[] = { "next", "ctx_reload", "eng_faulted", @@ -749,9 +679,9 @@ static int test_tsg_unbind_channel_check_hw_state(struct unit_module *m, struct gk20a *g, void *args) { struct gpu_ops gops = g->ops; - struct nvgpu_channel *ch; - struct nvgpu_tsg *tsg; - u32 branches; + struct nvgpu_channel *ch = NULL; + struct nvgpu_tsg *tsg = NULL; + u32 branches = 0U; int rc = UNIT_FAIL; int err; u32 prune = F_TSG_UNBIND_CHANNEL_CHECK_HW_NEXT; @@ -822,7 +752,7 @@ done: #define F_UNBIND_CHANNEL_CHECK_CTX_RELOAD_CHID_MATCH BIT(1) #define F_UNBIND_CHANNEL_CHECK_CTX_RELOAD_LAST BIT(2) -static const char const *f_unbind_channel_check_ctx_reload[] = { +static const char *f_unbind_channel_check_ctx_reload[] = { "reload_set", "chid_match", }; @@ -838,11 +768,12 @@ static int test_tsg_unbind_channel_check_ctx_reload(struct unit_module *m, struct gk20a *g, void *args) { struct gpu_ops gops = g->ops; - u32 branches; + u32 branches = 0U; int rc = UNIT_FAIL; struct nvgpu_channel_hw_state hw_state; - struct nvgpu_tsg *tsg; - struct nvgpu_channel *chA, *chB; + struct nvgpu_tsg *tsg = NULL; + struct nvgpu_channel *chA = NULL; + struct nvgpu_channel *chB = NULL; tsg = nvgpu_tsg_open(g, getpid()); chA = gk20a_open_new_channel(g, ~0U, false, getpid(), getpid()); @@ -906,22 +837,6 @@ done: return rc; } -static int test_fifo_remove_support(struct unit_module *m, - struct gk20a *g, void *args) -{ - struct test_tsg_args *t = args; - - if (!t->init_done) { - unit_return_fail(m, "missing init support"); - } - - if (g->fifo.remove_support) { - g->fifo.remove_support(&g->fifo); - } - - return UNIT_SUCCESS; -} - static int test_tsg_check_and_get_from_id(struct unit_module *m, struct gk20a *g, void *args) {