diff options
author | Konsta Holtta <kholtta@nvidia.com> | 2017-06-20 01:46:47 -0400 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-06-20 18:04:30 -0400 |
commit | 72726c70b8839fbaf6374b4daa9799501b6b6c50 (patch) | |
tree | a181ec0db30d33f014dfc0d6485a32634bc10916 /drivers/gpu | |
parent | 6c5c860e77af773c165818e2e2b806e46c1cad57 (diff) |
gpu: nvgpu: use ktime instead of jiffies in timeouts
Instead of the very coarse jiffies, use the more accurate monotonic
Linux ktime API for the nvgpu timeout API.
The expiration time is handled as an u64 nanosecond value to hide the
ktime_t from the public nvgpu_timeout struct. The conversion is cheap.
Jira NVGPU-83
Change-Id: I08a0a67be8935d46f05356162281463d4eb6f4ae
Signed-off-by: Konsta Holtta <kholtta@nvidia.com>
Reviewed-on: http://git-master/r/1505390
Reviewed-by: Alex Waterman <alexw@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/timers.c | 17 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/timers.h | 2 |
2 files changed, 13 insertions, 6 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/timers.c b/drivers/gpu/nvgpu/common/linux/timers.c index 140ae80e..cfebb799 100644 --- a/drivers/gpu/nvgpu/common/linux/timers.c +++ b/drivers/gpu/nvgpu/common/linux/timers.c | |||
@@ -14,7 +14,7 @@ | |||
14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. |
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/jiffies.h> | 17 | #include <linux/ktime.h> |
18 | #include <linux/delay.h> | 18 | #include <linux/delay.h> |
19 | 19 | ||
20 | #include <nvgpu/timers.h> | 20 | #include <nvgpu/timers.h> |
@@ -54,6 +54,9 @@ static int nvgpu_timeout_is_pre_silicon(struct nvgpu_timeout *timeout) | |||
54 | * | 54 | * |
55 | * If neither %NVGPU_TIMER_CPU_TIMER or %NVGPU_TIMER_RETRY_TIMER is passed then | 55 | * If neither %NVGPU_TIMER_CPU_TIMER or %NVGPU_TIMER_RETRY_TIMER is passed then |
56 | * a CPU timer is used by default. | 56 | * a CPU timer is used by default. |
57 | * | ||
58 | * A negative duration is interpreted as the maximum possible, which for our | ||
59 | * purposes means infinite wait. | ||
57 | */ | 60 | */ |
58 | int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout, | 61 | int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout, |
59 | int duration, unsigned long flags) | 62 | int duration, unsigned long flags) |
@@ -66,10 +69,14 @@ int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout, | |||
66 | timeout->g = g; | 69 | timeout->g = g; |
67 | timeout->flags = flags; | 70 | timeout->flags = flags; |
68 | 71 | ||
72 | if (duration < 0) | ||
73 | duration = INT_MAX; | ||
74 | |||
69 | if (flags & NVGPU_TIMER_RETRY_TIMER) | 75 | if (flags & NVGPU_TIMER_RETRY_TIMER) |
70 | timeout->retries.max = duration; | 76 | timeout->retries.max = duration; |
71 | else | 77 | else |
72 | timeout->time = jiffies + msecs_to_jiffies(duration); | 78 | timeout->time = ktime_to_ns(ktime_add_ns(ktime_get(), |
79 | (s64)NSEC_PER_MSEC * duration)); | ||
73 | 80 | ||
74 | return 0; | 81 | return 0; |
75 | } | 82 | } |
@@ -79,12 +86,12 @@ static int __nvgpu_timeout_expired_msg_cpu(struct nvgpu_timeout *timeout, | |||
79 | const char *fmt, va_list args) | 86 | const char *fmt, va_list args) |
80 | { | 87 | { |
81 | struct gk20a *g = timeout->g; | 88 | struct gk20a *g = timeout->g; |
82 | unsigned long now = jiffies; | 89 | ktime_t now = ktime_get(); |
83 | 90 | ||
84 | if (nvgpu_timeout_is_pre_silicon(timeout)) | 91 | if (nvgpu_timeout_is_pre_silicon(timeout)) |
85 | return 0; | 92 | return 0; |
86 | 93 | ||
87 | if (time_after(now, (unsigned long)timeout->time)) { | 94 | if (ktime_after(now, ns_to_ktime(timeout->time))) { |
88 | if (!(timeout->flags & NVGPU_TIMER_SILENT_TIMEOUT)) { | 95 | if (!(timeout->flags & NVGPU_TIMER_SILENT_TIMEOUT)) { |
89 | char buf[128]; | 96 | char buf[128]; |
90 | 97 | ||
@@ -176,7 +183,7 @@ int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout) | |||
176 | if (timeout->flags & NVGPU_TIMER_RETRY_TIMER) | 183 | if (timeout->flags & NVGPU_TIMER_RETRY_TIMER) |
177 | return timeout->retries.attempted >= timeout->retries.max; | 184 | return timeout->retries.attempted >= timeout->retries.max; |
178 | else | 185 | else |
179 | return time_after(jiffies, (unsigned long)timeout->time); | 186 | return ktime_after(ktime_get(), ns_to_ktime(timeout->time)); |
180 | } | 187 | } |
181 | 188 | ||
182 | /** | 189 | /** |
diff --git a/drivers/gpu/nvgpu/include/nvgpu/timers.h b/drivers/gpu/nvgpu/include/nvgpu/timers.h index be903e54..5265437e 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/timers.h +++ b/drivers/gpu/nvgpu/include/nvgpu/timers.h | |||
@@ -50,7 +50,7 @@ struct nvgpu_timeout { | |||
50 | unsigned int flags; | 50 | unsigned int flags; |
51 | 51 | ||
52 | union { | 52 | union { |
53 | unsigned long time; | 53 | s64 time; |
54 | struct { | 54 | struct { |
55 | int max; | 55 | int max; |
56 | int attempted; | 56 | int attempted; |