From patchwork Mon Feb 12 12:32:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199724 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2396689dyd; Mon, 12 Feb 2024 04:34:57 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUfxTa79MHI4B9RshkbxY5lP9jB7bye+adH2XLd2fvoQsIU6q4IKwT+dNZSaBEN1/EmfvYxTwWIt8dqfMnjhl6OGUFGdA== X-Google-Smtp-Source: AGHT+IH53chan2pXRBbX0SpkanuMPU56nx5cT18mHNYUlnj7CIus9Bwfw7rbvWeWLSYObbaTuV/B X-Received: by 2002:a17:906:3b9a:b0:a3c:d053:1272 with SMTP id u26-20020a1709063b9a00b00a3cd0531272mr733013ejf.15.1707741297360; Mon, 12 Feb 2024 04:34:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741297; cv=pass; d=google.com; s=arc-20160816; b=R3UfP2c20Zcyk3VI17Juf//rl5OY4ZwNmVH7DXuPkBv6iuZ78YlEvrUl9b5zs6mFlS V9bmkrmi6fsejBcsNYIxFp5KreHKv3X02V9RRxhcDdn0gxto9ifL4zF/G0SsOb+NAiKD wHwueyKBqarr+pvruE80baEJsNmlZO3pccIz7lQzlJ8hn73LS9Zjz10aI1l/s4KUEI5B SzInWA7nzMv3YX6t9TwPQZj+K3gm6Yx7yz3MoWftfYHgQylm6smKmQPGIHLp/rdpSIkt 7cU2iY51O47+DpUaDChrGnYe6VL/qMAlWL42IR810vygzWw2jVsE5BMhtNde1lbqHBqo KEHQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=UUk1lFXUqcSnfUN0Eym/sCu/TN3gaAXSxkanwGsQbfY=; fh=mNDdUzfQ+aokhYaY3MeRiVAP07dEgcQqjnPup6S4BlM=; b=Mj6yX5et8n5ZmztscSYz9G4g+YSIY3yHlRbvIBJRwBFrJDDmMr6g8Xg3qlcNbCpODl f3nv5ZRlw3SojwN2lO+eKlzqeNSU90cO4f4rbjBdZaIInAKB6fdGxhHMlPfO1U/RFP/4 tffi8OaSquU+vX+Iu1rTMLOiDJRcWwJpKBd2URckgSEJBhuB6ng+NpvsFiEcz/odHVLn MSA7+rPkAX/YJuNNcmxWcGlmTVL9XhA/WFiQShOweKGZOr/B+TDmOw96TmvlbxLiA4Ot 4yEvwrOENpQZ1uJoWUtA3dpn7av3A7aXWfkF2p2sbYCbgW/bXGVHghC5tCrx09b1uroz CkZQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-61554-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61554-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCVpZ+glcMwqEHFenS8t9H8t1Kg63XS2Ez8QF9V3dLu0IrmmZLENBeIF5yfT0voz12FQ/Yl3KFydZzVGA2ttJPhV/bjplA== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id e2-20020a17090681c200b00a3cc259099bsi142331ejx.338.2024.02.12.04.34.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:34:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61554-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=arm.com dmarc=pass fromdomain=arm.com); spf=pass (google.com: domain of linux-kernel+bounces-61554-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61554-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id F379B1F259F4 for ; Mon, 12 Feb 2024 12:34:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 99F503BB41; Mon, 12 Feb 2024 12:33:16 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FC583B2B6 for ; Mon, 12 Feb 2024 12:33:13 +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=1707741195; cv=none; b=nDleCUwSPlcIhw5ESgB5uvqxsZTddehMhwAON4nGheUxFs/1o3ar9RWnGXOnEuVaneCrbJXYYvapzuRijESmxrBgLSnQRS3e2Ptv5whzVVBUlwY5QedQLT/bm21As/gOndBxv/5DEYYVPufOA/HwI6TJ8kxCfa1k3aq0vHUn5us= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741195; c=relaxed/simple; bh=wTReGJB67HFBhTtXp137WsohGYKr3VR4+2E7nnpEzNs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hkAT1CThhUcVRmPeLFi/ggRl4wXYswLG+pMgIUsm0wIYS7rjyCh3fV8Lwz2ZPWmSIWptBTCij2docsG4QC9mdOlyscFQe+z/8klCnROJUocD5L0lPhRX0R0fy2B4JEVRy3wnTycy1EFuyu3Jq0xUW+eXe24kbyRktQfQQDQB44M= 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 692111063; Mon, 12 Feb 2024 04:33:54 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 9B3853F7BD; Mon, 12 Feb 2024 04:33:11 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, vincent.guittot@linaro.org, peng.fan@oss.nxp.com, michal.simek@amd.com, quic_sibis@quicinc.com, quic_nkela@quicinc.com, souvik.chakravarty@arm.com, Cristian Marussi Subject: [PATCH 07/11] firmware: arm_scmi: Implement Sensor .is_notify_supported callback Date: Mon, 12 Feb 2024 12:32:29 +0000 Message-ID: <20240212123233.1230090-8-cristian.marussi@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240212123233.1230090-1-cristian.marussi@arm.com> References: <20240212123233.1230090-1-cristian.marussi@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790696538696452279 X-GMAIL-MSGID: 1790696538696452279 Add a preliminary check to verify if Sensor-related notify enable commands are supported at all by the running platform, and then provide the callback needed to allow the core SCMI notification subsytem to fine-grain check if a specific resource domain supports notifications. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/sensors.c | 37 ++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/sensors.c b/drivers/firmware/arm_scmi/sensors.c index 311149965370..7fc5535ca34c 100644 --- a/drivers/firmware/arm_scmi/sensors.c +++ b/drivers/firmware/arm_scmi/sensors.c @@ -215,6 +215,8 @@ struct scmi_sensor_update_notify_payld { struct sensors_info { u32 version; + bool notify_trip_point_cmd; + bool notify_continuos_update_cmd; int num_sensors; int max_requests; u64 reg_addr; @@ -246,6 +248,18 @@ static int scmi_sensor_attributes_get(const struct scmi_protocol_handle *ph, } ph->xops->xfer_put(ph, t); + + if (!ret) { + if (!ph->hops->protocol_msg_check(ph, + SENSOR_TRIP_POINT_NOTIFY, NULL)) + si->notify_trip_point_cmd = true; + + if (!ph->hops->protocol_msg_check(ph, + SENSOR_CONTINUOUS_UPDATE_NOTIFY, + NULL)) + si->notify_continuos_update_cmd = true; + } + return ret; } @@ -594,7 +608,8 @@ iter_sens_descr_process_response(const struct scmi_protocol_handle *ph, * Such bitfields are assumed to be zeroed on non * relevant fw versions...assuming fw not buggy ! */ - s->update = SUPPORTS_UPDATE_NOTIFY(attrl); + if (si->notify_continuos_update_cmd) + s->update = SUPPORTS_UPDATE_NOTIFY(attrl); s->timestamped = SUPPORTS_TIMESTAMP(attrl); if (s->timestamped) s->tstamp_scale = S32_EXT(SENSOR_TSTAMP_EXP(attrl)); @@ -988,6 +1003,25 @@ static const struct scmi_sensor_proto_ops sensor_proto_ops = { .config_set = scmi_sensor_config_set, }; +static bool scmi_sensor_notify_supported(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id) +{ + bool supported = false; + const struct scmi_sensor_info *s; + struct sensors_info *sinfo = ph->get_priv(ph); + + s = scmi_sensor_info_get(ph, src_id); + if (!s) + return false; + + if (evt_id == SCMI_EVENT_SENSOR_TRIP_POINT_EVENT) + supported = sinfo->notify_trip_point_cmd; + else if (evt_id == SCMI_EVENT_SENSOR_UPDATE) + supported = s->update; + + return supported; +} + static int scmi_sensor_set_notify_enabled(const struct scmi_protocol_handle *ph, u8 evt_id, u32 src_id, bool enable) { @@ -1099,6 +1133,7 @@ static const struct scmi_event sensor_events[] = { }; static const struct scmi_event_ops sensor_event_ops = { + .is_notify_supported = scmi_sensor_notify_supported, .get_num_sources = scmi_sensor_get_num_sources, .set_notify_enabled = scmi_sensor_set_notify_enabled, .fill_custom_report = scmi_sensor_fill_custom_report,