Skip to contentSkip to conversation

PCI: tegra194: Fix debugfs directory creation when CONFIG_PCIEASPM is disabled

PATCH Applied Hans Zhang 3 participants 5 messages Apr 7, 2025 – May 2, 2025

Subsystems (3)
lore
Share & tools
lore

Hans Zhang

author
#0 lore raw

PATCH v3 1/1 PCI: tegra194: Fix debugfs directory creation when CONFIG_PCIEASPM is disabled

Previously, the debugfs directory was unconditionally created in tegra_pcie_config_rp() regardless of the CONFIG_PCIEASPM setting. This led to unnecessary directory creation when ASPM support was disabled.

Move the debugfs directory creation into init_debugfs() which is conditionally compiled based on CONFIG_PCIEASPM. This ensures:
- The directory is only created when ASPM-related debugfs entries are needed.
- Proper error handling for directory creation failures.
- Avoids cluttering debugfs with empty directories when ASPM is disabled.

---
Changes since v2:
https://lore.kernel.org/linux-pci/[email protected]/

- Maintainer recommends ignoring the devm_kasprintf return value. The module should still work correctly. So just a return;

Changes since v1:
https://lore.kernel.org/linux-pci/[email protected]/

- The first version was committed incorrectly because the judgment parameter in "debugfs_remove_recursive" was not noticed.

---
 drivers/pci/controller/dwc/pcie-tegra194.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +10 -9
index 5103995cd6c7..bc419688527a 100644
@@ -713,7 +713,16 @@ static void init_host_aspm(struct tegra_pcie_dw *pcie)
 
 static void init_debugfs(struct tegra_pcie_dw *pcie)
 {
-	debugfs_create_devm_seqfile(pcie->dev, "aspm_state_cnt", pcie->debugfs,
+	struct device *dev = pcie->dev;
+	char *name;
+
+	name = devm_kasprintf(dev, GFP_KERNEL, "%pOFP", dev->of_node);
+	if (!name)
+		return;
+
+	pcie->debugfs = debugfs_create_dir(name, NULL);
+
+	debugfs_create_devm_seqfile(dev, "aspm_state_cnt", pcie->debugfs,
 				    aspm_state_cnt);
 }
 #else
@@ -1634,7 +1643,6 @@ static void tegra_pcie_deinit_controller(struct tegra_pcie_dw *pcie)
 static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)
 {
 	struct device *dev = pcie->dev;
-	char *name;
 	int ret;
 
 	pm_runtime_enable(dev);
@@ -1664,13 +1672,6 @@ static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)
 		goto fail_host_init;
 	}
 
-	name = devm_kasprintf(dev, GFP_KERNEL, "%pOFP", dev->of_node);
-	if (!name) {
-		ret = -ENOMEM;
-		goto fail_host_init;
-	}
-
-	pcie->debugfs = debugfs_create_dir(name, NULL);
 	init_debugfs(pcie);
 
 	return ret;

base-commit: a8662bcd2ff152bfbc751cab20f33053d74d0963

Signature · 1 line
2.25.1
Reviewed-by on v3 1/1
#1 lore raw

Hi,

Nitpick: PATCH is missing within the [] in the subject.

Le 07/04/2025 à 14:43, Hans Zhang a écrit :

Quoted 11 lines

Previously, the debugfs directory was unconditionally created in tegra_pcie_config_rp() regardless of the CONFIG_PCIEASPM setting. This led to unnecessary directory creation when ASPM support was disabled.

Move the debugfs directory creation into init_debugfs() which is conditionally compiled based on CONFIG_PCIEASPM. This ensures:
- The directory is only created when ASPM-related debugfs entries are needed.
- Proper error handling for directory creation failures.
- Avoids cluttering debugfs with empty directories when ASPM is disabled.

Quoted 7 lines

---
Changes since v2:
https://lore.kernel.org/linux-pci/[email protected]/

- Maintainer recommends ignoring the devm_kasprintf return value. The module should still work correctly. So just a return;

Note, that I'm not a maintainer ;-)

For what it worth:

CJ

Quoted 56 lines

Changes since v1:
https://lore.kernel.org/linux-pci/[email protected]/

- The first version was committed incorrectly because the judgment parameter in "debugfs_remove_recursive" was not noticed.

---
  drivers/pci/controller/dwc/pcie-tegra194.c | 19 ++++++++++---------
  1 file changed, 10 insertions(+), 9 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +10 -9
