diff options
Diffstat (limited to 'drivers/gpu/nvgpu/common')
-rw-r--r-- | drivers/gpu/nvgpu/common/linux/timers.c | 52 |
1 files changed, 52 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 | } | ||