From 86be5112b29e58ca79a59711b2c83301435d8d97 Mon Sep 17 00:00:00 2001 From: Rajesh Devaraj Date: Tue, 8 Mar 2022 20:27:57 +0000 Subject: [PATCH] gpu: nvgpu: plug-in misc-ec interface for av+l This patch adds misc-ec interface into NvGPU driver to report GPU HW errors to Safety_Services, in AV+L. For this purpose, it introduces a new flag "CONFIG_NVGPU_ENABLE_MISC_EC". JIRA NVGPU-8094 Change-Id: Id8fff69487cad9ed4eb082a7d8615a1e15867ffa Signed-off-by: Rajesh Devaraj Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2678394 Reviewed-by: svcacv Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: Dinesh T Reviewed-by: Ankur Kishore --- drivers/gpu/nvgpu/Makefile.linux.configs | 8 ++++++ .../gpu/nvgpu/os/linux/cic/cic_report_err.c | 28 ++++++++++++++++--- 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/nvgpu/Makefile.linux.configs b/drivers/gpu/nvgpu/Makefile.linux.configs index 0dec525ee..b4a82dd2f 100644 --- a/drivers/gpu/nvgpu/Makefile.linux.configs +++ b/drivers/gpu/nvgpu/Makefile.linux.configs @@ -98,6 +98,11 @@ ifdef CONFIG_TEGRA_NVMAP_NEXT CONFIG_NVGPU_NVMAP_NEXT := y endif +CONFIG_NVGPU_ENABLE_MISC_EC := n +ifdef CONFIG_TEGRA_EPL +CONFIG_NVGPU_ENABLE_MISC_EC := y +endif + ifneq ($(findstring 5.10,$(NV_BUILD_KERNEL_OPTIONS)),) CONFIG_NVGPU_NVMAP_NEXT := y endif @@ -273,3 +278,6 @@ endif ifeq ($(CONFIG_NVGPU_IVM_BUILD),y) ccflags-y += -DCONFIG_NVGPU_IVM_BUILD endif +ifeq ($(CONFIG_NVGPU_ENABLE_MISC_EC),y) +ccflags-y += -DCONFIG_NVGPU_ENABLE_MISC_EC +endif diff --git a/drivers/gpu/nvgpu/os/linux/cic/cic_report_err.c b/drivers/gpu/nvgpu/os/linux/cic/cic_report_err.c index 46dc9fb5e..9e3cffdc0 100644 --- a/drivers/gpu/nvgpu/os/linux/cic/cic_report_err.c +++ b/drivers/gpu/nvgpu/os/linux/cic/cic_report_err.c @@ -17,13 +17,33 @@ #include #include +#ifdef CONFIG_NVGPU_ENABLE_MISC_EC +#include +#include "os/linux/os_linux.h" +#endif + struct gk20a; -int nvgpu_cic_mon_report_err_safety_services(struct gk20a *g, - u32 err_id) +int nvgpu_cic_mon_report_err_safety_services(struct gk20a *g, u32 err_id) { + int ret = 0U; + +#ifdef CONFIG_NVGPU_ENABLE_MISC_EC + struct device *dev = dev_from_gk20a(g); + /** - * ToDo: Add MISC_EC API to report error. + * MISC_EC_SW_ERR_CODE_0 register has been allocated for NvGPU + * to report GPU HW errors to Safety_Services via MISC_EC interface. */ - return 0; + ret = epl_report_misc_ec_error(dev, MISC_EC_SW_ERR_CODE_0, err_id); + if (ret != 0) { + nvgpu_err(g, "Error reporting to Safety_Services failed"); + nvgpu_err(g, "ret (%d). err (0x%x)", ret, err_id); + } else { + nvgpu_err(g, "Reported err (0x%x) to Safety_Services", + err_id); + } +#endif + + return ret; }