index 5103995cd6c7..bc419688527a 100644
@@ -713,7 +713,16 @@ static void init_host_aspm(struct tegra_pcie_dw *pcie)
 
  static void init_debugfs(struct tegra_pcie_dw *pcie)
  {
-	debugfs_create_devm_seqfile(pcie->dev, "aspm_state_cnt", pcie->debugfs,
+	struct device *dev = pcie->dev;
+	char *name;
+
+	name = devm_kasprintf(dev, GFP_KERNEL, "%pOFP", dev->of_node);
+	if (!name)
+		return;
+
+	pcie->debugfs = debugfs_create_dir(name, NULL);
+
+	debugfs_create_devm_seqfile(dev, "aspm_state_cnt", pcie->debugfs,
  				    aspm_state_cnt);
  }
  #else
@@ -1634,7 +1643,6 @@ static void tegra_pcie_deinit_controller(struct tegra_pcie_dw *pcie)
  static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)
  {
  	struct device *dev = pcie->dev;
-	char *name;
  	int ret;
 
  	pm_runtime_enable(dev);
@@ -1664,13 +1672,6 @@ static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)
  		goto fail_host_init;
  	}
 
-	name = devm_kasprintf(dev, GFP_KERNEL, "%pOFP", dev->of_node);
-	if (!name) {
-		ret = -ENOMEM;
-		goto fail_host_init;
-	}
-
-	pcie->debugfs = debugfs_create_dir(name, NULL);
  	init_debugfs(pcie);
 
  	return ret;

base-commit: a8662bcd2ff152bfbc751cab20f33053d74d0963

author
#2 lore raw
Quoted 4 lines · Christophe JAILLET

Hi,

Nitpick: PATCH is missing within the [] in the subject.

Hi Christophe,

I will pay attention in the future.

Quoted 18 lines

Le 07/04/2025 à 14:43, Hans Zhang a écrit :

Quoted 16 lines

Previously, the debugfs directory was unconditionally created in tegra_pcie_config_rp() regardless of the CONFIG_PCIEASPM setting. This led to unnecessary directory creation when ASPM support was disabled.

Move the debugfs directory creation into init_debugfs() which is conditionally compiled based on CONFIG_PCIEASPM. This ensures:
- The directory is only created when ASPM-related debugfs entries are needed.
- Proper error handling for directory creation failures.
- Avoids cluttering debugfs with empty directories when ASPM is disabled.

---
Changes since v2:
https://lore.kernel.org/linux-pci/[email protected]/

Quoted 5 lines
Quoted 2 lines

- Maintainer recommends ignoring the devm_kasprintf return value. The module should still work correctly. So just a return;

Note, that I'm not a maintainer ;-)

Maybe I made a mistake. ;-)

No.72 Christophe JAILLET <christophe ! jaillet () wanadoo ! fr> 2104(0.17%) @Hobbyists @French

Best regards,
Hans

Quoted 62 lines

For what it worth:

CJ

Quoted 56 lines

Changes since v1:
https://lore.kernel.org/linux-pci/[email protected]/

- The first version was committed incorrectly because the judgment parameter in "debugfs_remove_recursive" was not noticed.
---
  drivers/pci/controller/dwc/pcie-tegra194.c | 19 ++++++++++---------

  1 file changed, 10 insertions(+), 9 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +10 -1
index 5103995cd6c7..bc419688527a 100644
@@ -713,7 +713,16 @@ static void init_host_aspm(struct tegra_pcie_dw 
 *pcie)
   static void init_debugfs(struct tegra_pcie_dw *pcie)
   {
-    debugfs_create_devm_seqfile(pcie->dev, "aspm_state_cnt", 
 pcie->debugfs,
+    struct device *dev = pcie->dev;
+    char *name;
+
+    name = devm_kasprintf(dev, GFP_KERNEL, "%pOFP", dev->of_node);
+    if (!name)
+        return;
+
+    pcie->debugfs = debugfs_create_dir(name, NULL);
+
+    debugfs_create_devm_seqfile(dev, "aspm_state_cnt", pcie->debugfs,
                       aspm_state_cnt);
   }

  #else

drivers/pci/controller/dwc/pcie-tegra194.c +0 -8
@@ -1634,7 +1643,6 @@ static void tegra_pcie_deinit_controller(struct 
 tegra_pcie_dw *pcie)
   static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)
   {
       struct device *dev = pcie->dev;
-    char *name;
       int ret;
       pm_runtime_enable(dev);
@@ -1664,13 +1672,6 @@ static int tegra_pcie_config_rp(struct 
 tegra_pcie_dw *pcie)
           goto fail_host_init;
       }
-    name = devm_kasprintf(dev, GFP_KERNEL, "%pOFP", dev->of_node);
-    if (!name) {
-        ret = -ENOMEM;
-        goto fail_host_init;
-    }
-
-    pcie->debugfs = debugfs_create_dir(name, NULL);
       init_debugfs(pcie);
       return ret;
 

