mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-25 02:52:51 +03:00
gpu: nvgpu: Add an nvgpu_assert macro
This macro helps us differentiate what to do with debugging statements depending on OS. Different OSes have different considerations for what to do when bad state in the driver is detected. JIRA NVGPU-1323 Change-Id: If435ef490146e87e809645453e8ac1065e13cace Signed-off-by: Alex Waterman <alexw@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1945144 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
88e374d5eb
commit
e85752a468
@@ -30,4 +30,33 @@
|
||||
#include <nvgpu_rmos/include/bug.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Define an assert macro that code within nvgpu can use.
|
||||
*
|
||||
* The goal of this macro is for debugging but what that means varies from OS
|
||||
* to OS. On Linux wee don't want to BUG() for general driver misbehaving. BUG()
|
||||
* is a very heavy handed tool - in fact there's probably no where within the
|
||||
* nvgpu core code where it makes sense to use a BUG() when running under Linux.
|
||||
*
|
||||
* However, on QNX (and POSIX) BUG() will just kill the current process. This
|
||||
* means we can use it for handling bugs in nvgpu.
|
||||
*
|
||||
* As a result this macro varies depending on platform.
|
||||
*/
|
||||
#if defined(__KERNEL__)
|
||||
#define nvgpu_assert(cond) WARN_ON(!(cond))
|
||||
#elif defined(__NVGPU_POSIX__)
|
||||
/*
|
||||
* A static inline for POSIX so that we can hide the branch in BUG_ON() from the
|
||||
* branch analysis for users of this function. When this assert fails the
|
||||
* function will not return.
|
||||
*/
|
||||
static inline void nvgpu_assert(bool cond)
|
||||
{
|
||||
BUG_ON(!cond);
|
||||
}
|
||||
#else
|
||||
#define nvgpu_assert(cond) BUG_ON(!(cond))
|
||||
#endif
|
||||
|
||||
#endif /* NVGPU_BUG_H */
|
||||
|
||||
@@ -26,10 +26,6 @@
|
||||
#include <nvgpu/types.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
/*
|
||||
* TODO: make these actually useful!
|
||||
*/
|
||||
|
||||
#define BUG() __bug("")
|
||||
#define BUG_ON(cond) \
|
||||
do { \
|
||||
|
||||
Reference in New Issue
Block a user