mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-22 09:12:24 +03:00
gpu: nvgpu: Disable logging for safety build
This patch adds a conditional flag to filter out logging functions from safety release build. Logging functions are replaced with stubs. Jira NVGPU-869 Change-Id: If898b9ce8edb260727df28b407df83f0a92f61ad Signed-off-by: Vedashree Vidwans <vvidwans@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/2109509 Reviewed-by: Alex Waterman <alexw@nvidia.com> GVS: Gerrit_Virtual_Submit Reviewed-by: Vijayakumar Subbu <vsubbu@nvidia.com> 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
d8b2e22de9
commit
6f37ac5de2
@@ -181,3 +181,10 @@ config NVGPU_COMPRESSION
|
||||
default y
|
||||
help
|
||||
Support for compression
|
||||
|
||||
config NVGPU_LOGGING
|
||||
bool "Logging for non-safety build"
|
||||
depends on GK20A
|
||||
default y
|
||||
help
|
||||
Enable/Disable logging for non-safety builds
|
||||
|
||||
@@ -42,6 +42,10 @@ ccflags-y += -DCONFIG_NVGPU_POWER_PG
|
||||
ccflags-y += -DCONFIG_NVGPU_CE
|
||||
ccflags-y += -DCONFIG_NVGPU_COMPRESSION
|
||||
|
||||
ifeq ($(CONFIG_NVGPU_LOGGING),y)
|
||||
ccflags-y += -DCONFIG_NVGPU_LOGGING=1
|
||||
endif
|
||||
|
||||
obj-$(CONFIG_GK20A) := nvgpu.o
|
||||
|
||||
# OS independent parts of nvgpu. The work to collect files here
|
||||
@@ -384,7 +388,6 @@ nvgpu-y += \
|
||||
os/linux/ioctl_tsg.o \
|
||||
os/linux/ioctl_dbg.o \
|
||||
os/linux/ioctl_clk_arb.o \
|
||||
os/linux/log.o \
|
||||
os/linux/cond.o \
|
||||
os/linux/nvgpu_mem.o \
|
||||
os/linux/linux-dma.o \
|
||||
@@ -433,6 +436,8 @@ nvgpu-$(CONFIG_DEBUG_FS) += \
|
||||
os/linux/debug_volt.o \
|
||||
os/linux/debug_s_param.o
|
||||
|
||||
nvgpu-$(CONFIG_NVGPU_LOGGING) += os/linux/log.o
|
||||
|
||||
ifeq ($(CONFIG_NVGPU_TRACK_MEM_USAGE),y)
|
||||
nvgpu-$(CONFIG_DEBUG_FS) += \
|
||||
os/linux/debug_kmem.o
|
||||
|
||||
@@ -34,9 +34,16 @@ profile := default
|
||||
# Decide whether to use the safety profile or the regular profile.
|
||||
ifeq ($(NV_BUILD_CONFIGURATION_IS_SAFETY),1)
|
||||
profile := safety
|
||||
ifeq ($(NV_BUILD_CONFIGURATION_IS_DEBUG),1)
|
||||
profile := safety_debug
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(NVGPU_FORCE_SAFETY_PROFILE),1)
|
||||
profile := safety
|
||||
ifeq ($(NVGPU_FORCE_DEBUG_PROFILE),1)
|
||||
profile := safety_debug
|
||||
endif
|
||||
endif
|
||||
|
||||
NVGPU_COMMON_CFLAGS :=
|
||||
@@ -99,6 +106,12 @@ NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_COMPRESSION
|
||||
# Flags enabled for only the regular build profile.
|
||||
#
|
||||
ifneq ($(profile),safety)
|
||||
# Enable logging for non-safety builds
|
||||
CONFIG_NVGPU_LOGGING := 1
|
||||
NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_LOGGING
|
||||
|
||||
ifneq ($(profile),safety_debug)
|
||||
|
||||
# ACR feature to enable old tegra ACR profile support
|
||||
CONFIG_NVGPU_ACR_LEGACY := 1
|
||||
NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_ACR_LEGACY
|
||||
@@ -133,4 +146,6 @@ NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_LS_PMU
|
||||
# Enable elpg support for normal build
|
||||
CONFIG_NVGPU_POWER_PG := 1
|
||||
NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_POWER_PG
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -24,7 +24,6 @@ srcs :=
|
||||
|
||||
ifdef NVGPU_POSIX
|
||||
srcs += os/posix/nvgpu.c \
|
||||
os/posix/log.c \
|
||||
os/posix/posix-io.c \
|
||||
os/posix/posix-nvgpu_mem.c \
|
||||
os/posix/posix-dma.c \
|
||||
@@ -51,6 +50,10 @@ endif
|
||||
ifeq ($(CONFIG_NVGPU_COMPRESSION),1)
|
||||
srcs += os/posix/posix-comptags.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_NVGPU_LOGGING),1)
|
||||
srcs += os/posix/log.c
|
||||
endif
|
||||
endif
|
||||
|
||||
# POSIX sources shared between the POSIX and QNX builds.
|
||||
|
||||
@@ -57,6 +57,7 @@ NV_COMPONENT_CFLAGS += \
|
||||
-D__NVGPU_UNIT_TEST__
|
||||
|
||||
NVGPU_FORCE_SAFETY_PROFILE := 1
|
||||
NVGPU_FORCE_DEBUG_PROFILE := 1
|
||||
-include $(NV_COMPONENT_DIR)/Makefile.shared.configs
|
||||
NV_COMPONENT_CFLAGS += $(NVGPU_COMMON_CFLAGS)
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ enum nvgpu_log_type {
|
||||
* Each OS must implement these functions. They handle the OS specific nuances
|
||||
* of printing data to a UART, log, whatever.
|
||||
*/
|
||||
#ifdef CONFIG_NVGPU_LOGGING
|
||||
__attribute__((format (printf, 5, 6)))
|
||||
void nvgpu_log_msg_impl(struct gk20a *g, const char *func_name, int line,
|
||||
enum nvgpu_log_type type, const char *fmt, ...);
|
||||
@@ -47,6 +48,18 @@ __attribute__((format (printf, 5, 6)))
|
||||
void nvgpu_log_dbg_impl(struct gk20a *g, u64 log_mask,
|
||||
const char *func_name, int line,
|
||||
const char *fmt, ...);
|
||||
#else
|
||||
static inline void nvgpu_log_msg_impl(struct gk20a *g, const char *func_name,
|
||||
int line, enum nvgpu_log_type type, const char *fmt, ...)
|
||||
{
|
||||
}
|
||||
|
||||
static inline void nvgpu_log_dbg_impl(struct gk20a *g, u64 log_mask,
|
||||
const char *func_name, int line,
|
||||
const char *fmt, ...)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Use this define to set a default mask.
|
||||
@@ -95,7 +108,14 @@ void nvgpu_log_dbg_impl(struct gk20a *g, u64 log_mask,
|
||||
* said prints would not happen. For example for-loops of log statements in
|
||||
* critical paths.
|
||||
*/
|
||||
#ifdef CONFIG_NVGPU_LOGGING
|
||||
bool nvgpu_log_mask_enabled(struct gk20a *g, u64 log_mask);
|
||||
#else
|
||||
static inline bool nvgpu_log_mask_enabled(struct gk20a *g, u64 log_mask)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* nvgpu_log - Print a debug message
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
* Caps return at the size of the buffer not what would have been written if buf
|
||||
* were arbitrarily sized.
|
||||
*/
|
||||
#ifdef CONFIG_NVGPU_LOGGING
|
||||
static inline int scnprintf(char *buf, size_t size, const char *format, ...)
|
||||
{
|
||||
size_t ret;
|
||||
@@ -142,6 +143,12 @@ static inline int scnprintf(char *buf, size_t size, const char *format, ...)
|
||||
|
||||
return ret <= size ? (int)ret : (int)size;
|
||||
}
|
||||
#else
|
||||
static inline int scnprintf(char *buf, size_t size, const char *format, ...)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline u32 be32_to_cpu(u32 x)
|
||||
{
|
||||
|
||||
@@ -103,8 +103,6 @@ nvgpu_kmem_cache_destroy
|
||||
nvgpu_kmem_cache_free
|
||||
nvgpu_kmem_get_fault_injection
|
||||
nvgpu_kzalloc_impl
|
||||
nvgpu_log_dbg_impl
|
||||
nvgpu_log_msg_impl
|
||||
nvgpu_memset
|
||||
nvgpu_mem_create_from_phys
|
||||
nvgpu_mem_iommu_translate
|
||||
|
||||
@@ -95,65 +95,85 @@ int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nvgpu_timeout_expired_msg_cpu(struct nvgpu_timeout *timeout,
|
||||
void *caller,
|
||||
/*
|
||||
* NOTE: Logging is disabled in safety release build.
|
||||
* So, in safety release configuration, messages will not be printed or logged.
|
||||
*/
|
||||
#ifdef CONFIG_NVGPU_LOGGING
|
||||
static void nvgpu_timeout_expired_msg_print(struct nvgpu_timeout *timeout,
|
||||
bool retry, void *caller,
|
||||
const char *fmt, va_list args)
|
||||
{
|
||||
struct gk20a *g = timeout->g;
|
||||
|
||||
if (get_time_ns() >= timeout->time) {
|
||||
if ((timeout->flags & NVGPU_TIMER_SILENT_TIMEOUT) == 0U) {
|
||||
char buf[128];
|
||||
|
||||
(void) vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
|
||||
if (retry) {
|
||||
nvgpu_err(g, "No more retries @ %p %s", caller, buf);
|
||||
} else {
|
||||
nvgpu_err(g, "Timeout detected @ %p %s", caller, buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static int nvgpu_timeout_expired_msg_cpu(struct nvgpu_timeout *timeout)
|
||||
{
|
||||
if (get_time_ns() >= timeout->time) {
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int nvgpu_timeout_expired_msg_retry(struct nvgpu_timeout *timeout,
|
||||
void *caller,
|
||||
const char *fmt, va_list args)
|
||||
static int nvgpu_timeout_expired_msg_retry(struct nvgpu_timeout *timeout)
|
||||
{
|
||||
struct gk20a *g = timeout->g;
|
||||
|
||||
if (timeout->retries.attempted >= timeout->retries.max_attempts) {
|
||||
if ((timeout->flags & NVGPU_TIMER_SILENT_TIMEOUT) == 0U) {
|
||||
char buf[128];
|
||||
|
||||
(void) vsnprintf(buf, sizeof(buf), fmt, args);
|
||||
|
||||
nvgpu_err(g, "No more retries @ %p %s", caller, buf);
|
||||
}
|
||||
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
|
||||
timeout->retries.attempted++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* NOTE: Logging is disabled in safety release build.
|
||||
* So, in safety release configuration, messages will not be printed or logged.
|
||||
*/
|
||||
int nvgpu_timeout_expired_msg_impl(struct nvgpu_timeout *timeout,
|
||||
void *caller, const char *fmt, ...)
|
||||
{
|
||||
int ret;
|
||||
|
||||
if ((timeout->flags & NVGPU_TIMER_RETRY_TIMER) != 0U) {
|
||||
ret = nvgpu_timeout_expired_msg_retry(timeout);
|
||||
|
||||
#ifdef CONFIG_NVGPU_LOGGING
|
||||
if (ret != 0) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
if ((timeout->flags & NVGPU_TIMER_RETRY_TIMER) != 0U) {
|
||||
ret = nvgpu_timeout_expired_msg_retry(timeout, caller, fmt,
|
||||
args);
|
||||
} else {
|
||||
ret = nvgpu_timeout_expired_msg_cpu(timeout, caller, fmt,
|
||||
args);
|
||||
}
|
||||
nvgpu_timeout_expired_msg_print(timeout, true, caller,
|
||||
fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
ret = nvgpu_timeout_expired_msg_cpu(timeout);
|
||||
|
||||
#ifdef CONFIG_NVGPU_LOGGING
|
||||
if (ret != 0) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, fmt);
|
||||
nvgpu_timeout_expired_msg_print(timeout, false, caller,
|
||||
fmt, args);
|
||||
va_end(args);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -66,6 +66,7 @@ CONFIGS := -D__NVGPU_POSIX__ \
|
||||
-D__NVGPU_UNIT_TEST__
|
||||
|
||||
NVGPU_FORCE_SAFETY_PROFILE := 1
|
||||
NVGPU_FORCE_DEBUG_PROFILE := 1
|
||||
include $(NVGPU_SRC)/Makefile.shared.configs
|
||||
CONFIGS+=$(NVGPU_COMMON_CFLAGS)
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@ NV_COMPONENT_CFLAGS += \
|
||||
-DNVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
|
||||
|
||||
NVGPU_FORCE_SAFETY_PROFILE := 1
|
||||
NVGPU_FORCE_DEBUG_PROFILE := 1
|
||||
-include ../drivers/gpu/nvgpu/Makefile.shared.configs
|
||||
NV_COMPONENT_CFLAGS += $(NVGPU_COMMON_CFLAGS)
|
||||
|
||||
|
||||
@@ -55,6 +55,7 @@ NV_COMPONENT_CFLAGS += -D__NVGPU_UNIT_TEST__
|
||||
endif
|
||||
|
||||
NVGPU_FORCE_SAFETY_PROFILE := 1
|
||||
NVGPU_FORCE_DEBUG_PROFILE := 1
|
||||
-include $(NV_SOURCE)/kernel/nvgpu/drivers/gpu/nvgpu/Makefile.shared.configs
|
||||
NV_COMPONENT_CFLAGS += $(NVGPU_COMMON_CFLAGS)
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@
|
||||
#include "nvgpu-fifo.h"
|
||||
#include "nvgpu-fifo-gv11b.h"
|
||||
|
||||
static struct unit_module *global_m;
|
||||
|
||||
bool test_fifo_subtest_pruned(u32 branches, u32 final_branches)
|
||||
{
|
||||
u32 match = branches & final_branches;
|
||||
@@ -93,7 +95,7 @@ static int stub_userd_setup_sw(struct gk20a *g)
|
||||
|
||||
err = nvgpu_userd_init_slabs(g);
|
||||
if (err != 0) {
|
||||
nvgpu_err(g, "failed to init userd support");
|
||||
unit_err(global_m, "failed to init userd support");
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -116,6 +118,7 @@ int test_fifo_init_support(struct unit_module *m, struct gk20a *g, void *args)
|
||||
g->ops.tsg.init_eng_method_buffers = NULL;
|
||||
|
||||
#ifdef CONFIG_NVGPU_USERD
|
||||
global_m = m;
|
||||
/*
|
||||
* Regular USERD init requires bar1.vm to be initialized
|
||||
* Use a stub in unit tests, since it will be disabled in
|
||||
|
||||
@@ -472,7 +472,7 @@ static int test_nvgpu_gmmu_map_unmap(struct unit_module *m,
|
||||
unit_return_fail(m, "Mapped VA is not 4KB-aligned\n");
|
||||
}
|
||||
|
||||
nvgpu_log(g, gpu_dbg_map, "Mapped VA=%p", (void *) mem.gpu_va);
|
||||
unit_info(m, "Mapped VA=%p", (void *) mem.gpu_va);
|
||||
|
||||
/*
|
||||
* Based on the VA returned from gmmu_map, lookup the corresponding
|
||||
@@ -482,7 +482,7 @@ static int test_nvgpu_gmmu_map_unmap(struct unit_module *m,
|
||||
if (result != 0) {
|
||||
unit_return_fail(m, "PTE lookup failed with code=%d\n", result);
|
||||
}
|
||||
nvgpu_log(g, gpu_dbg_map, "Found PTE=%08x %08x", pte[1], pte[0]);
|
||||
unit_info(m, "Found PTE=%08x %08x", pte[1], pte[0]);
|
||||
|
||||
/* Make sure PTE is valid */
|
||||
if (!pte_is_valid(pte) &&
|
||||
@@ -925,7 +925,7 @@ static int check_pte_valid(struct unit_module *m, struct gk20a *g,
|
||||
if (result != 0) {
|
||||
unit_return_fail(m, "PTE lookup failed with code=%d\n", result);
|
||||
}
|
||||
nvgpu_log(g, gpu_dbg_map, "Found PTE=%08x %08x", pte[1], pte[0]);
|
||||
unit_info(m, "Found PTE=%08x %08x", pte[1], pte[0]);
|
||||
|
||||
/* Make sure PTE is valid */
|
||||
if (!pte_is_valid(pte)) {
|
||||
|
||||
Reference in New Issue
Block a user