From b45a67934faeba042dbf6ebe47c520db3ef4090d Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Fri, 17 Mar 2017 09:56:50 -0700 Subject: gpu: nvgpu: Use nvgpu_timeout for all loops There were still a few remaining loops where we did not use nvgpu_timeout and required Tegra specific functions for detecting if timeout should be skipped. Replace all of them with nvgpu_timeout and remove including chip-id.h where possible. FE power mode timeout loop also used wrong delay value. It always waited for the whole max timeout instead of looping with smaller increments. If SEC2 ACR boot fails to halt, we should not try to check ACR result from mailbox. Add an early return for that case. JIRA NVGPU-16 Change-Id: I9f0984250d7d01785755338e39822e6631dcaa5a Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1323227 --- drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index 9e6dc74c..c31f8482 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c @@ -22,7 +22,6 @@ #include #include #include -#include #include #include #include @@ -1543,7 +1542,6 @@ static void gk20a_vm_unmap_user(struct vm_gk20a *vm, u64 offset, struct vm_gk20a_mapping_batch *batch) { struct device *d = dev_from_vm(vm); - int retries = 10000; /* 50 ms */ struct mapped_buffer_node *mapped_buffer; nvgpu_mutex_acquire(&vm->update_gmmu_lock); @@ -1556,17 +1554,19 @@ static void gk20a_vm_unmap_user(struct vm_gk20a *vm, u64 offset, } if (mapped_buffer->flags & NVGPU_AS_MAP_BUFFER_FLAGS_FIXED_OFFSET) { + struct nvgpu_timeout timeout; + nvgpu_mutex_release(&vm->update_gmmu_lock); - while (retries >= 0 || !tegra_platform_is_silicon()) { + nvgpu_timeout_init(vm->mm->g, &timeout, 10000, + NVGPU_TIMER_RETRY_TIMER); + do { if (atomic_read(&mapped_buffer->ref.refcount) == 1) break; - retries--; udelay(5); - } - if (retries < 0 && tegra_platform_is_silicon()) - gk20a_err(d, "sync-unmap failed on 0x%llx", - offset); + } while (!nvgpu_timeout_expired_msg(&timeout, + "sync-unmap failed on 0x%llx")); + nvgpu_mutex_acquire(&vm->update_gmmu_lock); } -- cgit v1.2.2