Received: by 2002:a05:7412:3b8b:b0:fc:a2b0:25d7 with SMTP id nd11csp2420369rdb; Mon, 12 Feb 2024 04:33:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IHTSq46JO0QXVVQXfjyH2wOLhxwd5LznmjnYORsVPkMQ2BJoCXOEg5+hD8fcIc/vNf5DB16 X-Received: by 2002:a17:906:358f:b0:a3c:b078:fc45 with SMTP id o15-20020a170906358f00b00a3cb078fc45mr1222124ejb.18.1707741209989; Mon, 12 Feb 2024 04:33:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707741209; cv=pass; d=google.com; s=arc-20160816; b=IyOBU+Z6kvKbyDMPyseXgX/ySbHccxgpR26xe94aag53/G1iyjRusBqxVCbw6vLFTk YJMZ1OpGcvwS8X7v7sB6sJQIuyijO1veiQkjsDnJ95ywvcir3DdOlqAh7TTfTH2kAviV W8ZikfLL+5M53CYdVNH0n7CgBVxJcvU9fQtRJhPlpVyGv7iAtlYuU1vIeb3VJFfL07ad Qhz5bmGuu98kR6LFXWuuDuZL/WR8luHjerFpCHdOUM5xCqe8GkcaG1fk5vH8X7eiE3Qf JmQi5vcM8ESzukHaiD90ETh2ZPMdIp6MN1Fu4pqm7FoIEtDn1DfFRJ+Ijpuk6W7Jmvzz tNmA== 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=7pEe7VohcRgZ4oNIC8aTAASVkOXcyJYF1KuZT6N9V2s=; b=cBT/PFkYsiQXtZ+JszOvxA3jW1f6hAnbDO3NBCSjzxJkzmT2yhLbf3SYrqEzFWoppA vW5R8mt3ccnsxwLCfu515k/Hb7vsgZBtpAFWHph+pRdZ/UH7WG4UyyXg1Dz5Ftn5nG7r gGr4PG2k/Rwd0MpfBWcOQym5KEkKZ7WKbrS5ZKS/KkH3JEhNhh+2g5dsoZTfK53OT3QR Ly4kWJW7NLo9tTdTa+GPQb7ekUdv8eFCSFCNJfzP3q8tjYWO6BMTELMYyryUwE3ikwIH PS28UqkFIrZG0bryqyqdiciCdk6acIQ7l4paIeV1mHna8EmOnEZGGnnvF8BcgswxP/9J 15eA==; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61549-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com X-Forwarded-Encrypted: i=2; AJvYcCXA5mufWdzcsk+9j8sI5KGrAmaTJPdjzSTchx7y2B6uGhNKvUh3NDNfjeFMvEN5OV0r0pFMw1E+sjkQpBrWm12811jPIY3SBlJfHDZ7UQ== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id j19-20020a170906831300b00a3bedd611b2si145716ejx.477.2024.02.12.04.33.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Feb 2024 04:33:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-61549-linux.lists.archive=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-61549-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-61549-linux.lists.archive=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 9EB3F1F2608B for ; Mon, 12 Feb 2024 12:33:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 40F463A1BC; Mon, 12 Feb 2024 12:33:07 +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 Content-Transfer-Encoding: 8bit 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, -- 2.43.0