Received: by 2002:a05:7412:2a91:b0:fc:a2b0:25d7 with SMTP id u17csp763386rdh; Wed, 14 Feb 2024 10:32:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXQWXceE0J7D9AQs5YgBCzvVnNOpoiPW7tPYvT2X7DR5m32x4ybMsR6TuvHuX2tuSU0KKlF/qthB83Apcw12GTdtMo2YZopsw+NXcl7fA== X-Google-Smtp-Source: AGHT+IHtmMRvZjO4hieN3MUqH2nS86Yum26oSdYtNCWrGgWjjRNgWV6TMkxfmj+TUp0hh0A3+eyP X-Received: by 2002:a05:620a:9c2:b0:787:28bb:c804 with SMTP id y2-20020a05620a09c200b0078728bbc804mr4681874qky.2.1707935554962; Wed, 14 Feb 2024 10:32:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707935554; cv=pass; d=google.com; s=arc-20160816; b=FDCbXajF8+NUkbnTnVlcCjqUBIwraGHxWQUmLVjCtUiWZnjlyf3VndLAI0xRERinX/ Q3NbIOwsO4I4BE4UZqZ14IkAP1w1Rd+EZCBgZh5nSQBzPAcuwvQkyI/ToMx0sDfhs41m 8mU9MQINSYmV/MMpzJPi2maVY79i6ZYAw722oD0kFa54PAjTJbX4h2ARcL13rb6QjJhL ykRJqf5afbR9VhlqyaOVJebA+YKrjcCYEMX7VQxNZMK8vFuzKzYC/5+EC2eDvHcS76ee cDKqOFOpP3nLvyj4Ep3IX4eVlc88RLbzsN/dkdwHBGx7JDNNsBuwYGVx49OeIdb7u6U/ MIhA== 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=L2KQU0nEbN3vg/4yxyKgjDJH2cRaQGkzDGIXDkPec70=; b=a62GX5BinlTan6s+2rg8XraPTbMgtohpr8Vx3YJYOnEg8YZiF/QMkNAOUTP4T9GK9n wtOUMztzJnKxsqui4TyysbwzwU+fghM5HbfI4HmdaRUb9T0Ygh46R16bchz5ILW6qLC7 IIUMIh0YXxyBQneWJpaWBz14vynHa1baEyvrKA2mls5UL6KY/nG6++qxzASuHlVSbKHb fec8uff+0VR5GXT5TOlkk22LVxgGVG8EHaUbHczDqbck1zpooSdj+W8Jqz8J4fLjseyn oDNoAl2BFAuGiGXb8oitdDdds83pPcZ8K7Z7c/Ev1cHbkQzmj1iuPIOYz7b0JzDX6nFf 0MEw==; 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-65805-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65805-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; AJvYcCUrhqTt/MoWBHiCYnWslLv2VIvDF0hYtlHKP8H7wV1NzlYrENVMKgFV6XidZ14tS9S9eNxAcVku3S6ecP23R4FS7HgW7U5D+XgXkKDk7A== Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c3-20020a05620a0ce300b0078726f5e34fsi2688444qkj.102.2024.02.14.10.32.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Feb 2024 10:32:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-65805-linux.lists.archive=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-65805-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-65805-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id A91CE1C28D36 for ; Wed, 14 Feb 2024 18:30:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1C09412C547; Wed, 14 Feb 2024 18:30:36 +0000 (UTC) Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7594E12BF23 for ; Wed, 14 Feb 2024 18:30:33 +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=1707935435; cv=none; b=RiO1hVzT9W07Hh/QHN7p8ErB/RqR0yXYCbimyG0YcndRzDumKeqF1J46utp0v+fCtNpDVpvLis1YkYLLOrsQQw9F4ACEGI6sF9RUOSJaKpdovk4y2bmyRZxVUXRUhDud4Lzar9wHkUr8NAcUC+v5PXZhtmfT0Pim5Jtpm4ARgYs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707935435; c=relaxed/simple; bh=L7rCObjeJJ/6znwFBtlQDxE88+afFeZnyW7f58K3Lx8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=A2ApI2Hjq7lLD6/Xj1LRQqYLpYFng5tN2Ov48qjQq8VnRUFFy3itQJwla3TVhhYIFGlv9NT/AIeuLWP2bPHmDCOk4Zox4cU0DKsoh/GBsUnm8ctSY6wqw3l2iBDebJau75EgFxpAIix7eSG+elg2aawvv+ygKZcuU34JEwgU//M= 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 9AB90DA7; Wed, 14 Feb 2024 10:31:13 -0800 (PST) Received: from pluto.fritz.box (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E92FE3F7B4; Wed, 14 Feb 2024 10:30:30 -0800 (PST) From: Cristian Marussi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: sudeep.holla@arm.com, james.quinlan@broadcom.com, f.fainelli@gmail.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 1/7] firmware: arm_scmi: Add a common helper to check if a message is supported Date: Wed, 14 Feb 2024 18:30:00 +0000 Message-ID: <20240214183006.3403207-2-cristian.marussi@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240214183006.3403207-1-cristian.marussi@arm.com> References: <20240214183006.3403207-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