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 93FD13630B3 for ; Tue, 2 Jun 2026 16:27: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=1780417672; cv=none; b=tRNhPbIX/yzr/T5FLPeuviCnu1FzwJz/8/MMaIo89KJBTG0nq+FcTgT1tq358fa4qu58Om2Do9PF3gr1EF5PSCDnbed8nLZXFZEbH/rRJmFpj0HENEEuJ2fkuHpwSoPw1pEzz1YSWcNBSGY4lgswTtXLfg3QC3j7Xgms/q2hjoI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780417672; c=relaxed/simple; bh=WfdefGiGEkxFmrvhn9SBuU0/CLGvkO9Xmhc8VrHjCCQ=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=jfFV+/Hw3y4QUWziR1ypD2WkA5YkjMxW6H1z0dTeRWjnfj0u42xecgnj1xVNJDkdEwEWD73UaMFINquK5T9vza9xcMr9+2Q7S6qYnvCGSVSquqQXTDlaiAMOSiBWMauN9y90vuIn8iz6itj7mJQvVR2lwcUvztaEKIV37O8hFNA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=g6ti7ugc; 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="g6ti7ugc" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C59D1F00893; Tue, 2 Jun 2026 16:27:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780417671; bh=uJwauw3yIgL9Nn8rgrK60DliH14WU9hH1XUdWzb9RIg=; h=Date:From:To:Cc:Subject:References:In-Reply-To; b=g6ti7ugc7Q4yQ/Yv1cgs+KjEL5bXPLudNqMJCBXgkP6itRar9abMExf+0yKCjTY0H K9CD91i/vrgx0S4xEKfrrqSFq+Hg5gKbxuMWmbPs74dmDD5PnEIillMcKq+mZc7zjK 0w7j5hT/zJLu1O67eB3ejj0Rox04k+jtwwfj2rVhifgSAc7KL6t4lPzrVLFQ9WiAeW fVug6UC5B9qYe5ZK2t23EfQtFWKwTMJEvgFKkG/VCibOX9U2t1SgkVRrkV1Gr4ZGut hbQ6//irk4k2YK4vCB3M2acMHexyaS5fKll9u8YGw0/de6pxKAzN6mWk31jz/IaU4V yf5u/7DtYH1og== Date: Tue, 2 Jun 2026 17:27: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-accomplished-illegal-mole-ef2acc@sudeepholla> References: <20260601-b4-ffa-rxtx-map-fixes-v1-0-c071b12ae05c@nvidia.com> <20260601-b4-ffa-rxtx-map-fixes-v1-1-c071b12ae05c@nvidia.com> <20260602-grateful-elfish-elk-413154@sudeepholla> 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: On Tue, Jun 02, 2026 at 11:12:03AM -0500, Seth Forshee wrote: > On Tue, Jun 02, 2026 at 04:56:48PM +0100, Sudeep Holla wrote: > > 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. > > It is added just above ffa_init(). The code as been compile and run > tested on multiple platforms, as noted in the cover letter. > Ah sorry, my bad. It failed to apply and I must have messed it up. I have some changes in linux-next which conflicts and I dropped it when resolving. Sorry for that. > I hadn't checked older spec versions, so if they have it as MBZ then I > agree we can drop the check. > > > > > > + 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. > > Correct, though linters complain about it which is why I added it. I can > drop it though if you prefer. > Can you be more specific ? Any way to trigger it ? > > > > > > > + 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. > > I found it in v1.3 of the spec in Table 13.15: "Size must be greater or > equal to the minimum buffer size, else MBZ if there is no size limit." I > will remove the comment. > Ah v1.3, sorry I was just looking at v1.2. > Thanks, > Seth -- Regards, Sudeep