Files
linux-nvgpu/drivers/gpu/nvgpu/include/nvgpu/timers.h
ajesh fe9f1e9e5c gpu: nvgpu: fix MISRA violations in timers unit
MISRA rule 21.2 forbids the usage of identifier names which start with
an underscore.  Fix the violations of MISRA rule 21.2 in timers unit.

Jira NVGPU-3139

Change-Id: I507d0f2a51e83ce24d642dcc81975aa513fa41eb
Signed-off-by: ajesh <akv@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/2112599
Reviewed-by: svc-mobile-coverity <svc-mobile-coverity@nvidia.com>
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
2019-05-06 12:07:16 -07:00

117 lines
3.5 KiB
C

/*
* Copyright (c) 2016-2019, NVIDIA CORPORATION. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*/
#ifndef NVGPU_TIMERS_H
#define NVGPU_TIMERS_H
#include <nvgpu/types.h>
#include <nvgpu/utils.h>
struct gk20a;
/*
* struct nvgpu_timeout - define a timeout.
*
* There are two types of timer suported:
*
* o NVGPU_TIMER_CPU_TIMER
* Timer uses the CPU to measure the timeout.
*
* o NVGPU_TIMER_RETRY_TIMER
* Instead of measuring a time limit keep track of the number of times
* something has been attempted. After said limit, "expire" the timer.
*
* Available flags:
*
* o NVGPU_TIMER_NO_PRE_SI
* By default when the system is not running on silicon the timeout
* code will ignore the requested timeout. Specifying this flag will
* override that behavior and honor the timeout regardless of platform.
*
* o NVGPU_TIMER_SILENT_TIMEOUT
* Do not print any messages on timeout. Normally a simple message is
* printed that specifies where the timeout occurred.
*/
struct nvgpu_timeout {
struct gk20a *g;
unsigned int flags;
union {
s64 time;
struct {
u32 max;
u32 attempted;
} retries;
};
};
/*
* Bit 0 specifies the type of timer: CPU or retry.
*/
#define NVGPU_TIMER_CPU_TIMER (0x0U)
#define NVGPU_TIMER_RETRY_TIMER (0x1U)
/*
* Bits 1 through 7 are reserved; bits 8 and up are flags:
*/
#define NVGPU_TIMER_NO_PRE_SI BIT32(8)
#define NVGPU_TIMER_SILENT_TIMEOUT BIT32(9)
#define NVGPU_TIMER_FLAG_MASK (NVGPU_TIMER_RETRY_TIMER | \
NVGPU_TIMER_NO_PRE_SI | \
NVGPU_TIMER_SILENT_TIMEOUT)
int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout,
u32 duration, unsigned long flags);
int nvgpu_timeout_peek_expired(struct nvgpu_timeout *timeout);
#define nvgpu_timeout_expired(__timeout) \
nvgpu_timeout_expired_msg_impl(__timeout, _NVGPU_GET_IP_, "")
#define nvgpu_timeout_expired_msg(__timeout, fmt, args...) \
nvgpu_timeout_expired_msg_impl(__timeout, _NVGPU_GET_IP_, \
fmt, ##args)
/*
* Don't use this directly.
*/
int nvgpu_timeout_expired_msg_impl(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);
/*
* Timekeeping.
*/
s64 nvgpu_current_time_ms(void);
s64 nvgpu_current_time_ns(void);
u64 nvgpu_hr_timestamp(void);
#endif /* NVGPU_TIMERS_H */