From 6269abd251a73352813b429857d76ee626c6acc3 Mon Sep 17 00:00:00 2001 From: Tushar Nimkar Date: Fri, 26 Mar 2021 16:08:03 +0530 Subject: [PATCH] soc: qcom: qcom_stats: Create debugfs files for subsystems Currently qcom_stats driver creates subsystem files in debugfs only if qcom_smem_get() returns item pointer however this is true when subsystem allocates particular smem item. If the qcom_stats driver gets probed before all subsystems allocates smem then we will never see the same subsystem stats entry in debugfs. This change is to remove the dependency of other subsystems allocating item in smem and instead create debugfs files for all present subsystems. Change-Id: I199acbd7a6164c7c063e0f6ff0c880dcc9fd59e5 Signed-off-by: Tushar Nimkar Signed-off-by: Maulik Shah --- drivers/soc/qcom/qcom_stats.c | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/drivers/soc/qcom/qcom_stats.c b/drivers/soc/qcom/qcom_stats.c index 78661b62a215..146154e696cc 100644 --- a/drivers/soc/qcom/qcom_stats.c +++ b/drivers/soc/qcom/qcom_stats.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include @@ -266,21 +267,30 @@ static void qcom_create_soc_sleep_stat_files(struct dentry *root, void __iomem * } static void qcom_create_subsystem_stat_files(struct dentry *root, - const struct stats_config *config) + const struct stats_config *config, + struct device_node *node) { - const struct sleep_stats *stat; - int i; + int i, j, n_subsystems; + const char *name; if (!config->subsystem_stats_in_smem) return; - for (i = 0; i < ARRAY_SIZE(subsystems); i++) { - stat = qcom_smem_get(subsystems[i].pid, subsystems[i].smem_item, NULL); - if (IS_ERR(stat)) - continue; + n_subsystems = of_property_count_strings(node, "ss-name"); + if (n_subsystems < 0) + return; - debugfs_create_file(subsystems[i].name, 0400, root, (void *)&subsystems[i], - &qcom_subsystem_sleep_stats_fops); + for (i = 0; i < n_subsystems; i++) { + of_property_read_string_index(node, "ss-name", i, &name); + + for (j = 0; j < ARRAY_SIZE(subsystems); j++) { + if (!strcmp(subsystems[j].name, name)) { + debugfs_create_file(subsystems[j].name, 0400, root, + (void *)&subsystems[j], + &qcom_subsystem_sleep_stats_fops); + break; + } + } } } @@ -310,7 +320,7 @@ static int qcom_stats_probe(struct platform_device *pdev) root = debugfs_create_dir("qcom_stats", NULL); - qcom_create_subsystem_stat_files(root, config); + qcom_create_subsystem_stat_files(root, config, pdev->dev.of_node); qcom_create_soc_sleep_stat_files(root, reg, d, config); qcom_create_ddr_stat_files(root, reg, d, config);