base-commit: a8662bcd2ff152bfbc751cab20f33053d74d0963

author
#3 lore raw
In reply to Christophe JAILLET
Quoted 88 lines · Christophe JAILLET

Hi,

Nitpick: PATCH is missing within the [] in the subject.

Le 07/04/2025 à 14:43, Hans Zhang a écrit :

Quoted 11 lines

Previously, the debugfs directory was unconditionally created in tegra_pcie_config_rp() regardless of the CONFIG_PCIEASPM setting. This led to unnecessary directory creation when ASPM support was disabled.

Move the debugfs directory creation into init_debugfs() which is conditionally compiled based on CONFIG_PCIEASPM. This ensures:
- The directory is only created when ASPM-related debugfs entries are needed.
- Proper error handling for directory creation failures.
- Avoids cluttering debugfs with empty directories when ASPM is disabled.

Quoted 7 lines

---
Changes since v2:
https://lore.kernel.org/linux-pci/[email protected]/

- Maintainer recommends ignoring the devm_kasprintf return value. The module should still work correctly. So just a return;

Note, that I'm not a maintainer ;-)

For what it worth:

CJ

Quoted 55 lines

Changes since v1:
https://lore.kernel.org/linux-pci/[email protected]/

- The first version was committed incorrectly because the judgment parameter in "debugfs_remove_recursive" was not noticed.
---
  drivers/pci/controller/dwc/pcie-tegra194.c | 19 ++++++++++---------

  1 file changed, 10 insertions(+), 9 deletions(-)
drivers/pci/controller/dwc/pcie-tegra194.c +10 -1
index 5103995cd6c7..bc419688527a 100644
@@ -713,7 +713,16 @@ static void init_host_aspm(struct tegra_pcie_dw 
 *pcie)
   static void init_debugfs(struct tegra_pcie_dw *pcie)
   {
-    debugfs_create_devm_seqfile(pcie->dev, "aspm_state_cnt", 
 pcie->debugfs,
+    struct device *dev = pcie->dev;
+    char *name;
+
+    name = devm_kasprintf(dev, GFP_KERNEL, "%pOFP", dev->of_node);
+    if (!name)
+        return;
+
+    pcie->debugfs = debugfs_create_dir(name, NULL);
+
+    debugfs_create_devm_seqfile(dev, "aspm_state_cnt", pcie->debugfs,
                       aspm_state_cnt);
   }

  #else

drivers/pci/controller/dwc/pcie-tegra194.c +0 -8
@@ -1634,7 +1643,6 @@ static void tegra_pcie_deinit_controller(struct 
 tegra_pcie_dw *pcie)
   static int tegra_pcie_config_rp(struct tegra_pcie_dw *pcie)
   {
       struct device *dev = pcie->dev;
-    char *name;
       int ret;
       pm_runtime_enable(dev);
@@ -1664,13 +1672,6 @@ static int tegra_pcie_config_rp(struct 
 tegra_pcie_dw *pcie)
           goto fail_host_init;
       }
-    name = devm_kasprintf(dev, GFP_KERNEL, "%pOFP", dev->of_node);
-    if (!name) {
-        ret = -ENOMEM;
-        goto fail_host_init;
-    }
-
-    pcie->debugfs = debugfs_create_dir(name, NULL);
       init_debugfs(pcie);
       return ret;
 
Quoted 1 line
Quoted 1 line

base-commit: a8662bcd2ff152bfbc751cab20f33053d74d0963

Dear all,

I see that the status of this patch is Rejected and I want to know why.

Best regards,
Hans

#4 lore raw
In reply to Hans Zhang
Quoted 4 lines · Hans Zhang

Previously, the debugfs directory was unconditionally created in tegra_pcie_config_rp() regardless of the CONFIG_PCIEASPM setting. This led to unnecessary directory creation when ASPM support was disabled.

Quoted 8 lines

Move the debugfs directory creation into init_debugfs() which is conditionally compiled based on CONFIG_PCIEASPM. This ensures:
- The directory is only created when ASPM-related debugfs entries are needed.
- Proper error handling for directory creation failures.
- Avoids cluttering debugfs with empty directories when ASPM is disabled.

[...]

Applied, thanks!

[1/1] PCI: tegra194: Fix debugfs directory creation when CONFIG_PCIEASPM is disabled

      commit: ed798ff1c52f6fe232ce2e24e68fb63f5470ab97

Best regards,

Signature · 1 line
Manivannan Sadhasivam <[email protected]>