From patchwork Mon Feb 12 12:32:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199720 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2396096dyd; Mon, 12 Feb 2024 04:33:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IEhrw5P0+hz6wOAHqd2CL2XcryUj5c1CLOdQ31HkXo+BFUaX/KO0N0lHj+h3k2sCdKFg82w X-Received: by 2002:a17:906:ae93:b0:a3c:92c2:66e0 with SMTP id md19-20020a170906ae9300b00a3c92c266e0mr2049037ejb.64.1707741226393; Mon, 12 Feb 2024 04:33:46 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741226; cv=pass; d=google.com; s=arc-20160816; b=JnoquxLbR+EYCJe72ulgZKOK+7tV+WtjLGX4iMsQGqQNGIBr2Jg63bxBqsTwyveiT4 GnQ0H0ug5rAK0uKqC+iSwsK1eVgjPbherXTjNBCt1NPZh79LvTnPuHis3FzmRPNphzvS p6tet2Stc6b66s/kwbCSCylvyX5S1Tsw46bT2w0rcCb3aL6LZHbd5QQNJbDbF3OR7Ohi 3OfTYm9Kp3OOaVhUh95XpaUeyO5z/jRLuTuw4qIsuqC7avHswdij/w4I2FQNk5r4+pzY zaKVRb8orm6Utbo5LObDJ7xofQeMRRUANlyIoNfJ3NuDvbypIb45hOICo7NjH/sNvTzF CMpg== 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=4mUjNUITRP5XEHV6BkJXYYu6se2V8qu9LBG0CO68NgQ=; fh=MxMFHXAH879fk6I31q6eIo5lOeTgt1mTw8MedubiXvk=; b=jei+YWMgM5Wf3WM0EsXGcJNtw6/HRPwtpbYoVVOV5KzqzeIp5qjNGwD5H9U9nM6evT XrwC+nh1KFbOQhJMB7u3iAzJvADK6hsdWwypFethSoSaZzv1QP5xtPSw8fpJ2U9TYCaA 8I0ln5nyh1i9hqat2r8LbUPiW+XDd6tb4c6f4D4hYCa4PgOfRgumm9ay3FqDF/nZNFdl dEl4bVtycDTqQbQJPZjhwPGkVgBAgxmE3KAgkYPFovJbm9UNWlFvucyDzOJnNB7v4ZUw aMhe253OYtrofG+iEsnYdGkPujrsvI53LQZyPJwg4h/B5ds0cqZ21dfxjlkBgntCVsyN Znrg==; 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-61548-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61548-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCUroFARm80dWqRsIAkeGjNTAH+aE/d6TI6AdEJ/RwLa4zEtQvatAmyHQMrvL2TTYlpB7jAEVx7ulhAqbDeSy+wYHP82Bw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id t26-20020a1709063e5a00b00a3c9abc9b56si143295eji.892.2024.02.12.04.33.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:33:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61548-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-61548-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61548-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 078551F257EA for ; Mon, 12 Feb 2024 12:33:46 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 57F373A29E; Mon, 12 Feb 2024 12:33:08 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 03FCC1E487 for ; Mon, 12 Feb 2024 12:33:03 +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=1707741186; cv=none; b=ZvI7gIuPXNjZEdar2ryd23FEtmaW76xEMsX3MONAOdY9N7vq04lPsmC9TIqnFhvuOYOFrh/T7CSkCErCnh1p/vT/c/Oac5wvg+34MYwB/ifdvqX3ZtJoj7z4plJcZ8t67tDJnzY0nb+7yZdAxTT19aSunc/duhzazcwUny24YzM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741186; c=relaxed/simple; bh=JlkQiW/QuL/OX9TPCicFNqlZdcMRLppLsC1w6NTqto0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=X6UhkiMppLK/uGb/oCUdlBBdvW9mTmGrk0IlZMqCj54Ov3guU3bs0R/kx+gNXZxGkkOU+s9JNNUStVbveUbnf+ezSj9kpfHFAqw7Ec7/euTrGm5QUk8UINa+XcIPe+2PdmzqFgRBLICNXXd8+K1PYwWg0WHlvsIxa9MPeXNAyI0= 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 4A3BAFEC; Mon, 12 Feb 2024 04:33:44 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7A3E03F7BD; Mon, 12 Feb 2024 04:33:01 -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 01/11] firmware: arm_scmi: Check for notification support Date: Mon, 12 Feb 2024 12:32:23 +0000 Message-ID: <20240212123233.1230090-2-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: 1790696464031536091 X-GMAIL-MSGID: 1790696464031536091 When registering protocol events, use the optional .is_notify_supported callback provided by the protocol to check if that specific notification type is available for that particular resource on the running system, marking it as unsupported otherwise. Then, when a notification enable request is received, return an error if it was previously marked as unsuppported, so avoiding to send a needless notification enable command and check the returned value for failure. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/notify.c | 17 ++++++++++++++++- drivers/firmware/arm_scmi/notify.h | 4 ++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_scmi/notify.c b/drivers/firmware/arm_scmi/notify.c index 0efd20cd9d69..27c52531194d 100644 --- a/drivers/firmware/arm_scmi/notify.c +++ b/drivers/firmware/arm_scmi/notify.c @@ -99,6 +99,7 @@ #define PROTO_ID_MASK GENMASK(31, 24) #define EVT_ID_MASK GENMASK(23, 16) #define SRC_ID_MASK GENMASK(15, 0) +#define NOTIF_UNSUPP -1 /* * Builds an unsigned 32bit key from the given input tuple to be used @@ -788,6 +789,7 @@ int scmi_register_protocol_events(const struct scmi_handle *handle, u8 proto_id, pd->ph = ph; for (i = 0; i < ee->num_events; i++, evt++) { + int id; struct scmi_registered_event *r_evt; r_evt = devm_kzalloc(ni->handle->dev, sizeof(*r_evt), @@ -809,6 +811,11 @@ int scmi_register_protocol_events(const struct scmi_handle *handle, u8 proto_id, if (!r_evt->report) return -ENOMEM; + for (id = 0; id < r_evt->num_sources; id++) + if (ee->ops->is_notify_supported && + !ee->ops->is_notify_supported(ph, r_evt->evt->id, id)) + refcount_set(&r_evt->sources[id], NOTIF_UNSUPP); + pd->registered_events[i] = r_evt; /* Ensure events are updated */ smp_wmb(); @@ -1166,7 +1173,13 @@ static inline int __scmi_enable_evt(struct scmi_registered_event *r_evt, int ret = 0; sid = &r_evt->sources[src_id]; - if (refcount_read(sid) == 0) { + if (refcount_read(sid) == NOTIF_UNSUPP) { + dev_dbg(r_evt->proto->ph->dev, + "Notification NOT supported - proto_id:%d evt_id:%d src_id:%d", + r_evt->proto->id, r_evt->evt->id, + src_id); + ret = -EOPNOTSUPP; + } else if (refcount_read(sid) == 0) { ret = REVT_NOTIFY_ENABLE(r_evt, r_evt->evt->id, src_id); if (!ret) @@ -1179,6 +1192,8 @@ static inline int __scmi_enable_evt(struct scmi_registered_event *r_evt, } else { for (; num_sources; src_id++, num_sources--) { sid = &r_evt->sources[src_id]; + if (refcount_read(sid) == NOTIF_UNSUPP) + continue; if (refcount_dec_and_test(sid)) REVT_NOTIFY_DISABLE(r_evt, r_evt->evt->id, src_id); diff --git a/drivers/firmware/arm_scmi/notify.h b/drivers/firmware/arm_scmi/notify.h index 4e9b627edfef..76758a736cf4 100644 --- a/drivers/firmware/arm_scmi/notify.h +++ b/drivers/firmware/arm_scmi/notify.h @@ -35,6 +35,8 @@ struct scmi_protocol_handle; /** * struct scmi_event_ops - Protocol helpers called by the notification core. + * @is_notify_supported: Return 0 if the specified notification for the + * specified resource (src_id) is supported. * @get_num_sources: Returns the number of possible events' sources for this * protocol * @set_notify_enabled: Enable/disable the required evt_id/src_id notifications @@ -50,6 +52,8 @@ struct scmi_protocol_handle; * process context. */ struct scmi_event_ops { + bool (*is_notify_supported)(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id); int (*get_num_sources)(const struct scmi_protocol_handle *ph); int (*set_notify_enabled)(const struct scmi_protocol_handle *ph, u8 evt_id, u32 src_id, bool enabled); From patchwork Mon Feb 12 12:32:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199733 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2405993dyd; Mon, 12 Feb 2024 04:56:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1RluLNrzi0d0D0KmReVkRp83FKSqhduA3ZLZyIYJjfJHqBAII1k9Mt2yb5g8Ds24K387k X-Received: by 2002:a17:903:40cf:b0:1d9:6c3:e24f with SMTP id t15-20020a17090340cf00b001d906c3e24fmr8478813pld.38.1707742581063; Mon, 12 Feb 2024 04:56:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707742581; cv=pass; d=google.com; s=arc-20160816; b=Zla7IG8WiT4euFwTeKRmLXCviLV1iuf6xByK9E75TwF6c8n8wljo1suMxI+yDYnuYy ITcJZhd/jCg2VZJxQORKjuXLCjjMP33cdS1tuXNYn72+ZeISKMpySoPHB1I/zD4Vh2F5 RJ2nb/R0OqHKSg1QspLF3328kfE01DRKxtLo0jMSvqs6feQ7LDbAvtpFXuZyqS34bSRG vBuNvQ8SQeX1rk4ajIS6NugFH8YfUYtLLsG1hJHxq7vMCX76tqC0mxUUjssDAIA5bUkZ DgW1icS6kJdhrqAjCULkYFxgl5Tbub2xzFj7FsNoKGMSPooxxImcZOGdtIhCwEbOWb+D WLJQ== 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=iP0KHQ6mFkKeOPGjGlf8QnZIRtZ9toQAxnLVV2BfNys=; fh=qpwEmdk/fWQK+mobL2bCHuCDV58yw59galycdFhkhj0=; b=NoQnGcyaObTVICAxSj28eZrQLOQRpCLpiIs6Z0h6CoL6l6ymyjTEapUaF+FmRCmfvE G3syGkz0AejqvCe3qlXoUEOLzrmWddi24j6ZZVMPNzjhwfTVGu8Urp6d3yHYyysR95qk 2U+TqTfH/eQ7KkCFY6fuY0zlRMV3K/+z7ViFFZYcW4s+UULCet+xuqKCZd6QIKA5fdWC jqtV+T8KSYFsa+i7DLtTFDI2DCFt1Pu4CKujWijTizwpbQXyBQKn0J/ddBWEcM/0hAaW 3HrXK948uxHH1FR36nKQ0PWIhcgwTdEAXMSFJtgWho+7i5TivP6J2dkQFmx6lTdWqd/d +v4w==; 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-61549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61549-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCVoHjayN+5f57NUwE830dNhPESBSn0CAnt0Zmpkz9UdceBHxO7QbkVwagw5tPA6sOCL0VdSl0A/zRu9kGieakMxVLpMSA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id i11-20020a170902c94b00b001d953c582absi217211pla.23.2024.02.12.04.56.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:56:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-61549-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61549-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 87FEDB243C8 for ; Mon, 12 Feb 2024 12:33:45 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 55D313A29B; Mon, 12 Feb 2024 12:33:08 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 33ABC39FEB for ; Mon, 12 Feb 2024 12:33:04 +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=1707741186; cv=none; b=G1J1Z4g5o/4xwemQN9+NLzhv6yyrTD2PVqms9kOFeNzOZi8lkJj3U5fzAfNPv9phgDytjcgGSYBixqfbj6YipHYhZ6GLPY2EB4+adDmsK1ovS/AxJfT12LFPgIMfJ/Z+mTF/GzofOTAq/Lpg+OW940afF7XItK0hRS9yOaOvuB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741186; c=relaxed/simple; bh=L7rCObjeJJ/6znwFBtlQDxE88+afFeZnyW7f58K3Lx8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ersZqGFLtKzzsFwZpL/ebUqnkb1jdNGkIaoqNb1wwogAOcYUvi7JxqMk6OSL3TWVdaK2QSjEpMxksRBjzgdlk7m6XQOooPVRfz9GIYjn9lDiPQnomgwI935SfrTx0/v1Joqgfm1ROtVpdrHPcYxYQDU/oQv9HCxhziV2icgt3Ko= 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 F25981063; Mon, 12 Feb 2024 04:33:45 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2F0CF3F7BD; Mon, 12 Feb 2024 04:33:03 -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 02/11] firmware: arm_scmi: Add a common helper to check if a message is supported Date: Mon, 12 Feb 2024 12:32:24 +0000 Message-ID: <20240212123233.1230090-3-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: 1790697884646516488 X-GMAIL-MSGID: 1790697884646516488 A common helper is provided to check if a specific protocol message is supported or not. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/driver.c | 34 +++++++++++++++++++++++++++ drivers/firmware/arm_scmi/protocols.h | 4 ++++ 2 files changed, 38 insertions(+) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 3ea64b22cf0d..4a64ad5c21ee 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1754,10 +1754,44 @@ static void scmi_common_fastchannel_db_ring(struct scmi_fc_db_info *db) #endif } +/** + * scmi_protocol_msg_check - Check protocol message attributes + * + * @ph: A reference to the protocol handle. + * @message_id: The ID of the message to check. + * @attributes: A parameter to optionally return the retrieved message + * attributes, in case of Success. + * + * An helper to check protocol message attributes for a specific protocol + * and message pair. + * + * Return: 0 on SUCCESS + */ +static int scmi_protocol_msg_check(const struct scmi_protocol_handle *ph, + u32 message_id, u32 *attributes) +{ + int ret; + struct scmi_xfer *t; + + ret = xfer_get_init(ph, PROTOCOL_MESSAGE_ATTRIBUTES, + sizeof(__le32), 0, &t); + if (ret) + return ret; + + put_unaligned_le32(message_id, t->tx.buf); + ret = do_xfer(ph, t); + if (!ret && attributes) + *attributes = get_unaligned_le32(t->rx.buf); + xfer_put(ph, t); + + return ret; +} + static const struct scmi_proto_helpers_ops helpers_ops = { .extended_name_get = scmi_common_extended_name_get, .iter_response_init = scmi_iterator_init, .iter_response_run = scmi_iterator_run, + .protocol_msg_check = scmi_protocol_msg_check, .fastchannel_init = scmi_common_fastchannel_init, .fastchannel_db_ring = scmi_common_fastchannel_db_ring, }; diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h index e683c26f24eb..26a3edd49fea 100644 --- a/drivers/firmware/arm_scmi/protocols.h +++ b/drivers/firmware/arm_scmi/protocols.h @@ -251,6 +251,8 @@ struct scmi_fc_info { * provided in @ops. * @iter_response_run: A common helper to trigger the run of a previously * initialized iterator. + * @protocol_msg_check: A common helper to check is a specific protocol message + * is supported. * @fastchannel_init: A common helper used to initialize FC descriptors by * gathering FC descriptions from the SCMI platform server. * @fastchannel_db_ring: A common helper to ring a FC doorbell. @@ -264,6 +266,8 @@ struct scmi_proto_helpers_ops { unsigned int max_resources, u8 msg_id, size_t tx_size, void *priv); int (*iter_response_run)(void *iter); + int (*protocol_msg_check)(const struct scmi_protocol_handle *ph, + u32 message_id, u32 *attributes); void (*fastchannel_init)(const struct scmi_protocol_handle *ph, u8 describe_id, u32 message_id, u32 valid_size, u32 domain, From patchwork Mon Feb 12 12:32:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199721 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2396237dyd; Mon, 12 Feb 2024 04:34:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHz4by5nI3DmAIZMlGOUDW6SeNUoxeEHnG6djTm+F2bSmoRp+QXSwy/T5UMKJFFm4En9PPb X-Received: by 2002:a92:d352:0:b0:363:acbc:c106 with SMTP id a18-20020a92d352000000b00363acbcc106mr8355747ilh.18.1707741243876; Mon, 12 Feb 2024 04:34:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741243; cv=pass; d=google.com; s=arc-20160816; b=JGKTrU/yDvRVrl6eESX49YD3rlWto64HX/QNur3tnzUMPIpFeiQjJolZugTmDnKDzq wyZve5f9SK0kRRMSLkkzZLCkYoAC8Dsq9oHuwCuQHOG6O5drfCm21Pjz9AqYOt1YRagY cARoXd/JX21GJ2swBzS5iHJ9LjfZvFxFi/lax92EwGROEf3Ucpal4mM6zZyc+MQkLgpR lLmg0gve4Bghmns/3l8Ih5wlimVP6nIFxkaWNdvGNdgkPxT5xcbUlXtemMFNqOSo2Elo rO2RVIQmqeVHniOpMJ4UH2HDSlwegQxF9U62w/EIyHpMewNC8jLSSdPcWvBmA5EdL0jZ 4fyw== 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=AYRlYkexLw48fkrZoqD3nit2XYTFuaprm95T34c+PGw=; fh=I83D+XcNN+JlEpeDQbNV4BkWbqwK72AMzTMvGzYt0og=; b=qRsVVUVAqoHTdfe/hYQYB0CpadBnwp8yV2iFjArSE4VTsK86WFlDSCt+wMs37surp7 w/V0oz1aKPhMzdU1hQ+oqw8MzZapzG2aUTXrXObfr4q0sloJdUq7x6RlmZjAVi8puiVl 8tZQO6g+lGc6Jqs8+gf/i2ISquXRIS7Yu2dl0CcbLzLeKutus9uf7gIqPkvqXmsRCSIF ZutL7laPPkJUhMSN/X6T51CDZfLIvx1yW9ZcROY+wjs4CW02yhYahWmRzDK9seuE4AXq oHga/DvzVcok9kQlkGpiQl5dsnD61Bc9AdLigzsxID1Whwr+6HyxpDr26juw0K7Gh/CY 5lyw==; 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-61550-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61550-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCWftbQoz/eDJsTZcMGeW0q5MfKzy7jMEUrXe0dtRFZkLUqGaNmMZucPPLvGfyYoGs7GK84VBaffgkoZ4TsXXzpzMxCynQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id m185-20020a6326c2000000b005dc1330fadcsi186073pgm.6.2024.02.12.04.34.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:34:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61550-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-61550-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61550-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9FE39287E25 for ; Mon, 12 Feb 2024 12:34:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 66EB93A8F0; Mon, 12 Feb 2024 12:33:10 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2EBD43A1B2 for ; Mon, 12 Feb 2024 12:33:06 +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=1707741188; cv=none; b=XVIy+3IwOFiCKcZ7wIvXs7z9bDdQftDsWqy1CObDbuwe21F4f+CRfj19PrQcSP4ANE4R89CiaYFb+YoqHLOYtQ9i9urP++A25pwQlyd5fdDDuT2vuDKJDtGnipZ2o/If9PYXNRxMga72lOc6DnTi0+TSeAE+rRD4jdlazxjIaFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741188; c=relaxed/simple; bh=evkNOnm5oC5eo6hVIW+ZaWP1k6EADRqFYfcbNt8e4+o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IqnjS9ZMFgga2C7cAi2zJaqtvZX9SdgwmNwbZQrfcwWxuHFjITpHJxf4JUpmQu6ETBdtFrisBx+olxrrb5ZTaTQUFwyA98yyL26QY34NbYKTu/hMXp21eSyabzIz/limN0b+12bYMi+qSZ8aSw+aF3WNR719c9YbIlayELvK/y8= 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 A6B2911FB; Mon, 12 Feb 2024 04:33:47 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D7C1B3F7BD; Mon, 12 Feb 2024 04:33:04 -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 03/11] firmware: arm_scmi: Implement Perf .is_notify_supported callback Date: Mon, 12 Feb 2024 12:32:25 +0000 Message-ID: <20240212123233.1230090-4-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: 1790696482555438893 X-GMAIL-MSGID: 1790696482555438893 Add a preliminary check to verify if Perf-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/perf.c | 45 +++++++++++++++++++++++++++++--- 1 file changed, 42 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 9e7b1ee94940..2627ace5b07f 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -182,6 +182,8 @@ struct scmi_perf_info { enum scmi_power_scale power_scale; u64 stats_addr; u32 stats_size; + bool notify_lvl_cmd; + bool notify_lim_cmd; struct perf_dom_info *dom_info; }; @@ -222,6 +224,15 @@ static int scmi_perf_attributes_get(const struct scmi_protocol_handle *ph, } ph->xops->xfer_put(ph, t); + + if (!ret) { + if (!ph->hops->protocol_msg_check(ph, PERF_NOTIFY_LEVEL, NULL)) + pi->notify_lvl_cmd = true; + + if (!ph->hops->protocol_msg_check(ph, PERF_NOTIFY_LIMITS, NULL)) + pi->notify_lim_cmd = true; + } + return ret; } @@ -239,6 +250,7 @@ static void scmi_perf_xa_destroy(void *data) static int scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, struct perf_dom_info *dom_info, + bool notify_lim_cmd, bool notify_lvl_cmd, u32 version) { int ret; @@ -260,8 +272,12 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, dom_info->set_limits = SUPPORTS_SET_LIMITS(flags); dom_info->info.set_perf = SUPPORTS_SET_PERF_LVL(flags); - dom_info->perf_limit_notify = SUPPORTS_PERF_LIMIT_NOTIFY(flags); - dom_info->perf_level_notify = SUPPORTS_PERF_LEVEL_NOTIFY(flags); + if (notify_lim_cmd) + dom_info->perf_limit_notify = + SUPPORTS_PERF_LIMIT_NOTIFY(flags); + if (notify_lvl_cmd) + dom_info->perf_level_notify = + SUPPORTS_PERF_LEVEL_NOTIFY(flags); dom_info->perf_fastchannels = SUPPORTS_PERF_FASTCHANNELS(flags); if (PROTOCOL_REV_MAJOR(version) >= 0x4) dom_info->level_indexing_mode = @@ -993,6 +1009,27 @@ static const struct scmi_perf_proto_ops perf_proto_ops = { .power_scale_get = scmi_power_scale_get, }; +static bool scmi_perf_notify_supported(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id) +{ + bool supported; + struct perf_dom_info *dom; + + if (evt_id >= ARRAY_SIZE(evt_2_cmd)) + return false; + + dom = scmi_perf_domain_lookup(ph, src_id); + if (IS_ERR(dom)) + return false; + + if (evt_id == SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED) + supported = dom->perf_limit_notify; + else + supported = dom->perf_level_notify; + + return supported; +} + static int scmi_perf_set_notify_enabled(const struct scmi_protocol_handle *ph, u8 evt_id, u32 src_id, bool enable) { @@ -1082,6 +1119,7 @@ static const struct scmi_event perf_events[] = { }; static const struct scmi_event_ops perf_event_ops = { + .is_notify_supported = scmi_perf_notify_supported, .get_num_sources = scmi_perf_get_num_sources, .set_notify_enabled = scmi_perf_set_notify_enabled, .fill_custom_report = scmi_perf_fill_custom_report, @@ -1126,7 +1164,8 @@ static int scmi_perf_protocol_init(const struct scmi_protocol_handle *ph) struct perf_dom_info *dom = pinfo->dom_info + domain; dom->id = domain; - scmi_perf_domain_attributes_get(ph, dom, version); + scmi_perf_domain_attributes_get(ph, dom, pinfo->notify_lim_cmd, + pinfo->notify_lvl_cmd, version); scmi_perf_describe_levels_get(ph, dom, version); if (dom->perf_fastchannels) From patchwork Mon Feb 12 12:32:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199734 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2406186dyd; Mon, 12 Feb 2024 04:56:50 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVFNi33EzThDFunbv50SXnZSw22lvLsuaxr3ygi3L+JlzRSXeKhe5aSPpTKHUgCzbopSBe+CI7/clRo7ytDU9Fz56JjSA== X-Google-Smtp-Source: AGHT+IFBK6OAWlodITqdAK7qEebYET2VlO7W3rdypQRrvZz1ksJoC1naQkL3Hfc7AOo7xYQ2njqe X-Received: by 2002:a05:6a21:1690:b0:19a:4935:458 with SMTP id np16-20020a056a21169000b0019a49350458mr4821752pzb.35.1707742610156; Mon, 12 Feb 2024 04:56:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707742610; cv=pass; d=google.com; s=arc-20160816; b=PojrSygtbLfIhG8Mw5r0k+uVSmwYV/sn5Kjz43tZVS3vmljVO0Nb+JFYyhW3/CtZRz zQac1RvQFovuqSCVJA9sh0NAnIQ2iewlIMkdpannXYr/3HWsFnyJi5iNEITvfEFAJMFY SoYElplKyrjuXRJpaS91q+cyeU4bSn69Q/T6zc4QhSVieDuU8RVSsJtE+X83IzybUG18 jMQ5JGe+gvz1MHhkt8MH+9TczaG/0+2dSk1RwLmem5CHVrx1bquUaRBOT4qWnH/SLE33 l9X5UROzJO1JBBLjNVZFZ3+pxdRci+KSlP6eXA7So0k48sskn/f5kSSrwX8FNTyN6GWT 9aAQ== 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=rGJznXavVRtt8pRYdUom1+CjcyqlBikof9anUmkyzd8=; fh=ZbXavK2zXPCExZLEuMu8b3ppb92TKE6dwRoUYEVmm3c=; b=NxkP5xi3ftzxTnDRdzwcpmdLCUHIPyIVMn38IYRvsJTTpQok/evyK3zzGWfc95s9+7 +OvDiHv6B3zKla2wZcU7F7JReqhC+sxn96bbgE6wRHt/GdzQR4FL41ngEk9rz5CHIuqC zKyM5oN5SMxL74BubYjCaq/OG54YVSHlY/AM80quxTjrT3LLCpphMVa0eRocbpPOvNM8 vHUAtM0XmqxFQOAuHIoFmBxwJWZe/Tk5LWu+YHjcNB9XGvm9mMWorv0SVVJQprTU0SWs wNxBkdBBtz8HuwjUY873m8Hc+/TbAGXloY7fgGKRQ2aaCxk7NHXSOaRm0jtOCqxAtozX qXXw==; 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-61551-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61551-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCVT4Qd25t+IdLRli9huPOuukhTGceglP/niRZScU2HvzOHeaNl6BOxUEGpbZPDWzaHt6IcU4AbUal26lardxGElZaiJXQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id nl16-20020a17090b385000b00296c2af4c0bsi258789pjb.23.2024.02.12.04.56.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:56:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61551-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-61551-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61551-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 87BE1B248BA for ; Mon, 12 Feb 2024 12:34:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7FEED3B18A; Mon, 12 Feb 2024 12:33:11 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 345423A28B for ; Mon, 12 Feb 2024 12:33:08 +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=1707741190; cv=none; b=BJ1OsseFgKSScg3gaOgceaJ9B5pG5Hg0z+3BWLRpon8o7gGcVbb9MwOhJhofGaS4fHmdTYL43bysDzl8uVyo/cIRVoZbTEhnokwao4Tt91n2jzljJneiTf0Sd4Ui2ZGSBHapaDgwB2aLx0vBGtyiXXBb/0rgm/C2NykGSCmfTzU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741190; c=relaxed/simple; bh=EhRH6wggF4z9GA3aEnVE+YklK9O9votDc8JnIxKAR8g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qCZn9vISN80DdUu6drMcMtw31ojgjDonobnjHPxmDLEbiY88PcfotED3Y7U1v61HPkpRmJFPa7RkfRyUvzkp4WQlymcrpsZk0jMZ+eKSCXQPtfGEhr2Uzo5abvkhWYbqrHmGxcQqVgI4zJP0V5vjpQY/x844VTEEE6ucgP7y+2U= 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 59F7F139F; Mon, 12 Feb 2024 04:33:49 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 8BB033F7BD; Mon, 12 Feb 2024 04:33:06 -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 04/11] firmware: arm_scmi: Implement Power .is_notify_supported callback Date: Mon, 12 Feb 2024 12:32:26 +0000 Message-ID: <20240212123233.1230090-5-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: 1790697915455772270 X-GMAIL-MSGID: 1790697915455772270 Add a preliminary check to verify if Power-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/power.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_scmi/power.c b/drivers/firmware/arm_scmi/power.c index c2e6b9b4d941..49666bd1d8ac 100644 --- a/drivers/firmware/arm_scmi/power.c +++ b/drivers/firmware/arm_scmi/power.c @@ -68,6 +68,7 @@ struct power_dom_info { struct scmi_power_info { u32 version; + bool notify_state_change_cmd; int num_domains; u64 stats_addr; u32 stats_size; @@ -97,13 +98,18 @@ static int scmi_power_attributes_get(const struct scmi_protocol_handle *ph, } ph->xops->xfer_put(ph, t); + + if (!ret) + if (!ph->hops->protocol_msg_check(ph, POWER_STATE_NOTIFY, NULL)) + pi->notify_state_change_cmd = true; + return ret; } static int scmi_power_domain_attributes_get(const struct scmi_protocol_handle *ph, u32 domain, struct power_dom_info *dom_info, - u32 version) + u32 version, bool notify_state_change_cmd) { int ret; u32 flags; @@ -122,7 +128,9 @@ scmi_power_domain_attributes_get(const struct scmi_protocol_handle *ph, if (!ret) { flags = le32_to_cpu(attr->flags); - dom_info->state_set_notify = SUPPORTS_STATE_SET_NOTIFY(flags); + if (notify_state_change_cmd) + dom_info->state_set_notify = + SUPPORTS_STATE_SET_NOTIFY(flags); dom_info->state_set_async = SUPPORTS_STATE_SET_ASYNC(flags); dom_info->state_set_sync = SUPPORTS_STATE_SET_SYNC(flags); strscpy(dom_info->name, attr->name, SCMI_SHORT_NAME_MAX_SIZE); @@ -231,6 +239,20 @@ static int scmi_power_request_notify(const struct scmi_protocol_handle *ph, return ret; } +static bool scmi_power_notify_supported(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id) +{ + struct power_dom_info *dom; + struct scmi_power_info *pinfo = ph->get_priv(ph); + + if (evt_id != SCMI_EVENT_POWER_STATE_CHANGED || + src_id >= pinfo->num_domains) + return false; + + dom = pinfo->dom_info + src_id; + return dom->state_set_notify; +} + static int scmi_power_set_notify_enabled(const struct scmi_protocol_handle *ph, u8 evt_id, u32 src_id, bool enable) { @@ -285,6 +307,7 @@ static const struct scmi_event power_events[] = { }; static const struct scmi_event_ops power_event_ops = { + .is_notify_supported = scmi_power_notify_supported, .get_num_sources = scmi_power_get_num_sources, .set_notify_enabled = scmi_power_set_notify_enabled, .fill_custom_report = scmi_power_fill_custom_report, @@ -326,7 +349,8 @@ static int scmi_power_protocol_init(const struct scmi_protocol_handle *ph) for (domain = 0; domain < pinfo->num_domains; domain++) { struct power_dom_info *dom = pinfo->dom_info + domain; - scmi_power_domain_attributes_get(ph, domain, dom, version); + scmi_power_domain_attributes_get(ph, domain, dom, version, + pinfo->notify_state_change_cmd); } pinfo->version = version; From patchwork Mon Feb 12 12:32:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199722 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2396443dyd; Mon, 12 Feb 2024 04:34:28 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV4zrF/OitJGqgCliV7EgM+EqSWZGXt1qDYaDTVvWA31KU9TvckFrSWsZEt9lXrZ5wchMNVOl4SWABe8VeC6yJgNSvZGA== X-Google-Smtp-Source: AGHT+IHpIpm6llg0Dc4InhPoyDtlP4BWQMQpyWV/SH4NNsshAiF7E6mmmzizNxljx/B/aJgPTnoh X-Received: by 2002:a25:aba3:0:b0:dcb:d0cb:651e with SMTP id v32-20020a25aba3000000b00dcbd0cb651emr228396ybi.28.1707741268276; Mon, 12 Feb 2024 04:34:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741268; cv=pass; d=google.com; s=arc-20160816; b=ivulK+kwdELDgBGhkXAuFZksZZ1DDS9B1wfoN8yCwEAhxwbFgK7kA+BYgYBDyLeLdK wm/6wnH182fXGq4NMT0YNBPtUsuQ3cZHveDtitvgejr29qNPJ0T5W/XhkwRssCXgMBSP 3nikPvwKaJ9c1rncJs0rUOoIiY8WDWSB8yTP3O0zWha9rIMQByEP+YhYUksj2s1+XXeQ oIJIPJHn7RAnWgiXWRJZKCR+TZQ2kPALX3kSHBc7EH3vU+kfNSUyHTy43vtrxH1mFMJ1 aZ3uApf7di9bPqZ/WZM1jhg0Xj/PJ9d2kAJK/3BSXx12NTAVsdIP3bzBWIm3wj9oRBUm rEfg== 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=Rz5V9PvHLAZWEa2512fNA9JSbGQG1DJqUC3OSS6wcpQ=; fh=havvmS2fhYzhajfcJMDawEU+WajyE7s/axGyKTCUiAE=; b=C7DTYFmMgxw2Wm3bb5KKflPHgZOcS+lv4mJam14+zZA0IFIjMvy+pYEWi9uyI7Nd04 YhntXxV8pK9aFOGrxagPyaWeV8WMD0tXL8D1qmch6bCKDC+x8DQkRyysfFPQFKWV37qr uC7zQ/30rSMVMe7m+7/eJ5qFxUc/sv9FkbS81kWMRN6qh5AX1Aeo0Ep/5+D5ogO/R02D zLwQ/Eel5sgRUzEs1lIVROdayJNJs00fUEGEdpGeMGWK2RhQknWeq4s1G9bHRAoYBJTs mThelVZFW8Mtswu4bKh+QUMgW/MhJBXV1I8U8lYhZnCxpQHKT4f4RS9DWmudIwIMLX8e Kw+Q==; 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-61552-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61552-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCV4ZfwMUF3RK3m0fqmXAiflXBdWiCsk0zVTdbqBYMoqEwrv00yJD31RySh2tSi5CDO0s6yfUjaSoStypbv5h+T7M0yM5A== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id hf5-20020a0562140e8500b0068cb008e834si268933qvb.78.2024.02.12.04.34.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:34:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61552-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-61552-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61552-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 14ADF1C21E85 for ; Mon, 12 Feb 2024 12:34:28 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AE5033B29A; Mon, 12 Feb 2024 12:33:12 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CEAF33A8DE for ; Mon, 12 Feb 2024 12:33:09 +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=1707741191; cv=none; b=HhWIC5OEMG4jdsDy0pvuMzVFvYPxh+zZfETopzW10xM6tpsNNn2uEkTaaNtk3qb+v6YY4HSHJGIG/0P+KxjOhdvhgjsvJQH0VNfBbHGU1JTToURh4VvSL8DJqOoB8ggY9JbqcCuLsjqpwJCLMAcRaosrpHqG6W2wghH638IpwbA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741191; c=relaxed/simple; bh=jVHR1bg6dtwxToygY7pKHGPE6Yy7UaPmdSrAUqoo5JE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d7h14M6nRjbHbtALn8FjOr/uHqXZCKPD0Uobt4S+PJxxzrus/LTBpHTaMIDav1vHxYsIQ7WRkWpa5VaLZOncJw+AoAy0tGL5Cw6ZCcbNkROu7/enAoRtjrC6rsLedDSHoCJe8ctLHDhgCYNIMpXJYP+DvYSKzizzAPF1vY60W7o= 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 0D2131063; Mon, 12 Feb 2024 04:33:51 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 3F0ED3F7BD; Mon, 12 Feb 2024 04:33:08 -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 05/11] firmware: arm_scmi: Implement SysPower .is_notify_supported callback Date: Mon, 12 Feb 2024 12:32:27 +0000 Message-ID: <20240212123233.1230090-6-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: 1790696508038218599 X-GMAIL-MSGID: 1790696508038218599 Add a preliminary check to verify if SysPower-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/system.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/firmware/arm_scmi/system.c b/drivers/firmware/arm_scmi/system.c index 1621da97bcbb..b6358c155f7f 100644 --- a/drivers/firmware/arm_scmi/system.c +++ b/drivers/firmware/arm_scmi/system.c @@ -36,8 +36,20 @@ struct scmi_system_power_state_notifier_payld { struct scmi_system_info { u32 version; bool graceful_timeout_supported; + bool power_state_notify_cmd; }; +static bool scmi_system_notify_supported(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id) +{ + struct scmi_system_info *pinfo = ph->get_priv(ph); + + if (evt_id != SCMI_EVENT_SYSTEM_POWER_STATE_NOTIFIER) + return false; + + return pinfo->power_state_notify_cmd; +} + static int scmi_system_request_notify(const struct scmi_protocol_handle *ph, bool enable) { @@ -114,6 +126,7 @@ static const struct scmi_event system_events[] = { }; static const struct scmi_event_ops system_event_ops = { + .is_notify_supported = scmi_system_notify_supported, .set_notify_enabled = scmi_system_set_notify_enabled, .fill_custom_report = scmi_system_fill_custom_report, }; @@ -147,6 +160,9 @@ static int scmi_system_protocol_init(const struct scmi_protocol_handle *ph) if (PROTOCOL_REV_MAJOR(pinfo->version) >= 0x2) pinfo->graceful_timeout_supported = true; + if (!ph->hops->protocol_msg_check(ph, SYSTEM_POWER_STATE_NOTIFY, NULL)) + pinfo->power_state_notify_cmd = true; + return ph->set_priv(ph, pinfo, version); } From patchwork Mon Feb 12 12:32:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199723 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2396567dyd; Mon, 12 Feb 2024 04:34:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVEzZ0GyWRyTaCWXuyq39D80hGAwOSaX8MNzHYLoWQ/GW0KbqG1otCnXlOI4ANdITM4tNGkh0+n76HqUEreR6fuQnDa6Q== X-Google-Smtp-Source: AGHT+IEI715ml77yktcg9OD/DRv60Qd5cyxXO8j+pK300ve7Zh/ybvILTyjstj/bSRWkwfYHuRmO X-Received: by 2002:a05:6808:e83:b0:3bf:dff4:7055 with SMTP id k3-20020a0568080e8300b003bfdff47055mr8594727oil.50.1707741281939; Mon, 12 Feb 2024 04:34:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741281; cv=pass; d=google.com; s=arc-20160816; b=giMFoJX9AgDUnv6vXHKK3a0rj3/I/ZcEM/AsXo2neVUytP2V8ocCnz0QimUXIgdrCd SuNUIIQ5G207yxT9QXGSnknwEgAE3S4z3rGcADxwnEuz9VXhvAvC2CL333mv4pTazKrm SbNOXJzoMoz+SO3HMf9gpCD1mU+KdQojB5Cgp6P45+t+IOT83v+pyOCZaqtaa/ibU2yK cjr867I72ANFmqUH4WZ0GAluPLWxKaR3p9bSEe/3k+CXD8xDSJ1IWXv7UmaQtSuO9XYC D7QGhFj5pSul260dXD6zb8s+JQOpa+KOneRbzdqsxbzZu5Et/oCHy9a9+YQxo7ZWFiMa Npzg== 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=UIXaQnYGuYn463J/HrrObW/VqGSjTYYl1K0SBunCh9c=; fh=7B3+aRCMcrCkp6CQ7eVC5cPy2yt7BzCxA6NebWMgk0A=; b=UcNNcJwX6xGsJefJBMo9hF3VTL/jHg8VZM5976qbwWPI+q+GZEfmtL8x/cXyHnDqpl 0aKXuzJ2O0zFEvXCZqiW/RZvE5Oq7B9OdD7SoI4KSOdW2o9FmKRcjLzf3ZMROxGVX8Zd D8Pgu2i6gPRVRhIqXmvNoYL3IyMTVbU/BQ/vvdJeQlLmT134IXdDk7M3M9BT8hga8t+X 17zABEiOGGn5fZeYnbyhzHEWCO1fOxSyCFbHDbOfAWoSHbmry8btBEgKNXg1Ljcjv8GQ lIQDEutEQ0rMi3QAiMsMh1XzF9rcVmlPyiC22r5H9k66915Ak/SGP3qsYR2OnwEQ3ZAy CQvQ==; 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-61553-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61553-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCXcxopHRup8erhsoy630rggnAZBdW2lfFYE4UuhcM5pPQreSeGX36+UeMb11UIxz6BPGMfCdW8Lg20d3OgreuFPMqN1nQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id az44-20020a05620a172c00b00785da900320si944529qkb.78.2024.02.12.04.34.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:34:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61553-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; 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-61553-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61553-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id B4B051C2123C for ; Mon, 12 Feb 2024 12:34:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0ECA23B799; Mon, 12 Feb 2024 12:33:15 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C16BA3B199 for ; Mon, 12 Feb 2024 12:33:11 +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=1707741193; cv=none; b=r+VwA7q8iy3QZGofR3c9nG9QTvzhWqVn2Q1w0oK43jLOOS4Vp7swI7kZfApFuSNozU+6I7MbCRxweuyYaPoZdd60VwAcjEVHzDZF9epelslcvYZrRNX0N6xuweW9J069Jjdd+7g+ChKdo36dbfQNFc99YKN4uTbT/pyPtqIecHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741193; c=relaxed/simple; bh=0FGhoxplAJ+IDq58QH5NR/n1OkM218I0PRVsLtbpa/k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ARN8KlSNkwOYZ8+jcDgw1jpOj9OugSoM2uxPsJgloeg9aHj4o4Cueoy7XDO/KD8vNvNeJuWep2mmccak3vjvhN7IWj/IQOMghGROrO2E0GTljQLM5D/0nWgW5Bj1V4WxfCeOvD1svn7RkzxZlUwuKpda9nPHBRNXbSh+X+krZ3o= 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 B5EC8FEC; Mon, 12 Feb 2024 04:33:52 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E72233F7BD; Mon, 12 Feb 2024 04:33:09 -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 06/11] firmware: arm_scmi: Implement Clock .is_notify_supported callback Date: Mon, 12 Feb 2024 12:32:28 +0000 Message-ID: <20240212123233.1230090-7-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: 1790696522605268175 X-GMAIL-MSGID: 1790696522605268175 Add a preliminary check to verify if Clock-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/clock.c | 47 ++++++++++++++++++++++++++++--- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_scmi/clock.c b/drivers/firmware/arm_scmi/clock.c index 959e48aba1b5..85eda5db40ba 100644 --- a/drivers/firmware/arm_scmi/clock.c +++ b/drivers/firmware/arm_scmi/clock.c @@ -158,6 +158,8 @@ struct clock_info { u32 version; int num_clocks; int max_async_req; + bool notify_rate_changed_cmd; + bool notify_rate_change_requested_cmd; atomic_t cur_async_req; struct scmi_clock_info *clk; int (*clock_config_set)(const struct scmi_protocol_handle *ph, @@ -204,6 +206,17 @@ scmi_clock_protocol_attributes_get(const struct scmi_protocol_handle *ph, } ph->xops->xfer_put(ph, t); + + if (!ret) { + if (!ph->hops->protocol_msg_check(ph, CLOCK_RATE_NOTIFY, NULL)) + ci->notify_rate_changed_cmd = true; + + if (!ph->hops->protocol_msg_check(ph, + CLOCK_RATE_CHANGE_REQUESTED_NOTIFY, + NULL)) + ci->notify_rate_change_requested_cmd = true; + } + return ret; } @@ -329,13 +342,14 @@ scmi_clock_get_permissions(const struct scmi_protocol_handle *ph, u32 clk_id, } static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, - u32 clk_id, struct scmi_clock_info *clk, + u32 clk_id, struct clock_info *cinfo, u32 version) { int ret; u32 attributes; struct scmi_xfer *t; struct scmi_msg_resp_clock_attributes *attr; + struct scmi_clock_info *clk = cinfo->clk + clk_id; ret = ph->xops->xfer_get_init(ph, CLOCK_ATTRIBUTES, sizeof(clk_id), sizeof(*attr), &t); @@ -368,9 +382,11 @@ static int scmi_clock_attributes_get(const struct scmi_protocol_handle *ph, NULL, clk->name, SCMI_MAX_STR_SIZE); - if (SUPPORTS_RATE_CHANGED_NOTIF(attributes)) + if (cinfo->notify_rate_changed_cmd && + SUPPORTS_RATE_CHANGED_NOTIF(attributes)) clk->rate_changed_notifications = true; - if (SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(attributes)) + if (cinfo->notify_rate_change_requested_cmd && + SUPPORTS_RATE_CHANGE_REQUESTED_NOTIF(attributes)) clk->rate_change_requested_notifications = true; if (SUPPORTS_PARENT_CLOCK(attributes)) scmi_clock_possible_parents(ph, clk_id, clk); @@ -896,6 +912,28 @@ static const struct scmi_clk_proto_ops clk_proto_ops = { .parent_get = scmi_clock_get_parent, }; +static bool scmi_clk_notify_supported(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id) +{ + bool supported; + struct scmi_clock_info *clk; + struct clock_info *ci = ph->get_priv(ph); + + if (evt_id >= ARRAY_SIZE(evt_2_cmd)) + return false; + + clk = scmi_clock_domain_lookup(ci, src_id); + if (IS_ERR(clk)) + return false; + + if (evt_id == SCMI_EVENT_CLOCK_RATE_CHANGED) + supported = clk->rate_changed_notifications; + else + supported = clk->rate_change_requested_notifications; + + return supported; +} + static int scmi_clk_rate_notify(const struct scmi_protocol_handle *ph, u32 clk_id, int message_id, bool enable) { @@ -980,6 +1018,7 @@ static const struct scmi_event clk_events[] = { }; static const struct scmi_event_ops clk_event_ops = { + .is_notify_supported = scmi_clk_notify_supported, .get_num_sources = scmi_clk_get_num_sources, .set_notify_enabled = scmi_clk_set_notify_enabled, .fill_custom_report = scmi_clk_fill_custom_report, @@ -1021,7 +1060,7 @@ static int scmi_clock_protocol_init(const struct scmi_protocol_handle *ph) for (clkid = 0; clkid < cinfo->num_clocks; clkid++) { struct scmi_clock_info *clk = cinfo->clk + clkid; - ret = scmi_clock_attributes_get(ph, clkid, clk, version); + ret = scmi_clock_attributes_get(ph, clkid, cinfo, version); if (!ret) scmi_clock_describe_rates_get(ph, clkid, clk); } 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, From patchwork Mon Feb 12 12:32:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199725 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2396823dyd; Mon, 12 Feb 2024 04:35:12 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVpPrWyj/Yruj/R8nBioxTxFWXRm2q1UGe8A41BGN4GFakRWRZAITlJOrRi048liRasnurIi5vGeftdTHPTBpjAiXpqFg== X-Google-Smtp-Source: AGHT+IGXvcIXQJxWGUl9YbGpwojGIRa+upPRfCTGtsXIJptoP6LHY+X9xjVhfb0lA4DH6G7xxwHC X-Received: by 2002:a17:906:29c8:b0:a3c:b23a:9491 with SMTP id y8-20020a17090629c800b00a3cb23a9491mr1244892eje.19.1707741312120; Mon, 12 Feb 2024 04:35:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741312; cv=pass; d=google.com; s=arc-20160816; b=xYy3QhMoTqraWkslm5/ZApmwwL17BZmy6UlMKCVw3VETdVAakE/nPzDpoai1ZvBuFd pFWw9YupSazz31ba8i2KbD6WGVGJuNN3c85IDBa/xRZYyx7rItjrWMiAh6q4618fWB7u ZIJPOrjiMTIZ1Lv9nBO/CQEKqczCS9exDrRzmpxw2N/DuCXARjHEbhjDzltedTVYEdHH qgC9n+3oPXAFQwc6YqxUb6Pn94VW4EQTYhlDKs+6IF6U5/T+559o/1h0OnmUFShvVV4z 3QUyxKz5a4vuq8xPk3hWyCjxM9QexRpVktoodje0/EhH5ig1Tc3RYRrsjFEmtfAJsa1M qBUA== 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=EURRDnZZgYwdX85h6fkCX6nHnAYH2BU/NBP2OcIDdgc=; fh=HO2HGx7cPD5rE993n9KuWLWNxf5PCQ/6tGZXjZ72+44=; b=gX2pIMY7bil0hPx/VNMJnQ4wywVQaJN0mvuJNJusBxErh4C8c56c64AYLszpqhECuP MaCfuVR6GSTXBsxYEtrlzNRF3j9uW7DdJWrlYJiVzfP47b9LlgGrLoBiKyD5eeyWB/Je ys8tjZKgR7ub1HTRJXfpurUgJthymvK7qEnIpytSrllY05WdQ327QTQKirC9TlR24slL VDU95OTMkZ/61seB/1xPnAI1pDpCBd3lphHz7RdwaHciXSTVkBBjm8QMpL3DtafIVrGJ KPzGOc03WZXkfik7KPP3+fPC7Af+8AHUG4bSWiEP9vObr8TShKUcSRPZ+Wknz3Q2XWE0 Li/g==; 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-61555-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61555-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCW5Q5Xk5N3ZTrrTfEEfZIq44qK7AeBYDStvY658YGmd2S5tlNvFNzw6YdZfHLXkm9MUPGcc67f61FaROKNPZZWoasXszQ== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gs11-20020a170906f18b00b00a35bc1443f2si152624ejb.42.2024.02.12.04.35.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:35:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61555-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-61555-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61555-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 B7F121F26144 for ; Mon, 12 Feb 2024 12:35:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D5BD3C469; Mon, 12 Feb 2024 12:33:18 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 813113BB29 for ; Mon, 12 Feb 2024 12:33:15 +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=1707741197; cv=none; b=MGk7g86Zh87tDJUmJVLMoFW/kxqytQvbwk2RCAdpdaqVptx3FBzIUiEA5egAXHWIFRahNoNzqBeVqbZZtH77xuqNJlu66TZuLAjKvIJ893Bzx/EZR8QCpEFnThPTU6wyykAqT7WOXUCdWFobPH9RFbXJWmb9pBcKmbEO4y8JAcY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741197; c=relaxed/simple; bh=7MvD/ch+A5tGqG+rlOGbr5Kpr5QHYnQ1tNmpJNxdDFk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uP5W9MJezjfIax+fF335y5RZ30jtfzS1lX2NOdYO8lREqZwhOO+yJdyqobP4doUdvbLZy5PW9cuzps6BC6DvTngWIOOHJrz8S8B7VXLwJFW8C4VO4Ti5xoQpby3W40vS2j2DusONWDASnwGRxFasoQCvFXT6O35HSqz/+yEoSik= 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 1D34911FB; Mon, 12 Feb 2024 04:33:56 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4E3103F7BD; Mon, 12 Feb 2024 04:33:13 -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 08/11] firmware: arm_scmi: Implement Reset .is_notify_supported callback Date: Mon, 12 Feb 2024 12:32:30 +0000 Message-ID: <20240212123233.1230090-9-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: 1790696554328483073 X-GMAIL-MSGID: 1790696554328483073 Add a preliminary check to verify if Reset-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/reset.c | 37 ++++++++++++++++++++++++------- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/arm_scmi/reset.c b/drivers/firmware/arm_scmi/reset.c index 19970d9f9e36..1b318316535e 100644 --- a/drivers/firmware/arm_scmi/reset.c +++ b/drivers/firmware/arm_scmi/reset.c @@ -67,6 +67,7 @@ struct reset_dom_info { struct scmi_reset_info { u32 version; int num_domains; + bool notify_reset_cmd; struct reset_dom_info *dom_info; }; @@ -89,18 +90,24 @@ static int scmi_reset_attributes_get(const struct scmi_protocol_handle *ph, } ph->xops->xfer_put(ph, t); + + if (!ret) + if (!ph->hops->protocol_msg_check(ph, RESET_NOTIFY, NULL)) + pi->notify_reset_cmd = true; + return ret; } static int scmi_reset_domain_attributes_get(const struct scmi_protocol_handle *ph, - u32 domain, struct reset_dom_info *dom_info, - u32 version) + struct scmi_reset_info *pinfo, + u32 domain, u32 version) { int ret; u32 attributes; struct scmi_xfer *t; struct scmi_msg_resp_reset_domain_attributes *attr; + struct reset_dom_info *dom_info = pinfo->dom_info + domain; ret = ph->xops->xfer_get_init(ph, RESET_DOMAIN_ATTRIBUTES, sizeof(domain), sizeof(*attr), &t); @@ -115,7 +122,9 @@ scmi_reset_domain_attributes_get(const struct scmi_protocol_handle *ph, attributes = le32_to_cpu(attr->attributes); dom_info->async_reset = SUPPORTS_ASYNC_RESET(attributes); - dom_info->reset_notify = SUPPORTS_NOTIFY_RESET(attributes); + if (pinfo->notify_reset_cmd) + dom_info->reset_notify = + SUPPORTS_NOTIFY_RESET(attributes); dom_info->latency_us = le32_to_cpu(attr->latency); if (dom_info->latency_us == U32_MAX) dom_info->latency_us = 0; @@ -226,6 +235,20 @@ static const struct scmi_reset_proto_ops reset_proto_ops = { .deassert = scmi_reset_domain_deassert, }; +static bool scmi_reset_notify_supported(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id) +{ + struct reset_dom_info *dom; + struct scmi_reset_info *pi = ph->get_priv(ph); + + if (evt_id != SCMI_EVENT_RESET_ISSUED || src_id >= pi->num_domains) + return false; + + dom = pi->dom_info + src_id; + + return dom->reset_notify; +} + static int scmi_reset_notify(const struct scmi_protocol_handle *ph, u32 domain_id, bool enable) { @@ -301,6 +324,7 @@ static const struct scmi_event reset_events[] = { }; static const struct scmi_event_ops reset_event_ops = { + .is_notify_supported = scmi_reset_notify_supported, .get_num_sources = scmi_reset_get_num_sources, .set_notify_enabled = scmi_reset_set_notify_enabled, .fill_custom_report = scmi_reset_fill_custom_report, @@ -339,11 +363,8 @@ static int scmi_reset_protocol_init(const struct scmi_protocol_handle *ph) if (!pinfo->dom_info) return -ENOMEM; - for (domain = 0; domain < pinfo->num_domains; domain++) { - struct reset_dom_info *dom = pinfo->dom_info + domain; - - scmi_reset_domain_attributes_get(ph, domain, dom, version); - } + for (domain = 0; domain < pinfo->num_domains; domain++) + scmi_reset_domain_attributes_get(ph, pinfo, domain, version); pinfo->version = version; return ph->set_priv(ph, pinfo, version); From patchwork Mon Feb 12 12:32:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199726 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2396944dyd; Mon, 12 Feb 2024 04:35:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IGrv0tVSN+D+1wswjUhYalwbTPkH2QpipqEalCMovxEINzEyelHeOHqRCAnhFusAUxcmPQ4 X-Received: by 2002:a17:906:48ce:b0:a3c:9a4e:101d with SMTP id d14-20020a17090648ce00b00a3c9a4e101dmr1873472ejt.33.1707741324201; Mon, 12 Feb 2024 04:35:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741324; cv=pass; d=google.com; s=arc-20160816; b=KxtKUPogcoWaI4v90BBnP5WrMEJ8rwKAJCOJ/gfhJaVrpIr07VJ71cpUVFM7sHeadV hANkykr+AZE6vfRRSl4ONuQGKDmlig9kMNMRTkgNGNRkbb7Ntjmf0zQouPvyHMbgvjOR DFXSbOk6X+mCdmtT1cHpceeuzr++f2oZiYJAv1H2xQCzDTfXe0fzgbdp6iscwpa+5bfm rOUIkq+RT1TH/2VIVYZ8YFfbWfpa1TqlzqbA62U93qq8uEJ34p9KnrlIPzCBu5dEz9js OmCLx8Lx/xnvJkL03LONFneXlejH3luxhBXF5W/9QBP34bRICZHCa25JQdoaF/Jt1ckn 218Q== 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=sSyxay/YR1dwOXjCEpqsnpVcTPMGQKDgw5OBG+BlqHw=; fh=CTGZf+kcotVsKgOXo/5jja9pQNPeIrKu8X0n0SPELko=; b=gr/cXkfXdRFx7npYcp7xn04xBhr6G2h7mKz8bh8BW65oADsRg0Qmu0McOwDxfYCkUr P1LXMm1taELhNZ/m/In2K2EftcopZ2ud6XBN62M2icjqOdbn47f19Nfwk/98fI/p2SyV QAER65XGASrLlSuT8bSyDnDeSZMnVEDKip8tjPxowbCpmfim7PhkSilwi7ZMOubwcuRx /MYMV4CmFJD43dGYlhwLqiZVdzxLy8S28SWqRcD6JxGvK3/4Bq/rlVTQCRTNyjpOT+YU leyKxSqBGkfWnfUX8yl5/58+lSSXAvfQnDjbDxPoKDd9Za6qAh6hSSW8nlED9MsXqR+z J44Q==; 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-61556-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61556-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCXvmmA1VPWmLunrrqaI2pnKsIG4bK00MmAcsXe2uOUVjsslYl+tUtECxyhz1QGxnRTLmkNSlPN+hAwLcO+eP36Sexw+Gg== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id b13-20020a1709062b4d00b00a3c436d4d5csi145511ejg.819.2024.02.12.04.35.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:35:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61556-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-61556-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61556-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 C96611F26029 for ; Mon, 12 Feb 2024 12:35:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E0FEE3C490; Mon, 12 Feb 2024 12:33:19 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C822F3BB4D for ; Mon, 12 Feb 2024 12:33:16 +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=1707741198; cv=none; b=p4NOaIMNAqS5C7G245saql84VtLiQZugRK1r+tR+CkcIGQjW4LFJ76eUH2slCRyT/1fKWVZWzHrR/XfzILDGdaPQircM+Uf/3u4hT2b3c+lnZVSywv/4UPvScmHBzGYIWw3TSFqLpn44tBe9HdI1dnj1rd/qkB8BAJDsb48LPog= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741198; c=relaxed/simple; bh=f3NaXeeCKvIs3nlglu3hHw0k0LBV7uL3e/C7i/VqWeQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WZCjfXQfkkGqin9oIvn9JJuXU2JYh4kkNokSCBV3zUAhHzyyN11/rQ+8jUfrxwqh64ANrEf73UqSd55VAHF9rByVTmxFo9WnqtmZ6dpprk6CqG+y958eMQ2g3n+MVjfpd1cS5iddCETptbvJd8RXItVFIcjXYndV7PESXHgez6s= 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 C9FBCFEC; Mon, 12 Feb 2024 04:33:57 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 027123F7BD; Mon, 12 Feb 2024 04:33:14 -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 09/11] firmware: arm_scmi: Implement Powercap .is_notify_supported callback Date: Mon, 12 Feb 2024 12:32:31 +0000 Message-ID: <20240212123233.1230090-10-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: 1790696566512558944 X-GMAIL-MSGID: 1790696566512558944 Add a preliminary check to verify if Powercap-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/powercap.c | 45 +++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_scmi/powercap.c b/drivers/firmware/arm_scmi/powercap.c index a4c6cd4716fe..aae91f47303e 100644 --- a/drivers/firmware/arm_scmi/powercap.c +++ b/drivers/firmware/arm_scmi/powercap.c @@ -124,6 +124,8 @@ struct scmi_powercap_state { struct powercap_info { u32 version; int num_domains; + bool notify_cap_cmd; + bool notify_measurements_cmd; struct scmi_powercap_state *states; struct scmi_powercap_info *powercaps; }; @@ -157,6 +159,18 @@ scmi_powercap_attributes_get(const struct scmi_protocol_handle *ph, } ph->xops->xfer_put(ph, t); + + if (!ret) { + if (!ph->hops->protocol_msg_check(ph, + POWERCAP_CAP_NOTIFY, NULL)) + pi->notify_cap_cmd = true; + + if (!ph->hops->protocol_msg_check(ph, + POWERCAP_MEASUREMENTS_NOTIFY, + NULL)) + pi->notify_measurements_cmd = true; + } + return ret; } @@ -200,10 +214,12 @@ scmi_powercap_domain_attributes_get(const struct scmi_protocol_handle *ph, flags = le32_to_cpu(resp->attributes); dom_info->id = domain; - dom_info->notify_powercap_cap_change = - SUPPORTS_POWERCAP_CAP_CHANGE_NOTIFY(flags); - dom_info->notify_powercap_measurement_change = - SUPPORTS_POWERCAP_MEASUREMENTS_CHANGE_NOTIFY(flags); + if (pinfo->notify_cap_cmd) + dom_info->notify_powercap_cap_change = + SUPPORTS_POWERCAP_CAP_CHANGE_NOTIFY(flags); + if (pinfo->notify_measurements_cmd) + dom_info->notify_powercap_measurement_change = + SUPPORTS_POWERCAP_MEASUREMENTS_CHANGE_NOTIFY(flags); dom_info->async_powercap_cap_set = SUPPORTS_ASYNC_POWERCAP_CAP_SET(flags); dom_info->powercap_cap_config = @@ -788,6 +804,26 @@ static int scmi_powercap_notify(const struct scmi_protocol_handle *ph, return ret; } +static bool +scmi_powercap_notify_supported(const struct scmi_protocol_handle *ph, + u8 evt_id, u32 src_id) +{ + bool supported; + const struct scmi_powercap_info *dom_info; + struct powercap_info *pi = ph->get_priv(ph); + + if (evt_id >= ARRAY_SIZE(evt_2_cmd) || src_id >= pi->num_domains) + return false; + + dom_info = pi->powercaps + src_id; + if (evt_id == SCMI_EVENT_POWERCAP_CAP_CHANGED) + supported = dom_info->notify_powercap_cap_change; + else if (evt_id == SCMI_EVENT_POWERCAP_MEASUREMENTS_CHANGED) + supported = dom_info->notify_powercap_measurement_change; + + return supported; +} + static int scmi_powercap_set_notify_enabled(const struct scmi_protocol_handle *ph, u8 evt_id, u32 src_id, bool enable) @@ -904,6 +940,7 @@ static const struct scmi_event powercap_events[] = { }; static const struct scmi_event_ops powercap_event_ops = { + .is_notify_supported = scmi_powercap_notify_supported, .get_num_sources = scmi_powercap_get_num_sources, .set_notify_enabled = scmi_powercap_set_notify_enabled, .fill_custom_report = scmi_powercap_fill_custom_report, From patchwork Mon Feb 12 12:32:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199736 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2407591dyd; Mon, 12 Feb 2024 05:00:06 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCU1dVnxx+XqGR/OgFNrJzLg6e3cWDVlFRU+V/dbymc45wj8cIITf2KZQp06CaCkCwYdc7sp85pjKrc4y/Ry25emb/ZJww== X-Google-Smtp-Source: AGHT+IFo4LYUZ+i28+gXmtJCkK3NWtPvshjlKXlBKTcbN6Xcf250DHUCrlekElkTX2GW85TSkAmF X-Received: by 2002:a17:903:1250:b0:1d9:8bb5:7497 with SMTP id u16-20020a170903125000b001d98bb57497mr10216356plh.40.1707742806158; Mon, 12 Feb 2024 05:00:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707742806; cv=pass; d=google.com; s=arc-20160816; b=LEnAa2qa7fkUJadVkEKSOHCaM5sy/ZI+i6bre8FYpRV9NdJNVjmYBZZU6pvSM1YVpt YCBl1Jlwr6hWFvfr3NcvUQBZXiS1KIOXItmv+dudqPdFrt0tcQ5yFn2q/ruj1i0qzJB3 DGcT4EIRWRXF+5K+DjvZ3mPMqAXk9Ms192OJFsy7zHyaAYY51MwIkNJOMG313ggU5egG RX99zttdyy+lzUw53V2j9sbZ1zvGMoG8pCcuBxRQgYYXfUWiikk2oH55WdEvoa65+uGk 7D8316R9EoPWQlrBvKivdz9YXdE3sxvceF63q+tPJzqBzRo5Ai8Q6CjJX2n+VMvOoAl5 YUIA== 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=/5hHFSue9LLilvSYJyUEMABesIVy5lV4lvQcwiDdYos=; fh=wdz5rw4SylrR6H5yYZWyb4g0f6WgTEs9UhDNfoJkguw=; b=lSDkShHpC4cXLH1eKj0yAWT1wSCg4GmXlg7H8ISwL0vAK6C1tekno2LeDhtMipImzw jJjeqyvj2551fAhCklPOAxC+RKq1o+QFbtkqVM4BJniVZ8TsOE/lG/gb1J3MMN5oAw2B ZgswDeEIyn3PipwJynXBlGZI9aqnje+PgnNAgj3Ldjj+mmuLf3+vo7Ma7LffkxjXL4WD bkt9WlIJiHfTNaVGSbPW39E6k9BDy2XH3fUitrUC7uvV5HzpOLaBo9AOjvGqcaRnBTwi po/lS2izp60uw0pbwtVcSkuk/Os6xV0ER7DJ70cLq/A8k7UNmFapcFYRbcngjTae3AxR +gAQ==; 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-61557-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61557-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCXy7HtPy8McgX6jGERW2jaAHVsjibMwvR57PuVDysULUvrxMLa5mBJDPnAjwvkf+ckM6WyFvCIa+YS/nKyxGFMtf3hB9Q== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id mf6-20020a170902fc8600b001d7313028e5si214830plb.430.2024.02.12.05.00.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 05:00:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61557-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; 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-61557-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61557-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5ABDAB25247 for ; Mon, 12 Feb 2024 12:35:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D59803CF45; Mon, 12 Feb 2024 12:33:21 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B8A973C470 for ; Mon, 12 Feb 2024 12:33:18 +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=1707741200; cv=none; b=Y5FH2vpzstC+8DvPfOeeJ4KSQ7kqF617LY1FbB/lu8dZ3xF5fJh17m+mnlA4Xc4Uywi58GIYCXTSbUbRt5Re7gQcW2oAayPFXL4qB2hUfBfDv2kzYo4kIR2wYXc8ZH/Oulw1esJEZyNP8uOsXO9ZoP09KZ2mj/JBfV07YQfFhNo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741200; c=relaxed/simple; bh=yXhEbCbYSCQ4YzJa83bk7mpJs0n/q8sL94l7OJKG/SM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KDF7m+LjsXC/x19HoxEqhUJ/SXJ/zjCe5Cv+zssHaE5RLXcEr8A/xiFj9uaGe+IQenyjF6COuW1kqLbt4qUp/cvOvkwS5wowPmf5wMOAVLRGtkWItvpnJm0AIfiVpTXGqZ3R4E1d+1NPNJ8o14uFSDC7MsFUqESY0NODYza/RJ0= 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 7ACBC1063; Mon, 12 Feb 2024 04:33:59 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AD85F3F7BD; Mon, 12 Feb 2024 04:33:16 -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 10/11] firmware: arm_scmi: Use opps_by_lvl to store opps Date: Mon, 12 Feb 2024 12:32:32 +0000 Message-ID: <20240212123233.1230090-11-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: 1790698121004887284 X-GMAIL-MSGID: 1790698121004887284 Store all the discovered OPPs into the XArray opps_by_lvl even when level_indexing mode is not used, since it comes handy to easily retrieve OPPs by level. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/perf.c | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index 2627ace5b07f..e20d137a92f6 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -326,9 +326,9 @@ scmi_perf_domain_attributes_get(const struct scmi_protocol_handle *ph, dom_info->id, NULL, dom_info->info.name, SCMI_MAX_STR_SIZE); + xa_init(&dom_info->opps_by_lvl); if (dom_info->level_indexing_mode) { xa_init(&dom_info->opps_by_idx); - xa_init(&dom_info->opps_by_lvl); hash_init(dom_info->opps_by_freq); } @@ -371,13 +371,21 @@ static int iter_perf_levels_update_state(struct scmi_iterator_state *st, } static inline void -process_response_opp(struct scmi_opp *opp, unsigned int loop_idx, +process_response_opp(struct device *dev, struct perf_dom_info *dom, + struct scmi_opp *opp, unsigned int loop_idx, const struct scmi_msg_resp_perf_describe_levels *r) { + int ret; + opp->perf = le32_to_cpu(r->opp[loop_idx].perf_val); opp->power = le32_to_cpu(r->opp[loop_idx].power); opp->trans_latency_us = le16_to_cpu(r->opp[loop_idx].transition_latency_us); + + ret = xa_insert(&dom->opps_by_lvl, opp->perf, opp, GFP_KERNEL); + if (ret) + dev_warn(dev, "Failed to add opps_by_lvl at %d - ret:%d\n", + opp->perf, ret); } static inline void @@ -385,16 +393,21 @@ process_response_opp_v4(struct device *dev, struct perf_dom_info *dom, struct scmi_opp *opp, unsigned int loop_idx, const struct scmi_msg_resp_perf_describe_levels_v4 *r) { + int ret; + opp->perf = le32_to_cpu(r->opp[loop_idx].perf_val); opp->power = le32_to_cpu(r->opp[loop_idx].power); opp->trans_latency_us = le16_to_cpu(r->opp[loop_idx].transition_latency_us); + ret = xa_insert(&dom->opps_by_lvl, opp->perf, opp, GFP_KERNEL); + if (ret) + dev_warn(dev, "Failed to add opps_by_lvl at %d - ret:%d\n", + opp->perf, ret); + /* Note that PERF v4 reports always five 32-bit words */ opp->indicative_freq = le32_to_cpu(r->opp[loop_idx].indicative_freq); if (dom->level_indexing_mode) { - int ret; - opp->level_index = le32_to_cpu(r->opp[loop_idx].level_index); ret = xa_insert(&dom->opps_by_idx, opp->level_index, opp, @@ -404,12 +417,6 @@ process_response_opp_v4(struct device *dev, struct perf_dom_info *dom, "Failed to add opps_by_idx at %d - ret:%d\n", opp->level_index, ret); - ret = xa_insert(&dom->opps_by_lvl, opp->perf, opp, GFP_KERNEL); - if (ret) - dev_warn(dev, - "Failed to add opps_by_lvl at %d - ret:%d\n", - opp->perf, ret); - hash_add(dom->opps_by_freq, &opp->hash, opp->indicative_freq); } } @@ -424,7 +431,8 @@ iter_perf_levels_process_response(const struct scmi_protocol_handle *ph, opp = &p->perf_dom->opp[st->desc_index + st->loop_idx]; if (PROTOCOL_REV_MAJOR(p->version) <= 0x3) - process_response_opp(opp, st->loop_idx, response); + process_response_opp(ph->dev, p->perf_dom, opp, st->loop_idx, + response); else process_response_opp_v4(ph->dev, p->perf_dom, opp, st->loop_idx, response); From patchwork Mon Feb 12 12:32:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cristian Marussi X-Patchwork-Id: 199728 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp2398370dyd; Mon, 12 Feb 2024 04:38:30 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXKhxtAOB/cshC6Ala7A+Mpkcs1WXztcpTUU5fn6gEBbSX0V5q8ejwwtK5ctUckXc+7XxfhuzhLNFXcXEfLcVpCXpD4ZQ== X-Google-Smtp-Source: AGHT+IFeF6UAWXTSLLZCIt1ZRzCAPblIpsUKOPEJgruExwCtWd4f19opk4APshfrPpURiaq3PF9E X-Received: by 2002:a05:6871:1cd:b0:219:2d1a:90ab with SMTP id q13-20020a05687101cd00b002192d1a90abmr6315060oad.59.1707741510015; Mon, 12 Feb 2024 04:38:30 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741509; cv=pass; d=google.com; s=arc-20160816; b=h4l0ayQjkDhgZEUT/OPYcAXMi8+KGeQ2hBrLcMHeFlEQyOMxmXF7+O8nSjobunxMRs jjN+hIOUpHmupj3jYXALgaMUWqsBthKCNPatN7IPb0wdN/RlYc+DEp15YMeJjdRaikYO v5krkq8lZC+k+40rUav8p0GFh6lcuV1VPAQl5StxQrlLz8hrrFxpUCM0rObnVQLbhfym DJ71Zto8Mk6Z8qUdR3NbNUvyUh6pu5IeDlWaUH9TklKDJ97lWY3Xn/0gC+qWkRlWZC5h JNeGzHj0XXbfaFFXKT3GXwLUHKELoF7iNT80Mvc+dl4KftQU5OBp2iUBSa1HWPLpGPUz x03g== 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=7BNqAQHUbs/omZNvLE7Yml10kLoDj2gTRisUZztZnsE=; fh=ey5bSgSzYEmLAyXeFVco+2RBWBcNYGGU+CvscjrjyCE=; b=FZGjj2m8nH4M49mlGZW5JnXBCVX6vKKC1DsmcBtsp0+1qUIyv5rtFiIQpd9hcFqRUQ Pe+MOZh5UqCR3lRPAtSvxmhB+QL4MjxbdDMPpG+v6x5N23aiIL3hvJz2FioVM4EyOsh+ huZ1HMQj7kzB2Qr6dsdsqMwckQCXqvmW+piQGZPUpn6SA0hWPQ7v9RnAK3tLtAq2zLgs 0NWzWt+u9c4AcYEx+f094yRMAACSsmEnHOAfgwFT5NxEmdJ3JIK7WeS4Y54GWV0L2TSA /QGmar5EKYoA5O6viI61Sr9OYi1IofpSwPqPZ8DYdG+GiU98mCZSY1sPP9VaT6hY2dwG pL8A==; 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-61558-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61558-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCWS7uWTCtf53MBsKEXZUMrRGLFugZ/9uz0xLJSirOqXxwEJLrML+/tZl98eoVqQjWgdMseLMB1eHOa6a5Nz8G4q2+vFKA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id c9-20020a6566c9000000b005dc5070656csi187295pgw.785.2024.02.12.04.38.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:38:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61558-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; 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-61558-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61558-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DED0C28739C for ; Mon, 12 Feb 2024 12:35:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BE0703CF47; Mon, 12 Feb 2024 12:33:23 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 793EA3C680 for ; Mon, 12 Feb 2024 12:33:20 +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=1707741202; cv=none; b=uah3FQ8G9TciA6DCmSjKNi85L2ZoF81cjUrBJrKhsoFthIrkZeo1yIlGpo019mAqg7d2TFV+sZZQcB+JRsbqK75/EWE2M3fFIkL5+Bae292YCWQQyjK4qF3P/Tc+fOrf/Lz27idRzAD+IqRtNtNnHbhUyX8IGur6A7I+PZkRTrg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707741202; c=relaxed/simple; bh=Vq/13jyMTK0Hthb91RLpCC6/kQOlazmQH58gWq/rq14=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QbLPJ42jchclUbziFNQaNWMc+pz1IKQvO+Ln4RJR+LzttDx4ohY5dxjDOqQkbHLE/wpqIM5J+FUXbiXXQ74fpaUGIkABj2cCxbHUgHVrvOVRtfpYXx9gs3wJ5JMais2d4D7HZx2Ktgif3jdoUpOt328ccIKGZ870UKt9ewVpiog= 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 4FF1B139F; Mon, 12 Feb 2024 04:34:01 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 60AFF3F7BD; Mon, 12 Feb 2024 04:33:18 -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 11/11] firmware: arm_scmi: Report frequencies in Perf notifications Date: Mon, 12 Feb 2024 12:32:33 +0000 Message-ID: <20240212123233.1230090-12-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: 1790696761466655165 X-GMAIL-MSGID: 1790696761466655165 Extend the Perf notification report to include pre-calculated frequencies corresponding to the reported limits/levels event; such frequencies are properly computed based on the stored known OPPs information taking into consideration if the current operating mode is level indexed or not. Signed-off-by: Cristian Marussi --- drivers/firmware/arm_scmi/perf.c | 69 ++++++++++++++++++++++++++++++++ include/linux/scmi_protocol.h | 3 ++ 2 files changed, 72 insertions(+) diff --git a/drivers/firmware/arm_scmi/perf.c b/drivers/firmware/arm_scmi/perf.c index e20d137a92f6..981e327e63e3 100644 --- a/drivers/firmware/arm_scmi/perf.c +++ b/drivers/firmware/arm_scmi/perf.c @@ -1055,18 +1055,47 @@ static int scmi_perf_set_notify_enabled(const struct scmi_protocol_handle *ph, return ret; } +static int +scmi_perf_xlate_opp_to_freq(struct perf_dom_info *dom, + unsigned int index, unsigned long *freq) +{ + struct scmi_opp *opp; + + if (!dom || !freq) + return -EINVAL; + + if (!dom->level_indexing_mode) { + opp = xa_load(&dom->opps_by_lvl, index); + if (!opp) + return -ENODEV; + + *freq = opp->perf * dom->mult_factor; + } else { + opp = xa_load(&dom->opps_by_idx, index); + if (!opp) + return -ENODEV; + + *freq = opp->indicative_freq * dom->mult_factor; + } + + return 0; +} + static void *scmi_perf_fill_custom_report(const struct scmi_protocol_handle *ph, u8 evt_id, ktime_t timestamp, const void *payld, size_t payld_sz, void *report, u32 *src_id) { + int ret; void *rep = NULL; + struct perf_dom_info *dom; switch (evt_id) { case SCMI_EVENT_PERFORMANCE_LIMITS_CHANGED: { const struct scmi_perf_limits_notify_payld *p = payld; struct scmi_perf_limits_report *r = report; + unsigned long freq_min, freq_max; if (sizeof(*p) != payld_sz) break; @@ -1076,14 +1105,36 @@ static void *scmi_perf_fill_custom_report(const struct scmi_protocol_handle *ph, r->domain_id = le32_to_cpu(p->domain_id); r->range_max = le32_to_cpu(p->range_max); r->range_min = le32_to_cpu(p->range_min); + /* Check if the reported domain exist at all */ + dom = scmi_perf_domain_lookup(ph, r->domain_id); + if (IS_ERR(dom)) + break; + /* + * Event will be reported from this point on... + * ...even if, later, xlated frequencies were not retrieved. + */ *src_id = r->domain_id; rep = r; + + ret = scmi_perf_xlate_opp_to_freq(dom, r->range_max, &freq_max); + if (ret) + break; + + ret = scmi_perf_xlate_opp_to_freq(dom, r->range_min, &freq_min); + if (ret) + break; + + /* Report translated freqs ONLY if both available */ + r->range_max_freq = freq_max; + r->range_min_freq = freq_min; + break; } case SCMI_EVENT_PERFORMANCE_LEVEL_CHANGED: { const struct scmi_perf_level_notify_payld *p = payld; struct scmi_perf_level_report *r = report; + unsigned long freq; if (sizeof(*p) != payld_sz) break; @@ -1091,9 +1142,27 @@ static void *scmi_perf_fill_custom_report(const struct scmi_protocol_handle *ph, r->timestamp = timestamp; r->agent_id = le32_to_cpu(p->agent_id); r->domain_id = le32_to_cpu(p->domain_id); + /* Report translated freqs ONLY if available */ r->performance_level = le32_to_cpu(p->performance_level); + /* Check if the reported domain exist at all */ + dom = scmi_perf_domain_lookup(ph, r->domain_id); + if (IS_ERR(dom)) + break; + /* + * Event will be reported from this point on... + * ...even if, later, xlated frequencies were not retrieved. + */ *src_id = r->domain_id; rep = r; + + /* Report translated freqs ONLY if available */ + ret = scmi_perf_xlate_opp_to_freq(dom, r->performance_level, + &freq); + if (ret) + break; + + r->performance_level_freq = freq; + break; } default: diff --git a/include/linux/scmi_protocol.h b/include/linux/scmi_protocol.h index 0cc40af5519a..9b9351e07a11 100644 --- a/include/linux/scmi_protocol.h +++ b/include/linux/scmi_protocol.h @@ -956,6 +956,8 @@ struct scmi_perf_limits_report { unsigned int domain_id; unsigned int range_max; unsigned int range_min; + unsigned long range_max_freq; + unsigned long range_min_freq; }; struct scmi_perf_level_report { @@ -963,6 +965,7 @@ struct scmi_perf_level_report { unsigned int agent_id; unsigned int domain_id; unsigned int performance_level; + unsigned long performance_level_freq; }; struct scmi_sensor_trip_point_report {