mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Luke Parkin <luke.parkin@arm.com>
To: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org
Cc: sudeep.holla@arm.com, cristian.marussi@arm.com,
	Luke Parkin <luke.parkin@arm.com>
Subject: [PATCH v4 2/5] firmware: arm_scmi: Add support for tracking metrics
Date: Tue, 30 Jul 2024 10:33:39 +0100	[thread overview]
Message-ID: <20240730093342.3558162-3-luke.parkin@arm.com> (raw)
In-Reply-To: <20240730093342.3558162-1-luke.parkin@arm.com>

Add a new optional config option for tracking, configurable
	at build.
Add methods for counting key metrics

Signed-off-by: Luke Parkin <luke.parkin@arm.com>
---
v3->v4
Rename to counters rather than statistic tracking
Move enum tracker to common.h
Move stats array into debug
v2->v3
Switch to an enum & array method of storing statistics
v1->v2
Config option now depends on DEBUG_FS
Add scmi_log_stats rather than if(IS_ENABLED)
Move location of scmi_debug_stats in the scmi_info struct
---
 drivers/firmware/arm_scmi/Kconfig  | 11 +++++++++++
 drivers/firmware/arm_scmi/common.h | 13 +++++++++++++
 drivers/firmware/arm_scmi/driver.c |  2 ++
 3 files changed, 26 insertions(+)

diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/Kconfig
index aa5842be19b2..b3ccd565b986 100644
--- a/drivers/firmware/arm_scmi/Kconfig
+++ b/drivers/firmware/arm_scmi/Kconfig
@@ -55,6 +55,17 @@ config ARM_SCMI_RAW_MODE_SUPPORT_COEX
 	  operate normally, thing which could make an SCMI test suite using the
 	  SCMI Raw mode support unreliable. If unsure, say N.
 
+config ARM_SCMI_DEBUG_COUNTERS
+	bool "Enable SCMI debug tracking"
+	select ARM_SCMI_NEED_DEBUGFS
+	depends on DEBUG_FS
+	help
+	  Enables debug tracking for the SCMI subsystem.
+
+	  Enable this option to create a new debugfs directory which contains
+	  several useful debug counters. This can be helpful for debugging and
+	  SCMI monitoring. If unsure, say N.
+
 config ARM_SCMI_HAVE_TRANSPORT
 	bool
 	help
diff --git a/drivers/firmware/arm_scmi/common.h b/drivers/firmware/arm_scmi/common.h
index b5ac25dbc1ca..8f80bf0ddddd 100644
--- a/drivers/firmware/arm_scmi/common.h
+++ b/drivers/firmware/arm_scmi/common.h
@@ -301,6 +301,19 @@ extern const struct scmi_desc scmi_optee_desc;
 
 void scmi_rx_callback(struct scmi_chan_info *cinfo, u32 msg_hdr, void *priv);
 
+enum debug_counters {
+	SCMI_DEBUG_COUNTERS_LAST
+};
+
+#ifdef CONFIG_ARM_SCMI_DEBUG_COUNTERS
+static inline void scmi_inc_count(atomic_t *arr, int stat)
+{
+	atomic_inc(&arr[stat]);
+}
+#else
+static inline void scmi_inc_count(atomic_t *arr, int stat) {}
+#endif
+
 enum scmi_bad_msg {
 	MSG_UNEXPECTED = -1,
 	MSG_INVALID = -2,
diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c
index 56a93d20bf23..958b2ac92050 100644
--- a/drivers/firmware/arm_scmi/driver.c
+++ b/drivers/firmware/arm_scmi/driver.c
@@ -117,12 +117,14 @@ struct scmi_protocol_instance {
  * @name: Name of this SCMI instance
  * @type: Type of this SCMI instance
  * @is_atomic: Flag to state if the transport of this instance is atomic
+ * @counters: An array of atomic_c's used for tracking statistics (if enabled)
  */
 struct scmi_debug_info {
 	struct dentry *top_dentry;
 	const char *name;
 	const char *type;
 	bool is_atomic;
+	atomic_t counters[SCMI_DEBUG_COUNTERS_LAST];
 };
 
 /**
-- 
2.34.1


  parent reply	other threads:[~2024-07-30  9:33 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-30  9:33 [PATCH v4 0/5] Add Per-transport SCMI debug statistics Luke Parkin
2024-07-30  9:33 ` [PATCH v4 1/5] firmware: arm_scmi: Remove superfluous handle_to_scmi_info Luke Parkin
2024-07-30  9:33 ` Luke Parkin [this message]
2024-07-30 16:21   ` [PATCH v4 2/5] firmware: arm_scmi: Add support for tracking metrics Cristian Marussi
2024-07-30  9:33 ` [PATCH v4 3/5] firmware: arm_scmi: Track basic SCMI metrics Luke Parkin
2024-07-30 16:22   ` Cristian Marussi
2024-07-30  9:33 ` [PATCH v4 4/5] firmware: arm_scmi: Create debugfs files for counts Luke Parkin
2024-07-30 16:23   ` Cristian Marussi
2024-07-31 12:11   ` Sudeep Holla
2024-07-31 12:32     ` Cristian Marussi
2024-07-31 12:40       ` Sudeep Holla
2024-07-31 12:54         ` Cristian Marussi
2024-07-31 13:00           ` Luke Parkin
2024-07-30  9:33 ` [PATCH v4 5/5] firmware: arm_scmi: Reset counters Luke Parkin
2024-07-30 16:37   ` Cristian Marussi
2024-07-30 16:41 ` [PATCH v4 0/5] Add Per-transport SCMI debug statistics Cristian Marussi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240730093342.3558162-3-luke.parkin@arm.com \
    --to=luke.parkin@arm.com \
    --cc=arm-scmi@vger.kernel.org \
    --cc=cristian.marussi@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sudeep.holla@arm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®