mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 17:36:20 +03:00
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>
This commit is contained in:
committed by
mobile promotions
parent
6c58737bed
commit
a94b4bcde9
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include <nvgpu/timers.h>
|
||||
|
||||
@@ -175,3 +176,54 @@ int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout)
|
||||
else
|
||||
return time_after(jiffies, (unsigned long)timeout->time);
|
||||
}
|
||||
|
||||
/**
|
||||
* nvgpu_udelay - Delay for some number of microseconds.
|
||||
*
|
||||
* @usecs - Microseconds to wait for.
|
||||
*
|
||||
* Wait for at least @usecs microseconds. This is not guaranteed to be perfectly
|
||||
* accurate. This is normally backed by a busy-loop so this means waits should
|
||||
* be kept short, below 100us. If longer delays are necessary then
|
||||
* nvgpu_msleep() should be preferred.
|
||||
*
|
||||
* Alternatively, on some platforms, nvgpu_usleep_range() is usable. This
|
||||
* function will attempt to not use a busy-loop.
|
||||
*/
|
||||
void nvgpu_udelay(unsigned int usecs)
|
||||
{
|
||||
udelay(usecs);
|
||||
}
|
||||
|
||||
/**
|
||||
* nvgpu_usleep_range - Sleep for a range of microseconds.
|
||||
*
|
||||
* @min_us - Minimum wait time.
|
||||
* @max_us - Maximum wait time.
|
||||
*
|
||||
* Wait for some number of microseconds between @min_us and @max_us. This,
|
||||
* unlike nvgpu_udelay(), will attempt to sleep for the passed number of
|
||||
* microseconds instead of busy looping. Not all platforms support this,
|
||||
* and in that case this reduces to nvgpu_udelay(min_us).
|
||||
*
|
||||
* Linux note: this is not safe to use in atomic context. If you are in
|
||||
* atomic context you must use nvgpu_udelay().
|
||||
*/
|
||||
void nvgpu_usleep_range(unsigned int min_us, unsigned int max_us)
|
||||
{
|
||||
usleep_range(min_us, max_us);
|
||||
}
|
||||
|
||||
/**
|
||||
* nvgpu_msleep - Sleep for some milliseconds.
|
||||
*
|
||||
* @msecs - Sleep for at least this many milliseconds.
|
||||
*
|
||||
* Sleep for at least @msecs of milliseconds. For small @msecs (less than 20 ms
|
||||
* or so) the sleep will be significantly longer due to scheduling overhead and
|
||||
* mechanics.
|
||||
*/
|
||||
void nvgpu_msleep(unsigned int msecs)
|
||||
{
|
||||
msleep(msecs);
|
||||
}
|
||||
|
||||
@@ -89,4 +89,12 @@ int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout);
|
||||
int __nvgpu_timeout_expired_msg(struct nvgpu_timeout *timeout,
|
||||
void *caller, const char *fmt, ...);
|
||||
|
||||
|
||||
/*
|
||||
* Waits and delays.
|
||||
*/
|
||||
void nvgpu_msleep(unsigned int msecs);
|
||||
void nvgpu_usleep_range(unsigned int min_us, unsigned int max_us);
|
||||
void nvgpu_udelay(unsigned int usecs);
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user