From 48cd58d3327e9deabf4b70b82ed462c0a6928e25 Mon Sep 17 00:00:00 2001 From: Debarshi Dutta Date: Thu, 30 Sep 2021 17:44:53 +0530 Subject: [PATCH] gpu: nvgpu: add timeout error handling Report a timeout error when fb_mmu_ctrl_r() register doesn't correctly reflect the tlb invalidate status. Jira NVGPU-7192 Signed-off-by: Debarshi Dutta Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2603267 (cherry picked from commit b16ed38d087667bc2bddaddde820648d6a931064) Change-Id: I2360c8741b396b26079438a917770e0bb051c661 Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2700042 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Vijayakumar Subbu GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/hal/fb/fb_gm20b_fusa.c | 5 +++++ drivers/gpu/nvgpu/hal/fb/fb_tu104.c | 4 ++++ userspace/units/fb/fb_gm20b_fusa.c | 9 ++++----- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/nvgpu/hal/fb/fb_gm20b_fusa.c b/drivers/gpu/nvgpu/hal/fb/fb_gm20b_fusa.c index 0e18196f4..1842f72d5 100644 --- a/drivers/gpu/nvgpu/hal/fb/fb_gm20b_fusa.c +++ b/drivers/gpu/nvgpu/hal/fb/fb_gm20b_fusa.c @@ -139,6 +139,11 @@ int gm20b_fb_tlb_invalidate(struct gk20a *g, struct nvgpu_mem *pdb) } while (nvgpu_timeout_expired_msg(&timeout, "wait mmu invalidate") == 0); + if (nvgpu_timeout_peek_expired(&timeout)) { + err = -ETIMEDOUT; + goto out; + } + #ifdef CONFIG_NVGPU_TRACE trace_gk20a_mm_tlb_invalidate_done(g->name); #endif diff --git a/drivers/gpu/nvgpu/hal/fb/fb_tu104.c b/drivers/gpu/nvgpu/hal/fb/fb_tu104.c index b0ae89df7..0b3e61a2e 100644 --- a/drivers/gpu/nvgpu/hal/fb/fb_tu104.c +++ b/drivers/gpu/nvgpu/hal/fb/fb_tu104.c @@ -92,6 +92,10 @@ int fb_tu104_tlb_invalidate(struct gk20a *g, struct nvgpu_mem *pdb) } while (nvgpu_timeout_expired_msg(&timeout, "wait mmu invalidate") == 0); + if (nvgpu_timeout_peek_expired(&timeout)) { + err = -ETIMEDOUT; + } + #ifdef CONFIG_NVGPU_TRACE trace_gk20a_mm_tlb_invalidate_done(g->name); #endif diff --git a/userspace/units/fb/fb_gm20b_fusa.c b/userspace/units/fb/fb_gm20b_fusa.c index a357e3479..165b25dd8 100644 --- a/userspace/units/fb/fb_gm20b_fusa.c +++ b/userspace/units/fb/fb_gm20b_fusa.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019-2021, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2022, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -73,13 +73,12 @@ int fb_gm20b_tlb_invalidate_test(struct unit_module *m, struct gk20a *g, nvgpu_writel(g, fb_mmu_ctrl_r(), 1 << 16U); /* - * Timeout on fb_mmu_ctrl_r read after MMU invalidate (does not return - * a failure) + * Timeout on fb_mmu_ctrl_r read after MMU invalidate. */ helper_intercept_mmu_write(0); err = g->ops.fb.tlb_invalidate(g, &pdb); - if (err != 0) { - unit_return_fail(m, "tlb_invalidate failed (2)\n"); + if (err == 0) { + unit_return_fail(m, "tlb_invalidate did not fail as expected (2)\n"); } /* Success */