Received: by 2002:a05:6358:bb9e:b0:b9:5105:a5b4 with SMTP id df30csp5778440rwb; Wed, 7 Sep 2022 07:54:53 -0700 (PDT) X-Google-Smtp-Source: AA6agR4krHR54uLvap0onvml0SlacV/wqae3MC72rOGVfUwsfzlBDzKJPwFpxMlxGqpvP048PEfb X-Received: by 2002:a17:907:6d16:b0:731:17b5:699 with SMTP id sa22-20020a1709076d1600b0073117b50699mr2801065ejc.23.1662562492755; Wed, 07 Sep 2022 07:54:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662562492; cv=none; d=google.com; s=arc-20160816; b=BP2dJ5tulJFlgwkzeKdJgONevw+R6nUyrnvAUoCrEHXPu+QwREiDhPVGpllJy+Q+E1 AfHDoDbCnOzTB814kyNHNrDTMpvy5EcXtKGQySGO3Y6731jL7UqY3wJSP+b6prpx33yU n+n6KzOdNGfZFPLdnC7wR4Mx+9wUIv6fUW7WE3bnDr4C5w9j3crHzynS5E0s3+4sKU73 kUSs43RMIMDOPwqRg8MxU7JTMEcxlfwJJixDfgQVaMkntJjicTYMcsF0VFkdt/s3eVkM B1x+eLQUpZT2ZIlgwP96MJvKEYW5iS9Nl4gf14unD6jN2gu2m2aXBUgbStXJqTUDgtBK mKBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ztFY1p2MqFZkWApnS7S4Tf1LMWDUoJ1FzMS6Y+yJyBw=; b=tIobujBsG1TU2rYeMNd/iELBdtwwCOykHxw0DUed6Fpd0SCBhlAQ2fmWKBH0Ri4oQb k6mrwKb3Y16hzTyLKCzvDzWhJVhwci7lOk68qDtl9iFruQaSFIGqsHyx1L7ZUaWQRgmS I7vLI9M1+ug9Tcn7yc4/Fyd9iomAVeqI9X9NygIjbEF00RNqyzCVBiRa9JMemqFQuJsq 6qrDCnUVtp2s81rNt/xlFcrpit41XtP3LLDV0T2A1sICUhwdD1/F+g1adBRZP+sPphDn NBRDcang6h8GwDbRLUEvnzKQnZoEA+zrl9InI1xCAwMgRBJ1QaYBM87BejeLDGOy6eHe Ve3g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id o4-20020a170906974400b0073d679b2020si2742672ejy.387.2022.09.07.07.54.27; Wed, 07 Sep 2022 07:54:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230005AbiIGOxJ (ORCPT + 99 others); Wed, 7 Sep 2022 10:53:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229919AbiIGOwy (ORCPT ); Wed, 7 Sep 2022 10:52:54 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 448CCACA1C for ; Wed, 7 Sep 2022 07:52:52 -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 317DE1480; Wed, 7 Sep 2022 07:52:58 -0700 (PDT) Received: from usa.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 925483F71A; Wed, 7 Sep 2022 07:52:50 -0700 (PDT) From: Sudeep Holla To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org Cc: Sudeep Holla , Marc Bonnici , Achin Gupta , Jens Wiklander , Valentin Laurent , Lukas Hanel , Coboy Chen Subject: [PATCH v3 05/10] firmware: arm_ffa: Use FFA_FEATURES to detect if native versions are supported Date: Wed, 7 Sep 2022 15:52:35 +0100 Message-Id: <20220907145240.1683088-6-sudeep.holla@arm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220907145240.1683088-1-sudeep.holla@arm.com> References: <20220907145240.1683088-1-sudeep.holla@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE 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 Currently, the ffa_dev->mode_32bit is use to detect if the native 64-bit or 32-bit versions of FF-A ABI needs to be used. However for the FF-A memory ABIs, it is not dependent on the ffa_device(i.e. the partition) itself, but the partition manager(SPM). So, the FFA_FEATURES can be use to detect if the native 64bit ABIs are supported or not and appropriate calls can be made based on that. Use FFA_FEATURES to detect if native versions of MEM_LEND or MEM_SHARE are implemented and make of the same to use native memory ABIs later on. Reviewed-by: Jens Wiklander Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 81b8d578b6ea..37a8ee304508 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -163,6 +163,7 @@ struct ffa_drv_info { struct mutex tx_lock; /* lock to protect Tx buffer */ void *rx_buffer; void *tx_buffer; + bool mem_ops_native; }; static struct ffa_drv_info *drv_info; @@ -597,6 +598,13 @@ static int ffa_features(u32 func_feat_id, u32 input_props, return 0; } +static void ffa_set_up_mem_ops_native_flag(void) +{ + if (!ffa_features(FFA_FN_NATIVE(MEM_LEND), 0, NULL, NULL) || + !ffa_features(FFA_FN_NATIVE(MEM_SHARE), 0, NULL, NULL)) + drv_info->mem_ops_native = true; +} + static u32 ffa_api_version_get(void) { return drv_info->version; @@ -638,10 +646,10 @@ static int ffa_sync_send_receive(struct ffa_device *dev, static int ffa_memory_share(struct ffa_device *dev, struct ffa_mem_ops_args *args) { - if (dev->mode_32bit) - return ffa_memory_ops(FFA_MEM_SHARE, args); + if (drv_info->mem_ops_native) + return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args); - return ffa_memory_ops(FFA_FN_NATIVE(MEM_SHARE), args); + return ffa_memory_ops(FFA_MEM_SHARE, args); } static int @@ -654,10 +662,10 @@ ffa_memory_lend(struct ffa_device *dev, struct ffa_mem_ops_args *args) * however on systems without a hypervisor the responsibility * falls to the calling kernel driver to prevent access. */ - if (dev->mode_32bit) - return ffa_memory_ops(FFA_MEM_LEND, args); + if (drv_info->mem_ops_native) + return ffa_memory_ops(FFA_FN_NATIVE(MEM_LEND), args); - return ffa_memory_ops(FFA_FN_NATIVE(MEM_LEND), args); + return ffa_memory_ops(FFA_MEM_LEND, args); } static const struct ffa_dev_ops ffa_ops = { @@ -768,6 +776,8 @@ static int __init ffa_init(void) ffa_setup_partitions(); + ffa_set_up_mem_ops_native_flag(); + return 0; free_pages: if (drv_info->tx_buffer) -- 2.37.3