Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp872221rdb; Fri, 22 Dec 2023 07:30:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHDqJ/S3i9/XRBF4XYjOe80PiWf7Sh+FGyVo4QfbP6vjqYlU2d7zwRkFN49DGJiy460DZxp X-Received: by 2002:ac5:c4c5:0:b0:4b6:b9ea:ef33 with SMTP id a5-20020ac5c4c5000000b004b6b9eaef33mr779601vkl.7.1703259031898; Fri, 22 Dec 2023 07:30:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703259031; cv=none; d=google.com; s=arc-20160816; b=ZYkeRTLF4Ykg1++cNOxIwWRZjARyZQJSeoxezfRf8Mufc31q1RCFotr22ukL8/7mm+ +qPwnrUqUtDhKwQUUgbM0mmDmqActs8Q40VZqdzHxP2Pnf13Xl4rwObi3YotfbKJHfTD fMxvdsckKXfCZAZSk5rbQGXIT3Tnb1i9w3fblKRbtRZGaHQbe9+JJT0VwZ9GSvCYm/c+ 7XObgp2vhXO+hRLGK/pXaEG4h1g2v1TeLIIBSy6cbAqnQY8kWpTu4GvNd3Z6UOkuYhIW yh/s5blD/UdThhHL4Xm52OTrAl8PfnKUSNn0A0LsKcAZNNMG59qxmL71fzOuRueKWlHI 32QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=efssj2V0OqsPKz0eEQhpsw8QmuXUv2bkYQwi4WJ2Zu0=; fh=jBW8KDWSI25Hlsqh5xq/VCu7Qfr59m5k4B6O38VhCD0=; b=E/oqvQtWxtYP7VTfY98cBkHQbamKoutNmELpPvkINafPgaQOhclSZtmqmcHHi8vcmn GyTAHaBnEh8wy36QqSB18xMeoMJ1a5d1VWQTEZKvgdbkr81GYWuQmAYquscwOGb80TUj qfEzSZWzzWuK1hKN+upCEEQjnx2psx0WnnA1mGV5uPh0QqXKLs3OB5MGX9EJB+x4uUAL mASY9R9gi7S8yTUuH9QCjnbORtQLUeCqhHJqz7ta56jQh+wp3cQoWQYqlJdqUGKtoQl1 2yyOTgmrUNClnFBQjSpHU2wTBbX6/yvto7evUZ9MNAet11P9RVDj/r2e67oGr8dXHuKc SItw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-9839-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9839-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id c5-20020a1fcc05000000b004b2d51271fbsi914068vkg.123.2023.12.22.07.30.31 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Dec 2023 07:30:31 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-9839-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-9839-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-9839-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.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 9DEF01C218AE for ; Fri, 22 Dec 2023 15:30:31 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 80C672376E; Fri, 22 Dec 2023 15:30:21 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D70C923750; Fri, 22 Dec 2023 15:30:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 4C2322F4; Fri, 22 Dec 2023 07:31:03 -0800 (PST) Received: from pluto (unknown [172.31.20.19]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 999953F5A1; Fri, 22 Dec 2023 07:30:14 -0800 (PST) Date: Fri, 22 Dec 2023 15:30:11 +0000 From: Cristian Marussi To: "Peng Fan (OSS)" Cc: Sudeep Holla , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Oleksii Moisieiev , Linus Walleij , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , NXP Linux Team , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-gpio@vger.kernel.org, Peng Fan Subject: Re: [PATCH 1/7] firmware: arm_scmi: introduce helper get_max_msg_size Message-ID: References: <20231215-pinctrl-scmi-v1-0-0fe35e4611f7@nxp.com> <20231215-pinctrl-scmi-v1-1-0fe35e4611f7@nxp.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231215-pinctrl-scmi-v1-1-0fe35e4611f7@nxp.com> On Fri, Dec 15, 2023 at 07:56:29PM +0800, Peng Fan (OSS) wrote: > 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 > --- > 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); > }; This looks good to me, but please add a comment for this new helper in the comment block above. Other than that: Reviewed-by: Cristian Marussi Thanks, Cristian