From patchwork Mon Apr 15 16:05:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13630255 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 B5EDEC4345F for ; Mon, 15 Apr 2024 16:06: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=WVYndlcFWqUVAWXGL19NXo2jtGl+9bsSXC3EaNPYyls=; b=MlkfiCzUxAhIWu JCJfKFBQdJs33wxodJz7aIWLOk0fNUYR/C7zZxxCsb4sf+4wsmuCF3MJU7ABYkvSVRhRHBrDOFskb N/9Z/QmKvh12c3+oP1FsdBjEI2XrW7SY0QHWHgie1CgAk3xU0CdNn7cPIWWPSJqs6mmDpqy8/S481 +/vGCFINiEyRRnGWrzl4U/lEjS/zUznVyiKdzURccBOU37sstLDD6EUCqCFJziE9jTB2/kvlf51L6 s1BbKvrrieGrqgT/3x/rIIfmom4KFbjBN5RXBdkYAcrMVMmuKYkzluOHWKWVBn8z88iPmFFAfNhYh Tfug3PiEM/6loT5KBnpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwOqA-00000008zRI-2X3A; Mon, 15 Apr 2024 16:05: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 1rwOq0-00000008zOP-2gKC for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 16:05:49 +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 284F7DA7; Mon, 15 Apr 2024 09:06:11 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B2C503F64C; Mon, 15 Apr 2024 09:05:41 -0700 (PDT) From: Sudeep Holla Date: Mon, 15 Apr 2024 17:05:22 +0100 Subject: [PATCH 1/4] firmware: arm_ffa: Stash the partition properties for query purposes MIME-Version: 1.0 Message-Id: <20240415-ffa_msg2_support-v1-1-a28c964b1b3f@arm.com> References: <20240415-ffa_msg2_support-v1-0-a28c964b1b3f@arm.com> In-Reply-To: <20240415-ffa_msg2_support-v1-0-a28c964b1b3f@arm.com> To: linux-arm-kernel@lists.infradead.org Cc: Marc Bonnici , Olivier Deprez , Lorenzo Pieralisi , Bertrand Marquis , Jens Wiklander , Sudeep Holla X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1790; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=01ueOnMFKv1ELRCpb/gOgrd5/tzFwk+GbrYyJvUBkFk=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmHVBT+70xDXBgpCIi8Bww3fUFpuh32H34398EM rodc2AgBIGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZh1QUwAKCRAAQbq8MX7i mG1kEADCAYGkX6V5ZDGzpm5Lh+N5LuuxSXF2oprKf1DRcQOpf4LAqXGpN8+iJCI903uskD/uFD9 AoUz+s48FiCPDhQm6idzbLlm6X4mqfHeUjryKGE388V7V19++nf17M7y7LMBd48asgT4J/sFB1q R2hHOdZZE4O2ki2h4kjunkQjNsfr3+dpU61QpHgto9vKLzBx04UWELc8oarcdKsG/FKSS2X/yyA U24g4RWB8l7rWmwqbeOP+iqDGdvTQEouf+Ftq3xrbo0Bd9rRUoxOVVBZD7iQEoAXpq7Nvj0/Hwj 7kKo1yCs2cm43zSNGudzwcmQWfJiwkoaMEBQPLcH9H4XcgE3xszi2o4NmMXRSLic4Znv+fkMy7I OmajW79LgabZq5ZMui2Ea/5q99yYmAmyKF7ci71GNJ09IgT90KyrSejDEC8x2qClpuazUQMfzsk NOcmvvzr1CfKgDKNfUr61hs3Cz7IKQgJVXXB2v90JboHYt+Hofif/YE84IOR53acv64aADvpzpA N+y/FC7wlT4rEfx5cQ5mcblPMYGyaQ/mPnn7AJalp7E30Iiy7BcOxv0E+K3pYBz7ItwIOkXDWSA vxSk+GvOZELY4DOJhzc50rV4RgJAxIpW1ZLfwV6gsubZzeSGHesoMbGv7WCTpXb3vfqVoyU+3bF pModixwkS4cJo8Q== 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-20240415_090544_859034_021E9404 X-CRM114-Status: GOOD ( 10.48 ) 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 The properies obtained from the partition information descriptor as part of initial partitions discovery is useful as it contain info if the partition - Runs in AArch64 or AArch32 execution state - Can send and/or receive direct requests - Can send and receive indirect message - Does support receipt of notifications. These can be used for querying before attempting to do any of the above operations. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 9bc2e10381af..d258d04c1eda 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -721,6 +721,7 @@ static int ffa_notification_get(u32 flags, struct ffa_notify_bitmaps *notify) } struct ffa_dev_part_info { + u32 properties; ffa_sched_recv_cb callback; void *cb_data; rwlock_t rw_lock; @@ -863,6 +864,17 @@ static void ffa_mode_32bit_set(struct ffa_device *dev) dev->mode_32bit = true; } +static bool ffa_partition_check_property(struct ffa_device *dev, u32 property) +{ + struct ffa_dev_part_info *partition; + + partition = xa_load(&drv_info->partition_info, dev->vm_id); + if (!partition) + return false; + + return partition->properties & property; +} + static int ffa_sync_send_receive(struct ffa_device *dev, struct ffa_send_direct_data *data) { @@ -1236,6 +1248,8 @@ static int ffa_setup_partitions(void) ffa_device_unregister(ffa_dev); continue; } + + info->properties = tpbuf->properties; rwlock_init(&info->rw_lock); ret = xa_insert(&drv_info->partition_info, tpbuf->id, info, GFP_KERNEL); From patchwork Mon Apr 15 16:05:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13630253 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 6C323C4345F for ; Mon, 15 Apr 2024 16:06:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=z8Z4DfGCYk9eq641kh3Qti46j7uYdise9WwIqR0fOYc=; b=DtkhkElTCGwL32 9WBuhkADR1yk26f6Xx1aAyaRFDIwjKBajjFyuC449Hq6BxAVX8abKuiZ3Ihutc5yRdozWlD0Z3rzj RxfJ8NKW9DuDmEtDVuxQmvQhQWSwtRIU/CpLJZ/TwzsaXQvU9RhFHDzpzGGb0pfk3EAxAguwOLXO0 t1T5LXuhQPSDPnpDkPLUx+9GPPILcLZErQ9KYYZdHAyCLq7a2teRpLdei2PQqDxkt6SaBWlXkRqmw txQvOzOhib9GrfVoyvKsUeV98U5wvZ3qbNkBdX9z2RpJP7/uqjYf2MkKi0Q+1Acq5++K0orlRro+x HGqvEMFDxUkrJ8oTjAtg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwOqB-00000008zRa-12KV; Mon, 15 Apr 2024 16:05:55 +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 1rwOq0-00000008zOS-3VLT for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 16:05:50 +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 23D201476; Mon, 15 Apr 2024 09:06:12 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C584D3F64C; Mon, 15 Apr 2024 09:05:42 -0700 (PDT) From: Sudeep Holla Date: Mon, 15 Apr 2024 17:05:23 +0100 Subject: [PATCH 2/4] firmware: arm_ffa: Check if receiving direct requests are supported before sending MIME-Version: 1.0 Message-Id: <20240415-ffa_msg2_support-v1-2-a28c964b1b3f@arm.com> References: <20240415-ffa_msg2_support-v1-0-a28c964b1b3f@arm.com> In-Reply-To: <20240415-ffa_msg2_support-v1-0-a28c964b1b3f@arm.com> To: linux-arm-kernel@lists.infradead.org Cc: Marc Bonnici , Olivier Deprez , Lorenzo Pieralisi , Bertrand Marquis , Jens Wiklander , Sudeep Holla X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1040; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=ldcV2q/CyksOPnbMW3IM9q/GlT3LqBZyJRakr/Qu/lY=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmHVBUki8AoAfxLn6RHiPHGXc5qsU627EdiKYet AkXTCjqXRGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZh1QVAAKCRAAQbq8MX7i mFh9D/wMeQ6e6QHdrGqLNSqWy4+I9B5y1x169e0jq2aWoOuV25xZFeC4QaDo8bsxGLrcuke32Ie 5rShvtJ690D9PyLp7sFmMHWCTiV9v8G3btTgdG394ekrjsZ/t6cPCM025iYfwRtoCwkPcffRWep vWem4X3hMcPKYhfFJSDuaWIF218Ee3y/q3Wq8PMYQoImzHsQTs+Ex2RgWmOeGCsO+yj735oNaRM nxF/z+x9y0XarUoav0y5epNJFgmZ7zH8LQIh8G0H5r6sh//11UAh8auid7z2FRBkrkEzVlJGTo5 XHLeWmgfYYwvmOTy42ZTd8mIKlN7fFO3iptdczyaw5Tc4RbBv+wB2EMBXFa5kKWzuAJA0c6ZTYz pgQG+PLbhNb01oWpwKJQyXtB90HX7L3hSY1V0UXNLNq1rWha26O3zj8SfL4+3E6iaM5Cf2pFj7B 0DKXQusbmXpL5n0FafWraXW8dS3DV9ZgwMNxDPGEFHbOeDa6lBGlP19GvbjidkVmy4mCbsoSQyy qhsBccyZOcX7eoWI6q6brnrtPjAKLKfsLHn1GvDxp757DOcu0Oru+dT0MYzeSFYV6m4lXkr4Ynz H4J2mOw4F3J7KjnGbKVFRAeelMggFjjAvUCmqc70PLcTsp2LxwmDNhbCnOndJDa4w/JOTcS01iF b0mJuzxXEER4QPw== 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-20240415_090544_956069_FA4C70AC X-CRM114-Status: UNSURE ( 8.87 ) 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 Add check to see if the target partition can receive the direct requests before sending any message to the partition. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index d258d04c1eda..52379885a403 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -875,9 +875,15 @@ static bool ffa_partition_check_property(struct ffa_device *dev, u32 property) return partition->properties & property; } +#define ffa_partition_supports_direct_recv(dev) \ + ffa_partition_check_property(dev, FFA_PARTITION_DIRECT_RECV) + static int ffa_sync_send_receive(struct ffa_device *dev, struct ffa_send_direct_data *data) { + if (!ffa_partition_supports_direct_recv(dev)) + return -EOPNOTSUPP; + return ffa_msg_send_direct_req(drv_info->vm_id, dev->vm_id, dev->mode_32bit, data); } From patchwork Mon Apr 15 16:05:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13630256 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 55941C00A94 for ; Mon, 15 Apr 2024 16:06: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: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=SFlSsAYyLEBfb1HEroK/yyQP1sLYcJ2A8nTfHMOYwXU=; b=FgHdQVAX1iqYcq FesleJqBM2F6QpmR5SzjfLTO6M69cnJWMP9WWoVvDlzAVV3wfi+JAUwU6Q200b+/D8YaXvtLQVNHI WiB5BKlggpQh+HGFRQyqKIdJJdLHwRPnB1j3BYQqavjtkAmzZ5AA0SgdRbFCG+QLEOtsxu0Y7mmMP a/IUMSKs3bw3Bil57IjiOWhJ3lKysk6Oua6sbpjExVTFQqT5VYCRJM22j67rLO7UVTVaOs/Cpp8VT i3+z6x0CL9m6eT1NcrZJV/9uWXWJvzNy3w53mqHKf1b07JuM1SHuF+FZIDjvhfkJgC0rGbUz7k/NU mNvADTr3i4qWXuBWYe4w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwOqB-00000008zSA-3rsL; Mon, 15 Apr 2024 16:05:55 +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 1rwOq1-00000008zOu-1KIc for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 16:05:50 +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 37B1E150C; Mon, 15 Apr 2024 09:06:13 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D84743F64C; Mon, 15 Apr 2024 09:05:43 -0700 (PDT) From: Sudeep Holla Date: Mon, 15 Apr 2024 17:05:24 +0100 Subject: [PATCH 3/4] firmware: arm_ffa: Check if receiving notifications are supported before sending MIME-Version: 1.0 Message-Id: <20240415-ffa_msg2_support-v1-3-a28c964b1b3f@arm.com> References: <20240415-ffa_msg2_support-v1-0-a28c964b1b3f@arm.com> In-Reply-To: <20240415-ffa_msg2_support-v1-0-a28c964b1b3f@arm.com> To: linux-arm-kernel@lists.infradead.org Cc: Marc Bonnici , Olivier Deprez , Lorenzo Pieralisi , Bertrand Marquis , Jens Wiklander , Sudeep Holla X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1663; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=9mGNZxQu9HhTBRnPpfJ5d+3rs2D7y9hofOuhi+wmp+4=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmHVBUJaM6cwbumPIkVczmTxsz5pkfZ+5S+7wXi LC8MnyKFrGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZh1QVAAKCRAAQbq8MX7i mA8uD/9nEZjZZz4/ZBfBIorFdNWSpWnjNP1p/s/fjUIxyQ5pG8SECb0cORc3sDagM5WzJPjd2ok p4EyDN/Bh28xbcQaI3bbCKaOcqcX83ZZUR1zQOjFwBeEninJHqSclTZOqFM9YcAU2MKteUPo6VH rE/fEx2fS4HeTqZThOxbW/eXjM2hxSqKqPczETmwuakRnTv8LfywlUmpwsvjjH6LsS5WbVG6bg/ dmLsvUv84D9hlJSeevN0Rd3T/IZT5zyj+hoUmp9FvxkNtN0LOCGmu43erbEf7qkI2aEAfZUnTGP u6D0V3OEMSOfySCsGimlb7obtrXnuZm7YCoeyvbuHdTwmsZ+DBaSHfRr24NVjvznDDkKc9Atez/ Ois6+mPKsQq3xVoOPC95YVKFSEyPkb3+p08u5gw56/WnhKLyUIrDjX4Sb0NuJIUpAVwBErwlytK 46fhVJ2wWDEwCwoHpf/iZnCbDVR1eKYAvWNjCZNtKlkWvnDJlRHbPqOhxH8Jlec6/f001tJd8qx xzntd22fP9N7LmRrv3zlkcU/vuMakyY/bQMZM55ZF1TAD6UsUHn8j49Sy1BasQSbAXk2Zl3JbXY TfrxjWVu+3yt183FtzcRcQuiudojQ+R9YXllmTUgBPNA3JfGoJL9EDozYSUBaV7IFMO9V3YA8E8 DAaTkyQI0YuP67A== 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-20240415_090545_431840_1AC6F9B7 X-CRM114-Status: GOOD ( 12.50 ) 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 Add check to see if the target partition can receive the notifications before sending any notifications to the partition. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 6 +++++- include/linux/arm_ffa.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 52379885a403..d5087e4f6d35 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1092,12 +1092,16 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, return rc; } +#define ffa_partition_supports_notify_recv(dev) \ + ffa_partition_check_property(dev, FFA_PARTITION_NOTIFICATION_RECV) + static int ffa_notify_send(struct ffa_device *dev, int notify_id, bool is_per_vcpu, u16 vcpu) { u32 flags = 0; - if (ffa_notifications_disabled()) + if (ffa_notifications_disabled() || + !ffa_partition_supports_notify_recv(dev)) return -EOPNOTSUPP; if (is_per_vcpu) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index c906f666ff5d..13830be5851d 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -221,6 +221,8 @@ struct ffa_partition_info { #define FFA_PARTITION_DIRECT_SEND BIT(1) /* partition can send and receive indirect messages. */ #define FFA_PARTITION_INDIRECT_MSG BIT(2) +/* partition can receive notifications */ +#define FFA_PARTITION_NOTIFICATION_RECV BIT(3) /* partition runs in the AArch64 execution state. */ #define FFA_PARTITION_AARCH64_EXEC BIT(8) u32 properties; From patchwork Mon Apr 15 16:05:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13630252 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 CB175C00A94 for ; Mon, 15 Apr 2024 16:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:In-Reply-To:References:Message-Id :MIME-Version:Subject:Date:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=P9ZNkfp5Ms7PCdjaw26Hb9K/npkkdBYAP1dYSDXBkhQ=; b=0RzD2przO2tjf1 IeFseBd4QUneqCHHo+AuUUflL4VpqjbGqPyvTuyJAt1XubwDhcASw2QziyDZ5hllSEW4ZOu69GyAx wWRhd0M13tYF1PRSX5j+wcKjo4KAjeyRX69AJrUAMF2ubUyAH8pSlaPUwY5yS0uxgAXQSsE+GBTaC eUaZt5kYvEwv3MpR+MUtwTUweTBCdk7xrVZkJNwah+W7KV+/ErLJFbl0g2rwfNWFpGb8cfMAnlMOt nzg4CdXIgtT0+HV3cQ1c5gEKKAuKYjfxGSwieXoPjCf7m71JAZFTroFnCSfX10VPgXqcG1vJXvmdF N/vVISUu/CCs4zYgUOEQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rwOqC-00000008zSb-2t5y; Mon, 15 Apr 2024 16:05:56 +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 1rwOq5-00000008zQ8-2t2k for linux-arm-kernel@lists.infradead.org; Mon, 15 Apr 2024 16:05:51 +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 4B82C1515; Mon, 15 Apr 2024 09:06:14 -0700 (PDT) Received: from e103737-lin.cambridge.arm.com (e103737-lin.cambridge.arm.com [10.1.197.49]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id EB19D3F64C; Mon, 15 Apr 2024 09:05:44 -0700 (PDT) From: Sudeep Holla Date: Mon, 15 Apr 2024 17:05:25 +0100 Subject: [PATCH 4/4] firmware: arm_ffa: Add support for FFA_MSG_SEND2 MIME-Version: 1.0 Message-Id: <20240415-ffa_msg2_support-v1-4-a28c964b1b3f@arm.com> References: <20240415-ffa_msg2_support-v1-0-a28c964b1b3f@arm.com> In-Reply-To: <20240415-ffa_msg2_support-v1-0-a28c964b1b3f@arm.com> To: linux-arm-kernel@lists.infradead.org Cc: Marc Bonnici , Olivier Deprez , Lorenzo Pieralisi , Bertrand Marquis , Jens Wiklander , Sudeep Holla X-Mailer: b4 0.13.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=3720; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=j0t2yCqDDE/TbLnCOqfhb8D15PznKfc/QqPqYhCdXTY=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBmHVBUeAiaeTCY0HZFe/n+K0sm4u4YBJwo/f9f3 8XVo+bdyJ6JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZh1QVAAKCRAAQbq8MX7i mEjlEACMgLhF3MP7FWlgMLbnf9IZjjXxWO5JfqUaxbJZk46n+en+fTmrOj7S48sEcMShdJN/fMR rCjR3j0ujBAHNCgvf8NqTFmmggFVtgQl+6lPeDVWMhk/ZEnirL9o1dCgESnXpIVaD19pGR59M1m k0P6u3FaKZxOImdrcSIls2r39DnON+bPMByPEx2wQzNiETxr1b55pf/o1Ia2136SWph+IMqItWz ynSnFwFVCbO+hbK0Oego+FW72n1KpWp9FeWOf5m9WkJ1P3N+H/sOoMgJLvJcRzhncThkxdVY4MY IvBl9J/TKMplhbu6dsuBkXBvHm7K+m6g4Vmm9L6lXaWkWoTe9+HUzpXh1QTx6wL6naqrw4fDujD fP0+FxvGOjE8egBZK5bVsB+wtMUXPoEljFfnTaIFrztM6DkX8Kh1BTtR0n65iIW5MtB+xKse2Xh jNI3UA3IYoCMJYHc6fghVIlBso2haqrDkqa189X5A/U+t2PK8isbIjsanxDwiV+zOA2sks7I6XP RhEcZ66+2G16GIVzMJ6uCaUJVYWkZXmSNVpIgg0ZAjyg74Iyma+aO/5OLf/icHK+SMchunHSOmN WDkcyB8XjFsn2305UHbXR+YvHXsx780GVSXuycQ0OLpklg4VTOQ7c7Kq/5hXsReFMn+jz0EbPMc 7box5PfavMjq1Pw== 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-20240415_090549_859998_12715408 X-CRM114-Status: GOOD ( 14.69 ) 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 The FFA_MSG_SEND2 can be used to transmit a partition message from the Tx buffer of the sender(the driver in this case) endpoint to the Rx buffer of the receiver endpoint. An invocation of the FFA_MSG_SEND2 transfers the ownership to the receiver endpoint(or any intermediate consumer). Completion of an FFA_MSG_SEND2 invocation transfers the ownership back to the sender endpoint. The framework defines the FFA_MSG_SEND2 interface to transmit a partition message from the Tx buffer of the sender to the Rx buffer of a receiver and inform the scheduler that the receiver must be run. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 40 +++++++++++++++++++++++++++++++++++++++ include/linux/arm_ffa.h | 9 +++++++++ 2 files changed, 49 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index d5087e4f6d35..6c2602f7e7cc 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -344,6 +344,34 @@ static int ffa_msg_send_direct_req(u16 src_id, u16 dst_id, bool mode_32bit, return -EINVAL; } +static int ffa_msg_send2(u16 src_id, u16 dst_id, void *buf, size_t sz) +{ + u32 src_dst_ids = PACK_TARGET_INFO(src_id, dst_id); + struct ffa_indirect_msg_hdr *msg; + ffa_value_t ret; + + mutex_lock(&drv_info->tx_lock); + + msg = drv_info->tx_buffer; + msg->flags = 0; + msg->res0 = 0; + msg->offset = sizeof(*msg); + msg->send_recv_id = src_dst_ids; + msg->size = sz; + memcpy(msg + msg->offset, buf, sz); + + /* flags = 0, sender VMID = 0 works for both physical/virtual NS */ + invoke_ffa_fn((ffa_value_t){ + .a0 = FFA_MSG_SEND2, .a1 = 0, .a2 = 0 + }, &ret); + + if (ret.a0 == FFA_ERROR) + return ffa_to_linux_errno((int)ret.a2); + + mutex_lock(&drv_info->tx_lock); + return 0; +} + static int ffa_mem_first_frag(u32 func_id, phys_addr_t buf, u32 buf_sz, u32 frag_len, u32 len, u64 *handle) { @@ -888,6 +916,17 @@ static int ffa_sync_send_receive(struct ffa_device *dev, dev->mode_32bit, data); } +#define ffa_partition_supports_indirect_msg(dev) \ + ffa_partition_check_property(dev, FFA_PARTITION_INDIRECT_MSG) + +static int ffa_indirect_msg_send(struct ffa_device *dev, void *buf, size_t sz) +{ + if (!ffa_partition_supports_direct_recv(dev)) + return -EOPNOTSUPP; + + return ffa_msg_send2(drv_info->vm_id, dev->vm_id, buf, sz); +} + static int ffa_memory_share(struct ffa_mem_ops_args *args) { if (drv_info->mem_ops_native) @@ -1167,6 +1206,7 @@ static const struct ffa_info_ops ffa_drv_info_ops = { 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, }; static const struct ffa_mem_ops ffa_drv_mem_ops = { diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 13830be5851d..d61a6df397f6 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -238,6 +238,14 @@ struct ffa_send_direct_data { unsigned long data4; /* w7/x7 */ }; +struct ffa_indirect_msg_hdr { + u32 flags; + u32 res0; + u32 offset; + u32 send_recv_id; + u32 size; +}; + struct ffa_mem_region_addr_range { /* The base IPA of the constituent memory region, aligned to 4 kiB */ u64 address; @@ -398,6 +406,7 @@ struct ffa_msg_ops { void (*mode_32bit_set)(struct ffa_device *dev); 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); }; struct ffa_mem_ops {