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:
Vedashree Vidwans
2019-06-10 15:52:01 +00:00
committed by mobile promotions
parent d8b2e22de9
commit 6f37ac5de2
14 changed files with 118 additions and 36 deletions

View File

@@ -181,3 +181,10 @@ config NVGPU_COMPRESSION
default y default y
help help
Support for compression 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

View File

@@ -42,6 +42,10 @@ ccflags-y += -DCONFIG_NVGPU_POWER_PG
ccflags-y += -DCONFIG_NVGPU_CE ccflags-y += -DCONFIG_NVGPU_CE
ccflags-y += -DCONFIG_NVGPU_COMPRESSION ccflags-y += -DCONFIG_NVGPU_COMPRESSION
ifeq ($(CONFIG_NVGPU_LOGGING),y)
ccflags-y += -DCONFIG_NVGPU_LOGGING=1
endif
obj-$(CONFIG_GK20A) := nvgpu.o obj-$(CONFIG_GK20A) := nvgpu.o
# OS independent parts of nvgpu. The work to collect files here # 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_tsg.o \
os/linux/ioctl_dbg.o \ os/linux/ioctl_dbg.o \
os/linux/ioctl_clk_arb.o \ os/linux/ioctl_clk_arb.o \
os/linux/log.o \
os/linux/cond.o \ os/linux/cond.o \
os/linux/nvgpu_mem.o \ os/linux/nvgpu_mem.o \
os/linux/linux-dma.o \ os/linux/linux-dma.o \
@@ -433,6 +436,8 @@ nvgpu-$(CONFIG_DEBUG_FS) += \
os/linux/debug_volt.o \ os/linux/debug_volt.o \
os/linux/debug_s_param.o os/linux/debug_s_param.o
nvgpu-$(CONFIG_NVGPU_LOGGING) += os/linux/log.o
ifeq ($(CONFIG_NVGPU_TRACK_MEM_USAGE),y) ifeq ($(CONFIG_NVGPU_TRACK_MEM_USAGE),y)
nvgpu-$(CONFIG_DEBUG_FS) += \ nvgpu-$(CONFIG_DEBUG_FS) += \
os/linux/debug_kmem.o os/linux/debug_kmem.o

View File

@@ -34,9 +34,16 @@ profile := default
# Decide whether to use the safety profile or the regular profile. # Decide whether to use the safety profile or the regular profile.
ifeq ($(NV_BUILD_CONFIGURATION_IS_SAFETY),1) ifeq ($(NV_BUILD_CONFIGURATION_IS_SAFETY),1)
profile := safety profile := safety
ifeq ($(NV_BUILD_CONFIGURATION_IS_DEBUG),1)
profile := safety_debug
endif endif
endif
ifeq ($(NVGPU_FORCE_SAFETY_PROFILE),1) ifeq ($(NVGPU_FORCE_SAFETY_PROFILE),1)
profile := safety profile := safety
ifeq ($(NVGPU_FORCE_DEBUG_PROFILE),1)
profile := safety_debug
endif
endif endif
NVGPU_COMMON_CFLAGS := NVGPU_COMMON_CFLAGS :=
@@ -99,6 +106,12 @@ NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_COMPRESSION
# Flags enabled for only the regular build profile. # Flags enabled for only the regular build profile.
# #
ifneq ($(profile),safety) 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 # ACR feature to enable old tegra ACR profile support
CONFIG_NVGPU_ACR_LEGACY := 1 CONFIG_NVGPU_ACR_LEGACY := 1
NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_ACR_LEGACY NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_ACR_LEGACY
@@ -133,4 +146,6 @@ NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_LS_PMU
# Enable elpg support for normal build # Enable elpg support for normal build
CONFIG_NVGPU_POWER_PG := 1 CONFIG_NVGPU_POWER_PG := 1
NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_POWER_PG NVGPU_COMMON_CFLAGS += -DCONFIG_NVGPU_POWER_PG
endif
endif endif

View File

@@ -24,7 +24,6 @@ srcs :=
ifdef NVGPU_POSIX ifdef NVGPU_POSIX
srcs += os/posix/nvgpu.c \ srcs += os/posix/nvgpu.c \
os/posix/log.c \
os/posix/posix-io.c \ os/posix/posix-io.c \
os/posix/posix-nvgpu_mem.c \ os/posix/posix-nvgpu_mem.c \
os/posix/posix-dma.c \ os/posix/posix-dma.c \
@@ -51,6 +50,10 @@ endif
ifeq ($(CONFIG_NVGPU_COMPRESSION),1) ifeq ($(CONFIG_NVGPU_COMPRESSION),1)
srcs += os/posix/posix-comptags.c srcs += os/posix/posix-comptags.c
endif endif
ifeq ($(CONFIG_NVGPU_LOGGING),1)
srcs += os/posix/log.c
endif
endif endif
# POSIX sources shared between the POSIX and QNX builds. # POSIX sources shared between the POSIX and QNX builds.

