From 8613119529b37b78275092f274212b0a08e2e27d Mon Sep 17 00:00:00 2001 From: Deepak Nibade Date: Fri, 20 Jan 2017 12:30:14 +0530 Subject: gpu: nvgpu: add target refcount for gk20a_wait_for_idle() API gk20a_wait_for_idle() right now always waits for 0 usage count But in case railgating is disabled through sysfs, usage count will never get to 0 Hence in this case we should wait for usage count of 1 If platform->user_railgate_disabled is set, keep target usage count of 1, otherwise keep target usage count as 0 Bug 200260926 Change-Id: I1a80621ca61babbd6566989dc09a7b20670c649c Signed-off-by: Deepak Nibade Reviewed-on: http://git-master/r/1291421 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/gk20a.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'drivers/gpu/nvgpu/gk20a/gk20a.c') diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index 44786e4b..16acc1c9 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -1776,12 +1776,19 @@ void gk20a_driver_start_unload(struct gk20a *g) int gk20a_wait_for_idle(struct device *dev) { struct gk20a *g = get_gk20a(dev); + struct gk20a_platform *platform; int wait_length = 150; /* 3 second overall max wait. */ + int target_usage_count = 0; if (!g) return -ENODEV; - while (atomic_read(&g->usage_count) && wait_length-- >= 0) + platform = dev_get_drvdata(dev); + if (platform->user_railgate_disabled) + target_usage_count = 1; + + while ((atomic_read(&g->usage_count) != target_usage_count) + && (wait_length-- >= 0)) msleep(20); if (wait_length < 0) { -- cgit v1.2.2