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,