From nobody Sun Feb 8 21:36:07 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2D1D3167272; Mon, 1 Jul 2024 14:29:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719844169; cv=none; b=lbvPkpeDsoMVWQ2x3ZGCpElWKZmBWTfE1pP/DgGHpWZkakU9g2GWaYAPWbROLdQazYn+/1ILFNfpAsPNbCyQowM5ZUo3XkNx9nmdA//ZI49dIx9hRq7SqpJdoUq7SyaaL/DdiPCBMkCb1Uxbkdj/5i8Z3ao9Pa9V4EiX37xdSpU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719844169; c=relaxed/simple; bh=EKkJ5H6HYETh6az5TgIYrk5kx0HN2Nm66NAhMMcNQrw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=hGqNYYM2m9sllmzq6m0cQvMTTARMhjZAE4xGYqNnMFzuEdiqvm8nbCKist+999B+9r6qDEK5391GBtrwxBcdXed62krr5QJl5pPyYxB8zZJafS+XmpgokY7mMOGlwo1mq3H/XngHGBUu0SSaqV8rMfD1PL45q3xVCBD00fHwGX0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5795C339; Mon, 1 Jul 2024 07:29:51 -0700 (PDT) Received: from thinkcentre-m93p.cambridge.arm.com (thinkcentre-m93p.cambridge.arm.com [10.1.197.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8160E3F762; Mon, 1 Jul 2024 07:29:25 -0700 (PDT) From: Luke Parkin 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 Subject: [PATCH 1/3] Add Kconfig option for scmi debug statistics Date: Mon, 1 Jul 2024 15:28:49 +0100 Message-Id: <20240701142851.1448515-2-luke.parkin@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240701142851.1448515-1-luke.parkin@arm.com> References: <20240701142851.1448515-1-luke.parkin@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add a new config option for statistic tracking in SCMI subsystem. Signed-off-by: Luke Parkin --- drivers/firmware/arm_scmi/Kconfig | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/firmware/arm_scmi/Kconfig b/drivers/firmware/arm_scmi/= Kconfig index aa5842be19b2..fac50fd0be72 100644 --- a/drivers/firmware/arm_scmi/Kconfig +++ b/drivers/firmware/arm_scmi/Kconfig @@ -55,6 +55,16 @@ 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. =20 +config ARM_SCMI_DEBUG_STATISTICS + bool "Enable SCMI Raw mode statistic tracking" + select ARM_SCMI_NEED_DEBUGFS + help + Enables statistic tracking for the SCMI subsystem. + + Enable this option to create a new debugfs directory which contains + several useful statistics on various SCMI features. This can be useful + for debugging and SCMI monitoring. If unsure, say N. + config ARM_SCMI_HAVE_TRANSPORT bool help --=20 2.34.1 From nobody Sun Feb 8 21:36:07 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 91B8A16848A; Mon, 1 Jul 2024 14:29:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719844174; cv=none; b=HIQEjY8ayyFowbr1wRklFouMIJMIyGBOpdPnl8GLNGBBoegLmJI5eXtkpY9QuNpBi2SpCOdJFEBgCk/82s7DKU+Zsa/FPvway+LA+DEjunbJlw7VpM/xptjYSlSjAd6kDpAcHFoxPYozlpMPzDDq8UHb6Bd49lOALIrUguHOVTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719844174; c=relaxed/simple; bh=KnbCTh2kQyRbRrvFz2hnIOf9ZlZVQ3SBI8hzA4q53Rc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Thhb4bhW1Fdf/rT4FtNJgdVilFIMvMK9yVZbkAe2F4PMqsOVgue9fLmN7PnAPS08eVW5d+TUn1XqgAOmhkRUGSAWaJBslrqOaSHay6O3yl/D6kBNlcV2ZaTZXznHWeEZabmnR+VO0kVF8ASO0KMAxOf2POGzwX6b5gBMKmg4yUo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A2A12339; Mon, 1 Jul 2024 07:29:55 -0700 (PDT) Received: from thinkcentre-m93p.cambridge.arm.com (thinkcentre-m93p.cambridge.arm.com [10.1.197.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CD7683F762; Mon, 1 Jul 2024 07:29:29 -0700 (PDT) From: Luke Parkin 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 Subject: [PATCH 2/3] Track basic SCMI statistics Date: Mon, 1 Jul 2024 15:28:50 +0100 Message-Id: <20240701142851.1448515-3-luke.parkin@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240701142851.1448515-1-luke.parkin@arm.com> References: <20240701142851.1448515-1-luke.parkin@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add scmi_debug_stats struct with atomic_t types to prevent racing. Add tracking of 5 initial statistics - sent_ok & sent_fail - response_ok & dlyd_response_ok - xfers_response_timeout Signed-off-by: Luke Parkin --- drivers/firmware/arm_scmi/driver.c | 46 +++++++++++++++++++++++++++++- 1 file changed, 45 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi= /driver.c index 6b6957f4743f..f69dff699d48 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -125,6 +125,22 @@ struct scmi_debug_info { bool is_atomic; }; =20 +/** + * struct scmi_debug_stats - Debug statistics + * @sent_ok: Count of successful sends + * @sent_fail: Count of failed sends + * @response_ok: Count of successful responses + * @dlyd_response_ok: Count of successful delayed responses + * @xfers_response_timeout: Count of xfer response timeouts + */ +struct scmi_debug_stats { + atomic_t sent_ok; + atomic_t sent_fail; + atomic_t response_ok; + atomic_t dlyd_response_ok; + atomic_t xfers_response_timeout; +}; + /** * struct scmi_info - Structure representing a SCMI instance * @@ -141,6 +157,7 @@ struct scmi_debug_info { * @protocols: IDR for protocols' instance descriptors initialized for * this SCMI instance: populated on protocol's first attempted * usage. + * @stats: Contains several atomic_t's for tracking various statistics * @protocols_mtx: A mutex to protect protocols instances initialization. * @protocols_imp: List of protocols implemented, currently maximum of * scmi_revision_info.num_protocols elements allocated by the @@ -174,6 +191,7 @@ struct scmi_info { struct idr tx_idr; struct idr rx_idr; struct idr protocols; + struct scmi_debug_stats stats; /* Ensure mutual exclusive access to protocols instance array */ struct mutex protocols_mtx; u8 *protocols_imp; @@ -1143,7 +1161,12 @@ static void scmi_handle_response(struct scmi_chan_in= fo *cinfo, SCMI_RAW_REPLY_QUEUE, cinfo->id); } - + if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS)) { + if (xfer->hdr.type =3D=3D MSG_TYPE_DELAYED_RESP) + atomic_inc(&info->stats.dlyd_response_ok); + else + atomic_inc(&info->stats.response_ok); + } scmi_xfer_command_release(info, xfer); } =20 @@ -1279,6 +1302,12 @@ static int scmi_wait_for_reply(struct device *dev, c= onst struct scmi_desc *desc, } } =20 + if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS) && ret =3D=3D -ETIMEDOUT= ) { + struct scmi_info *info =3D + handle_to_scmi_info(cinfo->handle); + atomic_inc(&info->stats.xfers_response_timeout); + } + return ret; } =20 @@ -1414,6 +1443,13 @@ static int do_xfer(const struct scmi_protocol_handle= *ph, trace_scmi_xfer_end(xfer->transfer_id, xfer->hdr.id, xfer->hdr.protocol_id, xfer->hdr.seq, ret); =20 + if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS)) { + if (ret =3D=3D 0) + atomic_inc(&info->stats.sent_ok); + else + atomic_inc(&info->stats.sent_fail); + } + return ret; } =20 @@ -2994,6 +3030,14 @@ static int scmi_probe(struct platform_device *pdev) handle->devm_protocol_get =3D scmi_devm_protocol_get; handle->devm_protocol_put =3D scmi_devm_protocol_put; =20 + if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS)) { + atomic_set(&info->stats.response_ok, 0); + atomic_set(&info->stats.sent_fail, 0); + atomic_set(&info->stats.sent_ok, 0); + atomic_set(&info->stats.dlyd_response_ok, 0); + atomic_set(&info->stats.xfers_response_timeout, 0); + } + /* System wide atomic threshold for atomic ops .. if any */ if (!of_property_read_u32(np, "atomic-threshold-us", &info->atomic_threshold)) --=20 2.34.1 From nobody Sun Feb 8 21:36:07 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7B3421684BD; Mon, 1 Jul 2024 14:29:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719844175; cv=none; b=AXpo4T3qDSMwkVhhTM+sOlPWpawz7DtXGl1g00sPsxmLc7EamjM3b8kbKIcIUW9pOc9HValpLzNRmYABMCNqclwjVLHOHeZ7aNwFTrd5jd3PclJbcSjykLMvu2DSKqHNYwnbHLgzpPU6JdYXwVm/ZVgI7LegzRmhOInFGCqwAZk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1719844175; c=relaxed/simple; bh=RaUcUsCsJULxcj53PVFIPVEf5NAcdvwQU8sNh4SOEJI=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FnAvgqylNzuUWycsVm1PSQ7WykYneb7oL/haBbpPe9QSQn+87U+Qki+9jaG+HfW3zA3t7lo9xgui4GAO14iwnEw1rgJA3pu6vUqdpHrw3UYUbfB1Cij6s24UuHRrB2WQwfWGbWBYbeqWDf7ytUcwQDgNrbh6oxqOE/rQDpwTcMQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id EB64F367; Mon, 1 Jul 2024 07:29:57 -0700 (PDT) Received: from thinkcentre-m93p.cambridge.arm.com (thinkcentre-m93p.cambridge.arm.com [10.1.197.43]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 214883F762; Mon, 1 Jul 2024 07:29:32 -0700 (PDT) From: Luke Parkin 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 Subject: [PATCH 3/3] Create debugfs files for statistics Date: Mon, 1 Jul 2024 15:28:51 +0100 Message-Id: <20240701142851.1448515-4-luke.parkin@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240701142851.1448515-1-luke.parkin@arm.com> References: <20240701142851.1448515-1-luke.parkin@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Create debugfs files for the statistics in the scmi_debug_stats struct Signed-off-by: Luke Parkin --- 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; struct scmi_debug_info *dbg; const char *c_ptr =3D NULL; =20 @@ -2935,6 +2935,19 @@ static struct scmi_debug_info *scmi_debugfs_common_s= etup(struct scmi_info *info) debugfs_create_u32("rx_max_msg", 0400, trans, (u32 *)&info->rx_minfo.max_msg); =20 + if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS)) { + stats =3D 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 =3D top_dentry; =20 if (devm_add_action_or_reset(info->dev, --=20 2.34.1