From patchwork Wed Aug 14 13:48:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13763520 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D010CC531DD for ; Wed, 14 Aug 2024 13:51:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=+CweAkAJr9mntclzvPa7UIasbvY59T5xkn8SIizEWjc=; b=ygaCqtl46UPCquCJV73cA0GFQe 3XEH4o4YfWd8Bxo+YiA2PTo5j+dRRhMec/PfZuR+wnUOKyLas6MIEIgGxTi3mrtZmKFCu8vadedg/ RqAOyfh2kXqAAXrOGUKMxXXgmB0X3BADmQv1lpH8LEQ/ySJoC6qwXT5rD87cJufeaQoipMEvz+8EB GlHHUHew5FNmqJr03mTCiQoGrLeDVyGRTbi9Wza6gLGFzaT5qJ3wX7Y5Udn2HvqQghz+3H+gYGCMk A/GRs8ZU1rO71LsMVxn2ehsagBl7E3SM57VGgmbJrQwCvGvB18xgd1MFMh1i3aYn6e0pHvxx3grH8 ABUoQXpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEP1-000000079X3-17ks; Wed, 14 Aug 2024 13:51:03 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seENB-00000007947-3ORX for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 13:49:12 +0000 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 44F69FEC; Wed, 14 Aug 2024 06:49:35 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D27453F6A8; Wed, 14 Aug 2024 06:49:08 -0700 (PDT) From: Sudeep Holla Date: Wed, 14 Aug 2024 14:48:50 +0100 Subject: [PATCH 1/7] firmware: arm_ffa: Some coding style fixes MIME-Version: 1.0 Message-Id: <20240814-ffa_v1-2-v1-1-9e9abef69b21@arm.com> References: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> In-Reply-To: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> To: linux-arm-kernel@lists.infradead.org, Sudeep Holla , op-tee@lists.trustedfirmware.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1607; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=cZTAsRfmNjba/xBvkOD3FhtdQGmyLXIFXmSg73yxnqU=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmvLXSA+nVxOQ6UNH+d7B23MwuecbPWZ13Dmu/d O99FlDsRfiJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZry10gAKCRAAQbq8MX7i mLKgD/sGwmxjPzyP1piHwolf5JM1F/lpluueotzqszC/oVe9NDIDMdP06Cn2irZrhKrXCV5OPOI ZBL7dMTEH6CfiL8KcGdzfNzwyma2oZnov+r4K/Uy72RR93zXgTv7WHCmnFnuxwIeIAg6Eb/yCmN EPnMKBgHJhuj6bM2CIMumZ2I+jextl6QAz6yVUl2nM7Mf7MUKD/Hyn4He0BxM0odNl1ISM7XYiK +T8pwjkJ5T/3eJeHSxFWIOcDt1rWNmFGvU0+AAnb1GgWJrtkSiZ9/9nU9fte8nebHYVIkmG8h3T iHwchj3GSpRPnCiO6rB2SgDBRNabRqHkaZxFN5dE0uAEoQ/lSPtnCw3mUlTgapJKFlOu11EKlf7 hnL4KCNxbWk1L6Z+ouzjJXVMqLRDY1DHkngGYdZgiuAT5HFpuYp508b+VcVpjpSx7oOJo42qXGm u6Ro5yZqTHLGoQbrMZExk9RzeaUBJUrgu2c9az89E9aY4RW5WwlNQPzCFAD5px6pFWJuaqRzWRq FVJaMIeEmlDf53mKFnlhiw9aDKRS5fmVLe1gzEdHhehQ5VPog1wYdGUlHjaHFDfWw5OTCtwipd0 1Ee4nElqBZMdRkMlDolwP5i0xQgqJZGLtCOAL+ud81BKWgyFiT6If16LmWCJumdXvCaGy9wVoZs XQb/T/XU8Z44WZw== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_064909_955504_4FC8580C X-CRM114-Status: GOOD ( 11.35 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org These changes fixes a set of below coding style issues: 1. spaces required around that '=' (ctx:VxW) 2. possible unnecessary 'out of memory' message 3. unnecessary for single statement blocks Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 7ba98c7af2e9..b4b3ecc9824e 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1242,7 +1242,7 @@ ffa_bus_notifier(struct notifier_block *nb, unsigned long action, void *data) if (action == BUS_NOTIFY_BIND_DRIVER) { struct ffa_driver *ffa_drv = to_ffa_driver(dev->driver); - const struct ffa_device_id *id_table= ffa_drv->id_table; + const struct ffa_device_id *id_table = ffa_drv->id_table; /* * FF-A v1.1 provides UUID for each partition as part of the @@ -1327,8 +1327,6 @@ static int ffa_setup_partitions(void) /* Allocate for the host */ info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) { - pr_err("%s: failed to alloc Host partition ID 0x%x. Abort.\n", - __func__, drv_info->vm_id); /* Already registered devices are freed on bus_exit */ ffa_partitions_cleanup(); return -ENOMEM; @@ -1609,9 +1607,8 @@ static int __init ffa_init(void) return ret; drv_info = kzalloc(sizeof(*drv_info), GFP_KERNEL); - if (!drv_info) { + if (!drv_info) return -ENOMEM; - } ret = ffa_version_check(&drv_info->version); if (ret) From patchwork Wed Aug 14 13:48:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13763519 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7C5E4C3DA4A for ; Wed, 14 Aug 2024 13:50:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=gchUtsLbUGtLNc6yDyhqS96MooezdK+YC6vlXtOkivQ=; b=SxUWqV3sAORHKlnuPc03Vw3Vu8 BR/aD7HreMz5ONUrGp+3xz6wELeeI4iy640ArBROVPVz0TRgyZEn5Nn4s+iGj293u/U4qaeHDHLdT Qrp/ElAlWXcpfWiBkTuEPNFSkAFF4oR5D2h3eC0HVWSuM/HuK5vfSQ6HIOC4ZiBvkXX3ZodhWL4Ol Y7D0gnxOSusmhYIJ95R52TLZTy2xND4reWcUJb/RvvNU3OEcG3gYN2hzLy21XF7Se7ZLFSYE3vQxQ zAoQ6tF7+hVLhD3bS9Wvlfxg4SBM5hVzEcJkB0hcUfJsQXHlYOwcOXAgQXnNZUfa0HWEj5hgnQEb6 lRF/KCAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEOQ-000000079K8-2W9Q; Wed, 14 Aug 2024 13:50:26 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seENC-0000000794l-28iL for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 13:49:12 +0000 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 1E5F015A1; Wed, 14 Aug 2024 06:49:36 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 97C9B3F6A8; Wed, 14 Aug 2024 06:49:09 -0700 (PDT) From: Sudeep Holla Date: Wed, 14 Aug 2024 14:48:51 +0100 Subject: [PATCH 2/7] firmware: arm_ffa: Update the FF-A command list with v1.2 additions MIME-Version: 1.0 Message-Id: <20240814-ffa_v1-2-v1-2-9e9abef69b21@arm.com> References: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> In-Reply-To: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> To: linux-arm-kernel@lists.infradead.org, Sudeep Holla , op-tee@lists.trustedfirmware.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=1650; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=B5ybBlQuduDIRKaSmHbxC2AOR5xbIv/GkF8dEgAGsOk=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmvLXSq5j53UkFkpKh+W825ZPUyCAVNL9Hxld67 kSvST17Tz2JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZry10gAKCRAAQbq8MX7i mLI1D/sGLWibfcPkwSSso8NihFfogFUU04x/NtkwhRwZlH2u1lyqhDHsFGUXXrpfjDtsBMOZ8BA mfHxPtFkMYwGYnjFx5THvBxYKAaFxC0pLSrhEIrM9uzsPPJKY9vzpw+VVKbhkfF4HMaNNCttVEy 8QapoksLRKcXBzoiV5zRfuSQehUuSJFmbTtvESCV2MeSJC1o5BMtlX8+0dW5qMuv+luyrpVUx2r rVqbgth7aSsweHHdi1Wsk+muJHKXQsRjmxTw2wiTN65S0+NTANBFhyWeA1rrtYjFMYdRCR7hxd0 E3OWLRKtWcsKy3ng0yjC04rj3/DqPTxJc6VupAIKsCOgiTeO9rHREoamAoqiFL7Aa9XI6JveRJJ N2HAhtafbHsogjOGVh4v78ySsYgLYAvGuEplnWrnvUw5gxvhyoAh3ovdadGMOf7IUYXyVSXlm6U qfVmDEJGZ4r9jzIIB1futdoOacxMCb/+QqOhOZAMhZ9vcLzDXU6rH9Q2wIOkfqRrrZoCmDhk/+3 VRLB8iACFJBsRVa4kBMvBTI6zZNu616bpJu/3sdGcNjN6V7rKrRbNa5S23BWAdM4qMnXu25I63c bLKfiZTEwLYgibsxtu3AkW7jTII3aq/J060KJjFu8szwK7/JpqAksz8KoxU2PLPaWn1qAs2aWV8 CUzN5UZF5ScEhDQ== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_064910_626257_8AFDA952 X-CRM114-Status: UNSURE ( 9.69 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Arm Firmware Framework for A-profile(FFA) v1.2 introduces register based discovery mechanism and direct messaging extensions that enables to target specific UUID within a partition. Let us add all the newly supported FF-A function IDs in the spec. Also update to the error values and associated handling. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 1 + include/linux/arm_ffa.h | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index b4b3ecc9824e..be77e03578cc 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -75,6 +75,7 @@ static const int ffa_linux_errmap[] = { -EAGAIN, /* FFA_RET_RETRY */ -ECANCELED, /* FFA_RET_ABORTED */ -ENODATA, /* FFA_RET_NO_DATA */ + -EAGAIN, /* FFA_RET_NOT_READY */ }; static inline int ffa_to_linux_errno(int errno) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 89683f31ae12..b34f0c0dc2c5 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -73,6 +73,11 @@ #define FFA_FN64_MEM_PERM_GET FFA_SMC_64(0x88) #define FFA_MEM_PERM_SET FFA_SMC_32(0x89) #define FFA_FN64_MEM_PERM_SET FFA_SMC_64(0x89) +#define FFA_CONSOLE_LOG FFA_SMC_32(0x8A) +#define FFA_PARTITION_INFO_GET_REGS FFA_SMC_64(0x8B) +#define FFA_EL3_INTR_HANDLE FFA_SMC_32(0x8C) +#define FFA_MSG_SEND_DIRECT_REQ2 FFA_SMC_64(0x8D) +#define FFA_MSG_SEND_DIRECT_RESP2 FFA_SMC_64(0x8E) /* * For some calls it is necessary to use SMC64 to pass or return 64-bit values. From patchwork Wed Aug 14 13:48:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13763529 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7E6CBC52D7B for ; Wed, 14 Aug 2024 13:51:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=dREPgbVCJj2NGjs+soCAkcHWp7PucPGw8/me11+qV60=; b=asKx3AF3qrReG959+BJC0hPEPl NCWGU8kSugCSJCPieMQNWk8V9E1/+elieRjUsRoLtl/2iaRY49x6dxMGphYWIkRHI5lctIEMmdfDJ MVEmApdkp8cjYAOwJyvq6B5Fziu91nL1lAvJN1KJC5ZwZEfk2kDBcoN+yii1tV58yJ1YELn4vieK8 4jk3VPIOOjgIfv1EF37XlH4nJyvifdKAZ0Z5OPGB4/bBXOK7Xh6xmXbtZy+P4EEJHj5fziYEy8cPT dblohfb13le8g2FYDbfdbfXj4pbS2RPJITeSGjtfVzTtqNW2yXcrF/TnPVcK3HmXV0O1b0F323uix 6eUsUFPQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEPd-000000079jb-0Bou; Wed, 14 Aug 2024 13:51:41 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEND-00000007955-2BmF for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 13:49:12 +0000 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 C5F0F15BF; Wed, 14 Aug 2024 06:49:36 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 5D01F3F6A8; Wed, 14 Aug 2024 06:49:10 -0700 (PDT) From: Sudeep Holla Date: Wed, 14 Aug 2024 14:48:52 +0100 Subject: [PATCH 3/7] firmware: arm_ffa: Move the function ffa_features() earlier MIME-Version: 1.0 Message-Id: <20240814-ffa_v1-2-v1-3-9e9abef69b21@arm.com> References: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> In-Reply-To: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> To: linux-arm-kernel@lists.infradead.org, Sudeep Holla , op-tee@lists.trustedfirmware.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2366; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=JYHCrLtGgatFltjBhhLyMDdhO6Vb08f7f51oc6GSqpI=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmvLXTecjlT2DaNiL02SJtAzypgCxh9y0VpoLKi sB15KtkYbiJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZry10wAKCRAAQbq8MX7i mO9bD/4uIBS/sm2J8xLvY9l1XHhGH4cyLuQdLNYe7otYMrmUAsaNbPPRN19M4aK/LW6NrdL+YhT N80adDxwE92wIG7K3rI4kYe71zYtaZ2Sl/ylu1Va5uhsjs3o8qJxQ1tFfrkdTxDLMeQT1U/hqza t2OVpvLHtg4Xnt5LkcMF+FMn1sf4xWCk0zC/Jufj1ium5wwqBJUPNxf8Ci+Q0dIVCS1dXfZZt5i qchcrGOZNCABkM+wbGFtCY83AkqMliVEMy112giNhY9bNxYn0117EgRKg2mCPNqQRxC/Ih8GM43 vK8F7lMSKEjCkrshneJIY+MRUZ9eMUlOhht90YE78k0CrTO8iI3drwm7DBmCvLrOndchrMAp33m gcAF/UOszBW+EUPT0LDadjzUE/4IYMZTicxxHT4wMshz+0i0Jvn9gzPhjwlT1lNzdaGDXXwFnWj FJnfGzp4ZEWnWss4IW8E+EH7oprDlPEOJzeRxukJ9ZQRnuJ4rsSMoEyZlOYJjyLYMj0wVuki/2u RrscAnvsWbKDxb367MSJbFvLKlaOZ7q1zYLC1XUYkLaY3/QKNYWQ0T2coLxmUBGuCGQ8GOIPqMw 6OyRDh3ksMPu/blzwgAzp8Rrpev52NDLMO27aSR2Jp9FdUkJGSS1ooHXa2diSxnoi4eecmtxTQc KTMCtZu9z2bYlZQ== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_064911_715512_8F98B4E5 X-CRM114-Status: GOOD ( 10.23 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org We need to use ffa_features() in ffa_partition_probe() to detect if the newer FFA_PARTITION_INFO_GET_REGS API is supported in the platform or not. To avoid unnecessary forward declaration within the file, let us just move this ffa_features() earlier. No funtional change. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 52 +++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index be77e03578cc..91681933ece9 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -212,6 +212,32 @@ static int ffa_rxtx_unmap(u16 vm_id) return 0; } +static int ffa_features(u32 func_feat_id, u32 input_props, + u32 *if_props_1, u32 *if_props_2) +{ + ffa_value_t id; + + if (!ARM_SMCCC_IS_FAST_CALL(func_feat_id) && input_props) { + pr_err("%s: Invalid Parameters: %x, %x", __func__, + func_feat_id, input_props); + return ffa_to_linux_errno(FFA_RET_INVALID_PARAMETERS); + } + + invoke_ffa_fn((ffa_value_t){ + .a0 = FFA_FEATURES, .a1 = func_feat_id, .a2 = input_props, + }, &id); + + if (id.a0 == FFA_ERROR) + return ffa_to_linux_errno((int)id.a2); + + if (if_props_1) + *if_props_1 = id.a2; + if (if_props_2) + *if_props_2 = id.a3; + + return 0; +} + #define PARTITION_INFO_GET_RETURN_COUNT_ONLY BIT(0) /* buffer must be sizeof(struct ffa_partition_info) * num_partitions */ @@ -598,32 +624,6 @@ static int ffa_memory_reclaim(u64 g_handle, u32 flags) return 0; } -static int ffa_features(u32 func_feat_id, u32 input_props, - u32 *if_props_1, u32 *if_props_2) -{ - ffa_value_t id; - - if (!ARM_SMCCC_IS_FAST_CALL(func_feat_id) && input_props) { - pr_err("%s: Invalid Parameters: %x, %x", __func__, - func_feat_id, input_props); - return ffa_to_linux_errno(FFA_RET_INVALID_PARAMETERS); - } - - invoke_ffa_fn((ffa_value_t){ - .a0 = FFA_FEATURES, .a1 = func_feat_id, .a2 = input_props, - }, &id); - - if (id.a0 == FFA_ERROR) - return ffa_to_linux_errno((int)id.a2); - - if (if_props_1) - *if_props_1 = id.a2; - if (if_props_2) - *if_props_2 = id.a3; - - return 0; -} - static int ffa_notification_bitmap_create(void) { ffa_value_t ret; From patchwork Wed Aug 14 13:48:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13763530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0880CC3DA4A for ; Wed, 14 Aug 2024 13:52:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=hcCm5p5YH8b7Sms6yK/prYpfg8T+r6zExw2mnBIIZOc=; b=GEw0XpgIfXkmuNzjc4DCl0I9T/ ss5Hcd4UN2ktb4RjlvgN4SDimeJrVUQHIxSvDdhwXPj+N7zdstqwy7G5YJ/BeTGmc2jFW3jJEBUCA ru546MMPci9KigOYhuKLLsBrUJu1UVL9R5Ba/2WPqwe4gdRukn933nX/tCRfrI3VcVnstTt1L/gJh A7uheIUPR5B+A9bfiWh/1geMIuIKTXCWEPyGPFN0ig51rcTTYF2orx+ZZN9Eph0NTNt8kr5pwnWTF IMRUIj+iOzk/k6NOPscIBoUEbZQRDEEiCMPLFPE7+PDbCIP9752go7YtpO1IdV0H6wQngxWc9gKny Iow9wKBA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEQD-000000079rv-3kHP; Wed, 14 Aug 2024 13:52:17 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEND-0000000795Q-4C4R for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 13:49:13 +0000 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 8903F165C; Wed, 14 Aug 2024 06:49:37 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 226BF3F6A8; Wed, 14 Aug 2024 06:49:11 -0700 (PDT) From: Sudeep Holla Date: Wed, 14 Aug 2024 14:48:53 +0100 Subject: [PATCH 4/7] firmware: arm_ffa: Add support for FFA_PARTITION_INFO_GET_REGS MIME-Version: 1.0 Message-Id: <20240814-ffa_v1-2-v1-4-9e9abef69b21@arm.com> References: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> In-Reply-To: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> To: linux-arm-kernel@lists.infradead.org, Sudeep Holla , op-tee@lists.trustedfirmware.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=3998; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=FaVILUQPog5h0RCQzSV1xOE1pS2YhfiWm3kuEfz+kUc=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmvLXTJSW9ZRpxTJBJvY6AKuGV10PgWsRD02QD0 snFNHoonryJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZry10wAKCRAAQbq8MX7i mM13EADORvgERTejKyT5V1/JoTS5TefrWAvyexFUTZicSnOwClH4CNkfmTIyeesKoyHO24tBpFQ W4drEfiZP/5NtG/OyiAOgomVmB9UL0gDGnLxj2eQs4092WJ6GylRnNY063jMv8gjjpjyYXRf05U uCwf10OGc+Q81tVc5ndM9lqkcFV/Uwq/yVxuBp5eQ0Omvc9Ya4cRNbyQ1bhmR6Bn6XQ7NBYwW4L +8oNrWo5Cer2QHWcb44DwEI3t5HjqtLr31e6kzEDHD7COdb92SGB22M1idgiEZLfilsvKEQtGzB XAJbt1i/HsdjXd9pEOb+bQi1MEIxvaeLdHSad5fJcJpv+Z3CAynyd2cremlTykRKV1Mk/CV1fef 26PpEC/63qOC+SilY7uv4w90nOa+XF+z9gy4U9HWPaDxfQl5/eYid7xxuYs/rbtHBi7x2WFuatr oWkk/167T0DTKvKwL6ByGuR6g7lrKnyQw5lQQJGPBVHrphtt2qbJbOeKr0U0h892TbckgLSw1KH RkRSDIItP9t2kZkZ6zG/jHSvYbziZGy4ivKVUNZ9MGP2sn299jYLtprXeTUmAxL3iOQ246daodO j58DAynPlsCF7Dli+wLLBjvQ6CiiM1H4XD13l2AEnyEBO14luCapg4JgR62miQuJPHIgjLaHJe4 CUyeTMvtb8nTypw== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_064912_167962_D46E825F X-CRM114-Status: GOOD ( 14.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org FF-A v1.2 introduced FFA_PARTITION_INFO_GET_REGS which is similar to FFA_PARTITION_INFO_GET except that the former uses the registers to get the required information instead of the Rx buffer which the latter uses. We need to first check if the platform supports this new API using FFA_FEATURES so that we can fallback to the FFA_PARTITION_INFO_GET (which is mandatory) if FFA_PARTITION_INFO_GET_REGS is not implemented. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 72 ++++++++++++++++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 91681933ece9..e28cbfe9a801 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -287,17 +287,75 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, return count; } +#define LAST_INDEX_MASK GENMASK(15, 0) +#define CURRENT_INDEX_MASK GENMASK(31, 16) +#define UUID_INFO_TAG_MASK GENMASK(47, 32) +#define PARTITION_INFO_SZ_MASK GENMASK(63, 48) +#define PARTITION_COUNT(x) ((u16)(FIELD_GET(LAST_INDEX_MASK, (x))) + 1) +#define CURRENT_INDEX(x) ((u16)(FIELD_GET(CURRENT_INDEX_MASK, (x)))) +#define UUID_INFO_TAG(x) ((u16)(FIELD_GET(UUID_INFO_TAG_MASK, (x)))) +#define PARTITION_INFO_SZ(x) ((u16)(FIELD_GET(PARTITION_INFO_SZ_MASK, (x)))) +static int +__ffa_partition_info_get_regs(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, + struct ffa_partition_info *buffer, int num_parts) +{ + u16 buf_sz, start_idx, cur_idx, count = 0, prev_idx = 0, tag = 0; + ffa_value_t partition_info; + + do { + start_idx = prev_idx ? prev_idx + 1 : 0; + + invoke_ffa_fn((ffa_value_t){ + .a0 = FFA_PARTITION_INFO_GET_REGS, + .a1 = (u64)uuid1 << 32 | uuid0, + .a2 = (u64)uuid3 << 32 | uuid2, + .a3 = start_idx | tag << 16, + }, &partition_info); + + if (partition_info.a0 == FFA_ERROR) + return ffa_to_linux_errno((int)partition_info.a2); + + if (!count) + count = PARTITION_COUNT(partition_info.a2); + if (!buffer || !num_parts) /* count only */ + return count; + + cur_idx = CURRENT_INDEX(partition_info.a2); + tag = UUID_INFO_TAG(partition_info.a2); + buf_sz = PARTITION_INFO_SZ(partition_info.a2); + if (buf_sz > sizeof(*buffer)) + buf_sz = sizeof(*buffer); + + memcpy(buffer + prev_idx * buf_sz, &partition_info.a3, + (cur_idx - start_idx + 1) * buf_sz); + prev_idx = cur_idx; + + } while (cur_idx < (count - 1)); + + return count; +} + /* buffer is allocated and caller must free the same if returned count > 0 */ static int ffa_partition_probe(const uuid_t *uuid, struct ffa_partition_info **buffer) { int count; u32 uuid0_4[4]; + bool reg_mode = false; struct ffa_partition_info *pbuf; + if (!ffa_features(FFA_PARTITION_INFO_GET_REGS, 0, NULL, NULL)) + reg_mode = true; + export_uuid((u8 *)uuid0_4, uuid); - count = __ffa_partition_info_get(uuid0_4[0], uuid0_4[1], uuid0_4[2], - uuid0_4[3], NULL, 0); + if (reg_mode) + count = __ffa_partition_info_get_regs(uuid0_4[0], uuid0_4[1], + uuid0_4[2], uuid0_4[3], + NULL, 0); + else + count = __ffa_partition_info_get(uuid0_4[0], uuid0_4[1], + uuid0_4[2], uuid0_4[3], + NULL, 0); if (count <= 0) return count; @@ -305,8 +363,14 @@ ffa_partition_probe(const uuid_t *uuid, struct ffa_partition_info **buffer) if (!pbuf) return -ENOMEM; - count = __ffa_partition_info_get(uuid0_4[0], uuid0_4[1], uuid0_4[2], - uuid0_4[3], pbuf, count); + if (reg_mode) + count = __ffa_partition_info_get_regs(uuid0_4[0], uuid0_4[1], + uuid0_4[2], uuid0_4[3], + pbuf, count); + else + count = __ffa_partition_info_get(uuid0_4[0], uuid0_4[1], + uuid0_4[2], uuid0_4[3], + pbuf, count); if (count <= 0) kfree(pbuf); else From patchwork Wed Aug 14 13:48:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13763531 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 860DBC3DA4A for ; Wed, 14 Aug 2024 13:53:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ZlZu4MULN211cNoPMDpfX1W6nFodYcHupoDan3sQNz8=; b=j96GgL2MDVejmmktHme48UiM2/ LKiXaTjaVXT0LCjDfoCVwrzN7nDvENZglrivGCLMeBtj+35MwPFquWGLi6YBBXVPqvKDo9Kp9Er78 ebUPcMK+cUHdtk8JT0mIH+5oPTAOlWI9n+gOQEwu0gVhibTuLxf8osX4C+g+hpQQJlxShAHU6KfQv WMlZksS0q3swV/oDzXDBhNIzYi/dOCkNf3jXhr1p0ldeMmJSLUlXdLD2ZiqqRdgsiigA2cPL9a6p9 DFol1FBlE/ziMWi/ySHWTOLqUoR0aj9HfF5B35AcRr6AcFBb+GS6UGXD2Gyn5iyRlnLr7bTZfiKEw Xj6tuvAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seEQo-00000007A1M-2V2B; Wed, 14 Aug 2024 13:52:54 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seENF-00000007961-27TU for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 13:49:14 +0000 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 F33AEDA7; Wed, 14 Aug 2024 06:49:38 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DC0E43F6A8; Wed, 14 Aug 2024 06:49:11 -0700 (PDT) From: Sudeep Holla Date: Wed, 14 Aug 2024 14:48:54 +0100 Subject: [PATCH 5/7] firmware: arm_ffa: Add support for FFA_MSG_SEND_DIRECT_{REQ,RESP}2 MIME-Version: 1.0 Message-Id: <20240814-ffa_v1-2-v1-5-9e9abef69b21@arm.com> References: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> In-Reply-To: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> To: linux-arm-kernel@lists.infradead.org, Sudeep Holla , op-tee@lists.trustedfirmware.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=5056; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=qgAuDNZTFQ4C8ejuZ17n5K5w3xAOozS0XjwSuPDgv0U=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmvLXTweWDTfFQaMkErvIZAbaoi0EwfP8VxrU53 wpOzs1sSoyJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZry10wAKCRAAQbq8MX7i mC74D/95dhjZinjOQCSENkQYPUTD6nEuqWcfoSxDG4HbaqeGzmzhKhe9zgAhsDTWkKTE4J7VqnR Q4U3w+G1AaoKt12urS98mv0dUFUhWMByn5cylWORTSWJcyFZ0oGAh+9xJpixS/A4IRI2t0ADMff vvtfvmkbZKND5JWyrgqwoELJkGyf2DLRsIGqYh0Izlgdcp254YiFTIVxGt0I5QIMYAJNFCqbGoG VvCy/riib/rEZqQnEICMyg9bmqycReqe9eNNwtGPnYh9qcbxyUl3UdJdLYtVbxJykxNbEdHNm7d c4mj4KhpLg6725GzuiIrTJI7ijxqRCCLtMeGjCFigZmwlTTCOPLxaEGlM4g8OcfDmAB8r9X40YR nCq/8qAChaFqBKfVYmzTt/EggY5YPgouICJ7UATnf3xaaxD1ecP00oQlcF1u3VGgCEklh5zW8IU szDZBxc21bWjzG5Us8lTV3Tu+VWoGSIdfwBdgfOBOHqzvQGNQxUI9xomI4CsK3eYsMX7rRbt1zk nzf1qZ/6sIPeVQwk9Zn7K2eGLKkuwQYHZb4wHSuyVKoH50v6zPEZn0J+GFOwkX/N82fC5eG96p/ zAY1IOqSeqdBHeyaBHzGNQ/7SP8IxaU82kvgujYGJOHNa4Ik0ngg6KddRkotYz0X/FAeH4+asaS JeGzZn0Tm1lSwuQ== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_064913_688986_68652A8D X-CRM114-Status: GOOD ( 18.13 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org FFA_MSG_SEND_DIRECT_{REQ,RESP} supported only x3-x7 to pass implementation defined values as part of the message. This may not be sufficient sometimes and also it would be good to use all the registers supported by SMCCC v1.2 (x0-x17) for such register based communication. Also another limitation with the FFA_MSG_SEND_DIRECT_{REQ,RESP} is the ability to target a specific service within the partition based on it's UUID. In order to address both of the above limitation, FF-A v1.2 introduced FFA_MSG_SEND_DIRECT_{REQ,RESP}2 which has the ability to target the message to a specific service based on its UUID within a partition as well as utilise all the available registers(x4-x17 specifically) for the communication. This change adds support for FFA_MSG_SEND_DIRECT_REQ2 and FFA_MSG_SEND_DIRECT_RESP2. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 49 +++++++++++++++++++++++++++++++++++++-- include/linux/arm_ffa.h | 7 ++++++ 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index e28cbfe9a801..8af41be4b1c1 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -99,6 +99,7 @@ struct ffa_drv_info { void *rx_buffer; void *tx_buffer; bool mem_ops_native; + bool msg_direct_req2_supp; bool bitmap_created; bool notif_enabled; unsigned int sched_recv_irq; @@ -468,6 +469,35 @@ static int ffa_msg_send2(u16 src_id, u16 dst_id, void *buf, size_t sz) return retval; } +static int ffa_msg_send_direct_req2(u16 src_id, u16 dst_id, const uuid_t *uuid, + struct ffa_send_direct_data2 *data) +{ + u32 src_dst_ids = PACK_TARGET_INFO(src_id, dst_id); + ffa_value_t ret, args = { + .a0 = FFA_MSG_SEND_DIRECT_REQ2, .a1 = src_dst_ids, + }; + + export_uuid((u8 *)&args.a2, uuid); + memcpy(&args.a4, data, sizeof(*data)); + + invoke_ffa_fn(args, &ret); + + while (ret.a0 == FFA_INTERRUPT) + invoke_ffa_fn((ffa_value_t){ + .a0 = FFA_RUN, .a1 = ret.a1, + }, &ret); + + if (ret.a0 == FFA_ERROR) + return ffa_to_linux_errno((int)ret.a2); + + if (ret.a0 == FFA_MSG_SEND_DIRECT_RESP2) { + memcpy(data, &args.a4, sizeof(*data)); + return 0; + } + + return -EINVAL; +} + static int ffa_mem_first_frag(u32 func_id, phys_addr_t buf, u32 buf_sz, u32 frag_len, u32 len, u64 *handle) { @@ -923,11 +953,15 @@ static int ffa_run(struct ffa_device *dev, u16 vcpu) return 0; } -static void ffa_set_up_mem_ops_native_flag(void) +static void ffa_drvinfo_flags_init(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; + + if (!ffa_features(FFA_MSG_SEND_DIRECT_REQ2, 0, NULL, NULL) || + !ffa_features(FFA_MSG_SEND_DIRECT_RESP2, 0, NULL, NULL)) + drv_info->msg_direct_req2_supp = true; } static u32 ffa_api_version_get(void) @@ -973,6 +1007,16 @@ static int ffa_indirect_msg_send(struct ffa_device *dev, void *buf, size_t sz) return ffa_msg_send2(drv_info->vm_id, dev->vm_id, buf, sz); } +static int ffa_sync_send_receive2(struct ffa_device *dev, const uuid_t *uuid, + struct ffa_send_direct_data2 *data) +{ + if (!drv_info->msg_direct_req2_supp) + return -EOPNOTSUPP; + + return ffa_msg_send_direct_req2(drv_info->vm_id, dev->vm_id, + uuid, data); +} + static int ffa_memory_share(struct ffa_mem_ops_args *args) { if (drv_info->mem_ops_native) @@ -1256,6 +1300,7 @@ static const struct ffa_msg_ops ffa_drv_msg_ops = { .mode_32bit_set = ffa_mode_32bit_set, .sync_send_receive = ffa_sync_send_receive, .indirect_send = ffa_indirect_msg_send, + .sync_send_receive2 = ffa_sync_send_receive2, }; static const struct ffa_mem_ops ffa_drv_mem_ops = { @@ -1708,7 +1753,7 @@ static int __init ffa_init(void) mutex_init(&drv_info->rx_lock); mutex_init(&drv_info->tx_lock); - ffa_set_up_mem_ops_native_flag(); + ffa_drvinfo_flags_init(); ffa_notifications_setup(); diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index b34f0c0dc2c5..a28e2a6a13d0 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -270,6 +270,11 @@ struct ffa_indirect_msg_hdr { u32 size; }; +/* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP}2 which pass data via registers */ +struct ffa_send_direct_data2 { + unsigned long data[14]; /* x4-x17 */ +}; + struct ffa_mem_region_addr_range { /* The base IPA of the constituent memory region, aligned to 4 kiB */ u64 address; @@ -431,6 +436,8 @@ struct ffa_msg_ops { int (*sync_send_receive)(struct ffa_device *dev, struct ffa_send_direct_data *data); int (*indirect_send)(struct ffa_device *dev, void *buf, size_t sz); + int (*sync_send_receive2)(struct ffa_device *dev, const uuid_t *uuid, + struct ffa_send_direct_data2 *data); }; struct ffa_mem_ops { From patchwork Wed Aug 14 13:48:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13763532 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40FEAC52D7B for ; Wed, 14 Aug 2024 13:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bYz7JCAlrOb2CKWmxYTEOhBPC9PfM5X0hlluBaSf1vw=; b=R3DQp27+jBFrYjWFvqlzYGyXbo YtkTOhNH5x2dI09lQFXOYA7XlPYaIboqsU4Ddsy1XXNpQol7OQiSILqoFuri/+ZcJrYUP/oOBvwTl yQdSAg90Gy1AtTLYK78Skxm2VFvDnG7ONeubkNtuov9HXqg9ISCJp6OmiSOx1DdDR2ZAOQbfHT4V9 E31GmjBIiNLpM+HtDhSdEOqiXwuq+tSkiyIPnYW/qeUfq1c9PBogem8Yc4G8wPImlFFPlJI3860/U coStlfhgHJE5bqowYIQXJVpZ/JrL8nLp3IsufX0wBEZCvm0gDADzjlmyhDf7eeY+dXy9daIFyi27h yCivQXEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seERQ-00000007ACG-14qQ; Wed, 14 Aug 2024 13:53:32 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seENG-0000000796O-1Z9n for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 13:49:16 +0000 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 B89F5FEC; Wed, 14 Aug 2024 06:49:39 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 522433F6A8; Wed, 14 Aug 2024 06:49:13 -0700 (PDT) From: Sudeep Holla Date: Wed, 14 Aug 2024 14:48:55 +0100 Subject: [PATCH 6/7] firmware: arm_ffa: Add support for FFA_YIELD in direct messaging MIME-Version: 1.0 Message-Id: <20240814-ffa_v1-2-v1-6-9e9abef69b21@arm.com> References: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> In-Reply-To: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> To: linux-arm-kernel@lists.infradead.org, Sudeep Holla , op-tee@lists.trustedfirmware.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=2597; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=cHY26v9U/Lk2MBCwxFC2dfJwwz2Tg4YJHFlafzsj2dY=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmvLXT68la8JDEBbW+9sa3a4Ym5s80JxwNzgkBu b45L2dp8bOJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZry10wAKCRAAQbq8MX7i mDbGD/44X4sLdIsFoTVsYi8ZuiaVhccEvFksYYADQ35J5hf1YPKimN265u9sN4p+EK4z9gb2EtE jptZ7R69C+ufd3xGrKtzu5xJ+XyTt1223JeWa3BJ/72VAl2ynvCZWjelcyOZjoEQKL6M3CGsvIl gReEnMAGgsJg4k9qVUG2LPVrV2ApPv+uLfL9Rz92fYv8nLGTBFSzFnzIUxqEJ+rrCLrUoaiAVcZ smIoIYDdxUEjZCMN7Ofp2Xvfz9GwToz7SFBOnH7G0Wfe0I9wLcMJz4eH/jn0Ij1OE8NxsBujjPJ Py/cYBiIul+hZsxT671Nij1nyF8W/DhzCXDOyHob5VRHO+FxWJdpf8z1jIAVYXnvpsZqI0zOc6C rnrFwtnnBrKvEY+ZWDDyXOsqTpd0y15Lwt7aQntHd4RGlyZ4bKsCOWfww5Y6BsP+K/7xp6XoLP4 0ZSUq31Y3BZfE5kBUcxeUe65FLU1Yp85iANVTpePVI2M0nDQc38hCxAhR0U5OBocycggpeDa48m n1Qt7G/+rg2aGtF+3lGHEyHzqClkj84SrhsU0TwERv7eyThnz9maaHK+PtuKf9nEfX2O50gYD/B gCXNASIcpoimnjd+sfm9Af4KGIVFKsyLLBnWvZYTrIQpRfhEVMUTfpMsyn/G3tjj9Z7wIGkfGi5 KFJyMVqrTe/d0QA== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_064914_616342_DCEFF7E2 X-CRM114-Status: GOOD ( 13.09 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Successful completion of both direct messaging function can be indicated through an invocation of FFA_YIELD or GGA_INTERRUPT by the callee. FFA_INTERRUPT indicates that the direct request was interrupted and must be resumed through the FFA_RUN interface which is already done in the driver. FFA_YIELD indicates that the receiver endpoint has transitioned to the blocked runtime state and must be resumed through the FFA_RUN interface. However, the way receiver endpoint gets unblocked is implementation defined. So, the driver just sleeps for 1 - 2ms and issues FFA_RUN. It can return to the caller with FFA_YIELD is the receiver endpoint is still blocked. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 8af41be4b1c1..90102ed7bd18 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -397,6 +398,18 @@ static int ffa_id_get(u16 *vm_id) return 0; } +static inline void ffa_msg_send_wait_for_completion(ffa_value_t *ret) +{ + while (ret->a0 == FFA_INTERRUPT || ret->a0 == FFA_YIELD) { + if (ret->a0 == FFA_YIELD) + fsleep(1000); + + invoke_ffa_fn((ffa_value_t){ + .a0 = FFA_RUN, .a1 = ret->a1, + }, ret); + } +} + static int ffa_msg_send_direct_req(u16 src_id, u16 dst_id, bool mode_32bit, struct ffa_send_direct_data *data) { @@ -417,10 +430,7 @@ static int ffa_msg_send_direct_req(u16 src_id, u16 dst_id, bool mode_32bit, .a6 = data->data3, .a7 = data->data4, }, &ret); - while (ret.a0 == FFA_INTERRUPT) - invoke_ffa_fn((ffa_value_t){ - .a0 = FFA_RUN, .a1 = ret.a1, - }, &ret); + ffa_msg_send_wait_for_completion(&ret); if (ret.a0 == FFA_ERROR) return ffa_to_linux_errno((int)ret.a2); @@ -482,10 +492,7 @@ static int ffa_msg_send_direct_req2(u16 src_id, u16 dst_id, const uuid_t *uuid, invoke_ffa_fn(args, &ret); - while (ret.a0 == FFA_INTERRUPT) - invoke_ffa_fn((ffa_value_t){ - .a0 = FFA_RUN, .a1 = ret.a1, - }, &ret); + ffa_msg_send_wait_for_completion(&ret); if (ret.a0 == FFA_ERROR) return ffa_to_linux_errno((int)ret.a2); From patchwork Wed Aug 14 13:48:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13763533 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AC2B0C52D7B for ; Wed, 14 Aug 2024 13:54:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:To:In-Reply-To:References: Message-Id:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=uQ7IH6/k4P6ekdxP/23kutGhGzL7abv+AtBcW9j4JFY=; b=vjR0mkX+E+YhwlsMn2fP22bcEC ugFCz20MeiMagTyK/YFJ+/SHX/E3OTLOAyZhVxdKZ51ei4l+DJyZGQqIuYK0cxw2UYauowMbpEiN2 MFbUoKUKdc9JcpdcyDLAPcc7Frfz1T/0ka6kxSsx2UD1C4DJg3I0w8TorBIxbrtTHTrKA7uvWUwOV fiJGZh6X132oDosh2RWbT9FiNV6V4/2aumG786gN0DPaI5tBnrnLKYWd9fOo/zpgP8V8K+bZ9pR9C BLXlmWC7HSFpFTVXiRo0Vw/R9MxrZ0qIQT5AUfjQ7wQwDapFH8C2WgOhNSyFSTy9iveRyVmWB2HTo 2XlRL0Yw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seES2-00000007AO1-0DZN; Wed, 14 Aug 2024 13:54:10 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1seENG-0000000796q-3ckB for linux-arm-kernel@lists.infradead.org; Wed, 14 Aug 2024 13:49:16 +0000 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 7E22315A1; Wed, 14 Aug 2024 06:49:40 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.196.87]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 1780F3F6A8; Wed, 14 Aug 2024 06:49:13 -0700 (PDT) From: Sudeep Holla Date: Wed, 14 Aug 2024 14:48:56 +0100 Subject: [PATCH 7/7] firmware: arm_ffa: Fetch the Rx/Tx buffer size using ffa_features() MIME-Version: 1.0 Message-Id: <20240814-ffa_v1-2-v1-7-9e9abef69b21@arm.com> References: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> In-Reply-To: <20240814-ffa_v1-2-v1-0-9e9abef69b21@arm.com> To: linux-arm-kernel@lists.infradead.org, Sudeep Holla , op-tee@lists.trustedfirmware.org X-Mailer: b4 0.14.1 X-Developer-Signature: v=1; a=openpgp-sha256; l=4932; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=wpEpUfPg1xAdx6d8xOwHmpYZS/XjpyAeNNicZHdb610=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmvLXT3SHvTtBwDE48Sd5FcaMf1ROVucpIbF9Lt rYrDv1DPkuJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZry10wAKCRAAQbq8MX7i mK6LD/0Q4vAm3A/V349VGJX7XYFNb7+w/M9okQR83NyT8VcLK2f893aNMKVseHbUck/ghp0m9D6 bAgLd+HGvvQBATBgZMZlOhKTmmZWe8Kg5ztazsjYxaC0MMCOqYHatXHPlcaIs/xxF9yEcjb998I Oyvn0fw32n0NZKuq6Xix1V+N4ysbJB3wANCH+rMbZkRZir8Usos5tBv6TEBaEmVNzB+U1Tca51B uLvXaRjfLgu9pAiFGGb1D8JH1tE4hurRB7Ie+Y+4tpgwqNS4YyUEh6+IlCIfZb9+/ScJGT16y2D ksV08Ps5ZslO78IlQhMBmAlAKVmXoSfq7xw6WB8Bhn7H/PMWJnodyATCwjqasyXypATRjsxuHcs X9So66K3bRj80boNBX60Vi3CVFaT3/bkAuD8S2wAWkV/1+ySPcM/oh5PZF1gBLLSmag4m2mkD1F MNZbp9ezWWD6tomWvlgNhJlWpZj/tJPQY3GSk0Gan0QBU+brC58lCLzzqIEDak0eGc2plObVPXy m/ohciQCQi5Y4/vIDiPmy1LWPajvQ4TeJqLXAJq5BUc7SVKjsLcyvG8CbSGH+8/rFW4hf6dwNqx ugq/H60XzkVw10OlAZdUgFSyhIhN8w6D3P54PdlJMIHk8eWQj5H5b6jn6lKUib/MXWs9YhhozNL TYuA5eEl5qideBg== X-Developer-Key: i=sudeep.holla@arm.com; a=openpgp; fpr=7360A21742ADF5A11767C1C139CFD4755FE2D5B4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240814_064915_099877_9B77328E X-CRM114-Status: GOOD ( 17.67 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org An endpoint can discover the minimum size, maximum size and alignment boundary for the Rx/Tx buffers by passing the function ID of the FFA_RXTX_MAP ABI as input in the FFA_FEATURES interface. The maximum size is an optional field and a value of 0 means that the partition manager or the hypervisor does not enforce a maximum size. Use the discovery mechanism and remove the hardcoded 4kB buffer size. If the discovery fails, it still defaults to 4kB. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 44 +++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 90102ed7bd18..1e3764852118 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -54,11 +54,8 @@ #define PACK_TARGET_INFO(s, r) \ (FIELD_PREP(SENDER_ID_MASK, (s)) | FIELD_PREP(RECEIVER_ID_MASK, (r))) -/* - * Keeping RX TX buffer size as 4K for now - * 64K may be preferred to keep it min a page in 64K PAGE_SIZE config - */ -#define RXTX_BUFFER_SIZE SZ_4K +#define RXTX_MAP_MIN_BUFSZ_MASK GENMASK(1, 0) +#define RXTX_MAP_MIN_BUFSZ(x) ((x) & RXTX_MAP_MIN_BUFSZ_MASK) #define FFA_MAX_NOTIFICATIONS 64 @@ -99,6 +96,7 @@ struct ffa_drv_info { struct mutex tx_lock; /* lock to protect Tx buffer */ void *rx_buffer; void *tx_buffer; + size_t rxtx_bufsz; bool mem_ops_native; bool msg_direct_req2_supp; bool bitmap_created; @@ -454,7 +452,7 @@ static int ffa_msg_send2(u16 src_id, u16 dst_id, void *buf, size_t sz) ffa_value_t ret; int retval = 0; - if (sz > (RXTX_BUFFER_SIZE - sizeof(*msg))) + if (sz > (drv_info->rxtx_bufsz - sizeof(*msg))) return -ERANGE; mutex_lock(&drv_info->tx_lock); @@ -689,9 +687,10 @@ static int ffa_memory_ops(u32 func_id, struct ffa_mem_ops_args *args) { int ret; void *buffer; + size_t rxtx_bufsz = drv_info->rxtx_bufsz; if (!args->use_txbuf) { - buffer = alloc_pages_exact(RXTX_BUFFER_SIZE, GFP_KERNEL); + buffer = alloc_pages_exact(rxtx_bufsz, GFP_KERNEL); if (!buffer) return -ENOMEM; } else { @@ -699,12 +698,12 @@ static int ffa_memory_ops(u32 func_id, struct ffa_mem_ops_args *args) mutex_lock(&drv_info->tx_lock); } - ret = ffa_setup_and_transmit(func_id, buffer, RXTX_BUFFER_SIZE, args); + ret = ffa_setup_and_transmit(func_id, buffer, rxtx_bufsz, args); if (args->use_txbuf) mutex_unlock(&drv_info->tx_lock); else - free_pages_exact(buffer, RXTX_BUFFER_SIZE); + free_pages_exact(buffer, rxtx_bufsz); return ret < 0 ? ret : 0; } @@ -1718,6 +1717,8 @@ static void ffa_notifications_setup(void) static int __init ffa_init(void) { int ret; + u32 buf_sz; + size_t rxtx_bufsz = SZ_4K; ret = ffa_transport_init(&invoke_ffa_fn); if (ret) @@ -1737,13 +1738,24 @@ static int __init ffa_init(void) goto free_drv_info; } - drv_info->rx_buffer = alloc_pages_exact(RXTX_BUFFER_SIZE, GFP_KERNEL); + ret = ffa_features(FFA_FN_NATIVE(RXTX_MAP), 0, &buf_sz, NULL); + if (!ret) { + if (RXTX_MAP_MIN_BUFSZ(buf_sz) == 1) + rxtx_bufsz = SZ_64K; + else if (RXTX_MAP_MIN_BUFSZ(buf_sz) == 2) + rxtx_bufsz = SZ_16K; + else + rxtx_bufsz = SZ_4K; + } + + drv_info->rxtx_bufsz = rxtx_bufsz; + drv_info->rx_buffer = alloc_pages_exact(rxtx_bufsz, GFP_KERNEL); if (!drv_info->rx_buffer) { ret = -ENOMEM; goto free_pages; } - drv_info->tx_buffer = alloc_pages_exact(RXTX_BUFFER_SIZE, GFP_KERNEL); + drv_info->tx_buffer = alloc_pages_exact(rxtx_bufsz, GFP_KERNEL); if (!drv_info->tx_buffer) { ret = -ENOMEM; goto free_pages; @@ -1751,7 +1763,7 @@ static int __init ffa_init(void) ret = ffa_rxtx_map(virt_to_phys(drv_info->tx_buffer), virt_to_phys(drv_info->rx_buffer), - RXTX_BUFFER_SIZE / FFA_PAGE_SIZE); + rxtx_bufsz / FFA_PAGE_SIZE); if (ret) { pr_err("failed to register FFA RxTx buffers\n"); goto free_pages; @@ -1781,8 +1793,8 @@ static int __init ffa_init(void) ffa_notifications_cleanup(); free_pages: if (drv_info->tx_buffer) - free_pages_exact(drv_info->tx_buffer, RXTX_BUFFER_SIZE); - free_pages_exact(drv_info->rx_buffer, RXTX_BUFFER_SIZE); + free_pages_exact(drv_info->tx_buffer, rxtx_bufsz); + free_pages_exact(drv_info->rx_buffer, rxtx_bufsz); free_drv_info: kfree(drv_info); return ret; @@ -1794,8 +1806,8 @@ static void __exit ffa_exit(void) ffa_notifications_cleanup(); ffa_partitions_cleanup(); ffa_rxtx_unmap(drv_info->vm_id); - free_pages_exact(drv_info->tx_buffer, RXTX_BUFFER_SIZE); - free_pages_exact(drv_info->rx_buffer, RXTX_BUFFER_SIZE); + free_pages_exact(drv_info->tx_buffer, drv_info->rxtx_bufsz); + free_pages_exact(drv_info->rx_buffer, drv_info->rxtx_bufsz); kfree(drv_info); } module_exit(ffa_exit);