From patchwork Thu Jan 4 10:48:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 759970 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2040.outbound.protection.outlook.com [40.107.241.40]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ECA59210F0; Thu, 4 Jan 2024 10:44:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="JHeBpea3" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nINRsib9L2MPioXTYgQ3D01IPczqbM8Ow5XZFNOiJ1uIbf4E8kU4GvqGMIbd5aF1hbBObVvkyFjRE2YlteqvGThGpmoKNIPnsgGTGFaxQg7xJXUtgYBswCGQL/3v7uz8R3Cs7bn/HIP6Tw2c1KxJfkbxidwg9qY+xsm4KouZLq7rp73uj8js3gUTxVS8OJloQ0eQI8ANC8kWv8AxDTpPWxTgaVoMQy4HKe0kGO8g1jKVhL8D3ncOnBTr2sI2KVGxun/bemk9kmKpjuvX6ODi2tTKazVcN9VKkEEoNu1jd01lBzVAWKhOon6v1lNZsUxYs7GK/kvvikpoPKPwQ0K12g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=c8Q4gYjUQC14yC5W6QW/OwqgmYc1DkZqkRCHzTcTI5o=; b=AjuXufFRSuu7e6u6ptBmJT9FTpxBjAidKjWjATp+TZ0q7VQuCbseTYWNx8V31naEgnTXdM+OMixOa94L2Z2djX2hXoLh2yS3DLrewK34Xb4ATD7yD+tfkAZDpfAFd5oc0faspnspAIVDpPma7mAhkhPT30a5kRAZnOuXSzI97U2j6LX/tlyYZT/XtuQ7rB4ake6oh5Q/1Hk3PPVhKsNyrM7HiKWMOyCewE6Cq25jDh19MkiGZWn+VvtYYGtZbZXZl2N0KBPtQrgO2Gs8T9+PNxsX0z2R3yl1+/9bgvjnxLb2+bquuqy1e3wG9mf0AsVKCZHyxxSfQEmVH7O5hxlI+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=c8Q4gYjUQC14yC5W6QW/OwqgmYc1DkZqkRCHzTcTI5o=; b=JHeBpea39DfX5S3ePeg5lWEoqT5jR+Psi3cx9tuk+zRSpbEKderZKtYqHbntyLzZhhPfWdIzSOzXoKCK5AVE7dvzV3Wf1Purq8l+lyhG6pR0uuce5c/gx7byQskmElRr8qmGx8JdTQLLF3U2+aNGvYcx3XKQaqZeI9HndlVxzjg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=oss.nxp.com; Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by PAXPR04MB8847.eurprd04.prod.outlook.com (2603:10a6:102:20e::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7135.25; Thu, 4 Jan 2024 10:44:51 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::ff06:bbb2:c068:5fb3]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::ff06:bbb2:c068:5fb3%7]) with mapi id 15.20.7135.023; Thu, 4 Jan 2024 10:44:51 +0000 From: "Peng Fan (OSS)" Date: Thu, 04 Jan 2024 18:48:45 +0800 Subject: [PATCH v2 1/6] firmware: arm_scmi: introduce helper get_max_msg_size Message-Id: <20240104-pinctrl-scmi-v2-1-a9bd86ab5a84@nxp.com> References: <20240104-pinctrl-scmi-v2-0-a9bd86ab5a84@nxp.com> In-Reply-To: <20240104-pinctrl-scmi-v2-0-a9bd86ab5a84@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Oleksii Moisieiev , Linus Walleij , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, AKASHI Takahiro , Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1704365357; l=2660; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=woqhTHJgcBsnzMOI1imkT0MV1gtJZhQATiD3eryt0aA=; b=AfB8YdNCCChlIE9jt/x3WRkWZBYClWR/43M40BivfVd5eUxYH4kwJIKl+zhWFGgDFwSUbVrBO iqScQOzNKiaB6PB/8uLdfdI6kICzQiB7/S279wJTQNvEC3Y9GxTS0dB X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG3P274CA0004.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::16) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) Precedence: bulk X-Mailing-List: devicetree@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|PAXPR04MB8847:EE_ X-MS-Office365-Filtering-Correlation-Id: fa7142cd-e896-41e9-7d89-08dc0d122e18 X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bSb17y8Mlj8yemrZWAdF0mc4EAfPFumNlELjS2fSAzYbPzyuZgsAW4b/F5Bpl4hAcJGEMSTMH1/S90ZQiwfUTG8h+KA8pU34Rz3BnqKVHO2+HhuI863xYAjShFqThiG5jEgSRXZtrrkj+cdob0bVk6+mtQOT12e+K5V4lylmiVtsU1KLycGE8/ABgVo1SpXfTyExtHZcqO57ApWcH57weTNNXl4RqqzRnOocBXMMfDqLjv2OcEoEeIxezauNZTblgczb6vN1OPhZ494DDeZ1gzvvYCpslravVJcWmjggJBQa+kFgO9q79AUoA4Tirmrp5flm5cI+R83hX3YZcr7gsISt8k+Wpb827hh16/Hr2WAgfFqh4VRXilbyEdSZBCjSbsKdbz0YYp4BHxqt15Rft5qrZkVJlIjKZmjE4VnmyiAmS4i0xSYZKwho/ayXf6Y8gIQIjwWcIsbSSSqpCkD/rIwyXJTMmsaXtAC0IsUTuE9kRUtZeh1CbECxrtSUTm1Y5LeXPeWUhDx/giKjqy4BNidTwfxpgkJQWY/lJZl4u1fDahkPKXe4tEoiY3p2Rv/EtRPnbd/70DSIxPN2l6/Ufl1Nk7pCkGWFNWal5LFQfR9K8Knem2oCqJNpQyZ70eitiisSEdStqFr/kZMdiAVNWA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DU0PR04MB9417.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230031)(346002)(366004)(376002)(39860400002)(396003)(136003)(230922051799003)(64100799003)(1800799012)(451199024)(186009)(66476007)(66946007)(66556008)(6486002)(4326008)(8936002)(8676002)(26005)(54906003)(110136005)(316002)(83380400001)(6666004)(478600001)(52116002)(5660300002)(41300700001)(2906002)(7416002)(6506007)(6512007)(9686003)(38350700005)(921011)(36756003)(38100700002)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?c2aGIqMHQrZsQMOyfR2wzsfVPlkc?= =?utf-8?q?5Es/XigVaTEY4qG86H0Hwg5xFsiFfY8SKITsBTwGwfPUQ2xzL6yrq7KRUq9rypREd?= =?utf-8?q?eBXPyfzNQ9Z7RM1qQUnpdjyDHaALeOpVD52pE5H9M+SSUjCxxxGbgXnOk07/2rhfj?= =?utf-8?q?3oYAFNvZoUut0TfS8nRrPvuE6xe/3Ua6jOJzIw57fx1cElqMN6MzZd/cCrc/RgNP+?= =?utf-8?q?hQKzl9X/FQKZ9o9PTgnDZWIrzwbPMp2sPVKUtWQk8wMsHvEU51vdf2kwSjEQl8r8z?= =?utf-8?q?6Jce+Hd5IeZn6anHLM9UfMiwgwEXb/pxk8rKT3CB2WhcIyDiLrqAXhy9BezxpoAMj?= =?utf-8?q?VnrIHJ8Iu+g/gCtTQyTQZTJoIZKZrUlIu9tyGK18lWLHnfse5jUDmuV3HAyz8buf8?= =?utf-8?q?U1YGe0Rm7etq2rAgFnmk/51n9Ss5xSpwg0tF2P0qXmjWVPzmpHwhPwGFSXK7f6Wjw?= =?utf-8?q?VTGedEgzF1phL6KW+OaW1FDfIs67VmQNZUfLLSV8m7PPVCxdmVSK9kHOFT58AZTwg?= =?utf-8?q?Mw5iYoY4ArdgsxXG8BWQLrP+mr0Yiat9cRH+L06Oeu3qTAeFbpA5Kz7V1khi+Fq3a?= =?utf-8?q?1iXxE0tgFYbPDMxrgnjCMkKi8XZ5D70O/XBkj/1yY9DlhxmUbY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QGWaWHQkerU9sKo6q5mKZsUiu0Pzu?= =?utf-8?q?/fR3q2elYVw7?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: fa7142cd-e896-41e9-7d89-08dc0d122e18 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Jan 2024 10:44:51.4932 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2QYSMJrDSzIN6uf/s6qV2JvssjoB56WCBZS6QPTpwHn2JB5Z8lPKeMlYBWUl5ccbfP5m5foPxbhyf6tkvzRNlQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR04MB8847 From: Peng Fan When Agent sending data to SCMI server, the Agent driver could check the size to avoid protocol buffer overflow. So introduce the helper get_max_msg_size. Reviewed-by: Cristian Marussi Signed-off-by: Peng Fan --- drivers/firmware/arm_scmi/driver.c | 15 +++++++++++++++ drivers/firmware/arm_scmi/protocols.h | 2 ++ 2 files changed, 17 insertions(+) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index 3ea64b22cf0d..a12afc254afa 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1481,6 +1481,20 @@ static int scmi_common_extended_name_get(const struct scmi_protocol_handle *ph, return ret; } +/** + * scmi_common_get_max_msg_size - Get maximum message size + * @ph: A protocol handle reference. + * + * Return: Maximum message size for the current protocol. + */ +static int scmi_common_get_max_msg_size(const struct scmi_protocol_handle *ph) +{ + const struct scmi_protocol_instance *pi = ph_to_pi(ph); + struct scmi_info *info = handle_to_scmi_info(pi->handle); + + return info->desc->max_msg_size; +} + /** * struct scmi_iterator - Iterator descriptor * @msg: A reference to the message TX buffer; filled by @prepare_message with @@ -1756,6 +1770,7 @@ static void scmi_common_fastchannel_db_ring(struct scmi_fc_db_info *db) static const struct scmi_proto_helpers_ops helpers_ops = { .extended_name_get = scmi_common_extended_name_get, + .get_max_msg_size = scmi_common_get_max_msg_size, .iter_response_init = scmi_iterator_init, .iter_response_run = scmi_iterator_run, .fastchannel_init = scmi_common_fastchannel_init, diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h index e683c26f24eb..b5c65f26207b 100644 --- a/drivers/firmware/arm_scmi/protocols.h +++ b/drivers/firmware/arm_scmi/protocols.h @@ -254,6 +254,7 @@ struct scmi_fc_info { * @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. + * @get_max_msg_size: A common helper to get the maximum message size. */ struct scmi_proto_helpers_ops { int (*extended_name_get)(const struct scmi_protocol_handle *ph, @@ -270,6 +271,7 @@ struct scmi_proto_helpers_ops { void __iomem **p_addr, struct scmi_fc_db_info **p_db); void (*fastchannel_db_ring)(struct scmi_fc_db_info *db); + int (*get_max_msg_size)(const struct scmi_protocol_handle *ph); }; /**