From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (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 9DB1F3DA5A2 for ; Tue, 2 Jun 2026 15:56:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780415812; cv=none; b=kYl9tqe59TK/SCsYZKnOicK2oPO67rZMBr2S/dyrNFIUe8rZR6Fc43HgkrRO4ZoHIESNCfR2J5beLlTNyxeJJokx4PutqNLK5pyiLquSWJ+dk0iK3TibE70VY425EzYXziN5Z1TyC49Y9C9rgblIa0YAV416N4lzdEnisvdxiAo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780415812; c=relaxed/simple; bh=1aauHqbXtTiglt4NdniPBDUDwetibrJAWcVFbL9NxXA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MPfu5p8MBdEpIJjPEyTzzDtDY50HIDcrCxbTv17l/PqNXItYShy+XwD6jO0UPCSEj1lVCDXlYjeHeOWImYeR3sMc8dHNDYPz2qP7clfzw/JRUHzaonuiWACd4dfB8qEvOYnaHt2MZ7WYykrcSNNem1jRWpP/8crpiYiLCa0JV7g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AdWaTzp8; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AdWaTzp8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 849271F00893; Tue, 2 Jun 2026 15:56:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780415811; bh=Y9m8S6JyUzmFdM3Udt7t3oE3a4LWGNMVRc638npnOlA=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=AdWaTzp8bzhTy5l0gOgtLBl7/OluUXVmwcSlruLQ/GZvBbsPcrQpSp+blRZYNyjtX WnEDa6VNN6YQEWRiJrKk/RHRbg42aP/BgbcLeOuJODmT6Und49Og3J4tPcbEZj0Po+ F0mLEu7LJCv/MP43R9uhOZerWE5GKhFiRjO2PWBBbmxX9v9mpomt1cZzxpLRc0m4VI EKpHmXtZghsRbyaaKYcOIni+KJU+GX0KpJzT8cOxDDEyQC1LofR/Uwtc9c/CWLm8Kc LCWD21iuy4h8XkdHPe2+ECus/QeMj+bR3+x7C6UWbiIETbfCLM5Fwn8Ox2eqk/JvWo Cgk+OqXh6Copw== Date: Tue, 2 Jun 2026 16:56:48 +0100 From: Sudeep Holla To: Seth Forshee Cc: Sebastian Ene , Sudeep Holla , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] firmware: arm_ffa: Honor maximum RX/TX buffer size Message-ID: <20260602-grateful-elfish-elk-413154@sudeepholla> References: <20260601-b4-ffa-rxtx-map-fixes-v1-0-c071b12ae05c@nvidia.com> <20260601-b4-ffa-rxtx-map-fixes-v1-1-c071b12ae05c@nvidia.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: <20260601-b4-ffa-rxtx-map-fixes-v1-1-c071b12ae05c@nvidia.com> On Mon, Jun 01, 2026 at 03:45:11PM -0500, Seth Forshee wrote: > FFA_FEATURES in v1.2+ supports a maximum RXTX_MAP size. This maximum > size is not checked when page-aligning the RX/TX buffer size, and > FFA_RXTX_MAP may fail when passed a size greater than the maximum. > > Decode the maximum buffer size returned from FFA_FEATURES and limit the > buffer size based on this value if it is non-zero (zero indicates no > maximum). Include verification that the max returned by the SPMC is > larger than the minimum, otherwise use the minimum. > > While there, also update RXTX_MAP_MIN_BUFSZ() to use FIELD_GET() for > consistency. > > Fixes: 83210251fd70 ("firmware: arm_ffa: Use the correct buffer size during RXTX_MAP") > Assisted-by: Claude:claude-opus-4-8 > Signed-off-by: Seth Forshee > --- > drivers/firmware/arm_ffa/driver.c | 29 +++++++++++++++++++++++++++-- > 1 file changed, 27 insertions(+), 2 deletions(-) > > diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c > index b9f17fda7243..dc45724a29ba 100644 > --- a/drivers/firmware/arm_ffa/driver.c > +++ b/drivers/firmware/arm_ffa/driver.c > @@ -32,6 +32,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -55,7 +56,9 @@ > (FIELD_PREP(SENDER_ID_MASK, (s)) | FIELD_PREP(RECEIVER_ID_MASK, (r))) > > #define RXTX_MAP_MIN_BUFSZ_MASK GENMASK(1, 0) > -#define RXTX_MAP_MIN_BUFSZ(x) ((x) & RXTX_MAP_MIN_BUFSZ_MASK) > +#define RXTX_MAP_MAX_BUFSZ_MASK GENMASK(31, 16) > +#define RXTX_MAP_MIN_BUFSZ(x) (FIELD_GET(RXTX_MAP_MIN_BUFSZ_MASK, (x))) > +#define RXTX_MAP_MAX_BUFSZ(x) (FIELD_GET(RXTX_MAP_MAX_BUFSZ_MASK, (x))) > > #define FFA_MAX_NOTIFICATIONS 64 > > @@ -2086,11 +2089,13 @@ static void ffa_notifications_setup(void) > ffa_notifications_cleanup(); > } > > +#define FFA_SUPPORTS_RXTX_MAX_BUFSZ(version) ((version) > FFA_VERSION_1_1) > + > static int __init ffa_init(void) > { > int ret; > u32 buf_sz; > - size_t rxtx_bufsz = SZ_4K; > + size_t rxtx_bufsz = SZ_4K, rxtx_max_bufsz = 0; > > ret = ffa_transport_init(&invoke_ffa_fn); > if (ret) > @@ -2118,9 +2123,29 @@ static int __init ffa_init(void) > rxtx_bufsz = SZ_16K; > else > rxtx_bufsz = SZ_4K; > + > + if (FFA_SUPPORTS_RXTX_MAX_BUFSZ(drv_info->version)) { This is not even compile tested ? I don't think this is defined anyway. Anyways I don't think we need this condition as v1.1 or below had it MBZ, so it is fine to drop it. > + rxtx_max_bufsz = (size_t)RXTX_MAP_MAX_BUFSZ(buf_sz) * SZ_4K; The cast is unnecessary, its is 16 bit, so max 0xFFFF << 12. > + if (rxtx_max_bufsz != 0 && rxtx_max_bufsz < rxtx_bufsz) { > + /* > + * Per spec the maximum must be >= the minimum, or > + * else zero if there is no size limit. If the SPMC > + * violates this constraint, use the minimum as the > + * effective maximum. > + */ I don't see any text implying the above from the spec, drop it. Please point it to me if you find. Even otherwise it seems obvious here and doesn't need the note. -- Regards, Sudeep