From 4ee71f9852212843ca4cfb6e65fc9e281c17b25c Mon Sep 17 00:00:00 2001 From: Sagar Kamble Date: Fri, 21 Apr 2023 01:18:49 +0000 Subject: [PATCH] gpu: nvgpu: guard ecc sysfs remove with NVGPU_DISABLE_ECC_STATS Following error is seen on unloading nvgpu on platforms with NVGPU_DISABLE_ECC_STATS set to true. [ 3712.384639] Internal error: Oops: 96000004 [#1] PREEMPT SMP [ 3712.388479] pc : sysfs_remove_file_ns+0x28/0x50 [ 3712.389119] lr : sysfs_remove_file_ns+0x28/0x50 ... [ 3712.400640] sysfs_remove_file_ns+0x28/0x50 [ 3712.401280] device_remove_file+0x34/0x50 [ 3712.414720] nvgpu_ecc_sysfs_remove+0x74/0xc0 [nvgpu] [ 3712.428800] nvgpu_ecc_remove_support+0x38/0x80 [nvgpu] [ 3712.442240] nvgpu_put+0xb8/0x160 [nvgpu] [ 3712.456319] nvgpu_pci_remove+0x168/0x250 [nvgpu] [ 3712.456959] pci_device_remove+0x4c/0x100 This is happening as ecc sysfs files are not created, however their removal is attempted. Add NVGPU_DISABLE_ECC_STATS check for ecc sysfs removal. Bug 3495440 Change-Id: I9726cf43a740c2b591ca39bdc572e8f4ff5684d3 Signed-off-by: Sagar Kamble Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2891876 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-cert Reviewed-by: svc-mobile-misra Reviewed-by: Rajesh Devaraj Reviewed-by: Divya Singhatwaria Reviewed-by: Martin Radev Reviewed-by: Seema Khowala GVS: Gerrit_Virtual_Submit --- drivers/gpu/nvgpu/common/ecc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/common/ecc.c b/drivers/gpu/nvgpu/common/ecc.c index ddb085b6d..4cb5e7e59 100644 --- a/drivers/gpu/nvgpu/common/ecc.c +++ b/drivers/gpu/nvgpu/common/ecc.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2018-2022, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018-2023, 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"), @@ -162,7 +162,9 @@ void nvgpu_ecc_remove_support(struct gk20a *g) } #ifdef CONFIG_NVGPU_SYSFS - nvgpu_ecc_sysfs_remove(g); + if (!nvgpu_is_enabled(g, NVGPU_DISABLE_ECC_STATS)) { + nvgpu_ecc_sysfs_remove(g); + } #endif nvgpu_ecc_free(g);