View File

@@ -57,6 +57,7 @@ NV_COMPONENT_CFLAGS += \
-D__NVGPU_UNIT_TEST__ -D__NVGPU_UNIT_TEST__
NVGPU_FORCE_SAFETY_PROFILE := 1 NVGPU_FORCE_SAFETY_PROFILE := 1
NVGPU_FORCE_DEBUG_PROFILE := 1
-include $(NV_COMPONENT_DIR)/Makefile.shared.configs -include $(NV_COMPONENT_DIR)/Makefile.shared.configs
NV_COMPONENT_CFLAGS += $(NVGPU_COMMON_CFLAGS) NV_COMPONENT_CFLAGS += $(NVGPU_COMMON_CFLAGS)

View File

@@ -39,6 +39,7 @@ enum nvgpu_log_type {
* Each OS must implement these functions. They handle the OS specific nuances * Each OS must implement these functions. They handle the OS specific nuances
* of printing data to a UART, log, whatever. * of printing data to a UART, log, whatever.
*/ */
#ifdef CONFIG_NVGPU_LOGGING
__attribute__((format (printf, 5, 6))) __attribute__((format (printf, 5, 6)))
void nvgpu_log_msg_impl(struct gk20a *g, const char *func_name, int line, void nvgpu_log_msg_impl(struct gk20a *g, const char *func_name, int line,
enum nvgpu_log_type type, const char *fmt, ...); 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, void nvgpu_log_dbg_impl(struct gk20a *g, u64 log_mask,
const char *func_name, int line, const char *func_name, int line,
const char *fmt, ...); 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. * 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 * said prints would not happen. For example for-loops of log statements in
* critical paths. * critical paths.
*/ */
#ifdef CONFIG_NVGPU_LOGGING
bool nvgpu_log_mask_enabled(struct gk20a *g, u64 log_mask); 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 * nvgpu_log - Print a debug message

View File

@@ -131,6 +131,7 @@
* Caps return at the size of the buffer not what would have been written if buf * Caps return at the size of the buffer not what would have been written if buf
* were arbitrarily sized. * were arbitrarily sized.
*/ */
#ifdef CONFIG_NVGPU_LOGGING
static inline int scnprintf(char *buf, size_t size, const char *format, ...) static inline int scnprintf(char *buf, size_t size, const char *format, ...)
{ {
size_t ret; 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; 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) static inline u32 be32_to_cpu(u32 x)
{ {

View File

@@ -103,8 +103,6 @@ nvgpu_kmem_cache_destroy
nvgpu_kmem_cache_free nvgpu_kmem_cache_free
nvgpu_kmem_get_fault_injection nvgpu_kmem_get_fault_injection
nvgpu_kzalloc_impl nvgpu_kzalloc_impl
nvgpu_log_dbg_impl
nvgpu_log_msg_impl
nvgpu_memset nvgpu_memset
nvgpu_mem_create_from_phys nvgpu_mem_create_from_phys
nvgpu_mem_iommu_translate nvgpu_mem_iommu_translate

View File

@@ -95,65 +95,85 @@ int nvgpu_timeout_init(struct gk20a *g, struct nvgpu_timeout *timeout,
return 0; 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) const char *fmt, va_list args)
{ {
struct gk20a *g = timeout->g; struct gk20a *g = timeout->g;
if ((timeout->flags & NVGPU_TIMER_SILENT_TIMEOUT) == 0U) {
char buf[128];
if (get_time_ns() >= timeout->time) { (void) vsnprintf(buf, sizeof(buf), fmt, args);
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); 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 -ETIMEDOUT;
} }
return 0; return 0;
} }
static int nvgpu_timeout_expired_msg_retry(struct nvgpu_timeout *timeout, static int nvgpu_timeout_expired_msg_retry(struct nvgpu_timeout *timeout)
void *caller,
const char *fmt, va_list args)
{ {
struct gk20a *g = timeout->g;
if (timeout->retries.attempted >= timeout->retries.max_attempts) { 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; return -ETIMEDOUT;
} }
timeout->retries.attempted++; timeout->retries.attempted++;
return 0; 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, int nvgpu_timeout_expired_msg_impl(struct nvgpu_timeout *timeout,
void *caller, const char *fmt, ...) void *caller, const char *fmt, ...)
{ {
int ret; int ret;
va_list args;
va_start(args, fmt);
if ((timeout->flags & NVGPU_TIMER_RETRY_TIMER) != 0U) { if ((timeout->flags & NVGPU_TIMER_RETRY_TIMER) != 0U) {
ret = nvgpu_timeout_expired_msg_retry(timeout, caller, fmt, ret = nvgpu_timeout_expired_msg_retry(timeout);
args);
#ifdef CONFIG_NVGPU_LOGGING
if (ret != 0) {
va_list args;
va_start(args, fmt);
nvgpu_timeout_expired_msg_print(timeout, true, caller,
fmt, args);
va_end(args);
}
#endif
} else { } else {
ret = nvgpu_timeout_expired_msg_cpu(timeout, caller, fmt, ret = nvgpu_timeout_expired_msg_cpu(timeout);
args);
#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
} }
va_end(args);
return ret; return ret;
} }

View File

@@ -66,6 +66,7 @@ CONFIGS := -D__NVGPU_POSIX__ \
-D__NVGPU_UNIT_TEST__ -D__NVGPU_UNIT_TEST__
NVGPU_FORCE_SAFETY_PROFILE := 1 NVGPU_FORCE_SAFETY_PROFILE := 1
NVGPU_FORCE_DEBUG_PROFILE := 1
include $(NVGPU_SRC)/Makefile.shared.configs include $(NVGPU_SRC)/Makefile.shared.configs
CONFIGS+=$(NVGPU_COMMON_CFLAGS) CONFIGS+=$(NVGPU_COMMON_CFLAGS)

View File

@@ -112,6 +112,7 @@ NV_COMPONENT_CFLAGS += \
-DNVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT -DNVGPU_UNITTEST_FAULT_INJECTION_ENABLEMENT
NVGPU_FORCE_SAFETY_PROFILE := 1 NVGPU_FORCE_SAFETY_PROFILE := 1
NVGPU_FORCE_DEBUG_PROFILE := 1
-include ../drivers/gpu/nvgpu/Makefile.shared.configs -include ../drivers/gpu/nvgpu/Makefile.shared.configs
NV_COMPONENT_CFLAGS += $(NVGPU_COMMON_CFLAGS) NV_COMPONENT_CFLAGS += $(NVGPU_COMMON_CFLAGS)

View File

@@ -55,6 +55,7 @@ NV_COMPONENT_CFLAGS += -D__NVGPU_UNIT_TEST__
endif endif
NVGPU_FORCE_SAFETY_PROFILE := 1 NVGPU_FORCE_SAFETY_PROFILE := 1
NVGPU_FORCE_DEBUG_PROFILE := 1
-include $(NV_SOURCE)/kernel/nvgpu/drivers/gpu/nvgpu/Makefile.shared.configs -include $(NV_SOURCE)/kernel/nvgpu/drivers/gpu/nvgpu/Makefile.shared.configs
NV_COMPONENT_CFLAGS += $(NVGPU_COMMON_CFLAGS) NV_COMPONENT_CFLAGS += $(NVGPU_COMMON_CFLAGS)

View File

@@ -37,6 +37,8 @@
#include "nvgpu-fifo.h" #include "nvgpu-fifo.h"
#include "nvgpu-fifo-gv11b.h" #include "nvgpu-fifo-gv11b.h"
static struct unit_module *global_m;
bool test_fifo_subtest_pruned(u32 branches, u32 final_branches) bool test_fifo_subtest_pruned(u32 branches, u32 final_branches)
{ {
u32 match = branches & 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); err = nvgpu_userd_init_slabs(g);
if (err != 0) { if (err != 0) {
nvgpu_err(g, "failed to init userd support"); unit_err(global_m, "failed to init userd support");
return err; 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; g->ops.tsg.init_eng_method_buffers = NULL;
#ifdef CONFIG_NVGPU_USERD #ifdef CONFIG_NVGPU_USERD
global_m = m;
/* /*
* Regular USERD init requires bar1.vm to be initialized * Regular USERD init requires bar1.vm to be initialized
* Use a stub in unit tests, since it will be disabled in * Use a stub in unit tests, since it will be disabled in

View File

@@ -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"); 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 * 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) { if (result != 0) {
unit_return_fail(m, "PTE lookup failed with code=%d\n", result); 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 */ /* Make sure PTE is valid */
if (!pte_is_valid(pte) && if (!pte_is_valid(pte) &&
@@ -925,7 +925,7 @@ static int check_pte_valid(struct unit_module *m, struct gk20a *g,
if (result != 0) { if (result != 0) {
unit_return_fail(m, "PTE lookup failed with code=%d\n", result); 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 */ /* Make sure PTE is valid */
if (!pte_is_valid(pte)) { if (!pte_is_valid(pte)) {