From patchwork Thu Apr 18 01:32:28 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: 1924790 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=NXP1.onmicrosoft.com header.i=@NXP1.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-NXP1-onmicrosoft-com header.b=PMDumWxw; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=139.178.88.99; helo=sv.mirrors.kernel.org; envelope-from=linux-gpio+bounces-5638-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VKg7F3SXRz1yZ2 for ; Thu, 18 Apr 2024 11:24:57 +1000 (AEST) 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id DE20D282FC4 for ; Thu, 18 Apr 2024 01:24:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 73259383A1; Thu, 18 Apr 2024 01:24:43 +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="PMDumWxw" X-Original-To: linux-gpio@vger.kernel.org Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2064.outbound.protection.outlook.com [40.107.104.64]) (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 316A01DA4C; Thu, 18 Apr 2024 01:24:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.64 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713403483; cv=fail; b=TQWx35W99tZ1h9roNZz9U85/9PtQ1REEbBSuf93xDowup6gVb4zfDWCbza4j67oWQevRhY2PYPBoTL+yU1gjXKZm9r15KizMHYb6AD9VynjgWjcl6Xr8DcJ5KzkAs4XYtUn2uCr8Do1c0WzIHqZodf7KzdGcYfcZ00mCoe1DM2Q= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713403483; c=relaxed/simple; bh=RhCldLpWFoBisg6JxF8FQ42efMI/x7hxyuGNT8KbSHI=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=mCl+ZRxDIPLNQ6MK4FgjgeZdgJavQqMDZSiPbAtQXsVWav6YhIaIok0mWEoi6Ue6ESgfojh/3fhg/lYUptPHvviGflEGyNeFDBTNoSD6tZ24snzg35ieRuaUEhxJmM0wZPKMrQV5aWH+Dg3gTD/7Hhrhz4AzWEVbUN2vlBpVJp0= 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=PMDumWxw; arc=fail smtp.client-ip=40.107.104.64 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=PP8eVU9tQSmdQY27I6kCokUWWv+MeneGiwBzxV/y4KS0yAW8EoyzJQHENjEBys7cF1gK0CHDt46U9NIlNCgHpGZhnghjky0x3uIjcHGcwDpC/aYF1v6R2kGb0AlUlusELgPUzpARieiTxqv85Cjrrj7nkEA9kmwLwurg0oipAPrrmF/KGYpq82mN+fV5i4Dss+r+NdbP1fgcH5jXa22vbkgPa3RI9Vo92tLtLrpmSEnxDET3Ou3K4A96stUAhCtntr9d93f4TqPiZn1mk5gyBmGGt/qVlamuOMqVWrCSMbiHUxSu8JBBX54swr+bx3qBIGGc2JXA/JMEGmKOsp69+w== 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=y32EPUygoezOrwpSdGDK5Cezq+RoDLA6Ci/XuseYkwM=; b=gu6W/oy+Clkvt9+gj6WHbJHe1ZZrefbjXJ2Gs6iBsWnL/OhZi0VRxTTmSViUeEVlmhMTu2832Jfae1E38X5UMuCHKTbLvMZE0qJTn+Ysn/8vI+QLyBuNiGwqfGRVYSLPOiyEg4MDAgy4lM9otldHmb4FSEwDGpkT71GnC4H4Qgi7X7hesAQop6QHzHTrt6n9gFBrL5ny+LF6G6E8fEtG5GdMLDAsL+DB3Vpzx21+ZxHcheRf2H7Pq2ZqETOt2UqFKll/XSDJ6uN4khdaOI4pczs9x8DLGdoUiaIYtUgG1dL2aGpn3wFXxNhRvI5k8qW5wIYn7fnWu9Y9vbf5sz2/DQ== 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=y32EPUygoezOrwpSdGDK5Cezq+RoDLA6Ci/XuseYkwM=; b=PMDumWxwNmd5rq/S0BvKVcAWRrbbN1ME3ujEixkcX2GaTGeW5MNMURK8ja1IpVQNNOxzYGrCVz/mo3htpSwisWnzz/c9zySCy9TXJeo6SpNmGnlDdGGacTbquXGj0THq1ISlOYJznBmGgw24uF6vFfmoDVQQ5xa4F1//CR2Ajp0= 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 AS1PR04MB9264.eurprd04.prod.outlook.com (2603:10a6:20b:4c4::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7452.50; Thu, 18 Apr 2024 01:24:36 +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.7452.049; Thu, 18 Apr 2024 01:24:36 +0000 From: "Peng Fan (OSS)" Date: Thu, 18 Apr 2024 09:32:28 +0800 Subject: [PATCH v11 1/4] firmware: arm_scmi: introduce helper get_max_msg_size Message-Id: <20240418-pinctrl-scmi-v11-1-499dca9864a7@nxp.com> References: <20240418-pinctrl-scmi-v11-0-499dca9864a7@nxp.com> In-Reply-To: <20240418-pinctrl-scmi-v11-0-499dca9864a7@nxp.com> To: Sudeep Holla , Cristian Marussi , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Linus Walleij , Dan Carpenter Cc: Dhruva Gole , 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=1713403963; l=2695; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=fC1f9Mz+AZ7lC+TNU94i2E/beyKrQPUiXgoBP0YzZ74=; b=uvGNPiYqgihRcYCo3u01MEoYWEnTApbl6WtoFdgkeg2yPSLHnNnHKxaYow7E0JYtw3Y2Ph5oJ VMjur4H9GOMBVLegt5x3bUzYI4sZ0oWyo+cl7HVxPTP1d2auoz/7RJj X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR03CA0116.apcprd03.prod.outlook.com (2603:1096:4:91::20) 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_|AS1PR04MB9264:EE_ X-MS-Office365-Filtering-Correlation-Id: 788082d5-b6c1-4ac7-0827-08dc5f464f40 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: dIbXlh/XHPprriWeHssC8P2/XQGG2ou4/k3PeLQfG/MChKG12So4vKxnfVhXsivb0jog2ilYSKbexijEFSqww0H1TDkOhzzhIPwtaDzlEpK9+w/sDUYPF9MyyBvULZG+oHgqkrgdcDKZnQ66TNEyR/jXfA9eXRSHJ3s5Enjj+GfSlCdFwg/9GFWM5lEg5D/54ypT1364fviJEi7AbDP3lu6NcGZX2hBrikBZynM/qo9eQWn3VNp50jwF9k70KuforU2flO05KA3bWxw3eUv0kFh/Nw79/UIYKXCZ2BfZQoOd5UWMbtw89Ey8Dv4Ra+Vw5q0LIx9CFxHn56BBYnCCL5v1wAZbKgBDlQfQC0x3ygA1UbXPgGW3d73kYYy11g1/aNsNNVTmf770i9KFRhYvGMNN/B+9S8kQACPIprXl4bpHaDKzVng7ToNu85it7DgNoOXjNrdoc7auyP5mcasCHge3vHQIhOB831+UMqHNdkvuBJed3ZuohO6hAOTgefKMKAsfqoSksGMGS2XekbdeMQUTNezqKQaF7Df5Ks9qD5/wXBV9MHqWUKfcKIxCMXcdYBO7P9TwumTV35ONNMPBgIyRo/YfuGlGSzvEUGYUoG17YD2dXHRVhzGbaCQ6LZqhol9EsAvuONvhyy7s+0tQgoafhw3RDTboMoUFl0IE+iuqcomDk7lnVO0lQcG8/9XaiBho1sY3CQeAysgQ7XCEBcjgbAJ4tj2+cTewpk6fjy4= 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)(52116005)(366007)(1800799015)(376005)(7416005)(38350700005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?wQan1e6HoRCA9Mi1eXuotBVY9esf?= =?utf-8?q?oQpYQMzAx+rNGvEeKeSvRjAm19ZaHewGpEinKFv0IZHH5BT2Cr9fc2iR7cZsyd1UZ?= =?utf-8?q?h4I6kUGW0N+Uag9lhRGmE7a8FfMoXuSXRJza5eRrpAgrPt5ncPUJ08i6FcuSEMPeE?= =?utf-8?q?P6ChYX+8HNZ2Aqfeo0dds2WP643NFtbLDVuWkxbGM7bWZSoAMpPznzOJVSNzm4NF0?= =?utf-8?q?VpyED8ysSIwpyNFFQhTQSjZEoaASwamQ2XrTRfX6aLM4x2LGDAOIzlx2xFD940Zg7?= =?utf-8?q?JY+U3jewl3e393/YNYjiO2NEQGxmr1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7Yivw2nQ633Nf4ZCUHZV/lSLH+7WWH3pNo?= =?utf-8?q?nE5HFZdb2dv7CWTS8dR7K4zt9c47nDl1t9rPa26BPrBIx9HRTZdIdLaz6QQOIhy29?= =?utf-8?q?d9YiKTC1iq96+ZKoS/DsVmol9rYqK9S7S3dbCPuaYnUTsVxTiFHISbEX/bTcDbhHp?= =?utf-8?q?fF5z87qOdlsDaFSByrHLAwO6lmqnkMxWrtjSJnxQoIhvY7PwXuD0gcVyFVr8LZXfZ?= =?utf-8?q?mG20Kx6LShqpR169KmsNEm/khWSaNjEPNLPMab/0+mf1qFkfo/tI659d4iCC1ZOFK?= =?utf-8?q?RmQDX0rmd7R/vsH5hiNzpKzS/L9iH1RuiXtCW4dt2WhIDDxaFpho7hpw7en8oboRc?= =?utf-8?q?iWV/UMDGLGYF?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 788082d5-b6c1-4ac7-0827-08dc5f464f40 X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2024 01:24:36.2573 (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: TcHroXCLo7dpV/guGAsreR2hLW1g66iXDLqF1zuHTBj1PqdFxwqONv1KX+dIQdcooNWIre+wgN4i/OD6tMW+4w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS1PR04MB9264 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 Reviewed-by: Dhruva Gole 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 36e3eb50a8d4..a1e0e8fa4bb7 100644 --- a/drivers/firmware/arm_scmi/driver.c +++ b/drivers/firmware/arm_scmi/driver.c @@ -1537,6 +1537,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 @@ -1848,6 +1862,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); }; /**