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: 776048 Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2058.outbound.protection.outlook.com [40.107.21.58]) (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 D52C6AD58; Fri, 23 Feb 2024 01:08:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.21.58 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708650530; cv=fail; b=fpLTEws2vxdF3yHT59E81EWOIx1hZ9GCcmD3qVchbXxuv2kKC5EN/ZCa19ef6quN5AdolN70WohHfJ3N9DOUTZrkJSO2v/jXunZjh+8eSNzeh3AQkmuORl/2eaAeItgQHlYc6bkZ2f2rnyQvLjiFt2iEDPYjcDkKW1P619R2zYE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708650530; c=relaxed/simple; bh=LIbiOyIEb5ksMqwfw+ihfUycxea+JF7Ac2NBrH72rjM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=GsrWvd/Jm9xx/g7Gik5vzaEM6tY8IiibG6/w8z0H2LVNAI/gJ2GLjiA2FbAbYyPPB0YD17w/m+yP0+xkczJ+OCMQ/NzRpPtDQtKwdISsjxLitcH/Fnz9t1yfd/tAcVWfmMx0sAo0kjz+iL1jlURYUVZmDOA5f2IKGLTU2AxowRA= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=oss.nxp.com; spf=pass smtp.mailfrom=oss.nxp.com; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b=lhySqXsM; arc=fail smtp.client-ip=40.107.21.58 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="lhySqXsM" 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) Precedence: bulk X-Mailing-List: linux-gpio@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_|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/i5K3Xc1cyRPBBqfahPH4kfVZKK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HF4PuZ1HwewJZYjJFQSZHPpVyWSBJ+MiZ+O2lqirye7?= =?utf-8?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 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); }; /**