From ad227d9c310fa27b5b28ac87ea40ce09f09bbdfc Mon Sep 17 00:00:00 2001 From: Vedashree Vidwans Date: Tue, 3 Mar 2020 20:48:31 -0800 Subject: [PATCH] gpu: nvgpu: unit: fix mutex acquire fail for l4t In hal.mm.mmu_fault UT, some tests are dependent on each other. Reset environment variables at the end of test_gv11b_mm_mmu_fault_setup_sw(), Modify test_gv11b_mm_mmu_fault_setup_hw() to avoid destroying mmu_fault setup for branch coverage. Jira NVGPU-4987 Change-Id: I2e6904cb5304285123a29c24d00bd4dcd035e0ff Signed-off-by: Vedashree Vidwans Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2306652 Reviewed-by: svc-mobile-coverity Reviewed-by: Philip Elcan Reviewed-by: Alex Waterman Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit Tested-by: mobile promotions --- .../gv11b_fusa/mmu-fault-gv11b-fusa.c | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/userspace/units/mm/hal/mmu_fault/gv11b_fusa/mmu-fault-gv11b-fusa.c b/userspace/units/mm/hal/mmu_fault/gv11b_fusa/mmu-fault-gv11b-fusa.c index 8bc1d520e..52bf21359 100644 --- a/userspace/units/mm/hal/mmu_fault/gv11b_fusa/mmu-fault-gv11b-fusa.c +++ b/userspace/units/mm/hal/mmu_fault/gv11b_fusa/mmu-fault-gv11b-fusa.c @@ -263,34 +263,38 @@ done: f_mmu_fault_setup_sw[branch]); } nvgpu_posix_enable_fault_injection(l_dma_fi, false, 0); + err = gv11b_mm_mmu_fault_setup_sw(g); + if (err != 0) { + unit_return_fail(m, "mmu_fault_setup_sw failed"); + } return ret; } static void stub_fb_fault_buf_configure_hw(struct gk20a *g, u32 index) { - count = global_count++; + count = global_count; } int test_gv11b_mm_mmu_fault_setup_hw(struct unit_module *m, struct gk20a *g, void *args) { int ret = UNIT_FAIL; - int err; + enum nvgpu_aperture fb_aperture_orig = APERTURE_INVALID; global_count = 0U; + count = 1U; g->ops.fb.fault_buf_configure_hw = stub_fb_fault_buf_configure_hw; - err = gv11b_mm_mmu_fault_setup_sw(g); - unit_assert(err == 0, goto done); + gv11b_mm_mmu_fault_setup_hw(g); + unit_assert(count == global_count, goto done); + global_count++; + + fb_aperture_orig = g->mm.hw_fault_buf[NVGPU_MMU_FAULT_NONREPLAY_INDX].aperture; + g->mm.hw_fault_buf[NVGPU_MMU_FAULT_NONREPLAY_INDX].aperture = APERTURE_INVALID; gv11b_mm_mmu_fault_setup_hw(g); - unit_assert(count == global_count - 1U, goto done); - - gv11b_mm_mmu_fault_info_mem_destroy(g); - - gv11b_mm_mmu_fault_setup_hw(g); - unit_assert(count == global_count - 1U, goto done); + unit_assert(count != global_count, goto done); ret = UNIT_SUCCESS; @@ -298,6 +302,7 @@ done: if (ret != UNIT_SUCCESS) { unit_err(m, "%s failed\n", __func__); } + g->mm.hw_fault_buf[NVGPU_MMU_FAULT_NONREPLAY_INDX].aperture = fb_aperture_orig; return ret; } @@ -329,6 +334,7 @@ int test_gv11b_mm_mmu_fault_disable_hw(struct unit_module *m, struct gk20a *g, struct gpu_ops gops = g->ops; global_count = 0U; + count = 1U; g->ops.fb.is_fault_buf_enabled = stub_fb_is_fault_buf_enabled; g->ops.fb.fault_buf_set_state_hw = stub_fb_fault_buf_set_state_hw;