From 9d0d16cffd10144e04a22f17c4ec699be9a9ede8 Mon Sep 17 00:00:00 2001 From: sagar Date: Tue, 21 Jan 2020 17:25:15 +0530 Subject: [PATCH] nvgpu: add insturmentation for ctxsw error codes For integration testing in safety build, we need to test ctxsw firmware error codes. inorder to test this, we need some instrumentation in nvgpu driver. Added below instrumentation for CTXSW FW error code integration testing. 1. Reduce the ctxsw watchdog time, so ctxsw watchdog always triggered. Use CONFIG_NVGPU_CTXSW_FW_ERROR_WDT_TESTING for testing watchdog 2. Submit unsupported method to CTXSW FW, it will trigger err. Use CONFIG_NVGPU_CTXSW_FW_ERROR_CODE_TESTING for testing err code. JIRA NVGPU-4471 Change-Id: Ib45a946b3e38d3b6dd5bbee277c5d3e7c55521c0 Signed-off-by: sagar Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2284048 Tested-by: mobile promotions Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: svc-mobile-cert Reviewed-by: Deepak Nibade Reviewed-by: Ankur Kishore Reviewed-by: mobile promotions GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/Makefile.shared.configs | 8 ++++++++ .../nvgpu/hal/gr/falcon/gr_falcon_gm20b_fusa.c | 17 +++++++++++++++-- drivers/gpu/nvgpu/include/nvgpu/gr/gr_falcon.h | 5 +++-- 3 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/Makefile.shared.configs b/drivers/gpu/nvgpu/Makefile.shared.configs index 492b6f91f..2941a3c6d 100644 --- a/drivers/gpu/nvgpu/Makefile.shared.configs +++ b/drivers/gpu/nvgpu/Makefile.shared.configs @@ -71,6 +71,14 @@ NVGPU_COMMON_CFLAGS += \ -DCONFIG_NVGPU_GR_GOLDEN_CTX_VERIFICATION \ -DCONFIG_NVGPU_BUILD_CONFIGURATION_IS_SAFETY +## For tesing of CTXSW FW error codes manually, enable below configs in safety build. +## Enable only one config at a time, because only one error can be tested at a time. +# NVGPU_COMMON_CFLAGS += \ +# -DCONFIG_NVGPU_CTXSW_FW_ERROR_WDT_TESTING +# +# NVGPU_COMMON_CFLAGS += \ +# -DCONFIG_NVGPU_CTXSW_FW_ERROR_CODE_TESTING + endif # diff --git a/drivers/gpu/nvgpu/hal/gr/falcon/gr_falcon_gm20b_fusa.c b/drivers/gpu/nvgpu/hal/gr/falcon/gr_falcon_gm20b_fusa.c index 5737e5d50..bfd7823ac 100644 --- a/drivers/gpu/nvgpu/hal/gr/falcon/gr_falcon_gm20b_fusa.c +++ b/drivers/gpu/nvgpu/hal/gr/falcon/gr_falcon_gm20b_fusa.c @@ -43,7 +43,11 @@ #define CTXSW_MEM_SCRUBBING_TIMEOUT_MAX_US 1000U #define CTXSW_MEM_SCRUBBING_TIMEOUT_DEFAULT_US 10U +#ifdef CONFIG_NVGPU_CTXSW_FW_ERROR_WDT_TESTING +#define CTXSW_WDT_DEFAULT_VALUE 0x1U +#else #define CTXSW_WDT_DEFAULT_VALUE 0x7FFFFFFFU +#endif #define CTXSW_INTR0 BIT32(0) #define CTXSW_INTR1 BIT32(1) @@ -541,14 +545,22 @@ int gm20b_gr_falcon_init_ctx_state(struct gk20a *g, "query golden image size failed"); return ret; } -#ifdef CONFIG_NVGPU_DEBUGGER + +#if defined(CONFIG_NVGPU_DEBUGGER) || \ +defined(CONFIG_NVGPU_CTXSW_FW_ERROR_CODE_TESTING) ret = gm20b_gr_falcon_ctrl_ctxsw(g, NVGPU_GR_FALCON_METHOD_CTXSW_DISCOVER_PM_IMAGE_SIZE, +#ifndef CONFIG_NVGPU_CTXSW_FW_ERROR_CODE_TESTING 0, &sizes->pm_ctxsw_image_size); +#else + 0, NULL); +#endif if (ret != 0) { nvgpu_err(g, "query pm ctx image size failed"); +#ifndef CONFIG_NVGPU_CTXSW_FW_ERROR_CODE_TESTING return ret; +#endif } #endif @@ -715,7 +727,8 @@ int gm20b_gr_falcon_ctrl_ctxsw(struct gk20a *g, u32 fecs_method, break; #endif -#ifdef CONFIG_NVGPU_DEBUGGER +#if defined(CONFIG_NVGPU_DEBUGGER) || \ +defined(CONFIG_NVGPU_CTXSW_FW_ERROR_CODE_TESTING) case NVGPU_GR_FALCON_METHOD_CTXSW_DISCOVER_PM_IMAGE_SIZE: op.method.addr = gr_fecs_method_push_adr_discover_pm_image_size_v(); diff --git a/drivers/gpu/nvgpu/include/nvgpu/gr/gr_falcon.h b/drivers/gpu/nvgpu/include/nvgpu/gr/gr_falcon.h index 356b8e48e..4f0f3cf8e 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/gr/gr_falcon.h +++ b/drivers/gpu/nvgpu/include/nvgpu/gr/gr_falcon.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-2020, 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"), @@ -52,7 +52,8 @@ struct nvgpu_gr_falcon; #define NVGPU_GR_FALCON_METHOD_CTXSW_DISCOVER_ZCULL_IMAGE_SIZE 5 #endif -#ifdef CONFIG_NVGPU_DEBUGGER +#if defined(CONFIG_NVGPU_DEBUGGER) || \ +defined(CONFIG_NVGPU_CTXSW_FW_ERROR_CODE_TESTING) #define NVGPU_GR_FALCON_METHOD_CTXSW_DISCOVER_PM_IMAGE_SIZE 6 #endif