mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 10:34:43 +03:00
gpu: nvgpu: fix MISRA 17.1 in timeout_expired_msg
MISRA rule 17.1 forbids use of stdarg.h features defined for variable arguments. This patch creates timers.h header for posix and QNX to change nvgpu_timeout_expired_msg() to macro definition. Jira NVGPU-4075 Change-Id: I8167f0ff7fdfb74adbbbed9c3021a9df2ad6401b Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2200885 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
Alex Waterman
parent
7c98fbba42
commit
d6fc9d176e
76
drivers/gpu/nvgpu/include/nvgpu/posix/timers.h
Normal file
76
drivers/gpu/nvgpu/include/nvgpu/posix/timers.h
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 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_POSIX_TIMERS_H
|
||||
#define NVGPU_POSIX_TIMERS_H
|
||||
|
||||
#include <sys/time.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <nvgpu/types.h>
|
||||
#include <nvgpu/log.h>
|
||||
|
||||
|
||||
#define nvgpu_timeout_expired_msg_cpu(timeout, caller, fmt, arg...) \
|
||||
({ \
|
||||
struct nvgpu_timeout *t_ptr = (timeout); \
|
||||
int ret = 0; \
|
||||
if (nvgpu_current_time_ns() > t_ptr->time) { \
|
||||
if ((t_ptr->flags & NVGPU_TIMER_SILENT_TIMEOUT) == 0U) { \
|
||||
nvgpu_err(t_ptr->g, "Timeout detected @ %p" fmt, \
|
||||
caller, ##arg); \
|
||||
} \
|
||||
ret = -ETIMEDOUT; \
|
||||
} \
|
||||
(int)ret; \
|
||||
})
|
||||
|
||||
#define nvgpu_timeout_expired_msg_retry(timeout, caller, fmt, arg...) \
|
||||
({ \
|
||||
struct nvgpu_timeout *t_ptr = (timeout); \
|
||||
int ret = 0; \
|
||||
if (t_ptr->retries.attempted >= t_ptr->retries.max_attempts) { \
|
||||
if ((t_ptr->flags & NVGPU_TIMER_SILENT_TIMEOUT) == 0U) { \
|
||||
nvgpu_err(t_ptr->g, "No more retries @ %p" fmt, \
|
||||
caller, ##arg); \
|
||||
} \
|
||||
ret = -ETIMEDOUT; \
|
||||
} else { \
|
||||
t_ptr->retries.attempted++; \
|
||||
} \
|
||||
(int)ret; \
|
||||
})
|
||||
|
||||
#define nvgpu_timeout_expired_msg_impl(timeout, caller, fmt, arg...) \
|
||||
({ \
|
||||
int ret = 0; \
|
||||
if (((timeout)->flags & NVGPU_TIMER_RETRY_TIMER) != 0U) { \
|
||||
ret = nvgpu_timeout_expired_msg_retry((timeout), caller,\
|
||||
fmt, ##arg); \
|
||||
} else { \
|
||||
ret = nvgpu_timeout_expired_msg_cpu((timeout), caller, \
|
||||
fmt, ##arg); \
|
||||
} \
|
||||
(int)ret; \
|
||||
})
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user