Received: by 2002:ab2:2994:0:b0:1ef:ca3e:3cd5 with SMTP id n20csp94314lqb; Thu, 14 Mar 2024 06:27:35 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVX0xdUvBrENQFE7owm9yWi+WLFuE18/XZmDpciVzzJ4MeRuxOQ8Hc1veB5leJiVANmCpoUD1JpEKxXhgqT9kLDaVgImmGTWwlRS/fNfg== X-Google-Smtp-Source: AGHT+IFOE/7xNgk3GEhaiHAKV+6kikxv/AjEqWZW3aHXaEB0/5ApGki4Qk//ZAgykVIUvZ6SlJA7 X-Received: by 2002:a05:622a:58e:b0:42e:e53d:230e with SMTP id c14-20020a05622a058e00b0042ee53d230emr631522qtb.60.1710422855537; Thu, 14 Mar 2024 06:27:35 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y15-20020ac85f4f000000b0042f4db1ba40si1465198qta.608.2024.03.14.06.27.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 06:27:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-103293-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=BPpRTPWP; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-103293-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-103293-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 356F71C21057 for ; Thu, 14 Mar 2024 13:27:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 678A66F06E; Thu, 14 Mar 2024 13:27:20 +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="BPpRTPWP" Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2042.outbound.protection.outlook.com [40.107.8.42]) (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 5EC625BAFC; Thu, 14 Mar 2024 13:27:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.42 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710422839; cv=fail; b=njd/fopPLHhZEUHfS1sItF8Uk8KcS5gNbGDRn9BLrfFhHn7afOCFUc/aIBJDJfo3RJytWuiTJTsN6BxN5+Rq75vSjofYIHHkcyjItG9KTMeP+dp1w9Az25KWRonfZy+AeJor5tzAozs/g7Nb6IdEj7Z1aPC2s03qeAdkASkREMo= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710422839; c=relaxed/simple; bh=t5HLy5gFexuRUd/gcXkLur0tNUBqrWNFLScENOV0ZWY=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=qHQDi4hL+NQboxpjplNIQ3U3B3sBQ9SpWmuny07FusLSVEbzqf2CfsTLNaXccnB0Ieys9WwH+Lzp6GoAo8gq5RxBrnlKdrzpkfLSiTvhMyX4bD4S915ZndkEZ94r616leH0Of/LcZbIy2BTg/LlkQt9C5JXb+Z2t+wkGN3E40IM= 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=BPpRTPWP; arc=fail smtp.client-ip=40.107.8.42 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=D/I18MYCOba+ITMNpKFXky5/qV1a/5cbB9O0Q1eJJhH2tXbJbFmaVu3/9XOCGjytr4v93cCfDFr9JLC8pFY+1DCnHSGpEFjDQIHyMUuuw9KrPgh0rigTB+jLfhvFf8gzGQBwmegHKIPnAyDsFZyZhfwKVUHiiW/705H+fvfQK0RWirsy0uMwPBy7cyY90pDRcEOE7apETlaiE+oLeLZUcvrB10jgF/MZwxCifZErxD8Nl+ycUX1cOm5GgnxF9CowpYXLcSAvMndRnbT7rkxhMYq3ePBL4f9DQNxfdOcY2+Jnr9QmisZ/MC2ithD+p8GkKnf+o42xaqJQw9S+zcISkw== 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=Wzi8I1PEgs6w++cy2ImwhcNzoOrUHl6fUrpaY4EVn1+hcZ0kK90EnxCrNBRPHcwsTmgN0IQXiMmkvLdfmMt8BKf0VYLewN9ndq5MO31skyxAlGZVSPld1t8dqbCgShMvuKU33BgJF17zc7L+jrQGaXoUzkG8l4TFoMCLcGPqNRAXYqZ7S9j9OPCJh/PE96/ydb2DT/pKSILwGPkOZHgJREEy84x3gNPy7VK41FCJQQjF9rlmEp4/uHcZNCzC0D+Hp2Evdvq+2bkq0oZaFEQ5QHTLvCU9fSy+gZshGFquJ0lIzBYAxE20FvsY0vSO41HR08FOLuwhDStIfJ2+TCChRw== 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=BPpRTPWPL293Tza8Ny6nUgjHlAD7lk4LyGTqYuRvHDQ555lng1PrSibREfpS+TLQQjgy+NIRSEmNlchrLXyjPI+0s+TNOm+3FA1LH1V04niQCZXqhdo94G26SFqyK6PR6UBuQrUnup0Iy352JKGc4I6+Zr0Ab/lriU1zLLQ3RWk= 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 PAWPR04MB9861.eurprd04.prod.outlook.com (2603:10a6:102:381::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7362.36; Thu, 14 Mar 2024 13:27:14 +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.017; Thu, 14 Mar 2024 13:27:14 +0000 From: "Peng Fan (OSS)" Date: Thu, 14 Mar 2024 21:35:18 +0800 Subject: [PATCH v5 1/4] firmware: arm_scmi: introduce helper get_max_msg_size Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20240314-pinctrl-scmi-v5-1-b19576e557f2@nxp.com> References: <20240314-pinctrl-scmi-v5-0-b19576e557f2@nxp.com> In-Reply-To: <20240314-pinctrl-scmi-v5-0-b19576e557f2@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=1710423327; l=2653; i=peng.fan@nxp.com; s=20230812; h=from:subject:message-id; bh=dKDsMHnM+cuvfvX6K6tAU3ADCasBJe+OHaz6qBQ1Tuc=; b=4xzM3YkXuTqYU0tEDo6x/HN4gsRKw3cpJZgM2pUwWmhzTcBuCmBTTPCH+IZBUrrpdGdNWuVQ8 6MyD12S/yYnCjWetyg8RKWlUcjin4Jf8siW5hQolqJ7mOHzFtszNtL0 X-Developer-Key: i=peng.fan@nxp.com; a=ed25519; pk=I4sJg7atIT1g63H7bb5lDRGR2gJW14RKDD0wFL8TT1g= X-ClientProxiedBy: SG2PR06CA0188.apcprd06.prod.outlook.com (2603:1096:4:1::20) 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_|PAWPR04MB9861:EE_ X-MS-Office365-Filtering-Correlation-Id: 2640a9d6-c38f-404d-f731-08dc442a75fb 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: N5VTujBtBoO/i+cA10llx2BsBHIOkUQ/kQV2Ev0E/7x4JXhCSmSux6L+r1sdil4gduW6DPMgs812ypiNg+on03kzFubcJfOEq5cvUOJSaiR6psLiTLZeZeoXy8HW7cpwoj8hZVjXUtBECCw068mWu4t542197KD/yP5G9knFCkb0wmbLya44B3wY649nFvnqSi2sGsjQ+e044BV4yjKYmOXQ43weY6xdY3TSQ3j3sD/thbBvLrLN/GqgejwKpwYrLivn0m8IWXzCSiM3dl99bLrVIze1t0cXkMuRifWGmU2UlV93QetIJZ0IYNHsTnmUHXiTDrLCx8sigOLWor0lk+hCm+W4FGo5IoPb0CJmD6bqMou17cRbjEvhGDeCUfKBGLbHGZXn5aJ3UD/R7lT6Wvm4DWjW3a5j8qYxFLxmCgvFykpfUfrk0PpD91hfYXQn0diTddVew5vVGuu4J7yYLrqH/oz6Xp18k3JzwG8w+2MyiKgjIKo9m7vdy0Sd4g97+lgDvwF77oJ27T+kFji1yc67flBXf9mw1ZD2heJdK9MdFSJg8y6CUnFgsGhsHvo/rh/YRHttVJpyl/c4HeL0UXTGz11NoyzjMNB0Qf9Pf0RoYlFJYvDKpPDuxS8kYvmf6TTBkw59l5pOj34CFtMinLPRDWjSyuuIpVQnSjwKS5p6VHrSMUoOVGmsD7MUelvEFjYwDkFv1TyTlo8umn7JuRETT5gans/ENyBxeFcjjW0= 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)(52116005)(7416005)(1800799015)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?d0YrMEtFd29PdlF4cGRIYi9aeENpWFdIaHBW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uSUN1dDlub2V0ZUh2OHBaOGZFME1WNGtYMzhmN1NSUDdQRFRpT3JJZmJm?= =?utf-8?B?YzVZc1Q2a2Y3cEEwMWZYdUpnZDcvakVmQzlPY1ZZdThwWitXTWtQQ28vdmdm?= =?utf-8?B?a0M3aGROQ3VUQmpQVGUybitnaTdzY0JpejNBbGYxMllmeFU5Zld2NzNGaWRU?= =?utf-8?B?VlZpa3FQdTJKRy84T0RzdTFKRHoxL3Y5Z0hmMkFLQWx4eHFRazF3VFRBbVY3?= =?utf-8?B?NTdBMTBISXBURVlGQlBRTCtVakJpRithcDh6VE8xd2h2eXFURSt4Yzc5b1Q2?= =?utf-8?Q?X822JF602bLCF5vna69l4sLWb?= X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2640a9d6-c38f-404d-f731-08dc442a75fb X-MS-Exchange-CrossTenant-AuthSource: DU0PR04MB9417.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Mar 2024 13:27:14.0136 (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: YWnfXaZZPbqlvaphSEnMaLnzFdlKpr4wJg30PWA4kiHrjt1WPCVIZNpC1WJddCu8kfJnaPqMkakWrb7e3lZucQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAWPR04MB9861 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