From patchwork Thu Oct 5 14:45:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13410166 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 02383E9270A for ; Thu, 5 Oct 2023 14:46:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References:Message-Id: MIME-Version:Subject:Date:From:Reply-To:Cc:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Wjci7rEF9/LoogS4XFu8OB4w62dAqnDKtqhaYvo7NFA=; b=MIblD9riA+7DNG nvQa/uCWp4V+D7ACVvj0GD2duzRf9kR/N6S/FmYyjrF0o53kIrb7E5nhUcTmSgWzbgwtJ2RM7cdk8 Jg6/Nsw1keDxEyfesWImY0IDvCWPGm+VN9g9rSbrJHUqe3/E3KTT5vn0XYeVme0uJAsT4uzSImFbh erXJHcVdbU9p5k+Q+5K/uvALRwF0tprYvdxW8cNCL1heu9MASHCB8o/q1QA/dqVH4FX03Ulbc+Oj6 DBeoH8U4zGGqa8b69pjkkTx6ubLPZsJsnj02YpHSwPXYY8Ww9vSqi9FHkACSaCEaJegjvM6W2ztTI ptKjE1LYvn1DHIJGpOew==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoPbe-003lug-2I; Thu, 05 Oct 2023 14:45:38 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qoPbS-003lcW-0P for linux-arm-kernel@lists.infradead.org; Thu, 05 Oct 2023 14:45:28 +0000 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 2CB7015DB; Thu, 5 Oct 2023 07:46:03 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 76BCC3F8A4; Thu, 5 Oct 2023 07:45:23 -0700 (PDT) From: Sudeep Holla Date: Thu, 05 Oct 2023 15:45:06 +0100 Subject: [PATCH v4 13/17] firmware: arm_ffa: Simplify the computation of transmit and fragment length MIME-Version: 1.0 Message-Id: <20231005-ffa_v1-1_notif-v4-13-cddd3237809c@arm.com> References: <20231005-ffa_v1-1_notif-v4-0-cddd3237809c@arm.com> In-Reply-To: <20231005-ffa_v1-1_notif-v4-0-cddd3237809c@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Marc Bonnici , Jens Wiklander , Coboy Chen , Lorenzo Pieralisi , Olivier Deprez X-Mailer: b4 0.12.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3428; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=Bk/KguDz+Pa9YD44dR4bVtd5OHjZzTqIACMhi/OAstc=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlHsvy54FhXD9M3/xGz2SYo5UUiWjBKhS/CrOYm DIteIRcWumJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZR7L8gAKCRAAQbq8MX7i mJxdD/9iwVr+502At7oyF6Lgr+0lSTlhDAKQPpxK5BQ3baVM+bFBNobUFInNlj4NHXerZu82j3u ErROcKLWnk9PtI4ZeGC7Lr6vWIHhPPlsQjXVc2RoZhtJh5pVTyixbZwLDNeshdpAlgs3f0Fd9EK uK4oJAsfkM6R7uqO1BqUVv1B2xPk257JdObrqFBe1mY7lBmw+IqM+0CmFsCFia6P2jdK8NeDxxo ETqyQEn//VvVBATcDvvneF6jQfgaTiwU6U81lmkLOJpB0n1k6aYRqbAnhWNdwOByUWKIY9uNJKU GmSjN3IAPeGmqLaOTvZlXeLP6lgTIss3G6PNJ1lJChuyaHGhGWBE5BGT2mWtKzSPpXajXWrYKEP Um/zAnMG1FByBEGqopm0WfTI0XzJk3+w9KmnKPwsJxERVNcZwBZVifBHo4xuZpY79zHo2IZuIPS 86omoq3ypaNfWSJepmqd5DDWM/jP6/eCRvwVkB2qx4iGjCYz6Do0+ERW/AtwYI3/Lj+nnc98wWy 2incga0kZXWdQad2zcil4HEd5OrT7t2CNfLc6SG+pK4baDf7hwgca3ZMUpKCcRp3MZKaT3DJw7H S8g6D1fojvvMJSQBIuYqs57qtiOrt9P90hVO4p6ARwna608lqxgqOHpB8Ls2foVseWQLDkVaypN A7hJTpnH2aldgpw== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231005_074526_261961_E48E28A2 X-CRM114-Status: GOOD ( 11.71 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The computation of endpoint memory access descriptor's composite memory region descriptor offset is using COMPOSITE_CONSTITUENTS_OFFSET which is unnecessary complicated. Composite memory region descriptor always follow the endpoint memory access descriptor array and hence it is computed accordingly. COMPOSITE_CONSTITUENTS_OFFSET is useless and wrong for any input other than endpoint memory access descriptor count. Let us drop the usage of COMPOSITE_CONSTITUENTS_OFFSET to simplify the computation of total transmit and fragment length in the memory transactions. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 14 ++++++++------ include/linux/arm_ffa.h | 2 -- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 9dd5335001ee..45ad704734a2 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -442,23 +442,25 @@ ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize, { int rc = 0; bool first = true; + u32 composite_offset; phys_addr_t addr = 0; + struct ffa_mem_region *mem_region = buffer; struct ffa_composite_mem_region *composite; struct ffa_mem_region_addr_range *constituents; struct ffa_mem_region_attributes *ep_mem_access; - struct ffa_mem_region *mem_region = buffer; u32 idx, frag_len, length, buf_sz = 0, num_entries = sg_nents(args->sg); mem_region->tag = args->tag; mem_region->flags = args->flags; mem_region->sender_id = drv_info->vm_id; mem_region->attributes = ffa_memory_attributes_get(func_id); - ep_mem_access = &mem_region->ep_mem_access[0]; + ep_mem_access = buffer + COMPOSITE_OFFSET(0); + composite_offset = COMPOSITE_OFFSET(args->nattrs); for (idx = 0; idx < args->nattrs; idx++, ep_mem_access++) { ep_mem_access->receiver = args->attrs[idx].receiver; ep_mem_access->attrs = args->attrs[idx].attrs; - ep_mem_access->composite_off = COMPOSITE_OFFSET(args->nattrs); + ep_mem_access->composite_off = composite_offset; ep_mem_access->flag = 0; ep_mem_access->reserved = 0; } @@ -467,13 +469,13 @@ ffa_setup_and_transmit(u32 func_id, void *buffer, u32 max_fragsize, mem_region->reserved_1 = 0; mem_region->ep_count = args->nattrs; - composite = buffer + COMPOSITE_OFFSET(args->nattrs); + composite = buffer + composite_offset; composite->total_pg_cnt = ffa_get_num_pages_sg(args->sg); composite->addr_range_cnt = num_entries; composite->reserved = 0; - length = COMPOSITE_CONSTITUENTS_OFFSET(args->nattrs, num_entries); - frag_len = COMPOSITE_CONSTITUENTS_OFFSET(args->nattrs, 0); + length = composite_offset + CONSTITUENTS_OFFSET(num_entries); + frag_len = composite_offset + CONSTITUENTS_OFFSET(0); if (frag_len > max_fragsize) return -ENXIO; diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index f6df81f14b6d..748d0a83a4bc 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -356,8 +356,6 @@ struct ffa_mem_region { (offsetof(struct ffa_mem_region, ep_mem_access[x])) #define CONSTITUENTS_OFFSET(x) \ (offsetof(struct ffa_composite_mem_region, constituents[x])) -#define COMPOSITE_CONSTITUENTS_OFFSET(x, y) \ - (COMPOSITE_OFFSET(x) + CONSTITUENTS_OFFSET(y)) struct ffa_mem_ops_args { bool use_txbuf;