From patchwork Tue Apr 2 02:22:21 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: 784974 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2109.outbound.protection.outlook.com [40.107.6.109]) (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 EDA91DDAB; Tue, 2 Apr 2024 02:14:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.6.109 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024072; cv=fail; b=Qi75WqGSPt2+OedqB1MQHZpJ1fktJYgh6ioNo81qzOg/t6crpUYLc/OHYvraVcxV8DnyiOR1MDJXaZU/ppcTwGws7nKmNQi3qB61x990amct71GiekzBiTgDmJeiMlCk0Oya59MI24Ck0HcYXft8q1RLOd2lYHiwX92+uKIHEsk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712024072; c=relaxed/simple; bh=t5HLy5gFexuRUd/gcXkLur0tNUBqrWNFLScENOV0ZWY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=KzU9zNHe7tO9PuSQfL/NkG1c854sOeMWDYYP9/l6RRuPl3y+QfmbzadlksMYERYCSrhIktvAHPMqv7qIv3ig0WCcXtAwH+AK3kbgZFoEf09XHZIAtiJRq0jeXd315umtujNkd4LVWO9VHdynBhrQaeXpc/nVS/oVHUBSrHugHu8= 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=N8sKeHH/; arc=fail smtp.client-ip=40.107.6.109 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="N8sKeHH/" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OGY80pORGK0V5WXK5F+QvloLNgl0JFKxwdj5JOvCbDAhJnV5wHT/BdwyjvgaPA6wlyCmPfDd+xHb0SaQbdv/LCws3Wm7vkwsLrxDu+iv2VQaMvuW+NfRmQq4YULds20BXvPIHL0+0KSck7evtYWXQVzJ+W2mVmmp33hiHEhyzKhgcWDx71TJRy5+0UyjltGDsy3014A3Sgbf0d8qsqu5pT9tv6BZuY2NgrvoDiR9MSD7477oj05aJ3a2jsbrHcax85IOc7Fw6pRgsvqLv4u9cYMtK7YoKS1hbNGdyLqig86WAP3lv27Q07oY92AZy8DB/wA0zq18FG+JoyS9gnA/zw== 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=mV5KuqQjWfeKmIYlAK9YyOO/Cr7iTLfv3O+0NTI5nSKZY4/F4FHmgczr2um6oGD+xmCyEtYCogYVKTTiqPfJhANUfzUzGe8LVOdn7O4rG3GUlWnIP5AU6OSRfUral7bezCRp1pV/rjno8wmACdC+SAzr0NC2ibdbRjpTXb2RMe76vt6wNjxkJIBP5x0rga18qR+Zih7e3y8fIb7Erux2+DfzgxU3kZVUh2BWff0na4ERDYhNis1enlm6PdVWxfbypTKi/D7VysHohwLMy0kByg9VUTyokPUHg+4jioFKpHxJDPbdopb3/2zCs9QJpKIz8vwC1QcEpSl5YeyFlNB1yA== 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=N8sKeHH/M8AdyTjnZdNWgq8fFGuqKr4AnJOyzoD4ZT0Wwr/e8Vn4tyWHHpBfrYVA3skKMN4D5CofyZaFUuMdSFZLKZfM2/6L6y3Volx6LmuIoeNJr3/rlX7QDogUtv6B+Ot9eIuhjlnuQfF89EcXwgC6DRgEWEWHd+XSgtqQaII= Received: from DU0PR04MB9417.eurprd04.prod.outlook.com (2603:10a6:10:358::11) by VI0PR04MB10163.eurprd04.prod.outlook.com (2603:10a6:800:245::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Tue, 2 Apr 2024 02:14:26 +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; Tue, 2 Apr 2024 02:14:26 +0000 From: "Peng Fan (OSS)" Date: Tue, 02 Apr 2024 10:22:21 +0800 Subject: [PATCH v7 1/4] firmware: arm_scmi: introduce helper get_max_msg_size Message-Id: <20240402-pinctrl-scmi-v7-1-3ea519d12cf7@nxp.com> References: <20240402-pinctrl-scmi-v7-0-3ea519d12cf7@nxp.com> In-Reply-To: <20240402-pinctrl-scmi-v7-0-3ea519d12cf7@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Dan Carpenter Cc: 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=1712024557; l=2653; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=dKDsMHnM+cuvfvX6K6tAU3ADCasBJe+OHaz6qBQ1Tuc=; b=BXEvqDrMweYTrQWmeCX90oHZaEQ8sAgyCC+pFmkKF6QbH71xD0VSg0R59q76yjlcUJqjT+YPX 8bCHxaQc6NRDkbLO8e8F07O4pdjxaJT1bPKITT7N7CGrM0ypjjIEWXi X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SI2PR04CA0015.apcprd04.prod.outlook.com (2603:1096:4:197::21) 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_|VI0PR04MB10163: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: XeY4g3fFyAd3tOJanD9V5prcD+bNXO2c53OXcLUOnQh7TH3ElRBmgMedEtiLLJHOk5bgjRx3oG6ryobMN4TnTrJfsKihDeG1PEbsb59xXtAOk5PEiFxmB7JD/bFOLs2pZ1Vd74pPYRUKFGiqYNsDXQWzEVXWXIrwR9HEcrNeyw+W7VuFe6wixkWdbA7M0VbJ7LDAOrJr7nQ62UufVdOWnUmXWftHPGIzMeAUEpav0Y5ePuCcqABUA/oLcUp3mxDMSVBTUiPayjjb3lET5GvL6StP6vZaCIpZSUyZw85sl4HpgvKAje1Xu6jyy6vFRF2bcbKhgXc9eGNPH4r8ZAR6OR79Q95buGc62qS1n6dvdTZgPfSUdzEyOTHWV3nyV3EcXoPoOF1UctRH3XalHLEXm25/9e+i5Qe4lHfGaRP6rtCmk2MHL9oohPBRjDYtXCkEphGpeRNOt9n2Bj4LGdfQslb2ZRFrwvS8A86oQVLW9arMlOoPtQwRqmE83aA3vDdcr5EqBpK2TjOV7VF7m/wATwiMiQ5Q/v0V9R7rg4pGFdBkNJjMZTBTwR8Q9LLq56bKqsJ0Ka4WG3qJj0tZfweA7pVgO0em+z7ip4Pe5rfW0DKWp1SZzF+dJT9SkihReIrmJ8TIh84EeYz8ICj05KfM1HlCoeYf7ueGIi0ZoszKqTs77xM2h1spotnLiD2KPNKmuBGG81ReQq9FrBMYNKSDb621DHqXbXMYPiv5f7P1hdM= 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)(376005)(7416005)(366007)(52116005)(1800799015)(38350700005); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?VRQo+WmsR6Bot5gGZ1kv93TXxmKQ?= =?utf-8?q?YmJ/Ebgh+vyeiQ6I4IkR4qtJ6RiTnwRDqLCOjER0gArTWeTkanqtD55qGfv7eU99J?= =?utf-8?q?HUH64UDgUOUP9fxe9UU7gRE4SOKoNVOsxEsZEGdl/OTUVqNWINk5x5CUct6AcBVBh?= =?utf-8?q?9bq2DLTbpY56Cmfr1TUGEnduwaDdfXa8oNAgLRzDXr/UiplYiOGE73cFduqs8iqta?= =?utf-8?q?/8GqjC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NllaTLfz/cp4vEIoc2JEpzyrE/yExdJa9FG24W1Ljs6A5RePUOD8K9y?= =?utf-8?q?6CUC0+QKyzpbu+AdrRzcoEc5rRa4kMBFz7Pp8dcxt/1vkIrqdHOg7NTswRGuTO4BN?= =?utf-8?q?SQgEjlDOZ9HW+T10xpzC6H+byzUMS849LacaWZD+ZGFCTIiMvcjQnj6PFx1pjNXuC?= =?utf-8?q?zQYc/kSAQeeOghRi0KS/3fs6S0G9yNW29ILL5L7HVTis4yPDm3OhUMG7Q1tr+1cgE?= =?utf-8?q?qlUXp1CDBQtBFQBrFurelMVzREIES2vsVxH4qywVk9hrtaLjQnDpCeugE3UM/YS/j?= =?utf-8?q?fhUdJ05d64EnPOuYQFN0NvFtg07BMZZ0NLkbEw9vjdFQs1fCFIfK7XHDSFzGUgmgK?= =?utf-8?q?E5r9xJ7/Dcktexd58Y3Rqgde543WMH4CBcT7JjAL85O6nxLGtG9t/HGrwldQGqMhp?= =?utf-8?q?85R3d2wHAukO?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca47d151-f66f-4488-c4e8-08dc52ba9ee5 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Apr 2024 02:14:26.3867 (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: wFjV9CCWTLKjFXjK9O4Dr2rsjUMpnD7xDxq10isFrOYqUY+b8iUJ2ovRd+C6opasq7hgNOdVtZLoCQgfaAK3vw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI0PR04MB10163 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); }; /**