From 6e2237ef622113b8fa1149aa48988a99fa30594f Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Fri, 16 Dec 2016 12:29:34 -0800 Subject: gpu: nvgpu: Use timer API in gk20a code Use the timers API in the gk20a code instead of Linux specific API calls. This also changes the behavior of several functions to wait for the full timeout for each operation that can timeout. Previously the timeout was shared across each operation. Bug 1799159 Change-Id: I2bbed54630667b2b879b56a63a853266afc1e5d8 Signed-off-by: Alex Waterman Reviewed-on: http://git-master/r/1273826 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 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 74476fe4..b7ef21b3 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c @@ -1,7 +1,7 @@ /* * GK20A memory management * - * Copyright (c) 2011-2016, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2011-2017, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms and conditions of the GNU General Public License, @@ -894,14 +894,17 @@ static int gk20a_vidmem_clear_all(struct gk20a *g) } if (gk20a_fence_out) { - unsigned long end_jiffies = jiffies + - msecs_to_jiffies(gk20a_get_gr_idle_timeout(g)); + struct nvgpu_timeout timeout; + + nvgpu_timeout_init(g, &timeout, + gk20a_get_gr_idle_timeout(g), + NVGPU_TIMER_CPU_TIMER); do { - unsigned int timeout = jiffies_to_msecs(end_jiffies - jiffies); err = gk20a_fence_wait(gk20a_fence_out, - timeout); - } while ((err == -ERESTARTSYS) && time_before(jiffies, end_jiffies)); + gk20a_get_gr_idle_timeout(g)); + } while (err == -ERESTARTSYS && + !nvgpu_timeout_expired(&timeout)); gk20a_fence_put(gk20a_fence_out); if (err) { @@ -3103,14 +3106,17 @@ static int gk20a_gmmu_clear_vidmem_mem(struct gk20a *g, struct mem_desc *mem) } if (gk20a_last_fence) { - unsigned long end_jiffies = jiffies + - msecs_to_jiffies(gk20a_get_gr_idle_timeout(g)); + struct nvgpu_timeout timeout; + + nvgpu_timeout_init(g, &timeout, + gk20a_get_gr_idle_timeout(g), + NVGPU_TIMER_CPU_TIMER); do { - unsigned int timeout = jiffies_to_msecs(end_jiffies - jiffies); err = gk20a_fence_wait(gk20a_last_fence, - timeout); - } while ((err == -ERESTARTSYS) && time_before(jiffies, end_jiffies)); + gk20a_get_gr_idle_timeout(g)); + } while (err == -ERESTARTSYS && + !nvgpu_timeout_expired(&timeout)); gk20a_fence_put(gk20a_last_fence); if (err) -- cgit v1.2.2