From patchwork Tue Aug 20 14:27: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: 13770190 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 C5F1CC531DC for ; Tue, 20 Aug 2024 14:29:58 +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=kJ36QnfC/3V6mDmVI2l1VsPbcX s8OcZteks039UpzW3MbtuJxdG0lrbZ7nfKT+c5tXcyoAKwsstlD7BQO7zj35ZnzkY1AIaSzTmj1K2 n86k6WMPQrX7LhRwNBpKibUVtC2YkM6g9MNEM9feFzjO1FYY5zaYb7DXd9eobfm2RDH4r6qcwEaDo nqmdSVUtX0YpEczIZrljRWRPP7w5pnTIhh53lv46XMYeqebZ+0ONAiR6WNDgiEbgaD+VCqgxqgelw ZTSCFo244UB+ZZGGIaC9JJlVr8GOIRXEkAhUk2sRAUyMoyJjHT/WrnIv2lf2NXTlFiRprjjexZD6F qKyUU+bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPrl-00000005YLt-1MNb; Tue, 20 Aug 2024 14:29:45 +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 1sgPqw-00000005Y6U-0Yq8 for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 14:28:55 +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 EEE05FEC; Tue, 20 Aug 2024 07:29:17 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.198.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7EC8B3F66E; Tue, 20 Aug 2024 07:28:51 -0700 (PDT) From: Sudeep Holla Date: Tue, 20 Aug 2024 15:27:54 +0100 Subject: [PATCH v2 1/7] firmware: arm_ffa: Some coding style fixes MIME-Version: 1.0 Message-Id: <20240820-ffa_v1-2-v2-1-18c0c5f3c65e@arm.com> References: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@arm.com> In-Reply-To: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@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/ZANAwAIAQBBurwxfuKYAcsmYgBmxKghfslqVbS3kpxcU8jGknE9v79VrdVKhIdQg AaQtuN8sdKJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZsSoIQAKCRAAQbq8MX7i mKQCD/4xcg/hAFX/CTVLWxF3eFazSgvLQy5E/womndHJ0w7vCAgUglGZ6FWIrcENPXISNFK8IkV ApXyx/zW9fkcgVPi0l7cp3CugVe/266JNuH/SjuS6MMUNUdWez0L4LMxpLxVVvHYxeHwID5PEva V3aiP43XQees69RsBa/MaNsqMIvosd7LreI7e/kibPuUY+Gp1mIUfwTk4EglGkCP3j3Nd9UMMF+ lQPlGP5iR7afSw1q7NbkATzSh8VLFKFgHlbSGnR1RN0yJlcj4+Ld6u3rEI3lR71hu+aqdL8aw5q VZSbi/+TXsRAn2xYs7VHsi/4admtETVmsypSKVBLFO3iFfSlB67r0Kv6Buf20Q20+tB19ueT8Su PnabFce1xm+LcQCD3eyrK5Fzm+p/fRqdZWjvwCb2pd4a9hRlXpokcCeLWHrRIupRQqWW8UFfR/A swLu0H2GjkA4mLeMi7M8jXAm3zU3MWnSjVzwAb78Fouh53vN/MW+xxC8VWwstWkLkwQEaRRZr9i n5pArCmEVHZg6+yvLb5ie1EZWbQ4hshjtdk2HeS1r389kXFeV1B3NWCskzOgf8TVbaJS7+2ZY8n 9xZYOo6x1dZazsylAIhmlMqWfbNq5k9PLp/5PFw7DllvZAIeDljYDhYi0yov8hgTV6dZ2zg++vB Bu6+aKL/1VvJcJg== 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-20240820_072854_286349_A444286E X-CRM114-Status: GOOD ( 11.82 ) 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 Tue Aug 20 14:27: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: 13770222 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 904BEC3DA4A for ; Tue, 20 Aug 2024 14:31:23 +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=xsdBBr2uEEi7o97sbmyjAnOL0b pxAiB+DixIcVoN9wjJLoUhB5Q1rztc1De7Yn3wVZAqL2G356ZjMITFciDLCmBCtQymqIkbimy/Dmw 4G0ZcAmc5K5hbY7vhaG52qgUAlBPxKw4fIZvBH/mgbqSq6gzmx5/Y6Vx2noy04R9c6zxYXtvD0442 AyvIv3qiDCyzbYTEVOIqy38ZggW9t7BwrsY9VMPjuQv//KEXB+E6J8+tjJY/XBDUSp8LxzVbHAYDa Vo/YlaTllMcYe/fW8bda63nbUVbF7jnBq5UUgFjJlqjrJdsuKNKmc2HN8Q1SWVX47LNtEwBo6gdx9 NVt82oqA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPt6-00000005YfQ-0l7H; Tue, 20 Aug 2024 14:31:08 +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 1sgPqx-00000005Y72-05C1 for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 14:28:57 +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 955A5143D; Tue, 20 Aug 2024 07:29:18 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.198.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 254653F66E; Tue, 20 Aug 2024 07:28:52 -0700 (PDT) From: Sudeep Holla Date: Tue, 20 Aug 2024 15:27:55 +0100 Subject: [PATCH v2 2/7] firmware: arm_ffa: Update the FF-A command list with v1.2 additions MIME-Version: 1.0 Message-Id: <20240820-ffa_v1-2-v2-2-18c0c5f3c65e@arm.com> References: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@arm.com> In-Reply-To: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@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/ZANAwAIAQBBurwxfuKYAcsmYgBmxKghpDKN0PIdknmPV17SUNsfAIJ4Vm+dIHE9T bgb8gWLeN+JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZsSoIQAKCRAAQbq8MX7i mBxJEADAD2TJ9dm+SCeGbovpDvZYAw2K7PJkC0tW00SgpV5uFGAOImDTGUWWKIROzzOFJ9xlK7Q TVZQVj2TM/hnLwBPUPT1+Fe7tPqXfouCaWyEl+e6Kz6KVnhSQBDj0QHVZH7xnNn8D4/306TniUV z3iBpEcPopruX0MlH1Beapak4nPVE5jhaMvIAataqxkkcLJxhbT/uTyTDhMWRw7ay84CPgHs2zo 9Cnlk0tAhK/U36fQ7MhL5ujRyAJxuAFCQQhP9NfmDCTOLKuBy3VQou+9tI7XvZhFFjPKud4nNRf k0Jf0V5QrrVhh2NH2jJZQcXOHfxpFWUiO9y0R+ox77Qc+bDZVco5z9VGPqNZXShaLvoo5bnumTL eCUYruK+Y2FsMJNcWCVOsPUMgQQyBjWTQNHPOz01ByMPMtVpvoQ2Z5A35HmDW+J6E3vTBlBawWW rD4zIPsLaIKGMhrEil2wjzsp/TRabDhuUkar8TuMuCnzSV1g0hRfhTyQ55kyvKoyFeCF/6Nps3j 120HBO/PI/eoxeiJKrVRLy5mJT/CdFQeqSrsu4FPo9PZ+TLLO8UBbsTRZ38xWWSNN92pWqPz7mc 9mF1Xu4b+y0VJz24L6nfamCokrrWyzviPvNmeaXH28CfKjvtZzp+8+CSh17HN5dif2sHDF/X54r cGBelkxIW6tMHCA== 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-20240820_072855_141953_B712C506 X-CRM114-Status: GOOD ( 10.16 ) 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 Tue Aug 20 14:27: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: 13770223 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 33D9EC531DC for ; Tue, 20 Aug 2024 14:32:01 +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=Vwq/B3xBS3u2ysyfe1yd8bThOp mvPuMH0CDhoukaQFWAlUbN0+mDRXsBOmCx1d/5Kb9nBAYcbpyE3zyTOHka7SATAAA9DtoWfjj6hSb BPKeShpSkS2x63HPlNud7ZFGb5d4WqYE54iw7WCa0QLCHi2UgcMX8/XAImjrCbYGgmP/ndQ+SFc4h wFbT+fm/LJ9hzgE2lvI0My2xoAsPEeSUeN1PoEDMeEEZ6VmVDwy5gtgmqCc0a08+bxZ8Zwr2yoCHx R0UhpukUR/aNRS/PaP3HQraRvvOv7NGD9CqkuVMHhCqG6O9k4vFSQQ4Yp95jpqIoenKdtlCa9k+5O oCjqD8hQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPtn-00000005Yvi-2bav; Tue, 20 Aug 2024 14:31:51 +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 1sgPqx-00000005Y78-0sVL for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 14:28:57 +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 3C2261477; Tue, 20 Aug 2024 07:29:19 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.198.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C01A13F66E; Tue, 20 Aug 2024 07:28:52 -0700 (PDT) From: Sudeep Holla Date: Tue, 20 Aug 2024 15:27:56 +0100 Subject: [PATCH v2 3/7] firmware: arm_ffa: Move the function ffa_features() earlier MIME-Version: 1.0 Message-Id: <20240820-ffa_v1-2-v2-3-18c0c5f3c65e@arm.com> References: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@arm.com> In-Reply-To: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@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/ZANAwAIAQBBurwxfuKYAcsmYgBmxKghFPUAgNY+QC3sUqV8ljrlVXkYG0QGGSjxf +3pdbQWlpuJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZsSoIQAKCRAAQbq8MX7i mM7aD/9N4Ikcr9Nrpwcs6Aw0IuBM6+Jzhds204fQCbNqTePJeI4Ci2gPDmsTfIaxyBXUv2d8bor QLLu4CVCeOYLMfnjSfJQRFXZflDeOKga2RJYc6tTor9+LulTgUpPbyzVXm1/XWBPaTdEvB0yWq+ TImDS8QKBTH2B8NrgwEkGIDLGNLQBgbqSnepPdbvNEF/ZFt1+7a1z7ejO553fcQ6nUOSlGKElJ7 z2Akz36So1DaZR9X0gp4l++SPD3shiaKiiBhQaJah3hRNDSypZPUYNyMVeg4boiRuyo0dULDKRr ht/pTFxBVFxkaxxdP+u6QOpV84oe0OT+rlvNDTVU3JSBYC4RLAeCErForqtj6e90/tpBctA/+Sb WLVWT6/7di5mVQl8+JyX2U32wVlPlEwmXSZYZTHuPlGaeU+hwcOPwtEV9LY5x0dz2HF7aj6hFdu JCY3U1mzvEMoW/8BAlzwrYcQB21UZX5B5MGM5D6TEEBb+dwiy/Sf0pwP29HaOnJR4Vyfs+jbMT2 fiK+lqxmEAAmCWUa7mMWjxOKsGAjxHyn4kiZHKRkjorQY89R+FFOeibZtXJ72KamSt+KA3et+Jz BX/BNdVgRuQbDLvr3LKn5LY7wNsTxrTVeHFqb52sVLmaKZtEbffJdVPvzcMguPEj86vx5A4z7+C X85S7+WOqbwxerQ== 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-20240820_072855_385881_C1AE89FC X-CRM114-Status: GOOD ( 10.70 ) 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 Tue Aug 20 14:27:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13770224 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 065B8C3DA4A for ; Tue, 20 Aug 2024 14:32:46 +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=zcvgpmlTbjbRnxLmdpqUn0EOys 9K0JX7lBLQl13C49orzA7ns0PNa2tZcpxZdTUSukML2HDjFvHp5gAjZ2WnLivCPaiGJk1S02YUwc1 KzHeURPgtq35cc6AIjfVuSC19YX4N5YY1FyUCbYSEcQOWqimW20gfwI0cOP4NmA2HAVvECZSvMlez OJ5CW8iq++FKCrtGCZUzrCn4Sdq55ULHl1JpjBa4JaBlXMnJVZ0OqsyFJ8umRbQpag3HPZGdXY1xC pNxxxKk8nkuD0HVN0DMfC4rtQ8wDtTfPprYRXFBQhQtN9Qc0X2yH90LOfv/u64GUtcmixUrSv5N1V BtvjBxHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPuR-00000005Z2W-3Z5B; Tue, 20 Aug 2024 14:32:31 +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 1sgPqx-00000005Y7D-3kvU for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 14:28:58 +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 D6FC61480; Tue, 20 Aug 2024 07:29:19 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.198.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 66D443F66E; Tue, 20 Aug 2024 07:28:53 -0700 (PDT) From: Sudeep Holla Date: Tue, 20 Aug 2024 15:27:57 +0100 Subject: [PATCH v2 4/7] firmware: arm_ffa: Add support for FFA_PARTITION_INFO_GET_REGS MIME-Version: 1.0 Message-Id: <20240820-ffa_v1-2-v2-4-18c0c5f3c65e@arm.com> References: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@arm.com> In-Reply-To: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@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/ZANAwAIAQBBurwxfuKYAcsmYgBmxKgi9j49RTTtANoX8+PTTJahlBUwVmxlT+aKB ani/XphD8SJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZsSoIgAKCRAAQbq8MX7i mJlIEACANYQ0HdvQ9FXLK/aPt/XrKXyjqGeQ6hHkWWGu25gxSQ4zVDddJ/4RT3q+zz+EnGhKcOn 42ZsgudDiW7opNxuj9tBTohAEruz9AShAXMfjSEXrkKcYHBYVqLzQ6C8mg4f1UqJJ4bnD6Y3BZz lFIsDWxND/XBld8cAWK7FyysxWwpcZobp7OLi7bx+yxl1lIH7psDm/xkm6CTR76aaslW1QvNu03 TrFMSQZODb5m/PGXEwBpIbo2q1YTyLtjghiEyZkfUlMrJUquySBWYenoU7JaxteRIVkipGFELHm GZcFEFVGPewDFXJ6EpwEBQGYRrbJLm0DTwhZs8827mWyLikp6qKX5+8QV9wIdgfO1gw340tpcrR BCrbXH6QhkL0DkLUUZVFm/OTXVD5y55uR/cRd22lgTqhMDehmKcW89vmXRcGvhKEL/gPIEk2syb ecRvsSPTf8CuC/2kTIq0pr3gpbxWnSGkOgyI/oGRz4A+0lY/EdCXjL/H2HNwZB4XI5qH81D/fDD TIZGOfnrWmpRk95bNS+LRtp/Bstkd8cna1429z5KDGMEH0RBLgfKyt0SVKNvbmHdvW2+zrEXKI6 VoYlXI/a+gKA4N40/y84S0E+BiNEKufX+qC10MGWffZMdOWcpR4ZVD8QuDifK4umC8pqKF0ZnSq tZtIFCunAX620Jw== 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-20240820_072856_409137_4CE4F7A3 X-CRM114-Status: GOOD ( 15.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 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 Tue Aug 20 14:27:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13770227 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 78D5CC3DA4A for ; Tue, 20 Aug 2024 14:35:00 +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=5REihp7BBqd5sIoSmDenv2lpyt4CGvzjxz+x/jp9rfI=; b=uHrh5K0jBd2ChNu+OoGD+ZnPo6 PeZ07VyQIe9m5Ua5jGi5FlLKk0IyovMsu/iN579q/S1vaWUpu0POehvznPXHWs+HAXAN7msfQg+Cv X/jdC8wHMemKjQLWf1e/e2kLo/076XNIX3i2SFEkW4U7qGnF7nSWvFIiKK5F4f0RMrrL73dMZQ6ep DnKvBC5/HbBSP91Ep9EJHvojwgVV8GXsbFSKebxbD9SB8mcGBlLOUhXwYsGv3U2C4WgVDbcUyGN7t LYi5+XWzmZhKcEMGzLgrv/hiV55YeWNIcJoLxGzR142wOpKzdzI+smWwB3My4k6I3swALOpm2Mi2Y FMNbzvxg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPwR-00000005ZSv-1qcr; Tue, 20 Aug 2024 14:34:35 +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 1sgPqy-00000005Y9x-0ngm for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 14:28:59 +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 7DE3E150C; Tue, 20 Aug 2024 07:29:20 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.198.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0DE163F66E; Tue, 20 Aug 2024 07:28:53 -0700 (PDT) From: Sudeep Holla Date: Tue, 20 Aug 2024 15:27:58 +0100 Subject: [PATCH v2 5/7] firmware: arm_ffa: Add support for FFA_MSG_SEND_DIRECT_{REQ,RESP}2 MIME-Version: 1.0 Message-Id: <20240820-ffa_v1-2-v2-5-18c0c5f3c65e@arm.com> References: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@arm.com> In-Reply-To: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@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=5088; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=jXk9lcSVwO848Dah6kjrvt3ZPpn/HNlv8vDrHWiRnkg=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmxKgiW+MRoc+TYiorw0cqWEMiI0M8U35f5ZplL 9oTkiyQm6iJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZsSoIgAKCRAAQbq8MX7i mK7rD/44vfFxJprWJsiR4pMu+i6lKVMo3PscR9gniaZIRvpKL+7b4y3g0eSjLcup8Om4Q0mjAY+ xf3IvbQqwHkTTfdW8x7Cr7+di4IEQGwnxPbSyqXab+v/td7uPTo9Zcd6BJQHD9fbo46ZeBaHQ8A 5nNdQELn+BgBW6IWVWedmS+wjqBG8Y/oPZSbEODAmO3W83Sr55B8BQ2A9UAudkMHawyD1aGlMH7 Jvk2J1SHlLAutj6gmmuKpG9WaaCnfn2aMn3yuV4Ke9cogfQOTgsh/J1GzEXCyN1k1tzbScTooSx tBjmpDIEq+vsx7iVP7yXf0i2Ha/nrKzIo6TueoTEIc2qPzaif65aM1eK4y1m2td8mAYwi5b0iAD C2uZfr7ompH/QpnbNxIXr+HWow8CLp1v9gcLrIsVNJvJEhNHMVOWA9ecK8Mx6z5/1FaSrNx+l2q JOzcG5IfVE/lmsj9HEfWZyhaeiVnLttEjb2KAAm9qgusO6adAZtsN+qBlxgjDOdb0PZo9EJ1Pu7 wANXo3FqMX53UjuZ38ivvyjIilRbUTZSIeDhJ8tbzgP+tO3FrjYzo6tTB9d1z4805r6R4PHel8i Y27DAZD8YeZr4bImIBZg9X8lUSpPzzATa+VSenWau5AN6qO2ngQ9uvOtDkjyx+Ger+zYOeuhxC2 gHL7pam8YN/Wc0w== 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-20240820_072856_689035_6F331946 X-CRM114-Status: GOOD ( 18.66 ) 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..ec99fed5715d 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((void *)&args + offsetof(ffa_value_t, 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, &ret.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 Tue Aug 20 14:27:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13770225 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 3EB37C3DA4A for ; Tue, 20 Aug 2024 14:33:22 +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=+oD/hV5S024XBNJB+roKxBTw+HcmfynLqt2BZxGCG3M=; b=3En3vZaDaH13mekgd9tR95BHnz 4k9x8ka9PQ5SmQjYU2bSZUAV4XbVwRgc/zV0TnZGueMUsKjPLqOoPG1SD5CBqHAToiHTdoo8tyvGw KHwoQIHOL6M9ZfoZxY9CrAhlxv3ndnvKKVm8Kmm1Y4OpfnMYqa2/fyiXkqf5aj+P1KtYXL7gDgrXw XodritUnEq0qzKimu59KYopZIa6JdEbT8b26r17q4f37yt2L4wjywUWOTsA1QlSsCaynJtD0ULATx nFT0V8BcLj5ovy/Fw7PA8F0in7SQSb05/m56pl8owmB3SXCS/UTenI2M0an4yNZaZGeeUJmWh5KuW wd8pw2lg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPv6-00000005Z9d-2ykW; Tue, 20 Aug 2024 14:33:12 +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 1sgPqy-00000005Y9o-0FJO for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 14:28:59 +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 249A61515; Tue, 20 Aug 2024 07:29:21 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.198.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A8BC33F66E; Tue, 20 Aug 2024 07:28:54 -0700 (PDT) From: Sudeep Holla Date: Tue, 20 Aug 2024 15:27:59 +0100 Subject: [PATCH v2 6/7] firmware: arm_ffa: Add support for FFA_YIELD in direct messaging MIME-Version: 1.0 Message-Id: <20240820-ffa_v1-2-v2-6-18c0c5f3c65e@arm.com> References: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@arm.com> In-Reply-To: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@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=UPzZl1vZFx+imzj6babsbM3+MYlge8k3jow5sCrZRaI=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmxKgiz4HZYMztfxBqlSIPr2ZTREJKYnNjPx39F BhlnrU1T9+JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZsSoIgAKCRAAQbq8MX7i mHGQD/9bh6tkVePADuGMWm9yYai7OBCM7cs+lbqXBcEtshAKZyroHyc9LUTAjr12cfp6swTtG1r Zfxnaf1LZYIVF+dfxOZm3AJQUPX6q7mhDWfpUhNvE4a4AGu5SP39uln9ZlHdFtN3mFYMHhtDZNd 1H9mj4pehqZYuXolTedxNRXQT6Pk9bIe7iOiVVPETbDAxQhbAyl9602DvB2JAlR+8aVKh0oxXXJ LYjxsGcITYeyMTQrst32snsQYNLV0YdJRw3ld8ruVdItucVi1tMgcCVZprMRFHRWos57FhYRFYu tyUczrpKoYC1+u7/+b11mjIm7kF9jWA8m3q8wZ6hy7GDMvwIgoy/Oh0xbXw6SmH2W6MK4N8I1yG FlG8SDPspc96IMGAZB0KYTZ7Ne7T49upq09Bwj7GSxYT6lIOsHzWGrXQv0+NHqObXTLJDzv6ILr htGqfTGyOk9Z2foIA5IdfagSN+2KEjlM04Pz4SogdJW5AZhXnll6zUipK/A4HiqT4PpXaMsJSs9 ferHO44lYd+//UAdC16yVfrcLOtaLR+5fWVzXdPUX+F8P50nWAjWJVIiPsszWo5PZhEf+zZFzN5 UGDDq5O8ytElBk0KVQHpXHG3ybKB+w7NJvVJAH0449FNuP/X2nHe2VsDQDJWsAx9CSDlUhLgy+s 0FfjZPeEdsyF1lQ== 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-20240820_072856_533261_E22F001C X-CRM114-Status: GOOD ( 13.54 ) 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 ec99fed5715d..d47272859190 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 Tue Aug 20 14:28:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13770226 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 30230C531DF for ; Tue, 20 Aug 2024 14:34:12 +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=3Lk3l+hcUa60P/1Y2v3E5kRhZ4IjK3+6Zr2kN8fUP7Q=; b=3V0VMBXveQWb5FtVTkZHQt2cmT S1PVSEnahi6NbcXmKvkOfb3LZmYvaZTUYC6IznOBRc3IN/XbE1FY5OSZxSosNrCS/wxEBrF3It+Nb EnR7oFtlDwVshGo+t4sfCJgktfVMP90cLovfdXDphxC+SiMiz4pGcoDh6XAntDudMHQj+O5uf4arm CG9YyKqcqriyJjquqLzJKdU9npQUO6TIwjJB9b3wwrN+THchp3jBiMs5gp00gfr30l5XOSyakOasM 0BT157Z+K/PuQgFtZgmiZVvhdx7uhT40fRJMYJaLNXfAW76E88yqUm5/yL0/bBwAWJUF1+GPDrHfm TzxdHXQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sgPvl-00000005ZFh-1MYx; Tue, 20 Aug 2024 14:33:53 +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 1sgPqy-00000005YA2-2YE9 for linux-arm-kernel@lists.infradead.org; Tue, 20 Aug 2024 14:28:59 +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 C01F0FEC; Tue, 20 Aug 2024 07:29:21 -0700 (PDT) Received: from [127.0.1.1] (e107155-lin.cambridge.arm.com [10.1.198.42]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 4F50A3F66E; Tue, 20 Aug 2024 07:28:55 -0700 (PDT) From: Sudeep Holla Date: Tue, 20 Aug 2024 15:28:00 +0100 Subject: [PATCH v2 7/7] firmware: arm_ffa: Fetch the Rx/Tx buffer size using ffa_features() MIME-Version: 1.0 Message-Id: <20240820-ffa_v1-2-v2-7-18c0c5f3c65e@arm.com> References: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@arm.com> In-Reply-To: <20240820-ffa_v1-2-v2-0-18c0c5f3c65e@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=YwRPKaR4rw+PnBNm20T1PmsKDGJYi3guKmzuS5TAwko=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmxKgilPXvhnryjvY55MTclyv97JhP+yjyd3YI0 uCKpwazGcWJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZsSoIgAKCRAAQbq8MX7i mH14D/4y08UgzgplqHYkHRUFzF+82Wof2B3da6kprOevJ8/w82dYuFj4S6iDoPjjnox0+YYmiaZ LCsMHFVZT44iDh4F3GV0PWMHmUnnfLVMeuK38cSXzl/y6tHJ815b6ViLXv1cRPF1eZXFt1NoLWd bweX4XecvpanPGpR4XcSMnm4kpbCXNTfY/hin4hXAwL7UxhEETNXQbDedJ6nP+Koy6yH7ZRzRRA rcZvwfmDzGQDT25M5JgLUtUtUi6L4H7bn8APHGyNFw82PuT/b3EAj7/oDAo3KKtWpeN7lwJ5571 Zg3/Z9A/bGsKq+Sid6R9axZk8Ph/PRQKN52McCKeDsTnoeXp674J6chOgL4kBZNFA+A5BQVIKZm FouAwIVxxqHZWf9esLyGWN0MIborL+lj+aRHbVJ851q1Lwc1syUMa2EGLyxNJaUqkV1pohQBbbM IIGq3iDSHYuoU9URSJc4rr9eA7bJP+5QC03/wcAfFbGkdDMmn2ShGj6P5uUm6tLaOtAPAS9smCA okVOuaQGOD2KHJcq+lgTaEr2O0gbUEififiVdtAk5QDz6v6hRCqr8CmWGZVI8zaUotY8zF7gZqs LgwV5wu/NjqrKo7rQhnCZ5Xk6LAGis+fZ38nysMGuPqEnoLePUtAKZXDE1mA7vUyv87NTPQBUkz fx8GVA8jKjUVNpg== 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-20240820_072857_070866_6996D729 X-CRM114-Status: GOOD ( 18.14 ) 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 d47272859190..4d231bc375e0 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);