From patchwork Fri Feb 23 01:16:38 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: 13568446 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id ECF2DC54E41 for ; Fri, 23 Feb 2024 01:09:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To:In-Reply-To: References:Message-Id:Subject:Date:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=lsf0f4UgWmD24YeX14DeA6Uph92DpQplHnQqT1R32kc=; b=ZO/Nqa0OuMzacOvHWM+rCdQ59o zrLqxYlJ94DFirgH9mpEQbHEQTuQ9gg8uwOLeK0KniE+S/cMBbVZeRObWvkOB1ErzL5FdvVVA+Ija H5iSIjNDmzYMtZyz0dfVafHGX76maKpQgelqc2JqATf1yZqPfvy12FND0t/qN7oSXG9QqWflhK6S+ rJ1d2RHxnuaMPkZTaT77p1cohwNBsCODwI3P5VcpXoOjAz18rFel46UwSFlF6Nsqi+eOcQ4MBEt9n nN/8zDTukCt8pSURVtso8c9151jJ3jiFD8QRjcpE1vXKM1BBBQhRoE8grPjDYznxQYbstJm6MzDmv G6q/LOXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdK3r-00000007J0l-0hpu; Fri, 23 Feb 2024 01:09:14 +0000 Received: from mail-vi1eur04on20600.outbound.protection.outlook.com ([2a01:111:f403:2611::600] helo=EUR04-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rdK3c-00000007IuQ-2Wus for linux-arm-kernel@lists.infradead.org; Fri, 23 Feb 2024 01:08:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AqZBRfHh6k/5/3+S2XrijHRVS9HO0K8Ec8JCptOUHc64ayjechybcPQ8QpIWos5NHGjMZ78qoPA4PWVPC2IGCFiA5Ahizn+C+XKx9/Kpesm2OID6nIgPbpTRFi2QlJKBNojaTqY7Vbs9Mp/JT+8LhtNHbKTF28V1tDRx1pW5xNTKmVOaCRmD6mzpXitSdBwtG+pqei879frACSJAKzPLNxDu4mx3Omy7VPlK0isnj9YaybWvQiGY5dUuJZF2+V9TRrfo2OwUlMqwkLBlevp1pETB8+6KDIuqL0wufDJ5wqe057XA+hwafMMeZ/nzMQtUtCKINJ4TBxRodQSlqyhfCA== 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=cCcalEI+UIRZcakIjpwOIHhvXPGL1GR96ZhZnkDLELk=; b=DX0cTB41zDjXgWsxsuc17R29Ip9nYdgnp5bQzaixWuxlDTS3Jxrwy3Z8QBTEsT186IPtWSe9JLMIwkzuV44Swqra1S1aGsdHClREouuapGcDwDk8oWbcddfJ4h7ze4hP8yZxyEYqbad+r0H6sWVJGz0wYn0d0wllT8l4Kl7XI2Djiaa9MzK02gKnqbhH2a16n7eWcQiw/hUcld90jLqKERx/d0oS1sicR6rzLYHoHATkRvg+yFf5Owql89bW6QUG77bE3exYOgUlKx9D3RxK79bIHqCoD05dsrUi5pE0fEeG9BGeCE8DzIWmUYlXRJzlHBWpw3DL8zG6o1slSoHehw== 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=cCcalEI+UIRZcakIjpwOIHhvXPGL1GR96ZhZnkDLELk=; b=lhySqXsMmLIFmwoW4Qo08eGea1YDkwFiNujyQxvK0tLMPNCaFpVsfxea595lhRAX5eKKcodvIbY6ykoHlJbVSIyi6BowrvxcIiruinI8BaBxKN0ujIkvUtvtbdGJiXTV/SPwyQ0cfk1aBp5df/96sJYwuZZW1TntDLLTljRvztQ= 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 AS8PR04MB8418.eurprd04.prod.outlook.com (2603:10a6:20b:3fa::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7316.24; Fri, 23 Feb 2024 01:08:44 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::4ac3:3559:4200:38e1]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::4ac3:3559:4200:38e1%4]) with mapi id 15.20.7292.036; Fri, 23 Feb 2024 01:08:44 +0000 From: "Peng Fan (OSS)" Date: Fri, 23 Feb 2024 09:16:38 +0800 Subject: [PATCH v4 1/4] firmware: arm_scmi: introduce helper get_max_msg_size Message-Id: <20240223-pinctrl-scmi-v4-1-10eb5a379274@nxp.com> References: <20240223-pinctrl-scmi-v4-0-10eb5a379274@nxp.com> In-Reply-To: <20240223-pinctrl-scmi-v4-0-10eb5a379274@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=1708651021; l=2659; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=DBKFhaPpqrkJGCSTluDmc3QczHu1uAahbhhYhwpdRZI=; b=91F9bSboHX82fJggsXBcephRnZfsy9xqMLcMwDkRWe9p/LgccbEnm89/ki47oFaXfZ/Z10JfZ sm8rLjDrHieAYi11be0EZxS+PIW+YcvdRZ+y2I9kgTGmPNDEunemqbB X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR04CA0009.apcprd04.prod.outlook.com (2603:1096:4:197::8) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU0PR04MB9417:EE_|AS8PR04MB8418:EE_ X-MS-Office365-Filtering-Correlation-Id: 0e783a9f-5006-48a3-eaa3-08dc340bfb3f 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: hsnAbMRsZYxqXIyAllcuNfIq/DpXvWptDvayfCLJB/ibsWyZhlHXYNsJjrrM5LIREVfObd0XrIBCjF3vt3oawMnDtazgq8KzT9Ag5pvvs3HRQ6ebokJpnw2RnrkZepy6cPjVPiiAYnXLfUfy6UKwHj0984YfdOlgX2XGzgeL2tdonFSeOEjyD5MoUnlO/UUFmxaXzyxoDRgV/3JEUuAWiei2MMaSeh+isvcptXJSczg+uAzMCqDWuNIKKOF/+7YUWj7sM6CSUZadPWybgAqMLJBATDPxtfbzLULxOPyBYNoo/aBQlSQtgPM6PCt5M2oRS4ZFzNQnokrJEHjhjYDkIwI0FOpWJ6pPlEf0xNUpwZ3/E3P1nNQNM1Qjy4JvcmOGtS6UoajJYoHNtLnXgGu+gjG6U1ysW89OyAqfyLll0s8y+YIAAzOw+o2RrWCnrpJSPq/lNWvG5VH6vATiWTQRLLFhAwVko2pQsSqAeTQuqPZ4ajPbgYEj+VrShNYS1zpxHOVySD9E6virX74uqzcatqUxplbEl6pMW+86vdz5qeGaKxZ+L0j6IuDKoYQaA8RH0qlzhsd19/2TDriQI6nSZ0HCIUyJTTslpI1fqIuIsyIBWZC+WXXLRa3VTTHHKrg7dCtg3AMGRZZrtfrxgC0eXQ== 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)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?eqWJcBPfu0Y/cuKhLZzXSCswZEQc?= =?utf-8?q?c7s4BjdyNEkV//wWz/b3SLLhFTgEFOMH6qjIBAiQFGjS9+PCpxmnCoCNLVWmIY7Ov?= =?utf-8?q?5D2aQCPslETStqBwkLvI5fAC43XGlCK14Th2Cv70XyrQCX6om25U1RwqG6+yZXeGM?= =?utf-8?q?NkqEf/i5K3Xc1cyRPBBqfahPH4kfVZKKso0MZp1Tupy+0A09VUY+jKwDR7H0bLCln?= =?utf-8?q?rlSqDSYu5aS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q?ev9K50hCI7QI/7i3PjTmoDnr6AH31us5KDvsT9R8Yc2j5ISlS8LCnli5D0u0vfxGo?= =?utf-8?q?yFZmc7PlugWPgkJTmAuWXHT6o88SuV+KvAjNLcJqe19VgC5ljCNhQVNwbI9RvGzmv?= =?utf-8?q?3i4+JhRjsPSf4lv93/eACyGets3U3+Rt7DX3VIjDhuspJoaRTxQ4CVtJfwOV7sdPI?= =?utf-8?q?tYByfv3vM3PAXbv0BCVSEP6ICpn/bcKe41BUJjy6571RTkczjbRW94doLiQcOr34e?= =?utf-8?q?g4Pt3T70w+Zv8gHQkETF0hYitvH92wRHgD/pTo3gi0x3W4O4Ci5OTQPwsHq5lqCm4?= =?utf-8?q?JrY/i1qxWvXcRn2kW3i+01k+DxcRwIZeKOQYqH6oKfIq2HFkWzc2awRwhFj1eJQp5?= =?utf-8?q?MJGRQdy9BO6jlIXyoreIn00uCcVJ32VRwQ7Z5ZSv02Hqi5GJQGRLDtEM7Do0q/rn2?= =?utf-8?q?W/x56bG/tIup?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e783a9f-5006-48a3-eaa3-08dc340bfb3f X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Feb 2024 01:08:44.5884 (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: sFYsbZSxKxWIk4SlX2VLM+STEVNlB0Cck4OV7pzvSKDILg9hKHYwsVOyt1pyN2XhCBb7VZwtZM3NxHlU51kOqQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR04MB8418 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240222_170856_687039_554C6983 X-CRM114-Status: GOOD ( 11.57 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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 34d77802c990..6f059a585896 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1488,6 +1488,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 @@ -1796,6 +1810,7 @@ static int scmi_protocol_msg_check(const struct scmi_protocol_handle *ph, 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, .protocol_msg_check = scmi_protocol_msg_check, diff --git a/drivers/firmware/arm_scmi/protocols.h b/drivers/firmware/arm_scmi/protocols.h index 693019fff0f6..9c8edb1aa901 100644 --- a/drivers/firmware/arm_scmi/protocols.h +++ b/drivers/firmware/arm_scmi/protocols.h @@ -257,6 +257,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, @@ -275,6 +276,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); }; /**