Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4036997rwe; Tue, 30 Aug 2022 03:35:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR5H8gpJqv7L4/C2d0EZSaW/qUxI2aX1e7kcAnfFAeU8cclqvbzlbi5glGJHLnxLroqvx+tg X-Received: by 2002:a65:4682:0:b0:41d:f44b:4227 with SMTP id h2-20020a654682000000b0041df44b4227mr17054141pgr.381.1661855700853; Tue, 30 Aug 2022 03:35:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661855700; cv=none; d=google.com; s=arc-20160816; b=nxhu6ws2TW4xBG/sVBIbdHOwbMS9UZhxH968Sp2SfLF528THnJ4yN9gljkJE+PXsVu BzZby7Ty2LCmCecM3qXAAVcUECo9mZJxsbC9BJIjgq4jXQIs0RtZTdNidfpIJky096tO 5V3/xI/YenJK+ydL1GUZ6SVgykUC4FACsjMiRpLDgGICIvW/zA+7Ml4u2gc/4LcbNAFe +xeCs/UnuJV9+7fRrFLIK/YYFRjDr43xhuJazx2TsPQDdNJzzZKyEY+Q/WvEcJNfvfAo nVO22fC8bBSH5+ILFhrPeuxv+yxDCQ6nAIlViKEgDea2tUhx6WVkJfQPw+8RjuqLMJy2 EkYQ== 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=RapTs9EO3cA63iGhyOs7L8ROa+Th2uhfauQyTd3uAZA=; b=q9110NEIatGqIoI0M53FF2aXz5+FNSx8qxiqWs2aOiojw/EaLnS1ZaB0CYmVJnaqXj XvgAlQy4uiHrr6iGRLNn1qtqEB0oXH6IztQyoEBGcjEdRqTZhTN/J08RB46e5Pk7DimB 74lsQ2IlZ5dE8HNGmyZltgsIkc0cKmOP6aLluAaArl+r4iIbi4OXhC+ZchiYCRmERtHL dX7K8j5dkj1zhPlaByme+c1LX5NWTpnZN8r6OIVp9FSgdiE+uxAl/MftGd8CmF9+7NJI 3y2x8DCNi0j9ROAi84/71UHGW8NYUHVFSl7e+W4j2FoqAdvSvkPgsfu9hiOvJJayo7Y2 jf2g== 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 x13-20020a170902ec8d00b001727c70a717si12936248plg.184.2022.08.30.03.34.47; Tue, 30 Aug 2022 03:35:00 -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 S230221AbiH3KM0 (ORCPT + 99 others); Tue, 30 Aug 2022 06:12:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229705AbiH3KLx (ORCPT ); Tue, 30 Aug 2022 06:11:53 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 20CF7EA17E for ; Tue, 30 Aug 2022 03:07:34 -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 58BF823A; Tue, 30 Aug 2022 03:07:40 -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 F2CA23F766; Tue, 30 Aug 2022 03:07:32 -0700 (PDT) From: Sudeep Holla To: 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 5/9] firmware: arm_ffa: Use FFA_FEATURES to detect if native versions are supported Date: Tue, 30 Aug 2022 11:06:56 +0100 Message-Id: <20220830100700.344594-6-sudeep.holla@arm.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220830100700.344594-1-sudeep.holla@arm.com> References: <20220830100700.344594-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. 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 de94073f4109..5f02b670e964 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; @@ -594,6 +595,13 @@ static int ffa_features(u32 func_feat_id, u32 input_props, u32 *if_props) return 0; } +static void ffa_set_up_mem_ops_native_flag(void) +{ + if (!ffa_features(FFA_FN_NATIVE(MEM_LEND), 0, NULL) || + !ffa_features(FFA_FN_NATIVE(MEM_SHARE), 0, NULL)) + drv_info->mem_ops_native = true; +} + static u32 ffa_api_version_get(void) { return drv_info->version; @@ -635,10 +643,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 @@ -651,10 +659,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 = { @@ -765,6 +773,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.2