Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp4003185rdh; Fri, 29 Sep 2023 08:28:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE66n92rWoL7cH1MQTy7FJwGuPiyUVTuo0J+VTB4ob2trrMX4cpLiNM6iN+eUAzSs+SLzWk X-Received: by 2002:a05:6a20:970f:b0:153:a160:89dc with SMTP id hr15-20020a056a20970f00b00153a16089dcmr3362473pzc.58.1696001295726; Fri, 29 Sep 2023 08:28:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696001295; cv=none; d=google.com; s=arc-20160816; b=0/iYrbUPfwNbvtlJSIbi2taZ7yjqlpnGsblffSdpAo0VJAvCDfh1N6sPC0rI9CR0Gn ac7/V1Gjq+erwK9m/o1SyqMjznXN8mV3zMR22oEQYH+asAvn7MMEkWVmF+mRiCVEtxS3 P0fbeXSNf2EJ+HzqyCoYZS+uiKeTsOV2JU4lASC/p1tFAdnazB5v9C2qrdjLoESD+M/T nuklN2pGDGNgXhZ/tYZ3dk+NFLbQG4L1fQwbbjGlRUuZBJexoXuVYdUL1dw/XeiHrHye s3pG1WFUEXlpI6g0v/q8g2Yo4UDGoxRM2RYzvajjQcAY3QOxBqKAJ4wYWYZHEzIKUoFb swYA== 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=PToENyqfWLJn4YNhQnPzWZuy7Xyr9LEZIfJ9vDgKx9o=; fh=iZJRvoZuVJp3Jcg3UWu0imuTLbH0nKChof8pDyzNHj4=; b=nAN4pnhTesccs0ExkqzSEwdJFpga2rWdxlaep/970uW13XqV4wJFHD+GP4JHpHtdZT NPAdBtGooKJeJsnyTwZVI4Ir3bdV5IvpJdBhXwahI0pkhVD1iqXxVb2UrwcyEHkMDarW 5XaoPr/2RPeS6flF/ttTReSwRqRu0L4IQkhW63CpM9JrtAfmLseYxC3AhIjrfkcZixfi CAyeA6NHYUncBMnAOa9gamWj1k5D0gX/nFSRX02vG9lRdij2nY7uRfLlqCLTeiwmR3ov iCuHrtS7sYUX2EokAuO9LXF0Nm6hwq5e7VvJcjs2fhaLh1v/enOHVfpQZnqu6kRxzr+3 u9tQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id v3-20020a655c43000000b005859bd29c5bsi2217267pgr.723.2023.09.29.08.28.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 08:28:15 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 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 agentk.vger.email (Postfix) with ESMTP id E754C818C782; Fri, 29 Sep 2023 08:04:14 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233582AbjI2PED (ORCPT + 99 others); Fri, 29 Sep 2023 11:04:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233325AbjI2PDc (ORCPT ); Fri, 29 Sep 2023 11:03:32 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 40FA1CC6 for ; Fri, 29 Sep 2023 08:03:30 -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 830451063; Fri, 29 Sep 2023 08:04:08 -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 2C19E3F5A1; Fri, 29 Sep 2023 08:03:29 -0700 (PDT) From: Sudeep Holla Date: Fri, 29 Sep 2023 16:03:02 +0100 Subject: [PATCH v3 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: <20230929-ffa_v1-1_notif-v3-13-c8e4f15190c8@arm.com> References: <20230929-ffa_v1-1_notif-v3-0-c8e4f15190c8@arm.com> In-Reply-To: <20230929-ffa_v1-1_notif-v3-0-c8e4f15190c8@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=Rg2XKzRPf8SFjG3ZX7rctW9KFXN9uruVnGqowukr10g=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBlFucwynFFqxvHjHWr3fQpCjnPEZhI6MOOZvWa3 Vu9DXT+PxuJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZRbnMAAKCRAAQbq8MX7i mH0vD/9TOnvx/MRuf4JrzUDS0qYwarst+XtR3YA98cDVMU8SMMO++DDxeULkEmoW+QL2OvtpWCZ 8d3lTmNKbLFKIYuhEzURoXfKBUF35MeyPXSz76xnHUEQeFVMkZIAESgR36OsOMQLTzrzc7nN9d7 tcgtQD9modOPd0+6UzVfiVtrSykcD40pt5WHe2T6VHzFTK55owf95LIU7KvC/RC2X5cEW2rmzJn oY6Ja/kPJwEG95nzOKNGthIvx1TVkUeAE8Ddmvg8OQhCxVia1W155fGXV5awZjMQsI57RhafAWt 9ddvScF4rANyVsDwrNNgs5riRWtRr0puMtoSie1jLyYKrFkCdGDnLgITtlqseAFogwpb0qgy1uD 6CmbM8mZwNS9WRr++ufKCa6Ynmvott+IWrhJ3T9HCzV//d9dTlrngYy1lyM22EBDtc84xGEVtAi Cmao8jTeECdfRKgwaQjU2Bi7+iWI46p0qKrgfJahOtmn28QGaaFq2reFTUuHqpZL6e3hrZfzuSq mB+5RROSIdq8xfLzNtuBb2VuSIIseDUEPPgsI/Vba+/SaRcmjv0VNrnzwIcXQ60nRyMDTfHF9Mh g24xJTfJaxOVji9fNnczaH9U54X4vGsenurTg3yzOhRgawrk0kpbxeTbgUGv3uRwi3J+3YMU3Pu g0MMyU22hszKPMw== 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 agentk.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 (agentk.vger.email [0.0.0.0]); Fri, 29 Sep 2023 08:04:15 -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 28bf345862d9..d9ff3ec4f1eb 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