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 1DDA1C982E6 for ; Sun, 20 Sep 2026 09:21:19 +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=WwR4cNlRZvM74K/8QpqKnhDYWdJYf88dCQPn4glU5wg=; b=MLno4yJ/g0+aajB4FSywfCDE2w m10wATGbRXHvd1OqjhMHkDZPM/SMqV0hdLyjlKuLN/HKqpnAiBXewWOE2LjJtRZcJpygtmo/c+teq UqoJNEXrK+XOZUqrRHRcaWt6eR1UWLPRYRPeBuT9pZYFn+7G0icGw6xZ0dltTdZHuybUlLhwGUQHQ gdRHUPZ84YnhKVyKI1hOdTTAmMeRn0FIl2BEifqT69ugy2DJ/5G2mYNqvCZyr0EmA4u4+dZB/1brR gcKBUEtOcU/e10Jmpy2ILZlkFk/Ibl5Ui64Adv6I2lpCuQj6VYOCcMHjneeKpFzWJienFa2EaqREq Ww+d6R6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x8DjR-0000000H9gi-48hN; Sun, 20 Sep 2026 09:21:09 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x8DjC-0000000H9UV-435t for linux-arm-kernel@lists.infradead.org; Sun, 20 Sep 2026 09:20:57 +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 A95CE1D31; Sun, 20 Sep 2026 02:20:49 -0700 (PDT) Received: from pluto.fritz.box (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4C2293F59E; Sun, 20 Sep 2026 02:20:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1789896053; bh=XFBCgnqtRCtsLLlDGLuFPJMX0AdnyAny6gw768e5STU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G2bKRYaHkyLgYM78pm30BT1qkUU0Lrj/GEYo0ODKIRITMwECzlQpqnt+ep9p4n38D bKMdmXvVOFv4OvxbOUtL7HcIOc1bobqGS8NYrLPPTKBa/EPdsr4roQ7oUp5yrTXm3Z hhhn8SDwotPq4Duo7K+xTcHFyImzW4NbucqilVJE= From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, arm-scmi@vger.kernel.org, linux-doc@vger.kernel.org Cc: sudeep.holla@kernel.org, james.quinlan@broadcom.com, f.fainelli@gmail.com, vincent.guittot@linaro.org, etienne.carriere@st.com, peng.fan@oss.nxp.com, michal.simek@amd.com, d-gole@ti.com, jic23@kernel.org, elif.topuz@arm.com, lukasz.luba@arm.com, philip.radford@arm.com, david@kernel.org, souvik.chakravarty@arm.com, leitao@kernel.org, kas@kernel.org, puranjay@kernel.org, usama.arif@linux.dev, kernel-team@meta.com, Cristian Marussi Subject: [PATCH v12 10/25] firmware: arm_scmi: Add support for Telemetry reset Date: Sun, 20 Sep 2026 10:19:13 +0100 Message-ID: <20260920091928.2014972-11-cristian.marussi@arm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260920091928.2014972-1-cristian.marussi@arm.com> References: <20260920091928.2014972-1-cristian.marussi@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260920_022055_137968_1C4DA6FE X-CRM114-Status: GOOD ( 18.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 support for Telemetry operations needed to request platform to reset telemetry current configuration and data events values. Signed-off-by: Cristian Marussi --- v11 --> v12 - using config_mtx to sync with ongoing configurations - use proper helpers to update cache state v10 --> v11 - protect TDE updates on reset - use des_enable mutex when clearing des cache - zero also active_update_interval v8 --> v9 - add a commment on why NOT unlinking UUID v6 --> v7 - add proper cleanup of sid/offs/uuids and caches on RESET v5 --> v6 - added missing reset of global state v3 --> v4 - reset tracked Telemetry DE state v2 --> v3 - split from monolithic Telemetry patch - use scmi_telemetry_de_unlink --- drivers/firmware/arm_scmi/telemetry.c | 80 +++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 2 + 2 files changed, 82 insertions(+) diff --git a/drivers/firmware/arm_scmi/telemetry.c b/drivers/firmware/arm_scmi/telemetry.c index c4981d3f5457..3e0c3c42e5a7 100644 --- a/drivers/firmware/arm_scmi/telemetry.c +++ b/drivers/firmware/arm_scmi/telemetry.c @@ -3138,6 +3138,85 @@ static int scmi_telemetry_des_sample_get(const struct scmi_protocol_handle *ph, return ret; } +static void scmi_telemetry_local_resources_reset(struct telemetry_info *ti) +{ + struct scmi_telemetry_res_info *rinfo; + + /* Stall concurrent configuration request */ + guard(mutex)(&ti->config_mtx); + + ti->info.enabled = false; + ti->info.notif_enabled = false; + ti->info.current_mode = SCMI_TLM_ONDEMAND; + ti->info.active_update_interval = 0; + + /* Get rinfo as it is...without triggering an enumeration */ + rinfo = __scmi_telemetry_resources_get(ti); + + /* Clear all local state...*/ + for (int i = 0; i < rinfo->num_des; i++) { + struct telemetry_de *tde = to_tde(rinfo->des[i]); + + scoped_guard(mutex, &tde->mtx) { + tde->last_ts = 0; + tde->last_val = 0; + tde->last_magic = 0; + if (!tde->de.fc_support) { + tde->sid = SHMTI_ID_INVALID; + tde->base = NULL; + tde->offset = 0; + tde->eplg = NULL; + } + + scmi_telemetry_de_state_update(ti, ENA_STATE, + &tde->de.enabled, false); + + if (tde->de.tstamp_support) + scmi_telemetry_de_state_update(ti, ENA_TSTAMP, + &tde->de.tstamp_enabled, + false); + } + + /* + * Unlinking ONLY BLK_TS lines since, per the SCMI spec, the + * UUID/DE associations are permanent within the same session + * boot: after a reset has cleared the server-side configuration + * the next time SHMTIs will be re-populated, these same UUID/DE + * associations will be re-instated. + */ + scmi_telemetry_blkts_unlink(tde); + } + + for (int i = 0; i < rinfo->num_groups; i++) { + rinfo->grps[i].enabled = false; + rinfo->grps[i].tstamp_enabled = false; + rinfo->grps[i].current_mode = SCMI_TLM_ONDEMAND; + rinfo->grps[i].active_update_interval = 0; + } +} + +static int scmi_telemetry_reset(const struct scmi_protocol_handle *ph) +{ + struct scmi_xfer *t; + int ret; + + ret = ph->xops->xfer_get_init(ph, TELEMETRY_RESET, sizeof(u32), 0, &t); + if (ret) + return ret; + + put_unaligned_le32(0, t->tx.buf); + ret = ph->xops->do_xfer(ph, t); + if (!ret) { + struct telemetry_info *ti = ph->get_priv(ph); + + scmi_telemetry_local_resources_reset(ti); + } + + ph->xops->xfer_put(ph, t); + + return ret; +} + static const struct scmi_telemetry_proto_ops tlm_proto_ops = { .info_get = scmi_telemetry_info_get, .de_lookup = scmi_telemetry_de_lookup, @@ -3148,6 +3227,7 @@ static const struct scmi_telemetry_proto_ops tlm_proto_ops = { .de_data_read = scmi_telemetry_de_data_read, .des_bulk_read = scmi_telemetry_des_bulk_read, .des_sample_get = scmi_telemetry_des_sample_get, + .reset = scmi_telemetry_reset, }; /** diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index c401d04758c5..5a2787b30120 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -1016,6 +1016,7 @@ struct scmi_telemetry_de_sample { * the ones belonging to a specific group when provided. * This causes an immediate update platform-side of all the * enabled DEs. + * @reset: reset configuration and telemetry data. */ struct scmi_telemetry_proto_ops { const struct scmi_telemetry_info __must_check *(*info_get) @@ -1043,6 +1044,7 @@ struct scmi_telemetry_proto_ops { int __must_check (*des_sample_get)(const struct scmi_protocol_handle *ph, int grp_id, int *num_samples, struct scmi_telemetry_de_sample *samples); + int (*reset)(const struct scmi_protocol_handle *ph); }; /** -- 2.54.0