Received: by 2002:a05:7412:518d:b0:e2:908c:2ebd with SMTP id fn13csp374829rdb; Thu, 5 Oct 2023 08:23:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFtH5l3jqnMs5HWMrB8NWHHDTNJ0TtofBZ+5AgVO7SLydJlqxsYiXbQmeGwXWv94CTuoVvM X-Received: by 2002:a17:903:443:b0:1c5:ce3c:c391 with SMTP id iw3-20020a170903044300b001c5ce3cc391mr4999475plb.12.1696519415007; Thu, 05 Oct 2023 08:23:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696519414; cv=none; d=google.com; s=arc-20160816; b=ZSANAZL1QhL/hZTT1qkEr1DwAqSp2td6D6049TDEkjR4AKAmgP5gAeF0LS3WzEPyTh JT+HrJsDH81a4dWBq4bdQXmvfODf/FW7sUAe4cxFfLDBWSvOSrRiSmKFUsps5SB4/xdZ iZMNF72a3oTu4JCeoui8WYVVBCj8luraVzz2u6EW/u6r6J8HAt9dz4ZE8J0PJhyVE9m/ 9shdvX/kRq+EGR2A4bDn/MvNVNBvpPj5VZyx84ae4VS3idTZORIgn1B5l+PTiNeYpyjC i2L3funZQP4SgeKIKccxCHf+qVP4iXRh66iJoMuzLz4dLdLKjIaG73rdpGFszYnYwNNp WN9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:to:in-reply-to:references:message-id :content-transfer-encoding:mime-version:subject:date:from; bh=dggiQkkiE7oT7S/kWnOv92tsKaKhAJ7nP/SKyEkwZxs=; fh=iZJRvoZuVJp3Jcg3UWu0imuTLbH0nKChof8pDyzNHj4=; b=f2SMJ0MvTY+v2qTKMc+5Ywf2qbKLdhH3MOuCat6YZr99tsO8djOybC1CGKmCAu1U/v vbzK4YSAp2GUddTBD6hzkd4rff/l5Noeep1D3xcRepmxDnDYtk6OrSOhi6sWyB68C/bh cIIWnDk0HB8smoVMbse8qvKMc5sEMd7jSh56S95Tzshb9/C5khca8/dvXIxPtybgilRy 3s/nKzWMS6pCwiICVKZ6qIiyWR71nVa6jvEqB3dgqOlnpY1viKeC9EPYk0i6LBoWu876 pJWfwcvVLH87kn5eJz/9wjxGu43W1spkiVfu3zaGbAe59KsOI6alxfR15mTI0tYRbfMX oEqQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id w9-20020a1709026f0900b001c7342b46e4si1571735plk.23.2023.10.05.08.23.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 05 Oct 2023 08:23:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 23C08804A48D; Thu, 5 Oct 2023 08:22:03 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232518AbjJEPVy (ORCPT + 99 others); Thu, 5 Oct 2023 11:21:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42796 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233578AbjJEPVF (ORCPT ); Thu, 5 Oct 2023 11:21:05 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 759FD21345 for ; Thu, 5 Oct 2023 07:45:44 -0700 (PDT) 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Thu, 05 Oct 2023 08:22:03 -0700 (PDT) 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; -- 2.42.0