From 25ef9f869b7a13be0d9f0e453b6501c35bb9be1f Mon Sep 17 00:00:00 2001 From: Kyle Guo Date: Wed, 7 Nov 2018 17:20:03 -0800 Subject: [PATCH] gpu: nvgpu: fix timeout error msg in sync-unmap Fixed the erroneous timeout message in sync-unmap and corrected the condition for returning ETIMEDOUT. In the original codeflow, after waiting for mapped_buffer release, nvgpu_timeout_expired is called to check whether to return ETIMEDOUT. However, if there is a delay between the end of the waiting and the nvgpu_timeout_expired check, ETIMEDOUT is returned regardless if the mapped_buffer is released with the timeout message printed. This is an incorrect behavior. This patch fixes it by letting the refcount of the mapped_buffer be the only source to determine the return value. Bug 200434475 Change-Id: I8ca170c811da415c24045ab643da26476bc7463c Signed-off-by: Kyle Guo Reviewed-on: https://git-master.nvidia.com/r/1945388 Reviewed-by: svc-misra-checker GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/mm/vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/nvgpu/common/mm/vm.c b/drivers/gpu/nvgpu/common/mm/vm.c index 1f93d6928..9046205a5 100644 --- a/drivers/gpu/nvgpu/common/mm/vm.c +++ b/drivers/gpu/nvgpu/common/mm/vm.c @@ -1191,7 +1191,7 @@ static int nvgpu_vm_unmap_sync_buffer(struct vm_gk20a *vm, nvgpu_msleep(10); } - if (nvgpu_timeout_expired(&timeout) == -ETIMEDOUT) { + if (nvgpu_atomic_read(&mapped_buffer->ref.refcount) > 1) { ret = -ETIMEDOUT; }