summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/gk20a.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index 5f365d4b..9725442a 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -44,6 +44,7 @@
44#include <linux/version.h> 44#include <linux/version.h>
45 45
46#include <nvgpu/allocator.h> 46#include <nvgpu/allocator.h>
47#include <nvgpu/timers.h>
47 48
48#include "gk20a.h" 49#include "gk20a.h"
49#include "nvgpu_common.h" 50#include "nvgpu_common.h"
@@ -1923,8 +1924,7 @@ int __gk20a_do_idle(struct device *dev, bool force_reset)
1923{ 1924{
1924 struct gk20a *g = get_gk20a(dev); 1925 struct gk20a *g = get_gk20a(dev);
1925 struct gk20a_platform *platform = dev_get_drvdata(dev); 1926 struct gk20a_platform *platform = dev_get_drvdata(dev);
1926 unsigned long timeout = jiffies + 1927 struct nvgpu_timeout timeout;
1927 msecs_to_jiffies(GK20A_WAIT_FOR_IDLE_MS);
1928 int ref_cnt; 1928 int ref_cnt;
1929 int target_ref_cnt = 0; 1929 int target_ref_cnt = 0;
1930 bool is_railgated; 1930 bool is_railgated;
@@ -1958,11 +1958,14 @@ int __gk20a_do_idle(struct device *dev, bool force_reset)
1958 target_ref_cnt = 1; 1958 target_ref_cnt = 1;
1959 mutex_lock(&platform->railgate_lock); 1959 mutex_lock(&platform->railgate_lock);
1960 1960
1961 nvgpu_timeout_init(g, &timeout, GK20A_WAIT_FOR_IDLE_MS,
1962 NVGPU_TIMER_CPU_TIMER);
1963
1961 /* check and wait until GPU is idle (with a timeout) */ 1964 /* check and wait until GPU is idle (with a timeout) */
1962 do { 1965 do {
1963 msleep(1); 1966 msleep(1);
1964 ref_cnt = atomic_read(&dev->power.usage_count); 1967 ref_cnt = atomic_read(&dev->power.usage_count);
1965 } while (ref_cnt != target_ref_cnt && time_before(jiffies, timeout)); 1968 } while (ref_cnt != target_ref_cnt && !nvgpu_timeout_expired(&timeout));
1966 1969
1967 if (ref_cnt != target_ref_cnt) { 1970 if (ref_cnt != target_ref_cnt) {
1968 gk20a_err(dev, "failed to idle - refcount %d != 1\n", 1971 gk20a_err(dev, "failed to idle - refcount %d != 1\n",
@@ -1973,6 +1976,9 @@ int __gk20a_do_idle(struct device *dev, bool force_reset)
1973 /* check if global force_reset flag is set */ 1976 /* check if global force_reset flag is set */
1974 force_reset |= platform->force_reset_in_do_idle; 1977 force_reset |= platform->force_reset_in_do_idle;
1975 1978
1979 nvgpu_timeout_init(g, &timeout, GK20A_WAIT_FOR_IDLE_MS,
1980 NVGPU_TIMER_CPU_TIMER);
1981
1976 if (platform->can_railgate && !force_reset) { 1982 if (platform->can_railgate && !force_reset) {
1977 /* 1983 /*
1978 * Case 1 : GPU railgate is supported 1984 * Case 1 : GPU railgate is supported
@@ -1985,13 +1991,11 @@ int __gk20a_do_idle(struct device *dev, bool force_reset)
1985 /* add sufficient delay to allow GPU to rail gate */ 1991 /* add sufficient delay to allow GPU to rail gate */
1986 msleep(platform->railgate_delay); 1992 msleep(platform->railgate_delay);
1987 1993
1988 timeout = jiffies + msecs_to_jiffies(GK20A_WAIT_FOR_IDLE_MS);
1989
1990 /* check in loop if GPU is railgated or not */ 1994 /* check in loop if GPU is railgated or not */
1991 do { 1995 do {
1992 msleep(1); 1996 msleep(1);
1993 is_railgated = platform->is_railgated(dev); 1997 is_railgated = platform->is_railgated(dev);
1994 } while (!is_railgated && time_before(jiffies, timeout)); 1998 } while (!is_railgated && !nvgpu_timeout_expired(&timeout));
1995 1999
1996 if (is_railgated) { 2000 if (is_railgated) {
1997 return 0; 2001 return 0;