diff --git a/drivers/gpu/nvgpu/common/acr/acr_blob_construct.c b/drivers/gpu/nvgpu/common/acr/acr_blob_construct.c index 57b846aa0..ecbbd3bea 100644 --- a/drivers/gpu/nvgpu/common/acr/acr_blob_construct.c +++ b/drivers/gpu/nvgpu/common/acr/acr_blob_construct.c @@ -452,9 +452,9 @@ static int lsfm_discover_ucode_images(struct gk20a *g, acr->lsf[i].get_lsf_ucode_details != NULL) { (void) memset(&ucode_img, 0, sizeof(ucode_img)); - - if (acr->lsf[i].get_lsf_ucode_details(g, - (void *)&ucode_img) != 0) { + err = acr->lsf[i].get_lsf_ucode_details(g, + (void *)&ucode_img); + if (err != 0) { nvgpu_err(g, "LS falcon-%d ucode get failed", i); goto exit; } diff --git a/userspace/units/acr/nvgpu-acr.c b/userspace/units/acr/nvgpu-acr.c index 19e0c313f..514b2ffda 100644 --- a/userspace/units/acr/nvgpu-acr.c +++ b/userspace/units/acr/nvgpu-acr.c @@ -324,7 +324,7 @@ int test_acr_bootstrap_hs_acr(struct unit_module *m, /* * case 1: Calling nvgpu_acr_bootstrap_hs_acr() - * twice to coverrecovery branch + * twice to cover recovery branch */ err = nvgpu_acr_bootstrap_hs_acr(g, g->acr); err = nvgpu_acr_bootstrap_hs_acr(g, g->acr); @@ -471,6 +471,8 @@ int test_acr_prepare_ucode_blob(struct unit_module *m, struct gk20a *g, void *args) { int err; + struct nvgpu_posix_fault_inj *kmem_fi = + nvgpu_kmem_get_fault_injection(); /* * Initialise the test env and register space @@ -488,10 +490,51 @@ int test_acr_prepare_ucode_blob(struct unit_module *m, if (prepare_gr_hw_sw(m, g) != 0) { unit_return_fail(m, "Test env init failed\n"); } + /* + * Case 1: fail scenario + * g->acr->prepare_ucode_blob(g) fails due to memory + * allocation failure + * + * HAL init parameters for gv11b: Correct chip id + */ + g->params.gpu_arch = NV_PMC_BOOT_0_ARCHITECTURE_GV110; + g->params.gpu_impl = NV_PMC_BOOT_0_IMPLEMENTATION_B; + + nvgpu_posix_enable_fault_injection(kmem_fi, true, 0); + + err = g->acr->prepare_ucode_blob(g); + if (err == -ENOENT) { + unit_info(m, "test failed as expected\n"); + } else { + unit_return_fail(m, "test did not fail as expected\n"); + } + + nvgpu_posix_enable_fault_injection(kmem_fi, false, 0); + + /* + * Case 2: Fail scenario + * giving incorrect chip version number + */ + + /* + * giving incorrect chip id + */ + g->params.gpu_arch = NV_PMC_BOOT_0_ARCHITECTURE_INVALID; + g->params.gpu_impl = NV_PMC_BOOT_0_IMPLEMENTATION_INVALID; + + err = g->acr->prepare_ucode_blob(g); + if (err == -ENOENT) { + unit_info(m, "test failed as expected\n"); + } else { + unit_return_fail(m, "test did not fail as expected\n"); + } /* * case:pass scenario */ + g->params.gpu_arch = NV_PMC_BOOT_0_ARCHITECTURE_GV110; + g->params.gpu_impl = NV_PMC_BOOT_0_IMPLEMENTATION_B; + err = g->acr->prepare_ucode_blob(g); if (err != 0) { unit_return_fail(m, "test failed\n");