Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp2026553rwe; Fri, 2 Sep 2022 07:31:51 -0700 (PDT) X-Google-Smtp-Source: AA6agR468iQpqNEPENJsRX2T8YteZZHPUh3kyfefhrCge5JFUeXfv3T/fzffv2tmrKjKOoXXDO76 X-Received: by 2002:a05:6402:3489:b0:448:5486:fa10 with SMTP id v9-20020a056402348900b004485486fa10mr22588299edc.386.1662129111195; Fri, 02 Sep 2022 07:31:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1662129111; cv=none; d=google.com; s=arc-20160816; b=x86m4trS15HLeq6Tl7ZUmft5j80AH6Dppe1rRPNLXSr9uCPMg/togqffGEgu/q2+vs gAuB1hiGWLpKhM2ql8vF86XEIUw4/LuGFK1BAdTg+P9yC2gUJTEOLM7D1U1VGblxpEaD Ptr1yHvSwtzaJtASPKIz2s6YZni5ZN1fFqvdNggk9kOG/DENrGIYGbvt20wfGA5sVJFO eNZTaV9vUjyQwr8CcA5hk/QXeG71MuZw3k53dZdB594eVnQmojnTxhF3eogK7f7lvO+R T93BZG5Xkg3D/tT81wutF+JYQx+DvsdTFRxE3/6pnOwlk7jtNX4Os1FTFSFuqd7kDvJs uzXA== 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=zt/TJqsLIB6oGbjYXEBnZKtL/nbgbAdxda5zJQ4CjeE4TB0gf3mpaGp11Tr1EdHLMP /CiZXmK8KlR7Pk6k5MMhRR8bVginRvpIAj/42blZdjocpKOcw9up5QvPsDG5ks2DaZH/ tp1ZvnotFvkuqzrIlcD5LfOHLj1QVggA+RxMcjFPVpvlme7sGkkrru1w5fIlujhsyxMB Xt7HJg/gvOgNDRNa2DfdIkkTRrbvNBaclY0aikwPfEKHqeW3MjORs7y2SmRlih4F96UL 3He+oLQiBiOSO5jiwY96fWs0YaKY7+z1pxpVJfOiDZ+jnqSMUn4sGIBxifU2EPGSqCBr hDlA== 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 r24-20020a50d698000000b0044617f0fd6bsi1839869edi.79.2022.09.02.07.31.15; Fri, 02 Sep 2022 07:31:51 -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 S237257AbiIBOMB (ORCPT + 99 others); Fri, 2 Sep 2022 10:12:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53672 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238868AbiIBOLk (ORCPT ); Fri, 2 Sep 2022 10:11:40 -0400 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 39742BC25 for ; Fri, 2 Sep 2022 06:39:47 -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 2DB97153B; Fri, 2 Sep 2022 05:40:56 -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 A67AC3F766; Fri, 2 Sep 2022 05:40:48 -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 v2 05/10] firmware: arm_ffa: Use FFA_FEATURES to detect if native versions are supported Date: Fri, 2 Sep 2022 13:40:27 +0100 Message-Id: <20220902124032.788488-6-sudeep.holla@arm.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220902124032.788488-1-sudeep.holla@arm.com> References: <20220902124032.788488-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