Skip to contentSkip to conversation

platform/powernv: Avoid re-registration of imc debugfs directory

PATCH Superseded Anju T Sudhakar 1 participant 1 message Sep 3, 2019 PowerPC

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 platform/powernv: Avoid re-registration of imc debugfs directory

export_imc_mode_and_cmd() function which creates the debugfs interface for imc-mode and imc-command, is invoked when each nest pmu units is registered.
When the first nest pmu unit is registered, export_imc_mode_and_cmd() creates 'imc' directory under /debug/powerpc/. In the subsequent invocations debugfs_create_dir() function returns, since the directory already exists.

The recent commit <c33d442328f55> (debugfs: make error message a bit more verbose), throws a warning if we try to invoke debugfs_create_dir() with an already existing directory name.

Address this warning by searching for an existing 'imc' directory, and do not invoke debugfs_create_dir(), if the debugfs interface for imc already exists.

This patch is based on:
https://lists.ozlabs.org/pipermail/linuxppc-dev/2019-August/195898.html

---
Changes from v1 -> v2

* Minor changes in the commit message.
-------

 arch/powerpc/platforms/powernv/opal-imc.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
arch/powerpc/platforms/powernv/opal-imc.c +9 -4
index e04b20625cb9..fc2f0e60a44d 100644
@@ -55,14 +55,19 @@ static void export_imc_mode_and_cmd(struct device_node *node,
 	static u64 loc, *imc_mode_addr, *imc_cmd_addr;
 	char mode[16], cmd[16];
 	u32 cb_offset;
+	struct dentry *dir = NULL;
 	struct imc_mem_info *ptr = pmu_ptr->mem_info;
 
+
+	/* Return, if 'imc' interface already exists */
+	dir = debugfs_lookup("imc", powerpc_debugfs_root);
+	if (dir) {
+		dput(dir);
+		return;
+	}
 	imc_debugfs_parent = debugfs_create_dir("imc", powerpc_debugfs_root);
 
-	/*
-	 * Return here, either because 'imc' directory already exists,
-	 * Or failed to create a new one.
-	 */
+	/* Return here, if failed to create the directory */
 	if (!imc_debugfs_parent)
 		return;
 
Signature · 1 line
2.20.1