gpu: nvgpu: unit: init: add more testing for hal init

Expand coverage for the hal init unit test to include negative testing
and line/branch coverage.

Also add Targets tag for SWUTS.

JIRA NVGPU-927

Change-Id: Ied63756b0d5abaaa03cd9aaa7b6a7fd817a1a967
Signed-off-by: Philip Elcan <pelcan@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2245612
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: svc-mobile-cert <svc-mobile-cert@nvidia.com>
Reviewed-by: Thomas Fleury <tfleury@nvidia.com>
Reviewed-by: Deepak Nibade <dnibade@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Vinod Gopalakrishnakurup <vinodg@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Philip Elcan
2019-11-22 15:37:37 -05:00
committed by Alex Waterman
parent b69615ef00
commit 7de9f2c331
2 changed files with 86 additions and 4 deletions

View File

@@ -30,6 +30,7 @@
#include <nvgpu/enabled.h> #include <nvgpu/enabled.h>
#include <nvgpu/hw/gm20b/hw_mc_gm20b.h> #include <nvgpu/hw/gm20b/hw_mc_gm20b.h>
#include <nvgpu/posix/posix-fault-injection.h> #include <nvgpu/posix/posix-fault-injection.h>
#include <os/posix/os_posix.h>
#include <nvgpu/dma.h> #include <nvgpu/dma.h>
#include <nvgpu/gops_mc.h> #include <nvgpu/gops_mc.h>
@@ -41,7 +42,7 @@
#include "nvgpu-init.h" #include "nvgpu-init.h"
/* value for GV11B */ /* 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 */ /* to set the security fuses */
#define GP10B_FUSE_REG_BASE 0x00021000U #define GP10B_FUSE_REG_BASE 0x00021000U
#define GP10B_FUSE_OPT_PRIV_SEC_EN (GP10B_FUSE_REG_BASE+0x434U) #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, int test_hal_init(struct unit_module *m,
struct gk20a *g, void *args) 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, mc_boot_0_r(), MC_BOOT_0_GV11B);
nvgpu_posix_io_writel_reg_space(g, GP10B_FUSE_OPT_PRIV_SEC_EN, 0x0); nvgpu_posix_io_writel_reg_space(g, GP10B_FUSE_OPT_PRIV_SEC_EN, 0x0);
if (nvgpu_detect_chip(g) != 0) { if (nvgpu_detect_chip(g) != 0) {
@@ -414,6 +427,43 @@ int test_hal_init(struct unit_module *m,
return UNIT_FAIL; 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; return UNIT_SUCCESS;
} }

View File

@@ -76,6 +76,8 @@ int test_free_env(struct unit_module *m,
* *
* Test Type: Feature based * Test Type: Feature based
* *
* Targets: gv11b_get_litter_value
*
* Input: None * Input: None
* *
* Steps: * Steps:
@@ -97,6 +99,8 @@ int test_get_litter_value(struct unit_module *m,
* *
* Test Type: Feature based * Test Type: Feature based
* *
* Targets: nvgpu_can_busy
*
* Input: None * Input: None
* *
* Steps: * Steps:
@@ -118,6 +122,8 @@ int test_can_busy(struct unit_module *m,
* *
* Test Type: Feature based * Test Type: Feature based
* *
* Targets: nvgpu_get, nvgpu_put
*
* Input: * Input:
* - test_setup_env() must be called before. * - test_setup_env() must be called before.
* *
@@ -151,6 +157,8 @@ int test_get_put(struct unit_module *m,
* Input: * Input:
* - test_setup_env() must be called before. * - test_setup_env() must be called before.
* *
* Targets: nvgpu_check_gpu_state
*
* Steps: * Steps:
* - Test valid case. * - Test valid case.
* - Set the mc_boot_0 reg to a valid state. * - 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 * Test Type: Feature based
* *
* Targets: nvgpu_detect_chip
*
* Input: * Input:
* - test_setup_env() must be called before. * - test_setup_env() must be called before.
* *
* Steps: * Steps:
* - Nominal test
* - Setup the mc_boot_0 reg for GV11B. * - Setup the mc_boot_0 reg for GV11B.
* - Initialize the fuse regs. * - Initialize the fuse regs.
* - Init the HAL and verify return. * - 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: * Output:
* - UNIT_FAIL if HAL initialization fails * - UNIT_FAIL if HAL initialization fails
@@ -198,6 +224,8 @@ int test_hal_init(struct unit_module *m,
* *
* Test Type: Feature based * Test Type: Feature based
* *
* Targets: nvgpu_finalize_poweron
*
* Input: * Input:
* - test_setup_env() must be called before. * - 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 * Test Type: Feature based
* *
* Targets: nvgpu_finalize_poweron
*
* Input: * Input:
* - test_setup_env() must be called before. * - 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 * Test Type: Feature based
* *
* Targets: nvgpu_prepare_poweroff
*
* Input: * Input:
* - test_setup_env() must be called before. * - test_setup_env() must be called before.
* *