gpu: nvgpu: Fix crash when reading CE_APP debugfs

The CE_APP debugfs nodes are created when the NVGPU driver is probed,
however, the 'ce_app' structure which contains the variables exposed
via the debugfs, is not allocated until nvgpu_finalize_poweron() is
called. Therefore, if the user attempts to access the CE_APP debugfs
nodes before the NVGPU has been powered on, for example, right after
Linux has booted, then this results in a NULL pointer dereference crash.
Fix this by moving the creation of the CE_APP debugfs nodes to
nvgpu_finalize_poweron_linux() which is called after
nvgpu_finalize_poweron().

Bug 200747304

Change-Id: Icd28952112f86887a1d6b6f8beb382f5189461a9
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2572106
(cherry picked from commit 35a0c18d93e97265611c3bbfae41b39d9cd183e3)
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2587367
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: svc_kernel_abi <svc_kernel_abi@nvidia.com>
Reviewed-by: Alex Waterman <alexw@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
GVS: Gerrit_Virtual_Submit
This commit is contained in:
Jon Hunter
2021-08-06 11:30:54 -07:00
committed by mobile promotions
parent d1b34e50e2
commit 8a4b72a4aa
2 changed files with 6 additions and 3 deletions

View File

@@ -15,7 +15,6 @@
*/
#include "debug_cde.h"
#include "debug_ce.h"
#include "debug_fifo.h"
#include "debug_gr.h"
#include "debug_allocator.h"
@@ -520,8 +519,6 @@ void gk20a_debug_init(struct gk20a *g, const char *debugfs_symlink)
#endif
nvgpu_ltc_debugfs_init(g);
#ifdef CONFIG_NVGPU_DGPU
if (!g->is_virtual)
nvgpu_ce_debugfs_init(g);
if (g->pci_vendor_id) {
nvgpu_xve_debugfs_init(g);
nvgpu_bios_debugfs_init(g);

View File

@@ -82,6 +82,7 @@
#include "fecs_trace_linux.h"
#include "driver_common.h"
#include "channel.h"
#include "debug_ce.h"
#include "debug_pmgr.h"
#include "dmabuf_priv.h"
@@ -307,6 +308,11 @@ int nvgpu_finalize_poweron_linux(struct nvgpu_os_linux *l)
return err;
}
#ifdef CONFIG_NVGPU_DGPU
if (!g->is_virtual)
nvgpu_ce_debugfs_init(g);
#endif
l->init_done = true;
return 0;