diff mbox series

[3/3] Create debugfs files for statistics

Message ID 20240701142851.1448515-4-luke.parkin@arm.com (mailing list archive)
State New
Headers show
Series Add Per-transport SCMI debug statistics | expand

Commit Message

Luke Parkin July 1, 2024, 2:28 p.m. UTC
Create debugfs files for the statistics in the scmi_debug_stats struct

Signed-off-by: Luke Parkin <luke.parkin@arm.com>
---
 drivers/firmware/arm_scmi/driver.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

Comments

Cristian Marussi July 1, 2024, 4:19 p.m. UTC | #1
On Mon, Jul 01, 2024 at 03:28:51PM +0100, Luke Parkin wrote:
> Create debugfs files for the statistics in the scmi_debug_stats struct
> 
> Signed-off-by: Luke Parkin <luke.parkin@arm.com>
> ---
>  drivers/firmware/arm_scmi/driver.c | 15 ++++++++++++++-
>  1 file changed, 14 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
> index f69dff699d48..509ea42d17bf 100644
> --- a/drivers/firmware/arm_scmi/driver.c
> +++ b/drivers/firmware/arm_scmi/driver.c
> @@ -2884,7 +2884,7 @@ static void scmi_debugfs_common_cleanup(void *d)
>  static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info)
>  {
>  	char top_dir[16];
> -	struct dentry *trans, *top_dentry;
> +	struct dentry *trans, *top_dentry, *stats;

stats are conditional...so...

>  	struct scmi_debug_info *dbg;
>  	const char *c_ptr = NULL;
>  
> @@ -2935,6 +2935,19 @@ static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info)
>  	debugfs_create_u32("rx_max_msg", 0400, trans,
>  			   (u32 *)&info->rx_minfo.max_msg);
>  
> +	if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS)) {
> +		stats = debugfs_create_dir("stats", trans);

you can put the above local *stats var instead so that it is NOT even
defined when STATS=n

> +		debugfs_create_atomic_t("response_ok", 0400, stats,
> +					&info->stats.response_ok);
> +		debugfs_create_atomic_t("dlyd_response_ok", 0400, stats,
> +					&info->stats.dlyd_response_ok);
> +		debugfs_create_atomic_t("sent_ok", 0400, stats,
> +					&info->stats.sent_ok);
> +		debugfs_create_atomic_t("sent_fail", 0400, stats,
> +					&info->stats.sent_fail);
> +		debugfs_create_atomic_t("xfers_response_timeout", 0400, stats,
> +					&info->stats.xfers_response_timeout);
> +	}

... moreover...this is not always enabled BUT certainly will be extend
sooner with more counters...so please split this setup out in a local helper
function.

Thanks,
Cristian
diff mbox series

Patch

diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index f69dff699d48..509ea42d17bf 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -2884,7 +2884,7 @@  static void scmi_debugfs_common_cleanup(void *d)
 static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info)
 {
 	char top_dir[16];
-	struct dentry *trans, *top_dentry;
+	struct dentry *trans, *top_dentry, *stats;
 	struct scmi_debug_info *dbg;
 	const char *c_ptr = NULL;
 
@@ -2935,6 +2935,19 @@  static struct scmi_debug_info *scmi_debugfs_common_setup(struct scmi_info *info)
 	debugfs_create_u32("rx_max_msg", 0400, trans,
 			   (u32 *)&info->rx_minfo.max_msg);
 
+	if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS)) {
+		stats = debugfs_create_dir("stats", trans);
+		debugfs_create_atomic_t("response_ok", 0400, stats,
+					&info->stats.response_ok);
+		debugfs_create_atomic_t("dlyd_response_ok", 0400, stats,
+					&info->stats.dlyd_response_ok);
+		debugfs_create_atomic_t("sent_ok", 0400, stats,
+					&info->stats.sent_ok);
+		debugfs_create_atomic_t("sent_fail", 0400, stats,
+					&info->stats.sent_fail);
+		debugfs_create_atomic_t("xfers_response_timeout", 0400, stats,
+					&info->stats.xfers_response_timeout);
+	}
 	dbg->top_dentry = top_dentry;
 
 	if (devm_add_action_or_reset(info->dev,