From patchwork Fri Dec 15 11:56:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan \(OSS\)" X-Patchwork-Id: 754671 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2077.outbound.protection.outlook.com [40.107.104.77]) (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 289CB25567; Fri, 15 Dec 2023 11:52:19 +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="K59q91KX" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=L+e+fMQ0oPEHlHSxhEGeZPw+q/r2dGEkaKcg1lOr/y8x4zLOqPCVM8huOmHyguirKvVT9Fbz4HaEeNvLIjmbsKqXvivNBfK5GYFh42KlhQhAphw44dpwYIjbKDtYgMuryhKPtuGpa74qSpKPRA/yIH/1OowH5qez8YrHCfb6NuKU7t1EboDzU7lJUJ/C078ioC+3nrvz6YZEFoBvH3p9OPCFtYBJ+3aCyUGDCkFDcSkyTk2C01B9jaQXZoRXshFP54rrRd0l101yMZOn6FctJorOgphEgaMzE5cU5mBWSpPymn7hfkPMOK8icz44cPt/djwDtaGqNt80/tvw3n+VGw== 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=cCEamUi09ubpPY5s7jSHmF6ugaLgEH+EYKTxHeEJHsU=; b=Od/pdyMNTkzhiM3NCZFegdPrcV0/h3OqWbrbvBgDoMZgUO4d1ff1cA9ZiMPo0rFLBISelnG01xaBh9pjl1ALTJ64lhWLl5jmgqakQvbQ4wORctVIlAZeL5pkq7YC1LrgOrl3CCLtnO4sVwqNCk3zOTw+1HDHO3Y/pGyUVlP9fpCCeCVZtVsJeCaWDVPIgLrysYkY44nkSsYj+qiNwiT3nN08e32BMHjQZEdU0J1KsTFoEUP/UwtaRuZj9sq33bQ5hVQxHfn+iI9P3Hh70SlX8zSv2HDsxGRudFH5H91ynGfigd5lhkcOZwW2KdE9DTqFXqquu3oh72603+fjXrLmAQ== 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=cCEamUi09ubpPY5s7jSHmF6ugaLgEH+EYKTxHeEJHsU=; b=K59q91KXlZQEf0ayK2P7ZeTlaoRk66kQ8w/DNcQ7U+TJAaPq/vplNK400JLeQD4bIqXX+hM2NTQHXuj3KbU/T+FMs93CJRtLWEo7z+JqnKWNQwfm522ujxftQ0IjaW9qpv3A7hFqVqHcYrcZ3fJzgJAyMgzSyOffwcbyR8eOam8= 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 PR3PR04MB7435.eurprd04.prod.outlook.com (2603:10a6:102:88::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7091.31; Fri, 15 Dec 2023 11:52:17 +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.7046.015; Fri, 15 Dec 2023 11:52:17 +0000 From: "Peng Fan (OSS)" Date: Fri, 15 Dec 2023 19:56:29 +0800 Subject: [PATCH 1/7] firmware: arm_scmi: introduce helper get_max_msg_size Message-Id: <20231215-pinctrl-scmi-v1-1-0fe35e4611f7@nxp.com> References: <20231215-pinctrl-scmi-v1-0-0fe35e4611f7@nxp.com> In-Reply-To: <20231215-pinctrl-scmi-v1-0-0fe35e4611f7@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, Peng Fan X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=ed25519-sha256; t=1702641405; l=2166; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=68MbFg0oH740yCUj6NB45LS/NxU8ZebVwrXvl332/EQ=; b=rrzskCAyMB+F8eM/6WfbpA2eOAllulGxE/g/2vAyu4TpqHXYsVVA+ocBmH7A3gRgTJdiwg5vQ vCzmSpydIZ+Cen7mdbubch4pj6n25eF4f6zdvHaTfX3YnzRZBfyf0yC X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR02CA0138.apcprd02.prod.outlook.com (2603:1096:4:188::12) 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_|PR3PR04MB7435:EE_ X-MS-Office365-Filtering-Correlation-Id: 8356d424-362d-439c-ff48-08dbfd644919 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: HDYo9SIkxS+D3SgYHfWTsCXEK2Nr1aw/b1HNCjaZRaW99l/wErg61a98T+Gte7/0ojHIzLDt6gnTqP9nvhE/J9mEwExDwAa5U57VO7sG89zHKg+mQ8UbnUY4R4OzrlSgotfCt7PWMUBHZqgrXpJgNCWnTrWMfRYBYdrhTu5g4vDyXhQmzvjXw3PE3jPqfbiU5wkvaZtx5Xi4dvEAF9/kTUYV2xoDBnMuYzT+zfsSwcizgXe56It6W9GxoLmwi4Zrcq27iEJum8JqRFMO5dT71fjiFnuNG8lgooPW+uLSXeckRwQoUlcxt/AHcbGJdCB+T/DO54B/vd7bzRIsO0YoD/FAIOqkVYGGdY+Ot7JsFDwJJ0L3Em8WaKm2b87YJP/5dHrZfprx+zVKELsPkTza4OoufL3Zp9f3BZ4Kxz+/gEh0Uvy8GhONzBlZy68jMXzjKwUayhMhyzk3csG2MVm/tyzHEWCintlUT6c+tFVckOiVGJ7GYJOLFhdPemstzXjaOXFNxPQMxdxau6vU9JyBTJHaSbBLXDT2ZdHUGlIaY8bIfnOpizArl+oDFAlPAtD5toTdijwmT4ZvS1aTzM3OaQ5HabpksDoAeRd7yV2oCTLvaWPiGzGELi39it/1QTPZi+WK7lXM5u/dYII4cN/uhw== 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)(376002)(39860400002)(366004)(396003)(136003)(230922051799003)(451199024)(186009)(64100799003)(1800799012)(2906002)(86362001)(4326008)(8676002)(8936002)(5660300002)(7416002)(921008)(38350700005)(41300700001)(36756003)(478600001)(6486002)(83380400001)(26005)(6512007)(9686003)(6666004)(52116002)(6506007)(110136005)(66946007)(38100700002)(66556008)(66476007)(316002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?KrLQPOYmneE/q1dvR2wvCwFEDobm?= =?utf-8?q?GU1GjorBCrg8MqPnTFUXDbFx87IJL3ULo50aKpB5SxgiSnhNPYi/mw9OBF3TAvRwo?= =?utf-8?q?K14HtfggqzPBTm+FPf8ylqp8sI8DTnaatqBdF64o0WRcSPkYM0sEyWDg3pdjlpi4w?= =?utf-8?q?tL0ub6008qjd0U8YqMcPWWsQSK6m5lXvbrkS1U2qxUg1CVcf3u94hZtaKrQmiXpNn?= =?utf-8?q?oOAZtTfW7XmX+Ivnpr4n9z0EGhkQIZx1cy7wNm0Q7h7pnQ2yRLXQgTYgwL7zpzOTu?= =?utf-8?q?CqvFZ/4aTTX+nMppssPZkBoYUXKP3qZlrTVwq8Xdy5lxhvjMK1tEejwzS4HS0HboB?= =?utf-8?q?1GqrJYk+UaQGIO3JhSWGfUixoXf1b5kuXFVEFCrSk79H6EqfRav89oDYRfj697BTX?= =?utf-8?q?DQEJ5zFI//wMg0pxdRxMGdF0y5ogXu9XK9n3i/eh2l6mCcdtSSrvhpt9SLQuaYOQ+?= =?utf-8?q?xiyF1jek51hQqXrele80SlwM1Q6OkH9rsHMSwCsN/r+LpaT517hjShPgEXqnThblg?= =?utf-8?q?zZDKCcXv/165d6Lf0PMF2RL/8BOyY24nMxBKX0IAJsZIMlRClxM8pD7Zo6iTVI9F8?= =?utf-8?q?vWRLCLtbgPuLlhooLFOmoZB/gOX0f6KQh65WQ0cGIe/7TB8p+KTaY+BMn+MRJNkm9?= =?utf-8?q?Ul+0TkogQor37fdT7hG0acZSSi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p.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8356d424-362d-439c-ff48-08dbfd644919 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Dec 2023 11:52:16.9765 (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: l0+k/JnbLpTsUToWa1KuQqFFPNKwpmjGdyBab4nZa7ETXV9kNf05HE0iVwPx12l8Sh6Z4PtOoobx5kbZpsLo6A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PR3PR04MB7435 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. Signed-off-by: Peng Fan Reviewed-by: Cristian Marussi --- drivers/firmware/arm_scmi/driver.c | 15 +++++++++++++++ drivers/firmware/arm_scmi/protocols.h | 1 + 2 files changed, 16 insertions(+) diff --git a/drivers/firmware/arm_scmi/driver.c b/drivers/firmware/arm_scmi/driver.c index a9f70e6e58ac..b4f8f190351b 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..08de8dc064c1 100644 --- a/drivers/firmware/arm_scmi/protocols.h +++ b/drivers/firmware/arm_scmi/protocols.h @@ -270,6 +270,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); }; /**