Skip to contentSkip to conversation

memory: tegra20: Add debug statistics

PATCH Applied Dmitry Osipenko 2 participants 2 messages Mar 19, 2021 – Mar 21, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 memory: tegra20: Add debug statistics

Add debug statistics collection support. The statistics is available via debugfs in '/sys/kernel/debug/mc/stats', it shows percent of memory controller utilization for each memory client. This information is intended to help with debugging of memory performance issues, it already was proven to be useful by helping to improve memory bandwidth management of the display driver.

---

Changelog:

v2: - Removed handling of debugfs creation errors.

- Added more consts to the code.

- Reduced scope of local variables.

- Switched to use debugfs_create_devm_seqfile() helper.

- Corrected error message.

 drivers/memory/tegra/mc.c      |   9 +
 drivers/memory/tegra/mc.h      |   4 +-
 drivers/memory/tegra/tegra20.c | 326 +++++++++++++++++++++++++++++++++
 include/soc/tegra/mc.h         |   7 +
 4 files changed, 344 insertions(+), 2 deletions(-)
drivers/memory/tegra/mc.c +9 -0
index a21163ccadc4..e58c3e5baea0 100644
@@ -827,6 +827,15 @@ static int tegra_mc_probe(struct platform_device *pdev)
 		return err;
 	}
 
+	mc->debugfs.root = debugfs_create_dir("mc", NULL);
+
+	if (mc->soc->init) {
+		err = mc->soc->init(mc);
+		if (err < 0)
+			dev_err(&pdev->dev, "failed to initialize SoC driver: %d\n",
+				err);
+	}
+
 	err = tegra_mc_reset_setup(mc);
 	if (err < 0)
 		dev_err(&pdev->dev, "failed to register reset controller: %d\n",
drivers/memory/tegra/mc.h +2 -2
index 33e40d600592..1ee34f0da4f7 100644
@@ -92,12 +92,12 @@ icc_provider_to_tegra_mc(struct icc_provider *provider)
 	return container_of(provider, struct tegra_mc, provider);
 }
 
-static inline u32 mc_readl(struct tegra_mc *mc, unsigned long offset)
+static inline u32 mc_readl(const struct tegra_mc *mc, unsigned long offset)
 {
 	return readl_relaxed(mc->regs + offset);
 }
 
-static inline void mc_writel(struct tegra_mc *mc, u32 value,
+static inline void mc_writel(const struct tegra_mc *mc, u32 value,
 			     unsigned long offset)
 {
 	writel_relaxed(value, mc->regs + offset);
drivers/memory/tegra/tegra20.c +326 -0

348 lines not on this page · raw message

include/soc/tegra/mc.h +7 -0
index d731407e23bb..d2fbe6a8b25b 100644
@@ -7,6 +7,7 @@
 #define __SOC_TEGRA_MC_H__
 
 #include <linux/bits.h>
+#include <linux/debugfs.h>
 #include <linux/err.h>
 #include <linux/interconnect-provider.h>
 #include <linux/reset-controller.h>
@@ -175,6 +176,8 @@ struct tegra_mc_soc {
 	unsigned int num_resets;
 
 	const struct tegra_mc_icc_ops *icc_ops;
+
+	int (*init)(struct tegra_mc *mc);
 };
 
 struct tegra_mc {
@@ -196,6 +199,10 @@ struct tegra_mc {
 	struct icc_provider provider;
 
 	spinlock_t lock;
+
+	struct {
+		struct dentry *root;
+	} debugfs;
 };
 
 int tegra_mc_write_emem_configuration(struct tegra_mc *mc, unsigned long rate);
Signature · 1 line
2.30.2
#1 lore raw
Quoted 6 lines · Dmitry Osipenko

Add debug statistics collection support. The statistics is available via debugfs in '/sys/kernel/debug/mc/stats', it shows percent of memory controller utilization for each memory client. This information is intended to help with debugging of memory performance issues, it already was proven to be useful by helping to improve memory bandwidth management of the display driver.

Applied, thanks!

[1/1] memory: tegra20: Add debug statistics

      commit: 1ca59ca0afde17b75adc519858ccc30375cfad1d

Best regards,

Signature · 1 line
Krzysztof Kozlowski <[email protected]>