diff --git a/userspace/SWUTS.h b/userspace/SWUTS.h index 247f43bbe..475acc319 100644 --- a/userspace/SWUTS.h +++ b/userspace/SWUTS.h @@ -35,6 +35,7 @@ * - @ref SWUTS-interface-atomic * - @ref SWUTS-mm-nvgpu-mem * - @ref SWUTS-mm-vm + * - @ref SWUTS-fuse * - @ref SWUTS-sdl * */ diff --git a/userspace/SWUTS.sources b/userspace/SWUTS.sources index a09902d78..c75093110 100644 --- a/userspace/SWUTS.sources +++ b/userspace/SWUTS.sources @@ -1,5 +1,8 @@ INPUT += ../../../userspace/SWUTS.h INPUT += ../../../userspace/units/enabled/nvgpu-enabled.h +INPUT += ../../../userspace/units/fuse/nvgpu-fuse.h +INPUT += ../../../userspace/units/fuse/nvgpu-fuse-gm20b.h +INPUT += ../../../userspace/units/fuse/nvgpu-fuse-gp10b.h INPUT += ../../../userspace/units/init/nvgpu-init.h INPUT += ../../../userspace/units/interface/atomic/atomic.h INPUT += ../../../userspace/units/mm/nvgpu_mem/nvgpu_mem.h diff --git a/userspace/units/fuse/nvgpu-fuse-gm20b.c b/userspace/units/fuse/nvgpu-fuse-gm20b.c index ebf010b56..0231c3770 100644 --- a/userspace/units/fuse/nvgpu-fuse-gm20b.c +++ b/userspace/units/fuse/nvgpu-fuse-gm20b.c @@ -53,10 +53,6 @@ struct fuse_test_args gm20b_init_args = { .sec_fuse_addr = GM20B_FUSE_STATUS_OPT_PRIV_SEC_EN, }; -/* - * Verify fuse API check_priv_security() when security fuse is enabled. - * Tests with secure debug enabled and disabled. - */ int test_fuse_gm20b_check_sec(struct unit_module *m, struct gk20a *g, void *__args) { @@ -97,9 +93,6 @@ int test_fuse_gm20b_check_sec(struct unit_module *m, return ret; } -/* - * Verify fuse API check_priv_security() handles an error from reading gcplex - */ int test_fuse_gm20b_check_gcplex_fail(struct unit_module *m, struct gk20a *g, void *__args) { @@ -119,10 +112,6 @@ int test_fuse_gm20b_check_gcplex_fail(struct unit_module *m, return ret; } -/* - * Verify fuse API check_priv_security() handles invalid gcplex configurations - * of WPR and VPR bits. - */ int test_fuse_gm20b_check_sec_invalid_gcplex(struct unit_module *m, struct gk20a *g, void *__args) { @@ -157,10 +146,6 @@ int test_fuse_gm20b_check_sec_invalid_gcplex(struct unit_module *m, return ret; } - -/* - * Verify fuse API check_priv_security() when security fuse is enabled. - */ int test_fuse_gm20b_check_non_sec(struct unit_module *m, struct gk20a *g, void *__args) { @@ -190,7 +175,6 @@ int test_fuse_gm20b_check_non_sec(struct unit_module *m, return ret; } -/* Verify fuse reads for basic value return APIs */ int test_fuse_gm20b_basic_fuses(struct unit_module *m, struct gk20a *g, void *__args) { diff --git a/userspace/units/fuse/nvgpu-fuse-gm20b.h b/userspace/units/fuse/nvgpu-fuse-gm20b.h index 6eff3d7ff..0e324b9e0 100644 --- a/userspace/units/fuse/nvgpu-fuse-gm20b.h +++ b/userspace/units/fuse/nvgpu-fuse-gm20b.h @@ -23,22 +23,126 @@ #ifndef __UNIT_NVGPU_FUSE_GM20B_H__ #define __UNIT_NVGPU_FUSE_GM20B_H__ +struct gk20a; +struct unit_module; + +/** @addtogroup SWUTS-fuse + * @{ + */ + extern struct fuse_test_args gm20b_init_args; +/** + * Test specification for: test_fuse_gm20b_check_sec + * + * Description: Verify fuse API check_priv_security() when security fuse is + * enabled. + * + * Test Type: Feature based + * + * Input: test_fuse_device_common_init() must be called for this GPU. + * + * Steps: + * - Setup the security regs appropriately. + * - Call the fuse API check_priv_security(). + * - Verify Security flags are enabled/disabled correctly. + * - Repeat above steps for ACR enabled and disabled. + * + * Output: Returns SUCCESS if the steps above were executed successfully. FAIL + * otherwise. + */ int test_fuse_gm20b_check_sec(struct unit_module *m, struct gk20a *g, void *__args); + +/** + * Test specification for: test_fuse_gm20b_check_gcplex_fail + * + * Description: Verify fuse API check_priv_security() handles an error from + * reading gcplex. + * + * Test Type: Feature based + * + * Input: test_fuse_device_common_init() must be called for this GPU. + * + * Steps: + * - Override HAL for reading gcplex so it returns an error. + * - Call the fuse API check_priv_security(), which will read gcplex, and verify + * an error is returned. + * + * Output: Returns SUCCESS if the steps above were executed successfully. FAIL + * otherwise. + */ int test_fuse_gm20b_check_gcplex_fail(struct unit_module *m, struct gk20a *g, void *__args); + +/** + * Test specification for: test_fuse_gm20b_check_sec_invalid_gcplex + * + * Description: Verify fuse API check_priv_security() handles invalid gcplex + * configurations of WPR and VPR bits. + * + * Test Type: Feature based + * + * Input: test_fuse_device_common_init() must be called for this GPU. + * + * Steps: + * - Override HAL for reading gcplex so the WPR/VPR configuration can be + * overwritten. + * - Enable Security fuse. + * - Write an invalid WPR/VPR configuration into the gcplex override by using + * the overridden HAL. + * - Call the fuse API check_priv_security() and verify an error is returned. + * - Repeat the previous 2 steps for all invalid combinations of WPR/VPR + * configurations. + * + * Output: Returns SUCCESS if the steps above were executed successfully. FAIL + * otherwise. + */ int test_fuse_gm20b_check_sec_invalid_gcplex(struct unit_module *m, struct gk20a *g, void *__args); -int test_fuse_gm20b_ecc(struct unit_module *m, - struct gk20a *g, void *__args); -int test_fuse_gm20b_feature_override_disable(struct unit_module *m, - struct gk20a *g, void *__args); + +/** + * Test specification for: test_fuse_gm20b_check_non_sec + * + * Description: Verify fuse API check_priv_security() when security fuse is + * disabled. + * + * Test Type: Feature based + * + * Input: test_fuse_device_common_init() must be called for this GPU. + * + * Steps: + * - Disable Security fuse. + * - Call the fuse API check_priv_security(). + * - Verify correct security flags are disabled. + * + * Output: Returns SUCCESS if the steps above were executed successfully. FAIL + * otherwise. + */ int test_fuse_gm20b_check_non_sec(struct unit_module *m, struct gk20a *g, void *__args); + +/** + * Test specification for: test_fuse_gm20b_basic_fuses + * + * Description: Verify fuse reads for basic value-return APIs. + * + * Test Type: Feature based + * + * Input: test_fuse_device_common_init() must be called for this GPU. + * + * Steps: + * - For each fuse API that returns the value of the fuse, do the following: + * - Write valid values to the fuse register in the mock IO. + * - Call the API to read fuse. + * - Verify the correct value is returned. + * + * Output: Returns SUCCESS if the steps above were executed successfully. FAIL + * otherwise. + */ int test_fuse_gm20b_basic_fuses(struct unit_module *m, struct gk20a *g, void *__args); + #ifdef CONFIG_NVGPU_SIM int test_fuse_gm20b_check_fmodel(struct unit_module *m, struct gk20a *g, void *__args); diff --git a/userspace/units/fuse/nvgpu-fuse-gp10b.c b/userspace/units/fuse/nvgpu-fuse-gp10b.c index 306d070b3..5ecd52d9a 100644 --- a/userspace/units/fuse/nvgpu-fuse-gp10b.c +++ b/userspace/units/fuse/nvgpu-fuse-gp10b.c @@ -45,10 +45,6 @@ struct fuse_test_args gp10b_init_args = { .sec_fuse_addr = GP10B_FUSE_OPT_PRIV_SEC_EN, }; -/* - * Verify fuse API check_priv_security() when security fuse is enabled. - * Tests with secure debug enabled and disabled. - */ int test_fuse_gp10b_check_sec(struct unit_module *m, struct gk20a *g, void *__args) { @@ -88,9 +84,6 @@ int test_fuse_gp10b_check_sec(struct unit_module *m, return ret; } -/* - * Verify fuse API check_priv_security() handles an error from reading gcplex - */ int test_fuse_gp10b_check_gcplex_fail(struct unit_module *m, struct gk20a *g, void *__args) { @@ -110,10 +103,6 @@ int test_fuse_gp10b_check_gcplex_fail(struct unit_module *m, return ret; } -/* - * Verify fuse API check_priv_security() handles invalid gcplex configurations - * of WPR and VPR bits. - */ int test_fuse_gp10b_check_sec_invalid_gcplex(struct unit_module *m, struct gk20a *g, void *__args) { @@ -148,9 +137,6 @@ int test_fuse_gp10b_check_sec_invalid_gcplex(struct unit_module *m, } -/* - * Verify fuse API check_priv_security() when security fuse is enabled. - */ int test_fuse_gp10b_check_non_sec(struct unit_module *m, struct gk20a *g, void *__args) { @@ -179,7 +165,6 @@ int test_fuse_gp10b_check_non_sec(struct unit_module *m, return ret; } -/* Verify fuse reports ECC enable correctly */ int test_fuse_gp10b_ecc(struct unit_module *m, struct gk20a *g, void *__args) { @@ -207,7 +192,6 @@ int test_fuse_gp10b_ecc(struct unit_module *m, return ret; } -/* Verify fuse reports feature override correctly */ int test_fuse_gp10b_feature_override_disable(struct unit_module *m, struct gk20a *g, void *__args) { diff --git a/userspace/units/fuse/nvgpu-fuse-gp10b.h b/userspace/units/fuse/nvgpu-fuse-gp10b.h index ddddd95cc..0a049cb17 100644 --- a/userspace/units/fuse/nvgpu-fuse-gp10b.h +++ b/userspace/units/fuse/nvgpu-fuse-gp10b.h @@ -23,20 +23,146 @@ #ifndef __UNIT_NVGPU_FUSE_GP10B_H__ #define __UNIT_NVGPU_FUSE_GP10B_H__ +struct gk20a; +struct unit_module; + +/** @addtogroup SWUTS-fuse + * @{ + */ + extern struct fuse_test_args gp10b_init_args; +/** + * Test specification for: test_fuse_gp10b_check_sec + * + * Description: Verify fuse API check_priv_security() when security fuse is + * enabled. + * + * Test Type: Feature based + * + * Input: test_fuse_device_common_init() must be called for this GPU. + * + * Steps: + * - Setup the security regs appropriately. + * - Call the fuse API check_priv_security(). + * - Verify Security flags are enabled/disabled correctly. + * + * Output: Returns SUCCESS if the steps above were executed successfully. FAIL + * otherwise. + */ int test_fuse_gp10b_check_sec(struct unit_module *m, struct gk20a *g, void *__args); + +/** + * Test specification for: test_fuse_gp10b_check_gcplex_fail + * + * Description: Verify fuse API check_priv_security() handles an error from + * reading gcplex. + * + * Test Type: Feature based + * + * Input: test_fuse_device_common_init() must be called for this GPU. + * + * Steps: + * - Override HAL for reading gcplex so it returns an error. + * - Call the fuse API check_priv_security(), which will read gcplex, and verify + * an error is returned. + * + * Output: Returns SUCCESS if the steps above were executed successfully. FAIL + * otherwise. + */ int test_fuse_gp10b_check_gcplex_fail(struct unit_module *m, struct gk20a *g, void *__args); + +/** + * Test specification for: test_fuse_gp10b_check_sec_invalid_gcplex + * + * Description: Verify fuse API check_priv_security() handles invalid gcplex + * configurations of WPR and VPR bits. + * + * Test Type: Feature based + * + * Input: test_fuse_device_common_init() must be called for this GPU. + * + * Steps: + * - Override HAL for reading gcplex so the WPR/VPR configuration can be + * overwritten. + * - Enable Security fuse. + * - Write an invalid WPR/VPR configuration into the gcplex override by using + * the overridden HAL. + * - Call the fuse API check_priv_security() and verify an error is returned. + * - Repeat the previous 2 steps for all invalid combinations of WPR/VPR + * configurations. + * + * Output: Returns SUCCESS if the steps above were executed successfully. FAIL + * otherwise. + */ int test_fuse_gp10b_check_sec_invalid_gcplex(struct unit_module *m, struct gk20a *g, void *__args); + +/** + * Test specification for: test_fuse_gp10b_check_non_sec + * + * Description: Verify fuse API check_priv_security() when security fuse is + * disabled. + * + * Test Type: Feature based + * + * Input: test_fuse_device_common_init() must be called for this GPU. + * + * Steps: + * - Disable Security fuse. + * - Call the fuse API check_priv_security(). + * - Verify correct security flags are disabled. + * + * Output: Returns SUCCESS if the steps above were executed successfully. FAIL + * otherwise. + */ int test_fuse_gp10b_check_non_sec(struct unit_module *m, struct gk20a *g, void *__args); + +/** + * Test specification for: test_fuse_gp10b_ecc + * + * Description: Verify fuse reports ECC enable correctly. + * + * Test Type: Feature based + * + * Input: test_fuse_device_common_init() must be called for this GPU. + * + * Steps: + * - Disable ECC fuse. + * - Verify API is_opt_ecc_enable() returns false. + * - Enable ECC fuse. + * - Verify API is_opt_ecc_enable() returns true. + * + * Output: Returns SUCCESS if the steps above were executed successfully. FAIL + * otherwise. + */ int test_fuse_gp10b_ecc(struct unit_module *m, struct gk20a *g, void *__args); + +/** + * Test specification for: test_fuse_gp10b_feature_override_disable + * + * Description: Verify fuse reports Feature Override enable correctly. + * + * Test Type: Feature based + * + * Input: test_fuse_device_common_init() must be called for this GPU. + * + * Steps: + * - Disable Feature Override fuse. + * - Verify API is_opt_feature_override_disable() returns false. + * - Enable Feature Override fuse. + * - Verify API is_opt_feature_override_disable() returns true. + * + * Output: Returns SUCCESS if the steps above were executed successfully. FAIL + * otherwise. + */ int test_fuse_gp10b_feature_override_disable(struct unit_module *m, struct gk20a *g, void *__args); + #ifdef CONFIG_NVGPU_SIM int test_fuse_gp10b_check_fmodel(struct unit_module *m, struct gk20a *g, void *__args); diff --git a/userspace/units/fuse/nvgpu-fuse.c b/userspace/units/fuse/nvgpu-fuse.c index 6a675327c..12cba4639 100644 --- a/userspace/units/fuse/nvgpu-fuse.c +++ b/userspace/units/fuse/nvgpu-fuse.c @@ -89,14 +89,8 @@ int read_gcplex_config_fuse_fail(struct gk20a *g, u32 *val) return -ENODEV; } -/* - * Initialization for this unit test. - * Setup g struct - * Setup fuse ops - * Setup mock I/O - */ -static int test_fuse_device_common_init(struct unit_module *m, - struct gk20a *g, void *__args) +int test_fuse_device_common_init(struct unit_module *m, + struct gk20a *g, void *__args) { int ret = UNIT_SUCCESS; int result; @@ -129,7 +123,7 @@ static int test_fuse_device_common_init(struct unit_module *m, return ret; } -static int test_fuse_device_common_cleanup(struct unit_module *m, +int test_fuse_device_common_cleanup(struct unit_module *m, struct gk20a *g, void *__args) { struct fuse_test_args *args = (struct fuse_test_args *)__args;