diff --git a/userspace/units/netlist/nvgpu-netlist.c b/userspace/units/netlist/nvgpu-netlist.c index 09b4c52c8..f3eec1020 100644 --- a/userspace/units/netlist/nvgpu-netlist.c +++ b/userspace/units/netlist/nvgpu-netlist.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2020, 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"), @@ -27,6 +27,7 @@ #include #include +#include #include #include #include @@ -208,10 +209,29 @@ int test_netlist_query_tests(struct unit_module *m, return UNIT_SUCCESS; } +static int test_netlist_alloc_failure(struct gk20a *g) +{ + int err, i; + struct nvgpu_posix_fault_inj *kmem_fi = + nvgpu_kmem_get_fault_injection(); + + for (i = 0; i < 12; i++) { + nvgpu_posix_enable_fault_injection(kmem_fi, true, i); + err = nvgpu_netlist_init_ctx_vars(g); + if (err == 0) { + return UNIT_FAIL; + } + nvgpu_posix_enable_fault_injection(kmem_fi, false, 0); + } + + return UNIT_SUCCESS; +} + int test_netlist_negative_tests(struct unit_module *m, struct gk20a *g, void *args) { int err = 0; + struct nvgpu_netlist_vars *netlist_vars = g->netlist_vars; err = nvgpu_netlist_init_ctx_vars(g); if (err != 0) { @@ -219,7 +239,18 @@ int test_netlist_negative_tests(struct unit_module *m, } /* unload netlist info */ + /* with NULL pointer */ + g->netlist_vars = NULL; nvgpu_netlist_deinit_ctx_vars(g); + /* restore valid pointer */ + g->netlist_vars = netlist_vars; + nvgpu_netlist_deinit_ctx_vars(g); + + err = test_netlist_alloc_failure(g); + if (err != 0) { + unit_return_fail(m, "nvgpu_netlist_init_ctx_vars_fw failed\n"); + } + /* Set up HAL for invalid netlist checks */ g->ops.netlist.is_fw_defined = test_netlist_fw_not_defined; g->ops.gr.falcon.get_fecs_ctx_state_store_major_rev_id = @@ -228,6 +259,7 @@ int test_netlist_negative_tests(struct unit_module *m, if (err == 0) { unit_return_fail(m, "nvgpu_netlist_init_ctx_vars_fw failed\n"); } + /* Restore orginal HALs */ g->ops.netlist.is_fw_defined = gv11b_netlist_is_firmware_defined; g->ops.gr.falcon.get_fecs_ctx_state_store_major_rev_id = diff --git a/userspace/units/netlist/nvgpu-netlist.h b/userspace/units/netlist/nvgpu-netlist.h index a8edf725c..e25fe32c1 100644 --- a/userspace/units/netlist/nvgpu-netlist.h +++ b/userspace/units/netlist/nvgpu-netlist.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2020, 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"), @@ -38,6 +38,14 @@ * * Test Type: Feature * + * Targets: nvgpu_netlist_init_ctx_vars, + * gv11b_netlist_is_firmware_defined, + * gv11b_netlist_get_name, + * nvgpu_netlist_alloc_u32_list, + * nvgpu_netlist_alloc_aiv_list, + * nvgpu_netlist_alloc_av_list, + * nvgpu_netlist_alloc_av64_list + * * Input: None * * Steps: @@ -64,6 +72,21 @@ int test_netlist_init_support(struct unit_module *m, * * Test Type: Feature * + * Targets: nvgpu_netlist_get_sw_non_ctx_load_av_list, + * nvgpu_netlist_get_sw_ctx_load_aiv_list, + * nvgpu_netlist_get_sw_method_init_av_list, + * nvgpu_netlist_get_sw_bundle_init_av_list, + * nvgpu_netlist_get_sw_veid_bundle_init_av_list, + * nvgpu_netlist_get_sw_bundle64_init_av64_list, + * nvgpu_netlist_get_fecs_inst_count, + * nvgpu_netlist_get_fecs_data_count, + * nvgpu_netlist_get_gpccs_inst_count, + * nvgpu_netlist_get_gpccs_data_count, + * nvgpu_netlist_get_fecs_inst_list, + * nvgpu_netlist_get_fecs_data_list, + * nvgpu_netlist_get_gpccs_inst_list, + * nvgpu_netlist_get_gpccs_data_list + * * Input: None * * Steps: @@ -94,13 +117,17 @@ int test_netlist_query_tests(struct unit_module *m, * * Description: This test covers negative paths in netlist init. * - * Test Type: Feature + * Test Type: Feature, Error Injection + * + * Targets: nvgpu_netlist_init_ctx_vars, + * nvgpu_netlist_deinit_ctx_vars * * Input: None * * Steps: * - Call nvgpu_netlist_init_ctx_vars after already initilized netlist * - Call nvgpu_netlist_deinit_ctx_vars + * - Call nvgpu_netlist_init_ctx_vars injecting allocation failures. * - Set HALs with no netlist defined and invalid netlist check * - Call nvgpu_netlist_init_ctx_vars with above test HALs * - Restore orginals HALs @@ -119,6 +146,8 @@ int test_netlist_negative_tests(struct unit_module *m, * * Test Type: Feature * + * Targets: nvgpu_netlist_deinit_ctx_vars + * * Input: None * * Steps: