Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp423229lqp; Thu, 4 Apr 2024 18:53:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXhxWf0JQnZjxYWgG16rLXBzL+ggswpx8hstX/UYwiME9ndZdtSsRjadPqngJwQO9/k5u7RQMchBuD9bAI9i7rsiQ9IGUSEKNbT/5d6+Q== X-Google-Smtp-Source: AGHT+IFbPrtoSqWRIdK0dfrYWjBEdsm47SKpUItEfwIR6sDQwmYI/sMiRJVmr4DC/bJQgvA2aNXc X-Received: by 2002:a17:903:11c3:b0:1e0:b60f:5de3 with SMTP id q3-20020a17090311c300b001e0b60f5de3mr359296plh.7.1712282015235; Thu, 04 Apr 2024 18:53:35 -0700 (PDT) Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id me13-20020a170902fc4d00b001e3c16c18d7si207990plb.356.2024.04.04.18.53.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 18:53:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=bUd7P619; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-132316-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132316-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=nxp.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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 5A2C1B24020 for ; Fri, 5 Apr 2024 01:51:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34B6812B82; Fri, 5 Apr 2024 01:51:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.b="bUd7P619" Received: from EUR02-AM0-obe.outbound.protection.outlook.com (mail-am0eur02on2095.outbound.protection.outlook.com [40.107.247.95]) (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 EBBFBC13D; Fri, 5 Apr 2024 01:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.247.95 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712281899; cv=fail; b=BhinxiNIfHT8ndESTBSu8/MLSFlHK6WV4D9mT5hU2QmImE7QtQroZcr+HS1Uy6aMqOvZvZOGMVIhWJnpP2dFDjuaKyOavmlgEKpmjyykJw8SLlQ6BzR57uHpfK7MaafqRtjgVw7nu8kU7UCZubqjY92Ru3k7Ay+ns+3aUhWehSM= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712281899; c=relaxed/simple; bh=t5HLy5gFexuRUd/gcXkLur0tNUBqrWNFLScENOV0ZWY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=NBGc727nAM7UvWfYYX5nmQU30oVAIc0D89k7K5ycfsB73XDQCTM7iq5GJeH5CS0cchkNc365akHfPXD5ByZYfyNmXrLqzPmxXx3JBD7edH4B/uvAv5I0pK2iwsj0QKWM1x3GLsnsQbgLgP3II2+yzZEVNtGP1twuetNmYRJedkU= 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=bUd7P619; arc=fail smtp.client-ip=40.107.247.95 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 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m3KKLuBU/RaM3j1zf9hUhmTnMcx8+fTiOr7CJv17Aj+SbG1Cu4XmhUKCBCwi9VNDCMneLPjZZPHHoSEFBthrMncClJuPJXxoEBaYriw8yv5lj580uZYDCXPIyUOHBM6Tdg3kiybBeEFrznFsSpblqmpFSoIVSCU7U9itBsHmeBjSJCBN77E08+OcMPjFcE3bPTomjN1HIdPHN5lgVS5UIvpmmpp1joro7PnwjawdTkedGlAi47nJtXLzKf+GKmoCIdnMpfEMfPB4CzJlqro9JDiLMOcmhYxAOpnvWkQJO8zVxKQ2JWDKR+ZIOWny1FsXWl7Utk8lyyhl9BdFGBpLcA== 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=DkhFzy347CReKh8Y/3De5x5m9e7u839I/9k6SdaIf8U=; b=WmN3efy4xMIp/fUeGsA5R+g+i9NLUl3pXL3Zchy6s7WEFNc5y86I1IAxm2xWHH8VxQBvqaKNtjss+t46HSCL4w/EebHzCXds0F9j+Fmrfjl/jNR6QpmKwRqdghAISpDJ7HRFDi9+wXtAkGxXRif+4WP7TrZvw9C0WE66QHRLpVfp87G8a5Q6P8OrJQf16pNACUlD7AhRAZu0C3fAOBJi6dvSgEmaoEV9cpWW7IHiWcvvDpVGIe9bjL1UYHjF9MQ77tZG/KDrZk4hcjZcA8YTnE8WQLXxUR0BI8039oA0aUHn+LREgWFmMuvbq8b9qKpGBkjJ1qTzDgqut/7bWPE3aA== 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=DkhFzy347CReKh8Y/3De5x5m9e7u839I/9k6SdaIf8U=; b=bUd7P619XWnp3H7OB77VkVB8OjiOKtLehRwdwc7i7ObBojlmSrOn8fD4HC7nF+r7v3Li6Fo9F0JGYKulTHZOP7635PBPUu3X1fOt9sKeoc2jEPHd1uobkiZQPz0nN3ckPOicv2zJ+KWtilliMIezd33QiWN4Nn1VdajDVTZrmGA= Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by AS1PR04MB9334.eurprd04.prod.outlook.com (2603:10a6:20b:4de::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Fri, 5 Apr 2024 01:51:34 +0000 Received: from DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d]) by DU0PR04MB9417.eurprd04.prod.outlook.com ([fe80::d30b:44e7:e78e:662d%4]) with mapi id 15.20.7386.037; Fri, 5 Apr 2024 01:51:34 +0000 From: "Peng Fan (OSS)" Date: Fri, 05 Apr 2024 09:59:32 +0800 Subject: [PATCH v8 1/4] firmware: arm_scmi: introduce helper get_max_msg_size Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240405-pinctrl-scmi-v8-1-5fc8e33871bf@nxp.com> References: <20240405-pinctrl-scmi-v8-0-5fc8e33871bf@nxp.com> In-Reply-To: <20240405-pinctrl-scmi-v8-0-5fc8e33871bf@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Dan Carpenter Cc: Andy Shevchenko , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1712282385; l=2653; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=dKDsMHnM+cuvfvX6K6tAU3ADCasBJe+OHaz6qBQ1Tuc=; b=OKFZQg9iNV1rPeKGiN9dUt7Lvl/bm1h4ZwOVkECy3ViF7GlUxLssVqnSRyB0Yha8FHSCNp3PX 7aAXJzxNv0yB+24h16cq7oABrZSWw+2KTCYLGeC9R/8NXU8yEFeo0fW X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR01CA0012.apcprd01.prod.exchangelabs.com (2603:1096:4:191::8) To DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) Precedence: bulk X-Mailing-List: linux-kernel@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_|AS1PR04MB9334:EE_ 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: g9dfYGQpdcCOKQ8McC+8G15rjDNZ4jlFM9AOLx658oZd7XHdHopuO+jT3i+32LZww+7fdPw8me6KVOAf0gHM4549P+b/YtoHg/LfQOXozSUGugidZ1+uvi5hoJSP+4oz2x8zMYDSAexJ5QnhfbrVX7CEj1WfKToV3CzG5pL51dt7xk9khbN/vJHUoH7fAF0mpmGe8nuzSZ/W3ILvY04GZKdTuVauuBFGiNPISEbENVSd7pYfAnyg12hisPlxO4UJtbrnTxgTW0jg+JF3Tqz+2/zNfgGdeknhXvG1DCaj/DHqPY7QQx13BnsjHQSuFYmh6clDv+C5FOPur6HqdrTva/Yg1WaF+27U6K6mqNkfp5OiPOFynpY9vhn8yv/hfvrHHsumKzqYw0SnryzFLMTYXmOaI1M+Fgc7IMNiqSLjAV3HNeaMbQ+5o4TgfGL0x8ZFmYM/Kgy0Eh2PpKfbsId9p0xLcQKnssiN6hXV2VE54wpuhjhrHUjCrzh34sC/6w6q9DsK6t5XKbh03jWVDIZNjxfwbStIazuxHekfYQxs6rGShZUQdqsuNbwOIiIBZxTQjYivaHJV8YvwxJJYy+5ygfaTX4XKyzTSvOUqIzT36jCWDf6X15T2vI5iWYMYtvf9eKUXKw0BWERo/eNHGE+CypqtARB1p8cgBc1eaUXdW4khSJqip9KpO/YbbuOwlFtbvmo18J0IfZ0ZAKsOadsUxWrAiQGuYG/Cc99wfC+Q1B8= 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)(1800799015)(366007)(7416005)(52116005)(376005)(38350700005);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?VUFtV01IZTRhRjJmNTBDTEhKcTJKbmFmUmp0YVg4d0JxRTNKK1B1ZHRXRlI1?= =?utf-8?B?VTN4RWxXVy9yR2FEZDBISFJvR1RGZWZKaFdDTGJ3QjMwalBXeDM0K1pXUmpi?= =?utf-8?B?N0ZKUGMwdUs3YjlCYUdiUUh5Z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eGhlcjdwZUsvN3BEb2trSm85TnFPV3RiNnBldFNTbWN0R0s3?= =?utf-8?B?RTRvWVVkZDRDZTRFQU9PZ3NTV3ZJdXdiZ1NLTktRc3EzTjkwT2owQ200SUNk?= =?utf-8?B?TjJQcHZIWDRGS0Q1TWpveXBid0g1MFcvNlNpdG9aSXF2Z055Ylo5bTNDN01W?= =?utf-8?Q?brHAqQumnW+JOqzBhz2dIcApz?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8b766d00-8ad2-49cf-80e7-08dc5512ec3b X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2024 01:51:34.2107 (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: lANtDZAk84Tkv0d9S2t+ox0JJHJbEHIoQ3+D1/HwqKlUj+o7/1s1RKyF7O+4Cr8AJXA3gxUAWS7zDtFJ7YK9pg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9334 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 2709598f3008..415e6f510057 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 @@ -1799,6 +1813,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 317d3fb32676..3e91536a77a3 100644 --- a/drivers/firmware/arm_scmi/protocols.h +++ b/drivers/firmware/arm_scmi/protocols.h @@ -258,6 +258,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, @@ -277,6 +278,7 @@ struct scmi_proto_helpers_ops { struct scmi_fc_db_info **p_db, u32 *rate_limit); void (*fastchannel_db_ring)(struct scmi_fc_db_info *db); + int (*get_max_msg_size)(const struct scmi_protocol_handle *ph); }; /** -- 2.37.1