diff options
author | Alex Waterman <alexw@nvidia.com> | 2017-02-21 21:01:12 -0500 |
---|---|---|
committer | mobile promotions <svcmobile_promotions@nvidia.com> | 2017-04-03 16:20:55 -0400 |
commit | a94b4bcde9b88e856d4b6f2bcb9e0e23942a69cc (patch) | |
tree | 6a58bcf79e9a6d6277420b90888eca80d683b802 /drivers/gpu/nvgpu | |
parent | 6c58737bed4477f3e3199956b29b3948a465c14d (diff) |
gpu: nvgpu: Abstraction for *sleep, *delay
Add abstractions for the following:
msleep()
udelay()
usleep_range()
These functions are only a subset of the available Linux delay and sleep
functions but this seems to be what we use and what is actually useful
for driver development.
Bug 1799159
Jira NVGPU-16
Change-Id: I1a25b66314f365432f2f0a5ff1b3a0a5689fc047
Signed-off-by: Alex Waterman <alexw@nvidia.com>
Reviewed-on: http://git-master/r/1309087
Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
Reviewed-by: David Martinez Nieto <dmartineznie@nvidia.com>
Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
Tested-by: Terje Bergstrom <tbergstrom@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/timers.c | 52 | ||||
-rw-r--r-- | drivers/gpu/nvgpu/include/nvgpu/timers.h | 8 |
2 files changed, 60 insertions, 0 deletions
diff --git a/drivers/gpu/nvgpu/common/linux/timers.c b/drivers/gpu/nvgpu/common/linux/timers.c index 5c4f0fb1..07eb357a 100644 --- a/drivers/gpu/nvgpu/common/linux/timers.c +++ b/drivers/gpu/nvgpu/common/linux/timers.c | |||
@@ -15,6 +15,7 @@ | |||
15 | */ | 15 | */ |
16 | 16 | ||
17 | #include <linux/jiffies.h> | 17 | #include <linux/jiffies.h> |
18 | #include <linux/delay.h> | ||
18 | 19 | ||
19 | #include <nvgpu/timers.h> | 20 | #include <nvgpu/timers.h> |
20 | 21 | ||
@@ -175,3 +176,54 @@ int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout) | |||
175 | else | 176 | else |
176 | return time_after(jiffies, (unsigned long)timeout->time); | 177 | return time_after(jiffies, (unsigned long)timeout->time); |
177 | } | 178 | } |
179 | |||
180 | /** | ||
181 | * nvgpu_udelay - Delay for some number of microseconds. | ||
182 | * | ||
183 | * @usecs - Microseconds to wait for. | ||
184 | * | ||
185 | * Wait for at least @usecs microseconds. This is not guaranteed to be perfectly | ||
186 | * accurate. This is normally backed by a busy-loop so this means waits should | ||
187 | * be kept short, below 100us. If longer delays are necessary then | ||
188 | * nvgpu_msleep() should be preferred. | ||
189 | * | ||
190 | * Alternatively, on some platforms, nvgpu_usleep_range() is usable. This | ||
191 | * function will attempt to not use a busy-loop. | ||
192 | */ | ||
193 | void nvgpu_udelay(unsigned int usecs) | ||
194 | { | ||
195 | udelay(usecs); | ||
196 | } | ||
197 | |||
198 | /** | ||
199 | * nvgpu_usleep_range - Sleep for a range of microseconds. | ||
200 | * | ||
201 | * @min_us - Minimum wait time. | ||
202 | * @max_us - Maximum wait time. | ||
203 | * | ||
204 | * Wait for some number of microseconds between @min_us and @max_us. This, | ||
205 | * unlike nvgpu_udelay(), will attempt to sleep for the passed number of | ||
206 | * microseconds instead of busy looping. Not all platforms support this, | ||
207 | * and in that case this reduces to nvgpu_udelay(min_us). | ||
208 | * | ||
209 | * Linux note: this is not safe to use in atomic context. If you are in | ||
210 | * atomic context you must use nvgpu_udelay(). | ||
211 | */ | ||
212 | void nvgpu_usleep_range(unsigned int min_us, unsigned int max_us) | ||
213 | { | ||
214 | usleep_range(min_us, max_us); | ||
215 | } | ||
216 | |||
217 | /** | ||
218 | * nvgpu_msleep - Sleep for some milliseconds. | ||
219 | * | ||
220 | * @msecs - Sleep for at least this many milliseconds. | ||
221 | * | ||
222 | * Sleep for at least @msecs of milliseconds. For small @msecs (less than 20 ms | ||
223 | * or so) the sleep will be significantly longer due to scheduling overhead and | ||
224 | * mechanics. | ||
225 | */ | ||
226 | void nvgpu_msleep(unsigned int msecs) | ||
227 | { | ||
228 | msleep(msecs); | ||
229 | } | ||
diff --git a/drivers/gpu/nvgpu/include/nvgpu/timers.h b/drivers/gpu/nvgpu/include/nvgpu/timers.h index abf8b736..0aadd0df 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/timers.h +++ b/drivers/gpu/nvgpu/include/nvgpu/timers.h | |||
@@ -89,4 +89,12 @@ int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout); | |||
89 | int __nvgpu_timeout_expired_msg(struct nvgpu_timeout *timeout, | 89 | int __nvgpu_timeout_expired_msg(struct nvgpu_timeout *timeout, |
90 | void *caller, const char *fmt, ...); | 90 | void *caller, const char *fmt, ...); |
91 | 91 | ||
92 | |||
93 | /* | ||
94 | * Waits and delays. | ||
95 | */ | ||
96 | void nvgpu_msleep(unsigned int msecs); | ||
97 | void nvgpu_usleep_range(unsigned int min_us, unsigned int max_us); | ||
98 | void nvgpu_udelay(unsigned int usecs); | ||
99 | |||
92 | #endif | 100 | #endif |