From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B97FC3E49F6; Sun, 6 Sep 2026 10:07:54 +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=1788689277; cv=none; b=aJaxJUoXLZnKWe1ECrb8MDMG8G9JoPSJUqnrE/UU+UsAaB2hHrJDazQrzLPYM2UFXxW99QytfuJeBQMhiPFc+DgF0V4gfni1LLxx3eI+6N1+BetrntMar3+kREOgy9YucStHEiZz7hY8to7JdjpOoD3SxYJYUmDF80kihk0MjeU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788689277; c=relaxed/simple; bh=Aa9A0rdUL5ogoZxGZm81WYLEGqED/5Clc4LFZsquSFM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=StKb7PkZW2humDWM0/nGOWsDvAjLDd1WxEBzkoI2YdS6UVbSChCMDJ2TbQ/u2Vzp9TFRr87iuhpDWVDzyIzhF1JMkGJpbyrO+kQhb+uHBZFH36Tgv73z2Ku8Lh5u3yn1LBMMa+ZsX97ACI7w9xjZfndB8HxYe9JDYEhfgGlSmwQ= 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; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=ee8C1eVz; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="ee8C1eVz" 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 ED08A1A25; Sun, 6 Sep 2026 03:07:49 -0700 (PDT) Received: from pluto (usa-sjc-mx-foss1.foss.arm.com [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D366E3F7D8; Sun, 6 Sep 2026 03:07:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1788689273; bh=Aa9A0rdUL5ogoZxGZm81WYLEGqED/5Clc4LFZsquSFM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ee8C1eVzX0MWcoW+Ejg+0UCTm0jRkp9EgtR0jPMcmWq/zwM+9v5uXRTzWWMJMUKkz 6Ne79hO/nb5YBApIQgiPV1oN3uIMVx2Vpr47vJ0A0kRYyfcJ/x0uvGSqJZxq4t0B5k 0Ic1GLew9rxiUTCwYZj72TgPhrWDwrjeq0ZGl044= 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 v11 10/25] firmware: arm_scmi: Add support for Telemetry reset Date: Sun, 6 Sep 2026 11:06:08 +0100 Message-ID: <20260906100623.3488327-11-cristian.marussi@arm.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260906100623.3488327-1-cristian.marussi@arm.com> References: <20260906100623.3488327-1-cristian.marussi@arm.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add support for Telemetry operations needed to request platform to reset telemetry current configuration and data events values. Signed-off-by: Cristian Marussi --- 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 | 76 +++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 2 + 2 files changed, 78 insertions(+) diff --git a/drivers/firmware/arm_scmi/telemetry.c b/drivers/firmware/arm_scmi/telemetry.c index d3c6116db2a8..28ed644577a3 100644 --- a/drivers/firmware/arm_scmi/telemetry.c +++ b/drivers/firmware/arm_scmi/telemetry.c @@ -3033,6 +3033,81 @@ 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; + + 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) { + rinfo->des[i]->enabled = false; + rinfo->des[i]->tstamp_enabled = false; + + 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; + } + } + + /* + * 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; + } + + guard(mutex)(&ti->des_enabled_mtx); + atomic_set(&ti->des_enabled[ENA_STATE], 0); + atomic_set(&ti->des_enabled[ENA_TSTAMP], 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, @@ -3043,6 +3118,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 96940d6e80a4..aadabaee6067 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