From 3dfd89c75e067e852d829e88b57bf17f8e1bb239 Mon Sep 17 00:00:00 2001 From: Mohit Ingale Date: Mon, 29 Jul 2024 15:52:41 -0700 Subject: [PATCH] vi: Don't create debugfs node if base addr is NULL A crash is observed when trying to access ch1 debugfs register in vi0 and vi1 folder. This is because the base reg address is not defined in DT. This seems like an old legacy code which is ported over. The registers accessed by this debugfs node are not longer directly accessible using CCPLEX. While we wait on confirmation for this, adding this check to not create debugfs node, if register base address is not defined. Bug 4626339 Change-Id: Ife714fa7e989bcaf187956920d757870e5fd9701 Signed-off-by: Mohit Ingale Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3184450 (cherry picked from commit 1fb6c087c924a540b151183cb5be13311f2c4af1) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3185971 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/video/tegra/host/vi/vi5.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/video/tegra/host/vi/vi5.c b/drivers/video/tegra/host/vi/vi5.c index 92143efe..638c1992 100644 --- a/drivers/video/tegra/host/vi/vi5.c +++ b/drivers/video/tegra/host/vi/vi5.c @@ -458,13 +458,18 @@ static int vi5_init_debugfs(struct host_vi5 *vi5) { .name = "channel_count", 0x80 }, }; struct nvhost_device_data *pdata = platform_get_drvdata(vi5->pdev); - struct dentry *dir = pdata->debugfs; - struct vi5_debug *debug = &vi5->debug; - debug->ch0.base = pdata->aperture[0]; - debug->ch0.regs = vi5_ch_regs; - debug->ch0.nregs = ARRAY_SIZE(vi5_ch_regs); - debugfs_create_regset32("ch0", S_IRUGO, dir, &debug->ch0); + if (pdata->aperture[0]) { + struct dentry *dir = pdata->debugfs; + struct vi5_debug *debug = &vi5->debug; + + debug->ch0.base = pdata->aperture[0]; + debug->ch0.regs = vi5_ch_regs; + debug->ch0.nregs = ARRAY_SIZE(vi5_ch_regs); + debugfs_create_regset32("ch0", 0444, dir, &debug->ch0); + } else { + dev_info(&vi5->pdev->dev, "Unable to create debugfs entry\n"); + } return 0; }