diff --git a/userspace/units/init/nvgpu-init.c b/userspace/units/init/nvgpu-init.c index b95c902f3..e03fd5d19 100644 --- a/userspace/units/init/nvgpu-init.c +++ b/userspace/units/init/nvgpu-init.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -41,7 +42,7 @@ #include "nvgpu-init.h" /* value for GV11B */ -#define MC_BOOT_0_GV11B ((0x15 << 24) | (0xB << 20)) +#define MC_BOOT_0_GV11B (NVGPU_GPUID_GV11B << 20) /* to set the security fuses */ #define GP10B_FUSE_REG_BASE 0x00021000U #define GP10B_FUSE_OPT_PRIV_SEC_EN (GP10B_FUSE_REG_BASE+0x434U) @@ -407,6 +408,18 @@ int test_check_gpu_state(struct unit_module *m, int test_hal_init(struct unit_module *m, struct gk20a *g, void *args) { + const u32 invalid_mc_boot_0[] = { + GK20A_GPUID_GK20A << 20, + GK20A_GPUID_GM20B << 20, + GK20A_GPUID_GM20B_B << 20, + NVGPU_GPUID_GP10B << 20, + NVGPU_GPUID_GV100 << 20, + NVGPU_GPUID_TU104 << 20, + U32_MAX, + }; + u32 i; + struct nvgpu_os_posix *p = nvgpu_os_posix_from_gk20a(g); + nvgpu_posix_io_writel_reg_space(g, mc_boot_0_r(), MC_BOOT_0_GV11B); nvgpu_posix_io_writel_reg_space(g, GP10B_FUSE_OPT_PRIV_SEC_EN, 0x0); if (nvgpu_detect_chip(g) != 0) { @@ -414,6 +427,43 @@ int test_hal_init(struct unit_module *m, return UNIT_FAIL; } + /* Branch test for check if already inited the hal */ + if (nvgpu_detect_chip(g) != 0) { + unit_err(m, "%s: failed to init HAL\n", __func__); + return UNIT_FAIL; + } + + /* Branch test for check GPU is version a01 */ + p->is_soc_t194_a01 = true; + g->params.gpu_arch = 0; + if (nvgpu_detect_chip(g) != 0) { + unit_err(m, "%s: failed to init HAL\n", __func__); + return UNIT_FAIL; + } + p->is_soc_t194_a01 = false; + + /* Negative testing for secure fuse */ + g->params.gpu_arch = 0; + nvgpu_posix_io_writel_reg_space(g, GP10B_FUSE_OPT_PRIV_SEC_EN, 0x1); + if (nvgpu_detect_chip(g) == 0) { + unit_err(m, "%s: HAL init failed to detect incorrect security\n", + __func__); + return UNIT_FAIL; + } + + /* Negative testing for invalid GPU version */ + nvgpu_posix_io_writel_reg_space(g, GP10B_FUSE_OPT_PRIV_SEC_EN, 0x0); + for (i = 0; i < ARRAY_SIZE(invalid_mc_boot_0); i++) { + nvgpu_posix_io_writel_reg_space(g, mc_boot_0_r(), + invalid_mc_boot_0[i]); + g->params.gpu_arch = 0; + if (nvgpu_detect_chip(g) == 0) { + unit_err(m, "%s: HAL init failed to detect invalid GPU %08x\n", + __func__, invalid_mc_boot_0[i]); + return UNIT_FAIL; + } + } + return UNIT_SUCCESS; } diff --git a/userspace/units/init/nvgpu-init.h b/userspace/units/init/nvgpu-init.h index 0a0c8add5..113c82403 100644 --- a/userspace/units/init/nvgpu-init.h +++ b/userspace/units/init/nvgpu-init.h @@ -76,6 +76,8 @@ int test_free_env(struct unit_module *m, * * Test Type: Feature based * + * Targets: gv11b_get_litter_value + * * Input: None * * Steps: @@ -97,6 +99,8 @@ int test_get_litter_value(struct unit_module *m, * * Test Type: Feature based * + * Targets: nvgpu_can_busy + * * Input: None * * Steps: @@ -118,6 +122,8 @@ int test_can_busy(struct unit_module *m, * * Test Type: Feature based * + * Targets: nvgpu_get, nvgpu_put + * * Input: * - test_setup_env() must be called before. * @@ -151,6 +157,8 @@ int test_get_put(struct unit_module *m, * Input: * - test_setup_env() must be called before. * + * Targets: nvgpu_check_gpu_state + * * Steps: * - Test valid case. * - Set the mc_boot_0 reg to a valid state. @@ -176,13 +184,31 @@ int test_check_gpu_state(struct unit_module *m, * * Test Type: Feature based * + * Targets: nvgpu_detect_chip + * * Input: * - test_setup_env() must be called before. * * Steps: - * - Setup the mc_boot_0 reg for GV11B. - * - Initialize the fuse regs. - * - Init the HAL and verify return. + * - Nominal test + * - Setup the mc_boot_0 reg for GV11B. + * - Initialize the fuse regs. + * - Init the HAL and verify successful return. + * - Branch test (re-init HAL) + * - Init the HAL again and verify successful return. + * - Branch test (GPU version a01 check) + * - Clear HAL inited flag in gk20a. + * - Set Posix flag to make device version a01. + * - Init the HAL and verify successful return. + * - Clear Posix a01 version flag. + * - Negative test (security fuse) + * - Clear HAL inited flag in gk20a. + * - Initialize the fuse regs for secure mode. + * - Init the HAL and verify failure return. + * - Reset the fuse regs for non-secure mode. + * - Negative test (invalid GPU versions) + * - Loop setting invalid GPU versions. + * - Init the HAL and verify failure return. * * Output: * - UNIT_FAIL if HAL initialization fails @@ -198,6 +224,8 @@ int test_hal_init(struct unit_module *m, * * Test Type: Feature based * + * Targets: nvgpu_finalize_poweron + * * Input: * - test_setup_env() must be called before. * @@ -224,6 +252,8 @@ int test_poweron(struct unit_module *m, struct gk20a *g, void *args); * * Test Type: Feature based * + * Targets: nvgpu_finalize_poweron + * * Input: * - test_setup_env() must be called before. * @@ -247,6 +277,8 @@ int test_poweron_branches(struct unit_module *m, struct gk20a *g, void *args); * * Test Type: Feature based * + * Targets: nvgpu_prepare_poweroff + * * Input: * - test_setup_env() must be called before. *