From patchwork Mon Jul 1 14:28:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luke Parkin X-Patchwork-Id: 13718214 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 457AEC2BD09 for ; Mon, 1 Jul 2024 14:29:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=rf4D91UGQ0CC/WnzFA3CHK+bhyoXCbM66wWkvDzovNQ=; b=YimzYY8ErLBlC2uvyzQkKVRbSY iR4d3JlYVR6eFfAR3fYEv94oFYUqNm86H7xl7gcKuzF44GzpILs1B5zYolrhRvQDJxYmv+4x0SV2R cwoVRHJzETYqGyDwGRUgsVPQNGhBEVjTAZ1HOP0JER28XprXdab/hHBQTQq55TKCyE7fYY5p/f3c1 JNwGplNaTitlYSGnzp5AuzngTYXEh9bjO1IWF0gujW2qp1VGA6/0AHBUhJ05V/yRa0rDT1sWvnQmp evPm3h/wYB1Yr2XzFMkCEw6w6/WzRW4WpHNlflY2S/vSQOfzEdf5MOIyw5T5Vn4MlLW5YbavmYEtz cMRGVlOw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOI2H-00000003jRN-04FH; Mon, 01 Jul 2024 14:29:41 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOI22-00000003jNv-3qkR for linux-arm-kernel@lists.infradead.org; Mon, 01 Jul 2024 14:29:28 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_072927_059875_15CA652F X-CRM114-Status: UNSURE ( 9.08 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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. +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 From patchwork Mon Jul 1 14:28:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luke Parkin X-Patchwork-Id: 13718215 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2B666C2BD09 for ; Mon, 1 Jul 2024 14:29:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=R1pVDBJkjsPM/xhtTixTGyWZEiAd2wgvigyx0zAPGxQ=; b=tWr4g9mwIwmGF82Z/qLKMT0wF7 ZlnWeUDjVmtfHCfR7gBjGyWxz6Ly70wvkPWPUR+0xUjq0ma4ODQFmhdZCby+baaQ2ZYcgSKMJMbpI sGfERzIT3VnKRP016xVvgPBQsweAoxmPyxKIeRII3Rfp14y/8YhODAhcnyjHItSd7ior/bzSrRpLN t/MabKBClGqa/czlc7pOGui3GgoU/mq+Oo5o0kLNsSCsVDdIrbtaV1tvvRCn04BV74uV5xqdTqPEV KsgFZkAoDx6caMRb86ny5DWFspgNjdsoTHc690/lwPZczzNotYdjmCr10Lmq1fFVYj39UztRPQCfU 1h8QAOzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOI2P-00000003jTO-01Pq; Mon, 01 Jul 2024 14:29:49 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOI27-00000003jPG-2lOV for linux-arm-kernel@lists.infradead.org; Mon, 01 Jul 2024 14:29:33 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_072931_898959_DE52E6D2 X-CRM114-Status: GOOD ( 13.61 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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; }; +/** + * 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_info *cinfo, SCMI_RAW_REPLY_QUEUE, cinfo->id); } - + if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS)) { + if (xfer->hdr.type == MSG_TYPE_DELAYED_RESP) + atomic_inc(&info->stats.dlyd_response_ok); + else + atomic_inc(&info->stats.response_ok); + } scmi_xfer_command_release(info, xfer); } @@ -1279,6 +1302,12 @@ static int scmi_wait_for_reply(struct device *dev, const struct scmi_desc *desc, } } + if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS) && ret == -ETIMEDOUT) { + struct scmi_info *info = + handle_to_scmi_info(cinfo->handle); + atomic_inc(&info->stats.xfers_response_timeout); + } + return ret; } @@ -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); + if (IS_ENABLED(CONFIG_ARM_SCMI_DEBUG_STATISTICS)) { + if (ret == 0) + atomic_inc(&info->stats.sent_ok); + else + atomic_inc(&info->stats.sent_fail); + } + return ret; } @@ -2994,6 +3030,14 @@ static int scmi_probe(struct platform_device *pdev) handle->devm_protocol_get = scmi_devm_protocol_get; handle->devm_protocol_put = scmi_devm_protocol_put; + 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)) From patchwork Mon Jul 1 14:28:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luke Parkin X-Patchwork-Id: 13718216 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 35174C2BD09 for ; Mon, 1 Jul 2024 14:30:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Y5XmYOHa0wupa6rNqu+uT+AhOAqn8yOvCFNFIhCeGyE=; b=xEOu5uOVpf7iRmeo1dff/akMJh 8uPmUcY1uHbRU7UXeZPOQzrfPwIsIb36u0rDSAozpbe8ltbWgXuONTIadLM8lenyT3yfrsXMjcABN 4RKbeXgQGH0ksT83mCNc0djEIlGYyGlq5hROWZ5r4X2Egwqrxj74vDqmVkyNZ/MrYKh1oof6VFrse FDlDIcITkzo1ofd7zwaKRQQkzWEp4t6ou2TOWFCMWqqNxSf5tCN+jZ1MLCEKonRyGO04eFAyb/dLx gZGedmq9Ti9+phvabReSqpAUO49xuF6RnG4ANYKCtLFeCph7IW2Ap5h0DiQ5CozlxvAqN3cBI1yJl fhCFAYIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOI2Y-00000003jXs-0Kql; Mon, 01 Jul 2024 14:29:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sOI29-00000003jQ6-3HBI for linux-arm-kernel@lists.infradead.org; Mon, 01 Jul 2024 14:29:35 +0000 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> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240701_072933_961586_6D10F8AF X-CRM114-Status: UNSURE ( 9.82 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 = 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,