From mboxrd@z Thu Jan 1 00:00:00 1970 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 5DFBEC3DA49 for ; Tue, 30 Jul 2024 09:35:53 +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=omCYDUiQ07tpmrSMpSmYCe/R+uxPD8jOqz8Z2Jaib50=; b=n9ATGhKYHjytCSQZztA9Qg3R1T rgigCGY+JDm6WRu33nKGWLE7OsQyZy25oTr6y3Sm0bQTohXXiw+2hMVrZu9D0E8gFLpG175EbC0Cm Gi8+Q5sOBmzZYNzVkG22ElrY3Ol1teyyBoCgU5YB5dn0jtBXU14geeDGe/WqrvyyQEN/d3IJPXKA3 fITUTcPzSazJ/q49AZMywjzZH8jGndWHPRjMLE1utWSQK3TpzxsOhiYmRUCcKGC2IFs3SC15j57zk yjbzvZiIq43p4Essa7RE2V2/us0xsDNnx+VYgKOkNpmR95B5whsJD6hjzB4Dx5lc8D7AFXyofGpFN cYfPTeiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sYjGe-0000000EYGV-3vWz; Tue, 30 Jul 2024 09:35:40 +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 1sYjF1-0000000EXjK-41eK for linux-arm-kernel@lists.infradead.org; Tue, 30 Jul 2024 09:34:01 +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 1CF93168F; Tue, 30 Jul 2024 02:34:23 -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 7D41D3F5A1; Tue, 30 Jul 2024 02:33:56 -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 v4 5/5] firmware: arm_scmi: Reset counters Date: Tue, 30 Jul 2024 10:33:42 +0100 Message-Id: <20240730093342.3558162-6-luke.parkin@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240730093342.3558162-1-luke.parkin@arm.com> References: <20240730093342.3558162-1-luke.parkin@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240730_023400_129333_7C4DD7C9 X-CRM114-Status: UNSURE ( 9.89 ) 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 Allow writing to atomics to reset Create reset_all counters debugfs file to reset all counters Signed-off-by: Luke Parkin --- v3->v4 Use basic writing to allow any number to be set rather than forcing a set to 0 --- drivers/firmware/arm_scmi/driver.c | 45 +++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 13 deletions(-) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index ec6434692d1a..9e8720c27d51 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -2847,6 +2847,24 @@ static int scmi_device_request_notifier(struct notifier_block *nb, return NOTIFY_OK; } +static ssize_t reset_all_on_write(struct file *filp, const char __user *buf, + size_t count, loff_t *ppos) +{ + struct scmi_debug_info *dbg = filp->private_data; + + for (int i = 0; i < SCMI_DEBUG_COUNTERS_LAST; i++) + atomic_set(&dbg->counters[i], 0); + + return count; +} + +static const struct file_operations fops_reset_counts = { + .owner = THIS_MODULE, + .open = simple_open, + .llseek = no_llseek, + .write = reset_all_on_write, +}; + static void scmi_debugfs_counters_setup(struct scmi_debug_info *dbg, struct dentry *trans) { @@ -2854,32 +2872,33 @@ static void scmi_debugfs_counters_setup(struct scmi_debug_info *dbg, counters = debugfs_create_dir("counters", trans); - debugfs_create_atomic_t("sent_ok", 0400, counters, + debugfs_create_atomic_t("sent_ok", 0600, counters, &dbg->counters[SENT_OK]); - debugfs_create_atomic_t("sent_fail", 0400, counters, + debugfs_create_atomic_t("sent_fail", 0600, counters, &dbg->counters[SENT_FAIL]); - debugfs_create_atomic_t("sent_fail_polling_unsupported", 0400, counters, + debugfs_create_atomic_t("sent_fail_polling_unsupported", 0600, counters, &dbg->counters[SENT_FAIL_POLLING_UNSUPPORTED]); - debugfs_create_atomic_t("sent_fail_channel_not_found", 0400, counters, + debugfs_create_atomic_t("sent_fail_channel_not_found", 0600, counters, &dbg->counters[SENT_FAIL_CHANNEL_NOT_FOUND]); - debugfs_create_atomic_t("response_ok", 0400, counters, + debugfs_create_atomic_t("response_ok", 0600, counters, &dbg->counters[RESPONSE_OK]); - debugfs_create_atomic_t("notif_ok", 0400, counters, + debugfs_create_atomic_t("notif_ok", 0600, counters, &dbg->counters[NOTIF_OK]); - debugfs_create_atomic_t("dlyd_resp_ok", 0400, counters, + debugfs_create_atomic_t("dlyd_resp_ok", 0600, counters, &dbg->counters[DLYD_RESPONSE_OK]); - debugfs_create_atomic_t("xfers_resp_timeout", 0400, counters, + debugfs_create_atomic_t("xfers_resp_timeout", 0600, counters, &dbg->counters[XFERS_RESPONSE_TIMEOUT]); - debugfs_create_atomic_t("response_polled_ok", 0400, counters, + debugfs_create_atomic_t("response_polled_ok", 0600, counters, &dbg->counters[RESPONSE_POLLED_OK]); - debugfs_create_atomic_t("err_msg_unexpected", 0400, counters, + debugfs_create_atomic_t("err_msg_unexpected", 0600, counters, &dbg->counters[ERR_MSG_UNEXPECTED]); - debugfs_create_atomic_t("err_msg_invalid", 0400, counters, + debugfs_create_atomic_t("err_msg_invalid", 0600, counters, &dbg->counters[ERR_MSG_INVALID]); - debugfs_create_atomic_t("err_msg_nomem", 0400, counters, + debugfs_create_atomic_t("err_msg_nomem", 0600, counters, &dbg->counters[ERR_MSG_NOMEM]); - debugfs_create_atomic_t("err_protocol", 0400, counters, + debugfs_create_atomic_t("err_protocol", 0600, counters, &dbg->counters[ERR_PROTOCOL]); + debugfs_create_file("reset", 0200, counters, dbg, &fops_reset_counts); } static void scmi_debugfs_common_cleanup(void *d) -- 2.34.1