Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp809889rdb; Tue, 19 Sep 2023 10:44:08 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjzv4Ikgxt2SpKMtY26yukcf9RjXPLyvmNCzO9RKB0WXGWYznXFstXTMIXztlzYJQ95YWK X-Received: by 2002:a17:902:e743:b0:1c3:9544:cf63 with SMTP id p3-20020a170902e74300b001c39544cf63mr162009plf.23.1695145447727; Tue, 19 Sep 2023 10:44:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695145447; cv=none; d=google.com; s=arc-20160816; b=WI3JkR3H1FcnEUR4g6z95HjxvvOSl3exV+5O0GZ10lWcKisSyWT1rDr/0qIjde1LIC H1rtqLJUXaWBRAHsphK2NGeoODW07+HuhT8r+yEKAWisuZswLnbHIy81E9+tL2TtDZ6m 4DyYDWjGKB+jf5BL6WKaMKX++NON4eneVp0MXo5t0Lzgu0/AQYdIZ+bQaxrgdulLLcC5 ilkb6h7HqBHuSWjrfwpezmdrRzQN5MIzsZqUadiZamZdHowGQH49oxDvqJx7yTxhSOQE y9MuCZCy6Mriw1BRu7Pl3MgjOKk357HreaegXIBg7JQXzCs3JPJ+BzFEmefKyQ3vLLHK u3TA== 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=IDd+lByaYtRjVl5S/GE4YECUcLVw+5BkT2HRtJIyazI=; fh=vcyxKNiHD7TmKqmM0/rwqxGOTauIz60tMzPVV7I2N7Q=; b=rj+kaPf8Xn/DHWatNJKqv3/t7UlrWt/uRESvpIJNilIAP0IhTbDcFHfg4Hr6xljjUb Ec+mfCfZUY2tdB0CjlrdzEV4ZCC2/gFV0CtWsWvoYJsJhDYtWnEOuXiacntpcItn6vXD hRJiYE0qeB1UPjcgfBl6+UI8xMGYuLoZJ/lEY748wah9Ga6iMsOkWATWIu4di44JbEMY LrW1InEdWZdFPUK3TawIHTTXTbqD8ZJ+SOt4WFoobPRUp7YURbZOAqlX+f5shN2RzXsA Jtr91guau27Vl5lIfu1iiTc9Kz4dCVYwrzot+lBoRTBRYZjuOnBD30x4adOjfvqb/Wgm 2Gww== 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:1 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 morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id lv14-20020a1709032a8e00b001bbc0ca8650si10008867plb.370.2023.09.19.10.44.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Sep 2023 10:44:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 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 morse.vger.email (Postfix) with ESMTP id E8C1782A177C; Tue, 19 Sep 2023 10:42:16 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229648AbjISRmP (ORCPT + 99 others); Tue, 19 Sep 2023 13:42:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232477AbjISRlw (ORCPT ); Tue, 19 Sep 2023 13:41:52 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 6B159197 for ; Tue, 19 Sep 2023 10:41:35 -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 A0770C15; Tue, 19 Sep 2023 10:42:12 -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 551533F5A1; Tue, 19 Sep 2023 10:41:34 -0700 (PDT) From: Sudeep Holla Date: Tue, 19 Sep 2023 18:41:02 +0100 Subject: [PATCH RFT v2 14/18] 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: <20230919-ffa_v1-1_notif-v2-14-6f3a3ca3923c@arm.com> References: <20230919-ffa_v1-1_notif-v2-0-6f3a3ca3923c@arm.com> In-Reply-To: <20230919-ffa_v1-1_notif-v2-0-6f3a3ca3923c@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Jens Wiklander , Marc Bonnici , 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=PHZUUrZvOCnNHDI+i/Plgq+A2R5oHmSmqrncoEkZxGs=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlCd0811YapzFopiMGNcOkCEDvNWtWDiwYdXrG3 kWMD0B7SwaJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZQndPAAKCRAAQbq8MX7i mHA2D/9/hF3VaKABoZURL5PKUaLFVp4zmlY7MYesN4/HMnZgVyMesjmml5nF7p+NmU4bnmnlpeZ UwWEcZDjOrOsjw3HdtcCnYGUM/KfbefJ2BY5ZGCH+GSFDpARZUQc8mduZRjMi0AUdJCIMCzyEQo U65ki8FOQ3rx3LQdy+Z5hGX8QCnYp8moaUXIDEzlcQ2QWa5wJt01zOyPzzHG6ukiYth6jVU1uMN +fir+ORoT4ubFBBbMp1i5ZiIB4hmBx4FgziIeqNycD7x0z4wwA0lScBKVeolSwSpb1eFNMRXelZ Wn2gIDcMRL+iA2PLa6SsRbR0/HLVXiVQbYHAhAVqVJhgWLIglZF8sNlVVGlvydUXoNxpcZphc3b scodmQN0np1fqydWw3CqQKw7p5vvx3YlcqPa1mcc5hv0MoH5z9wCX0iF+vyUlg84LKEKupp9lI8 b9/nTJ+1VJvIfUDufNn1ZHBSKbv7t3kK0aFAVK8oQna3qtOB5XzPKIazmtxwmwGg33SeMFcSwcJ cA/uB6F9YxRy3h7bVeoglf9zZpncg2EJMh3dgBSzMG4NOQGbgLlw5PQspzg4Y2jA4Qpg4BPSFNP DrnnjTTKXSK9w5yq6tdmuJm434Fg43PhYgRbrXnYKwMRRuSktX/+PDLIVAhg4puIm5EAasb37OL nhMLLL13zDzsCbA== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Tue, 19 Sep 2023 10:42:17 -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 6312a7807d37..dadd56d17c20 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -443,23 +443,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; } @@ -468,13 +470,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