From: Hans Zhang <18255117159@163.com>
To: lpieralisi@kernel.org
Cc: manivannan.sadhasivam@linaro.org, thierry.reding@gmail.com,
kw@linux.com, robh@kernel.org, bhelgaas@google.com,
jonathanh@nvidia.com, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org,
Hans Zhang <18255117159@163.com>
Subject: [PATCH] pci: tegra194: Fix debugfs cleanup for !CONFIG_PCIEASPM
Date: Sat, 5 Apr 2025 22:54:59 +0800 [thread overview]
Message-ID: <20250405145459.26800-1-18255117159@163.com> (raw)
When CONFIG_PCIEASPM is disabled, debugfs entries are not created, but
tegra_pcie_dw_remove() and tegra_pcie_dw_shutdown() unconditionally call
debugfs_remove_recursive(), leading to potential NULL pointer operations.
Introduce deinit_debugfs() to wrap debugfs_remove_recursive(), which is
stubbed for !CONFIG_PCIEASPM. Use this function during removal/shutdown to
ensure debugfs cleanup only occurs when entries were initialized.
This prevents kernel warnings and instability when ASPM support is
disabled.
Signed-off-by: Hans Zhang <18255117159@163.com>
---
drivers/pci/controller/dwc/pcie-tegra194.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/pci/controller/dwc/pcie-tegra194.c b/drivers/pci/controller/dwc/pcie-tegra194.c
index 5103995cd6c7..d762e733c2d8 100644
--- a/drivers/pci/controller/dwc/pcie-tegra194.c
+++ b/drivers/pci/controller/dwc/pcie-tegra194.c
@@ -716,11 +716,20 @@ static void init_debugfs(struct tegra_pcie_dw *pcie)
debugfs_create_devm_seqfile(pcie->dev, "aspm_state_cnt", pcie->debugfs,
aspm_state_cnt);
}
+
+static void deinit_debugfs(struct tegra_pcie_dw *pcie)
+{
+ if (!pcie->debugfs)
+ return;
+
+ debugfs_remove_recursive(pcie->debugfs);
+}
#else
static inline void disable_aspm_l12(struct tegra_pcie_dw *pcie) { return; }
static inline void disable_aspm_l11(struct tegra_pcie_dw *pcie) { return; }
static inline void init_host_aspm(struct tegra_pcie_dw *pcie) { return; }
static inline void init_debugfs(struct tegra_pcie_dw *pcie) { return; }
+static inline void deinit_debugfs(struct tegra_pcie_dw *pcie) { return; }
#endif
static void tegra_pcie_enable_system_interrupts(struct dw_pcie_rp *pp)
@@ -2289,7 +2298,7 @@ static void tegra_pcie_dw_remove(struct platform_device *pdev)
if (!pcie->link_state)
return;
- debugfs_remove_recursive(pcie->debugfs);
+ deinit_debugfs(pcie->debugfs);
tegra_pcie_deinit_controller(pcie);
pm_runtime_put_sync(pcie->dev);
} else {
@@ -2408,7 +2417,7 @@ static void tegra_pcie_dw_shutdown(struct platform_device *pdev)
if (!pcie->link_state)
return;
- debugfs_remove_recursive(pcie->debugfs);
+ deinit_debugfs(pcie->debugfs);
tegra_pcie_downstream_dev_to_D0(pcie);
disable_irq(pcie->pci.pp.irq);
base-commit: a8662bcd2ff152bfbc751cab20f33053d74d0963
--
2.25.1
next reply other threads:[~2025-04-05 14:55 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-05 14:54 Hans Zhang [this message]
2025-04-05 15:28 ` [PATCH] pci: tegra194: Fix debugfs cleanup for !CONFIG_PCIEASPM Bjorn Helgaas
2025-04-05 15:49 ` Hans Zhang
2025-04-05 16:17 ` Christophe JAILLET
2025-04-05 16:35 ` Hans Zhang
2025-04-05 16:47 ` Hans Zhang
2025-04-05 17:04 ` Christophe JAILLET
2025-04-05 17:10 ` Hans Zhang
2025-04-05 16:14 ` Christophe JAILLET
2025-04-05 16:41 ` Hans Zhang
2025-04-06 0:48 ` kernel test robot
2025-04-06 2:10 ` kernel test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250405145459.26800-1-18255117159@163.com \
--to=18255117159@163.com \
--cc=bhelgaas@google.com \
--cc=jonathanh@nvidia.com \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
--cc=robh@kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox