From patchwork Fri Jan 31 11:24:01 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955261 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 B1C98C0218D for ; Fri, 31 Jan 2025 11:29:18 +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=S0+k3ZM3JtMWXlLNUUxvrkkZLMXDXhX+hu570K0txQk=; b=TBjPK/hgmtvjI/1cCUFyJkbopI 9ln0XVQ9vAQbscJ/6cbm8/2uNswKunUvGWxG7Zf1FH6gNc24g3hPJCw9zqexSSWa0CaAMSeWbIeQt 8ijYlULi9lYNPPxJpA/7Q1dzTAGRlQn0sfyIFts1u8/vuXc4oj6EGMkDgwbCkp5nXcovcWxM2JXD3 YsvHVDCt+ibcYLnyfww4TF24QgxuBQit9BHVnxGV182l2K5wJcQGZGIvQ24HVji6lUqGxqBKCNfbG CsMR8Tk5LGCSFWChfgvwjhCt5eJBDDuy3Z8Iew2SX3irQlr1zqnpZQ6j2T6JUSwVOk9M+cdN5Ey1m 8peXHEfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpCv-0000000AV2Q-2NLT; Fri, 31 Jan 2025 11:29:09 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp93-0000000ATnp-2kSr for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:11 +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 C9BCFFEC; Fri, 31 Jan 2025 03:25:32 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A52C23F63F; Fri, 31 Jan 2025 03:25:06 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:01 +0000 Subject: [PATCH v2 01/18] firmware: arm_ffa: Replace SCMI by FF-A in the macro MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-1-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1548; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=F0mUi+DToOzDCZQ+Cn7ewDbLcZibROUf9A/AQezLWS0=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMPHU0BHBADhcUbjEDO5bElZzu4c8yq1eRlV dx2WhQzW1yJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzDwAKCRAAQbq8MX7i mB8YD/4kyPIAVsx80cJp2NPKX7f5qxVzLjzZzMNN++CP1xKfIOW+r44nTZTgLy4UdBUg5q1pPdX X6nz1YIlZ8mD2YcY5tYSdg8NrTaFXf80oPI4ikreyqpaCPHYh3u9od44kesatM8JrlqeEQvKRg3 NXW/5J/wxil2TK7VY4dLNgOOujsgH9E3LrbIRYYFKx3/CWTSzpkprItloXO4VNq2PGuVCvdGQeT 71lacqAfSQM7BEc/kNy744L2yEnRY05I/laQo+k04IdjtMhs8I30eozX1BkjDq0eFYLwCB6ZD9p istKdpa/DzqTr5GwS/CN2vcbNABilzXS3kFwLT0Vr81iuvfxAal1+oYNIsAA7F73y6wKz3ac6BX 1vlpNN68jF/1yw71n70jUEzvz7HbBxWgpaePtuyoZGjJs5ha28T31GO20XZwn6wrWWXg5KMHHzB XwTzMmH74zpd9qx77x3vgoIV+6M+mjA1hzXN3QsSs3tOHGEPJ3mExUCBzuh2n3Y/YPR2CS5J17v 2VWArp6Yt+6l0XSxQLQVlGCuW9FP7VL2yqSuFytJ+jt7C3bxh/83PYv/skPj9MIwzUMKWOBdBc4 yWRcawxarc3kd9kYiX7BjnSe0c1cKVWPB2LCPxKyYCv9Ip1TwAfkQMaXd9zDUrLtzGl0NXcrYCe Jnf4nLuX/kPRVkg== 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-20250131_032509_743678_DFC3A6F1 X-CRM114-Status: GOOD ( 10.39 ) 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 Commit 22779149e93d ("firmware: arm_ffa: Emit modalias for FF-A devices") added modalias for FF-A devices. However the macro added used SCMI incorrectly. Replace the reference to SCMI by FF-A and update the macro. (i.e. s/SCMI/FFA/) No functional change. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/bus.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index dfda5ffc14db7208e8b622cdd648194c9cb1ef34..52b1f09209a0e51e321cd23a69aa7e4c4daa8dd1 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -15,7 +15,7 @@ #include "common.h" -#define SCMI_UEVENT_MODALIAS_FMT "arm_ffa:%04x:%pUb" +#define FFA_UEVENT_MODALIAS_FMT "arm_ffa:%04x:%pUb" static DEFINE_IDA(ffa_bus_id); @@ -68,7 +68,7 @@ static int ffa_device_uevent(const struct device *dev, struct kobj_uevent_env *e { const struct ffa_device *ffa_dev = to_ffa_dev(dev); - return add_uevent_var(env, "MODALIAS=" SCMI_UEVENT_MODALIAS_FMT, + return add_uevent_var(env, "MODALIAS=" FFA_UEVENT_MODALIAS_FMT, ffa_dev->vm_id, &ffa_dev->uuid); } @@ -77,7 +77,7 @@ static ssize_t modalias_show(struct device *dev, { struct ffa_device *ffa_dev = to_ffa_dev(dev); - return sysfs_emit(buf, SCMI_UEVENT_MODALIAS_FMT, ffa_dev->vm_id, + return sysfs_emit(buf, FFA_UEVENT_MODALIAS_FMT, ffa_dev->vm_id, &ffa_dev->uuid); } static DEVICE_ATTR_RO(modalias); From patchwork Fri Jan 31 11:24:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955260 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 A3E4CC0218D for ; Fri, 31 Jan 2025 11:28: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=abfUfSyO0Ovqz60dSjdmWlKLDKX9WWl1WsL2R6WWMKY=; b=VseietXy1s9sbNcGfHpEkdfGc3 1/UN67u/1KZEA5UrdB+tN63HPY7zLAkswKkMgfwIx1bdsSzb0V43pVrgRBZiflVSpaFsXqKlYBq2g xDZHGu6ywbTGNT9QC0tragHO/Um+U3AOvPBQ1NJoc6RSefRqEHK1sYmenuugg/bzkOHZnJi8sIpwf EfnhrDHY9ZHNLt5WKzSZAmduHz61k7QLgmsNNOSfKTLi4Vv+uXTMiJMqfS92/neD5hviQsKxyiSOL h+7uY4xdsm+IUZJFmqeCDhJslpJWGGZckMVmaSiyFKQD1o8LwMLxSkn6SnyczOzHqiFO6FFnLvmwJ JNrkDO9g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpBe-0000000AUUq-3qVX; Fri, 31 Jan 2025 11:27:50 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp93-0000000ATo5-1P0z for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:10 +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 D07481007; Fri, 31 Jan 2025 03:25:33 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AB21C3F63F; Fri, 31 Jan 2025 03:25:07 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:02 +0000 Subject: [PATCH v2 02/18] firmware: arm_ffa: Replace UUID buffer to standard UUID format MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-2-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1783; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=an0T8BaHmmjnOIWFrg0XcNclda/TDCEpL5ml8sjKwio=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMPvsTuXlYTc75Eg3d1Qp62BX2OhJ9rXBo1N ddU03iBR4OJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzDwAKCRAAQbq8MX7i mIpVEACLNNX/8+chGpqM9MPBuCAooVDzcLaWm3lQnrrmEwQ+PbGHAqdrGo+tDKF7W3eklxpVXK7 QAZvGsVXzkVbIdYQzRkn8N76ysNopUkNIC9fhVYfDCjNpxi1QazaeusfyskztdqRGURwP4wDnJt zDA6skVjvdoOiBDHRWvkdZ/7lXu/EL4QPDvyusVYiK9LCUOUEpZGaVYI13+IWGbqtstufisPX/F rFQgM9iKwPiAJ1EFxc1xkauvDcHaiwt+f6FvWW+xq4TrXg1+DcYV3OdxxWzQGSnSFIl+5UHSTg4 0z3Tu4jeS8hysbBtN4Baih0/BNBQVrsgf287rYs+VxaUHnQSQUmS7oqtCBwj8lMf2POxbh32g+W 02+z0tsk4nnLIOs2fcYwUm+O0Q1/ANrkwteaX0AHJuS+PbDvnFJJYalYwC/auIO0gBFh1u2sof4 LbGiZRBiaVo0Kc2uEMXGd+GuqCykagTct9ZQQlD/E53ihlO0a/5vY2ghCYDjFHoJhUfwltAKLfV g0fUt0OZ6OtOWOt2215nBo9lM5zgXeY1RNwph/jfD7KWUHRfQQTtCLX1JCaJo6dhUsTmJ8FJxze tujiPj20cDuAGsCbQO45fcnRath7xuX5D/wtFSEnyLVvp84IP3o4dqb7cz+PiKS7Ujy6tAzugpP WdXWHUZHAJ2ooxw== 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-20250131_032509_420584_35BEB709 X-CRM114-Status: GOOD ( 11.55 ) 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 Currently ffa_partition_info structure holds the UUID in the format compatible with the firmware interface. However, most of the functions in the FF-A core driver deals directly with uuid_t type. Replace UUID buffer to standard UUID format in the ffa_partition_info structure. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/bus.c | 4 +--- include/linux/arm_ffa.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index 52b1f09209a0e51e321cd23a69aa7e4c4daa8dd1..a90e2faa990219574ff20b8f573dbb7ca76137d9 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -192,7 +192,6 @@ ffa_device_register(const struct ffa_partition_info *part_info, const struct ffa_ops *ops) { int id, ret; - uuid_t uuid; struct device *dev; struct ffa_device *ffa_dev; @@ -218,8 +217,7 @@ ffa_device_register(const struct ffa_partition_info *part_info, ffa_dev->vm_id = part_info->id; ffa_dev->properties = part_info->properties; ffa_dev->ops = ops; - import_uuid(&uuid, (u8 *)part_info->uuid); - uuid_copy(&ffa_dev->uuid, &uuid); + uuid_copy(&ffa_dev->uuid, &part_info->uuid); ret = device_register(&ffa_dev->dev); if (ret) { diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 74169dd0f65948b05991732358855cdc31b54adb..abd0208f0f74c15ef4ee4c81de81eb7800a0eb1d 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -238,7 +238,7 @@ struct ffa_partition_info { /* partition runs in the AArch64 execution state. */ #define FFA_PARTITION_AARCH64_EXEC BIT(8) u32 properties; - u32 uuid[4]; + uuid_t uuid; }; static inline From patchwork Fri Jan 31 11:24:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955284 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 A4C2BC0218D for ; Fri, 31 Jan 2025 11:31:59 +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=0GYJNCreNKeiqS8nDDLgAEq5nbjMlv8pyHF1gavhYhw=; b=w7p6hUBPki3xKMURsHpR7QSq1w cgWu2R4yhuar6czifPdRJlALFVfLzDolOqjeLsfSedj71wnRZRPX+f57ouop0EGbX7DP6i4ikyze9 CQ/7ecKhHP1piNaX5vL2tVX2iLkXtpGlZuYuj0/szwjSEIcmt0xQbMgeoGTrpVXZP6/P5rXvriRxZ A6nP6YygyZmSL85zfHZEGQKlHoNZK72PPskOPz00kXByknELo4N/TPoEfyAaKMuv9VnWMtxuK3UFU o7PfGAh2yBioEH6zrH3876glKlH71WJAa2ChaV4kz6AaNh4tbPjoZrSHZxuMjrdlFl86dzD9lEeRu VtJ/Dniw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpFU-0000000AVsm-3mNw; Fri, 31 Jan 2025 11:31:48 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp94-0000000ATof-0Pia for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25: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 D71411477; Fri, 31 Jan 2025 03:25:34 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B10343F63F; Fri, 31 Jan 2025 03:25:08 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:03 +0000 Subject: [PATCH v2 03/18] firmware: arm_ffa: Align sync_send_receive{,2} function prototypes MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-3-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1948; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=llehAUqDTyE8tsnbqX0XKeEGbtFXiSKUAGLSD+1hoi8=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMPkKCWm5ZAQF/ShpVrftIiiw7VlFUeSwUBr AMJt2HQzGKJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzDwAKCRAAQbq8MX7i mB8xD/0UeYGhs1EoqVrQ2tjc49+GiEqkXvQwEcyx8tOnuXRzsERNYXlVoIcE8gEY1olxl7ASlv/ pEERkoGGsc6YiXBh6gw/ucmjSt8t7gTZNwKNn1KocfptgHrUnRGs6jCBjz+oMEAmf8DPAr82vm2 oiHgLeiomAIilGwwDXKTrVG4IVpdAbSwAIVhm7OX/0rYfrRbB8IGNFSmEVsusmGWkyLXwGTTLLs vrjd12hnZjORo3UJ+vJcIG5OBCDG0sml8PDIlyxT6k86+sUERfvT6il/noI5eCs6YVZSBUO0lRf 0nhmZaPpuiuDWdbi4iKCP+EXceMufk5SupnMSVXLdOLxAd3ocy3PzIUCaC3NrG+JorJlzixuvNq iwgDRMhMySlyQOoBpqr8berBocdGrW5qb2ESgqbGNv8th9tP5jnVWc7PXKm+O8QEwx2zy2xTPnm Rqw0NQ6ppDQ3PNv17F3CmXMFPXpqDuCTCclBK/2Zunb4p9ZlBbUSGrTq1cDcFty1c0fpLf5CTWU Wvd0OiqcYTyQOhmytbxFrAxdkACEXyXpQ1ZZ03lgUGTc7SRpDr0NOrNuGnmAHvYa9JIuEmgHaFE JlCvoihlWWbA5Hj9iFiBOEKr505192FRR+fVQVG6Jgpx0U98JOHB+j5r9qiupfEk93pjKq+cCPC k5u2DlEFLL4Ug+A== 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-20250131_032510_189353_B7E21833 X-CRM114-Status: GOOD ( 10.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 Currently ffa_sync_send_receive2() takes UUID as a separate parameter instead of using the one available in ffa_device structure. Change the prototype of ffa_sync_send_receive2() to align with the ffa_sync_send_receive() and use ffa_device->uuid. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 4 ++-- include/linux/arm_ffa.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 2c2ec3c35f15612168cdf0ef94022e00c08677b5..037e0d684994fd30971f40bf139367d1e45c1bf0 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1018,14 +1018,14 @@ 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, +static int ffa_sync_send_receive2(struct ffa_device *dev, 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); + &dev->uuid, data); } static int ffa_memory_share(struct ffa_mem_ops_args *args) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index abd0208f0f74c15ef4ee4c81de81eb7800a0eb1d..e8b8ae8b192ab11d5550c16fd33fa9d192b07f67 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -439,7 +439,7 @@ 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, + int (*sync_send_receive2)(struct ffa_device *dev, struct ffa_send_direct_data2 *data); }; From patchwork Fri Jan 31 11:24:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955283 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 E5296C0218D for ; Fri, 31 Jan 2025 11:30:42 +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=77M7OzMT8CcBilT9EriBScvbhYmJy/Zk47gwOsgZtSQ=; b=e7V1qPmfc1hyGsdErExBFpWCnY +TUsD4uj1MZMv/J2jZkt3taSu7VBJ5zu0DkYN+cyUvzOhmHBEmy6Jg/9OYSiA2JSufa1wKSCKgE7a enpyiuCaRoOD7d1nA73R6z9IhgDW6imYalPy4ZHrif/LJcaOm9G51VdR/AncUp1g1+BAxStY+e68R UDbnN8TV61Aww1kwsshVdkjdPLAtxHcpSYr4heWjJimADz2EuwWsS4XIHFx7kDy1X67hkAVj+KX0g uBBhLXTvB8cg/Y8zzKokNm6ZVtxX/zOt8iG3ptwdVBt8qinSrxoHTlkk685aSGpMYd0dNQLnArkaH +TZR9+FQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpED-0000000AVej-0pNz; Fri, 31 Jan 2025 11:30:29 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp94-0000000ATpA-3ckA for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:11 +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 DB445497; Fri, 31 Jan 2025 03:25:35 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B6EB63F63F; Fri, 31 Jan 2025 03:25:09 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:04 +0000 Subject: [PATCH v2 04/18] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_get() MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-4-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1735; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=2q64Jp03o3t6jzZXlU/yVP9FQTQM5OdzbtR25jurl9s=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMPnP9ExfE8fla7raoFlnr7IpF0OjFWczOiv Sf5EBnuITGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzDwAKCRAAQbq8MX7i mGdnEACugNIFXNf49mz7Um8HzraL+3TgBPJ/wdom1HRJgDOM92XhsBKfv7SfsVe3WJkqL/ATlqc UFDuvOzs4kqU95bix/3pSfB3c30Q+YlgqyZh8te8RGkX85jnhyFcXbBm2Z87ryISHEPqiKWdD2k /io7a2jeLdYSjFoHLEFhmDD6ttCL/7hTo90baNHL28Utz7QxcVzxuAIqewyUw5YqZkuLHCwzSfi Z02vaaYOhQlfXTG/KLuiAZU7cwfbQbzIu4bP5Pwd2KRsgJq2V2f8CFgVJ39J/HhGDNMqHjVYzfg xMqSD7oquCQQOjq8RcnYLvne5mXrMKNTvmk+We7vKHoAuYLu4rZscVLLWS+rnv9Nq72FDlp7bQ5 /BEiihNqTFm04RPjiJ+0mwzBpxGF3s8RxlW1/yCLn/nR5SobZV5THDf79tlO1G7E6UMbal7kVMV XrTvYiCMWqm/nAjjPZocuSil3dTjHfH78jsxfQCtdKwnzefxSUWflbito7YomQVwxwL7cP2HMH5 Okz423qbPXqoAqWC9SpDCkis1CRjz2xi0g8ieB1ywEGHzkbFSC6VK1yrYAtSK26O1zbLfitxRSU tsi44V3OVXQpawkoNAWwWtzpN54SsWBPJLVbwDRYKppWOsSqHV+/IUGXGFqeF4zoB5Y+0pKAc+6 8d9O2GUkbnCfUVw== 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-20250131_032510_957731_B966EC66 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 Currently the FF-A driver doesn't support big-endian correctly. It is hard to regularly test the setup due to lack of test infrastructure and tools. In order to support full stack, we need to take small steps in getting the support for big-endian kernel added slowly. This change fixes the support in __ffa_partition_info_get() so that the response from the firmware are converted correctly as required. With this change, we can enumerate all the FF-A devices correctly in the big-endian kernel. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 037e0d684994fd30971f40bf139367d1e45c1bf0..bc6ffd25ad2e2fea0fe3610cf896718dbed8f0ad 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -276,9 +276,21 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, } if (buffer && count <= num_partitions) - for (idx = 0; idx < count; idx++) - memcpy(buffer + idx, drv_info->rx_buffer + idx * sz, - buf_sz); + for (idx = 0; idx < count; idx++) { + struct ffa_partition_info_le { + __le16 id; + __le16 exec_ctxt; + __le32 properties; + uuid_t uuid; + } *rx_buf = drv_info->rx_buffer + idx * sz; + struct ffa_partition_info *buf = buffer + idx; + + buf->id = le16_to_cpu(rx_buf->id); + buf->exec_ctxt = le16_to_cpu(rx_buf->exec_ctxt); + buf->properties = le32_to_cpu(rx_buf->properties); + if (buf_sz > 8) + import_uuid(&buf->uuid, (u8 *)&rx_buf->uuid); + } ffa_rx_release(); From patchwork Fri Jan 31 11:24:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955285 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 D50A2C0218D for ; Fri, 31 Jan 2025 11:33: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=loJQQ4pqZ47nrjW4300ckgAvNibzSRJeQXViPmPbc+8=; b=s1vhkj6CpLgiiDwGWnlf2iI4fL /X6ZWL+Eg+TVgdbOsoMBahXkFINy9Aea9sHwDgwal+xPr9IZYdEWhuroXhf4Zz8Ml/NSJ5NkduIfN AsdAu64xUct8YESlhbZmqOkZcLyQGqbeNlOt9Ctfp9kWbPWps3hHZhPFsLi3bXVt+HbMKx8QGEIdu YMjAPMKtTSZsvEUM+e9jlvdaH1JGQ8nSX2Cs+PQceFN3X/1qdrDYQDxC7HYoEW+Dxqaak9ICSv/9h CjXnD2alEQf4mL8SpmjgfDWNhksVJuNWQm5IP5lrrIO7fQz7I4uVbQIUf/y2P2UbO1brd+swTw8kX mISWiK1Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpGl-0000000AVzC-276h; Fri, 31 Jan 2025 11:33:07 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp95-0000000ATpp-3QV9 for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25: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 E16F2FEC; Fri, 31 Jan 2025 03:25:36 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id BCCBD3F63F; Fri, 31 Jan 2025 03:25:10 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:05 +0000 Subject: [PATCH v2 05/18] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_regs_get() MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-5-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2970; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=8PoYp80YnxCA99g/OmQlLeeIzCDfYeP4snzLnAUmwtk=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMPF3AwbZPpDnrAK4QCNPF48Pwgb7Ddgyfwj ery7HTg8GCJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzDwAKCRAAQbq8MX7i mEKpEACGGMhs9IiGXnsVEw18BL1U9sImXyJ7pzdVolX7K9YpyZ7q9B1YoVpSDXyn5qftYgdFuec 4q+Kt0bPJlMO2fEonRfhu6lKwdAd0hl4BF8UNqIr4QQpClxQcJh1TfoY2sf5Fv0LwokK11ZEcgJ juvhpxT6poK21pRWBkpc8hPGipeyQilieDRrzQf90xVap1HNgBsTZiO8FVdTrNgHN5J/eCqILld LRaa1uGOBAt7syDbwa8h3Gxbez2hwwuMF5pw0Cra2qF41ZO+KHl/xs5P6YMGb4g1/RkVHIn7Rl7 WpEjks7Em6DZUGo7RWf4cUHxlSqXOzAwTc9wCZWRDCM+MBvREwVVR8Sf4bwGB0MoVAIQgN3aBur 1PVOHiOuWJCjMfutp2J0N0wgVLqOXAEmD9Fxzwa/SfcBPRG1fXb21smqFHQnW/mtXmx5Uvq36Mq 8VeTCvc1sHpnecLYX1GC68TWTmmU3SocYBPNVFotiJQPyQxbXmaCpt1Pz1S1prSmPuKr+c7VekG DfkzijcHeOTaobE2KmWcSqrHSX/hcg7FPo1Iygf97OPJQQSHsNPzXJIL73Y9Rd6yJqDlEAhb4SP zdc+vcMU1O/GQwtT+uluZK4LshUHQlMPWWuPbw6Xn24rZGHqQL2ViR4NdzZJZ4yxqUpfMuNl/s/ L0YTBxzAZWQc9MQ== 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-20250131_032511_945959_A70BD06E X-CRM114-Status: GOOD ( 14.72 ) 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 Currently the FF-A driver doesn't support big-endian correctly. It is hard to regularly test the setup due to lack of test infrastructure and tools. In order to support full stack, we need to take small steps in getting the support for big-endian kernel added slowly. This change fixes the support in __ffa_partition_info_regs_get() so that the response from the firmware are converted correctly as required. With this change, we can enumerate all the FF-A devices correctly in the big-endian kernel if the FFA_PARTITION_INFO_REGS_GET is supported. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index bc6ffd25ad2e2fea0fe3610cf896718dbed8f0ad..87e106c728b89f3ce7c11219cf7cad9cc166dda2 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -307,14 +307,24 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, #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)))) +#define PART_INFO_ID_MASK GENMASK(15, 0) +#define PART_INFO_EXEC_CXT_MASK GENMASK(31, 16) +#define PART_INFO_PROPS_MASK GENMASK(63, 32) +#define PART_INFO_ID(x) ((u16)(FIELD_GET(PART_INFO_ID_MASK, (x)))) +#define PART_INFO_EXEC_CXT(x) ((u16)(FIELD_GET(PART_INFO_EXEC_CXT_MASK, (x)))) +#define PART_INFO_PROPERTIES(x) ((u32)(FIELD_GET(PART_INFO_PROPS_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; + struct ffa_partition_info *buf = buffer; ffa_value_t partition_info; do { + __le64 *regs; + int idx; + start_idx = prev_idx ? prev_idx + 1 : 0; invoke_ffa_fn((ffa_value_t){ @@ -338,8 +348,25 @@ __ffa_partition_info_get_regs(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3, 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); + regs = (void *)&partition_info.a3; + for (idx = 0; idx < cur_idx - start_idx + 1; idx++, buf++) { + union { + uuid_t uuid; + u64 regs[2]; + } uuid_regs = { + .regs = { + le64_to_cpu(*(regs + 1)), + le64_to_cpu(*(regs + 2)), + } + }; + u64 val = *(u64 *)regs; + + buf->id = PART_INFO_ID(val); + buf->exec_ctxt = PART_INFO_EXEC_CXT(val); + buf->properties = PART_INFO_PROPERTIES(val); + uuid_copy(&buf->uuid, &uuid_regs.uuid); + regs += 3; + } prev_idx = cur_idx; } while (cur_idx < (count - 1)); From patchwork Fri Jan 31 11:24:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955287 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 28110C0218D for ; Fri, 31 Jan 2025 11:34:39 +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=Wb8Ch2o/C1+/8OFb2fziJnkIwhTZQBpHxWQly4R1jGY=; b=cv/dvbpc6+rcwQ8UaVOrhJfirS FMHLsPoz7L/3X9EfK96zzww26T0ht7OT2UKz9V8JUDYMnP7ghY3At7iZF4dlxXx9JHRtm7ap15fWC yYvgP9Gt9o2aODa0s3djo/GpXqQZcmhn3LCiOKg3DyXG+f8oalFGDzIkUJ+8kDgx7FCcRzW3D5iaf rtrEvRG4stl1YYIPKGrKt6TNoHD1mvf3LT4Zh5qpJYg4Rol6JNgQE/oFBQVHK4M0r2ZbPk2atuD7t DTYUpWlR9jcysoP/929moWpgSHW43Q6RArrdLngf8d6+I4876PGWuCf95V1/PR3J76+pzQzPU5wzD VZnV9nMw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpI3-0000000AWBS-2oYb; Fri, 31 Jan 2025 11:34:27 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp96-0000000ATpA-2z2W for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25: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 E7ABD497; Fri, 31 Jan 2025 03:25:37 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C2F463F63F; Fri, 31 Jan 2025 03:25:11 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:06 +0000 Subject: [PATCH v2 06/18] firmware: arm_ffa: Refactor addition of partition information into XArray MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-6-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2741; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=nhubqO1qEmc8fhsAz3PI0VU0iirPJL57lKmAlJbAdIM=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMQMImWsaOOj6QlbeWqTk6hdTAkKzs79VXh5 ffUESKoX1CJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEAAKCRAAQbq8MX7i mN3/D/4iY7ODMH0FWbCMqW9yhcba9bnW+pM4y51fofubRlEBD0wl+NV8fbKV9THg618PuAcCuZx SjFc/8M+sPpTGkxjyxwz442jGSV7gcyqFgmkIS+t9wmEifZy2cmZ5F2xAkGTrTTrDDl6gUxhKm5 nCdtDI9O6nEqkpFrWBwV+GQm9TtcBbqxAjk45r3/sMZeWGHN47AkpeCYHdTVU/iEUrYHD8dH9ht Q8yj2FwDZMU+uIR6140Dujw3paLj0XbouGtvhWKn/fPHMm7A+t5Xta7rQzagraonuGBOV5Uv5WV m74NJRnbMewlmoBk3Jp8ao+TLK+bD2o3ZrslEE4M9WLbjchGWA0wBdfDRZgpDtNFJcXCvwPMpEg 30evia28Fqsu4Xq0y/PP10sOUhaH648zm8d2uOvKYNGMLNwpKKJ2wjMl1aNOmQSKg6Jb/CIoeTg WDcF8cK3H6qzMqt+YL6+84rSFrRVorxwYfkpbu2oNCed86e2ATX/XW1d0za1s+2euyX/sZ4Y/P9 sJ1ZmFuzj3iLB1h0E3IgFZX7B62ci0cc49oGsTd8uxEbMYwV8gT8T+HUPnfnHPkhJQXPX4Kuh9L t8FFKhYOSPTh9nwzFWXFDXCcS8Ef7pXkAm+uMwB9H/Zp209UUEviSsgQAW2nfixhHVqwRWdAbXN q7Zl0xvCyeP11WQ== 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-20250131_032512_881457_2F9E397A X-CRM114-Status: GOOD ( 13.33 ) 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 From: Viresh Kumar Move the common code handling addition of the FF-A partition information into the XArray as a new routine. No functional change. Signed-off-by: Viresh Kumar Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 48 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 87e106c728b89f3ce7c11219cf7cad9cc166dda2..67d5be261d83633805c81dd84fdfc2b5c702f3ca 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1423,11 +1423,30 @@ static struct notifier_block ffa_bus_nb = { .notifier_call = ffa_bus_notifier, }; +static int ffa_xa_add_partition_info(int vm_id) +{ + struct ffa_dev_part_info *info; + int ret; + + info = kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + rwlock_init(&info->rw_lock); + ret = xa_insert(&drv_info->partition_info, vm_id, info, GFP_KERNEL); + if (ret) { + pr_err("%s: failed to save partition ID 0x%x - ret:%d. Abort.\n", + __func__, vm_id, ret); + kfree(info); + } + + return ret; +} + static int ffa_setup_partitions(void) { int count, idx, ret; struct ffa_device *ffa_dev; - struct ffa_dev_part_info *info; struct ffa_partition_info *pbuf, *tpbuf; if (drv_info->version == FFA_VERSION_1_0) { @@ -1461,39 +1480,18 @@ static int ffa_setup_partitions(void) !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)) ffa_mode_32bit_set(ffa_dev); - info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) { + if (ffa_xa_add_partition_info(ffa_dev->vm_id)) { ffa_device_unregister(ffa_dev); continue; } - rwlock_init(&info->rw_lock); - ret = xa_insert(&drv_info->partition_info, tpbuf->id, - info, GFP_KERNEL); - if (ret) { - pr_err("%s: failed to save partition ID 0x%x - ret:%d\n", - __func__, tpbuf->id, ret); - ffa_device_unregister(ffa_dev); - kfree(info); - } + } kfree(pbuf); /* Allocate for the host */ - info = kzalloc(sizeof(*info), GFP_KERNEL); - if (!info) { - /* Already registered devices are freed on bus_exit */ - ffa_partitions_cleanup(); - return -ENOMEM; - } - - rwlock_init(&info->rw_lock); - ret = xa_insert(&drv_info->partition_info, drv_info->vm_id, - info, GFP_KERNEL); + ret = ffa_xa_add_partition_info(drv_info->vm_id); if (ret) { - pr_err("%s: failed to save Host partition ID 0x%x - ret:%d. Abort.\n", - __func__, drv_info->vm_id, ret); - kfree(info); /* Already registered devices are freed on bus_exit */ ffa_partitions_cleanup(); } From patchwork Fri Jan 31 11:24:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955288 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 3C0CAC0218F for ; Fri, 31 Jan 2025 11:35:56 +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=/fxc9RCS0yJMcxzv/R39+HJdfE9CEG2gSGkEU0ozgl8=; b=j3AeyCLxK9eLogGmyCHp3at2Fp 7+VXOZv8FwUEZ4ffaPu3uPdsTPypgJ01iW0Ff0ZVxk9KQ0uhaPG5FPBhBqnPrLDSPQ7zVMlquIh9t wCZNpWi8wQqou3Cg2lwr5ynu+ehmPSHHbUgUsCvun6BtL0EjPiba6d8hv0HJTYYaaxE8ascL2v/MW gMZUZjORiWTgcfn5MMXzKngR5UNi8pmeYg/JBdw3kT75+7EITuMllnuIjMUUjIAZE0fjgUT835yK+ iyLltlp/7+lZRBrBrUtSxnrKYYJcozhcw0I9kXyMiiih0l+5cer7G5OVqMRo4Hhj2zdHqcDpWHBAp wRRPBSYg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpJK-0000000AWHK-1D9P; Fri, 31 Jan 2025 11:35:46 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp97-0000000ATpp-3W5i for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:15 +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 EDBC71007; Fri, 31 Jan 2025 03:25:38 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id C919E3F63F; Fri, 31 Jan 2025 03:25:12 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:07 +0000 Subject: [PATCH v2 07/18] firmware: arm_ffa: Handle the presence of host partition in the partition info MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-7-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1248; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=NzKYKTJax7pPW/1p5r9wLFeoyYWNp6T+H8b/gc+oDek=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMQTwKrUk2nwtAsORQMj+77uPDpexNxTwmxk sUAJk00vreJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEAAKCRAAQbq8MX7i mIPiEAC0Dx2fkcPYfjDpwPAdLR/zezjoEdMKNoWqDAOjxWbTNbcKztt3Qywl1sd0Cha70uYIi1f Rv25U0ITRCmmiYuaLnfkVA/e8/O9EokNqR0xAIQXco28DbSrMWvPLsisvg9hIRNG6xOT1tf/+EZ vJZWMuvMivkuTlkcF2D+2emeKVrHI9AExeuQIL65d4j6YVvIaAm3FkLN5Fm5lRTA8atNDRl/qht an0JTBKCkaHdh8L+029OTANcU0/MpEdD0m79l1RSnOrgOKGr6U6oow5WY7IyjRcR3yJBT1gIkjw W2p9B1hMcu7Uxsv8REApjKLhP2VrT8Uq3lq8kbGoNAQe0hnUNIZ+xgxMTnN9wdwE5ZPAOW2ekYb 6rfHBa3lpvN+nN+d5hsPgj/FOGsYU3TOQXLxBmYEkKJ5JnhbMQQkQ1nI0yNxUBXuSYaw50ZGn9D bQ8l360l1mJJ3S4xDzDP1Si7HHVtmtySQCqInQoDunAXbDOT329Zf+jS8ep2Lk8G253go86a6mp Ip5TghlZrXqP1W4WU0yCFWxrntIB7A3LB44giCc/miIGh4r5wOAlW3XmZ/bGmlzStsPUGkq4AlO iKvHDW7GVF0CNL2f3c7uk6offFlOtSZpWaxKc9sdAtrnNGK49as7WITf8DB/lFaAjVe6gbrY3T9 mBdXsIPXapk0B7w== 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-20250131_032513_922024_68AD2976 X-CRM114-Status: GOOD ( 13.93 ) 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 Currently it is assumed that the firmware doesn't present the host partition in the list of partitions presented as part of the response to PARTITION_INFO_GET from the firmware. However, there are few platforms that prefer to present the same in the list of partitions. It is not manadatory but not restricted as well. So handle the same by making sure to check the presence of the host VM ID in the XArray partition information maintained/managed in the driver before attempting to add it. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 67d5be261d83633805c81dd84fdfc2b5c702f3ca..54777055d54f5bf2dba1128e6a91bd1c0ece04fc 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1489,6 +1489,10 @@ static int ffa_setup_partitions(void) kfree(pbuf); + /* Check if the host is already added as part of partition info */ + if (xa_load(&drv_info->partition_info, drv_info->vm_id)) + return 0; + /* Allocate for the host */ ret = ffa_xa_add_partition_info(drv_info->vm_id); if (ret) { From patchwork Fri Jan 31 11:24:08 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955289 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 7851DC0218D for ; Fri, 31 Jan 2025 11:37:15 +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=BYak8X6Q13HPsC1Bl6EKAXDPRPCrDDw0VT53ybVmYVg=; b=KhuiQ9GzeKsk9LGL1zj33iiqfq bgaGZGAGWJqQlwcBcNnbnCyg+Nl+GbqY9dIFtExhDHmyzodzKgqHMcPPZtcjbL4cDf2G+2jst9PTM xuADH3WiHFD8Ru2tJhgOloRxH/jpJydSq1I94ixOvVUY6ZeWhi+0BtjuQEymyTrXObhLi7owPnY8h xCwv9y5bLLBUafwrGv4WfR/gr0sqQA6skRnEy5Kby/UUb2djuGf1J1zWrPGT66WvCesjzpLg+IxAl l634M45OwAky1l72ikFQDiXT7DdwG0ePsAKY+aR2bEK0QnGfp30nKgrbC7N2w636idtSqN0uFqXjZ K57Jj+sw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpKb-0000000AWOX-4Aif; Fri, 31 Jan 2025 11:37:05 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp98-0000000ATpA-3APR for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:15 +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 F3C3FFEC; Fri, 31 Jan 2025 03:25:39 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id CF05F3F63F; Fri, 31 Jan 2025 03:25:13 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:08 +0000 Subject: [PATCH v2 08/18] firmware: arm_ffa: Unregister the FF-A devices when cleaning up the partitions MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-8-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3364; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=UyvgBew/9tfLcZTn4CJGNUBHLEV5T/tT9Fwl0cys6ss=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMQqaN7Qz/8kQqhg3bwymtxpJ4DdZKymS/ur Pi9HREHP2eJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEAAKCRAAQbq8MX7i mH9oD/sFu8KvmYaFZMVNEp29ZDpfdQ0JBLAKchZ3shUPhvssBGWtHRIx4r19b687HlskCqk5tSR UIlNF8yoxe9G2fWwC2jzo1HoCv4DWfUV7m6l5eewG2eX/ocG3TyPjSYW3wbKEgn12sByyDuTKcu KMFGBVWApYmLKcvjRvzl69kI8537oWPh+vgNx++fklElrklytUUn4mFan4n4jQyVmkSlXTZkVsu S9bbRmCV4cB0iVijF3ccOtbBMSrYn6sI7Afmsn3Bb9zgsmJb1gij/dXeqvYXDA/Mj1gq7ECZqax TbTwRxnIYPA0kMK7KceHgwgHQ7XaiwNhXCCgjKlRAv14dbDHvdZ1E0Av/7x9OMV1lKcykIiSIvr gx/qQcPKn4CI/oOxzlIgKX7aHgGehj1eedhpeGtoh7m8HPIdzMsgPeTs8zeW2eaJFojfyxrQDxD mhJ43qrYVZjQtvrsxxRMWtbTqBLK2yu2+c2ya25fQfrv2Bo0rJr0v2oqu5rKi+2/YCeEERoXjLl hLBK5tMkyF0yJ7neDJyku737wkaAdfzI0IteFDkrcAOEyoGXOKSUHEl5UWyUYbtvYn7YiYYiTrs 3wd/u/mgQz+iYK1+Yv2WU1wg3lSALjVbWCprvhmdjjB7Y1WmL1ZSBS/yy9QEgjFoqXYS6ps9/Qu 75K+EWIzwqCn5Pg== 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-20250131_032514_893464_B01F6351 X-CRM114-Status: GOOD ( 13.12 ) 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 Both the FF-A core and the bus were in a single module before the commit 18c250bd7ed0 ("firmware: arm_ffa: Split bus and driver into distinct modules"). The arm_ffa_bus_exit() takes care of unregistering all the FF-A devices. Now that there are 2 distinct modules, if the core driver is unloaded and reloaded, it will end up adding duplicate FF-A devices as the previously registered devices weren't unregistered when we cleaned up the modules. Fix the same by unregistering all the FF-A devices on the FF-A bus during the cleaning up of the partitions and hence the cleanup of the module. Fixes: 18c250bd7ed0 ("firmware: arm_ffa: Split bus and driver into distinct modules") Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/bus.c | 3 ++- drivers/firmware/arm_ffa/driver.c | 7 ++++--- include/linux/arm_ffa.h | 3 +++ 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index a90e2faa990219574ff20b8f573dbb7ca76137d9..98118823cf84969480fc25c937881f9b773a38c2 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -160,11 +160,12 @@ static int __ffa_devices_unregister(struct device *dev, void *data) return 0; } -static void ffa_devices_unregister(void) +void ffa_devices_unregister(void) { bus_for_each_dev(&ffa_bus_type, NULL, NULL, __ffa_devices_unregister); } +EXPORT_SYMBOL_GPL(ffa_devices_unregister); bool ffa_device_is_valid(struct ffa_device *ffa_dev) { diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 54777055d54f5bf2dba1128e6a91bd1c0ece04fc..1df1c28978a5e70c31d5136e43033635c515e261 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1495,10 +1495,8 @@ static int ffa_setup_partitions(void) /* Allocate for the host */ ret = ffa_xa_add_partition_info(drv_info->vm_id); - if (ret) { - /* Already registered devices are freed on bus_exit */ + if (ret) ffa_partitions_cleanup(); - } return ret; } @@ -1508,6 +1506,9 @@ static void ffa_partitions_cleanup(void) struct ffa_dev_part_info *info; unsigned long idx; + /* Clean up/free all registered devices */ + ffa_devices_unregister(); + xa_for_each(&drv_info->partition_info, idx, info) { xa_erase(&drv_info->partition_info, idx); kfree(info); diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index e8b8ae8b192ab11d5550c16fd33fa9d192b07f67..ca2ad5b0ac4309052d55dcf546d29423bbd40a67 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -176,6 +176,7 @@ void ffa_device_unregister(struct ffa_device *ffa_dev); int ffa_driver_register(struct ffa_driver *driver, struct module *owner, const char *mod_name); void ffa_driver_unregister(struct ffa_driver *driver); +void ffa_devices_unregister(void); bool ffa_device_is_valid(struct ffa_device *ffa_dev); #else @@ -188,6 +189,8 @@ ffa_device_register(const struct ffa_partition_info *part_info, static inline void ffa_device_unregister(struct ffa_device *dev) {} +static inline void ffa_devices_unregister(void) {} + static inline int ffa_driver_register(struct ffa_driver *driver, struct module *owner, const char *mod_name) From patchwork Fri Jan 31 11:24:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955290 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 8C1F7C0218D for ; Fri, 31 Jan 2025 11:38: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=66sB2dOA/mj8YLTysd0+acjeEnRU/o0CfX5HEN6hopw=; b=SdTh/vazC53MXgbefwswPuBCyi /qiMpgZ8zRfgnuaF412SAUAle8OtlDG4BOSjs1fZyilJ5tuT0P97A/LOo9KiilbOJnbsov9+DFU+5 JZSpFzUdehetDNj7WsjLr0siApmww3zCCsFUhWcVSGrv223prfTPF8nxDwmy3PpoILUQvDi4ERsjG 8GnHy1TqogLFcmlYrsGoObCZTRpIHxnZczoqmNHCu7dU0InxrXua43yZKcK+agHbed9txC6R8X+MN F6e6gAPrkIWBag3iZ6VKbl4lHqfbB2o/3Z5q2iOOEO+UqEOQn5RrZJ6pKVAYFPPWA9GVZGAWoA4sn iy/jIUhA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpLs-0000000AWTD-2PNc; Fri, 31 Jan 2025 11:38:24 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp99-0000000ATpp-35IR for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25: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 05750497; Fri, 31 Jan 2025 03:25:41 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id D52813F63F; Fri, 31 Jan 2025 03:25:14 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:09 +0000 Subject: [PATCH v2 09/18] firmware: arm_ffa: Helper to check if a partition can receive REQUEST2 messages MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-9-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1461; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=G64rfImpbF1FYzyYP/gR8hcx9nPoEHeOmwT4HxZwJJs=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMQBBTTtnffuet9l2+whZjxfNSeTSb6KoWvk SGzsRKCtBmJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEAAKCRAAQbq8MX7i mNdTEACWqF8ZwLi5yHJXwb/LhPoAIwDMgMqpsuz7af0FGXblGxFVhmRdTUjmSmrlfDQ3W93QAaT qveCYsxwY3uAkbIgnY058DM+rvVB9AJlGN0Dgvtzv/DaP4dUtqWaAsinTXf5iL2TdkbrwKR2byt 05gsqi3AzLjII1yiJz7jGIrbxyXrth6vPZicD3jQOxTdhCPMXcQ9EoYzKFbfd4nZOZrUmzq18d5 SDtcS2eiD4di8Kj2GS74U7vH0rlhYsgzWfS/yKM6szVYR4iuFIHc/w2I9+Kx2YTU5S3Uc8jgX2v H8ejmruD60cUqCcHPfhheFR+UqA09XaPu6cbqKa3bIP5DSug5v43C28uHJNJtVnzB09WL4XHw9D RCh+Rr7fNLrZaTEYjathiL7D6mY8PphFgV2qL2p0e9jVJoRZBIiRTauud3qVCGf18zsfaJCqtvd ttqaoUivbbsFFAmZ5CaZ6smW4aIKYqU3lDFzzu62Yk9LKUcZBgXTjpU1Q4/Xm2x81KeOYTvWeHf CGeKR8HWqdyWfnc6Bgh/hIwutjOtm8/rRzblmMfDLb4LAUlFU2r9MXJBBXHtLCYRKW7RfE4aN0l aPsdSIRqoptUu2RNHmkMAk81pQkoMk9kSdIf3P41edlECtKb0VEubvd3lL5I7YXYnpb1sid4MrA QC06iw8whIcVtwg== 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-20250131_032515_814049_F0804BAE X-CRM114-Status: UNSURE ( 8.99 ) 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 a helper that allows FF-A drivers to check if the partition can receive the direct requests via the FFA_MSG_SEND_DIRECT_REQ2 ABI. Signed-off-by: Sudeep Holla --- include/linux/arm_ffa.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index ca2ad5b0ac4309052d55dcf546d29423bbd40a67..761ea8fe3bb6080c893a5eb365358b62d6a4f3ff 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -240,6 +240,10 @@ struct ffa_partition_info { #define FFA_PARTITION_NOTIFICATION_RECV BIT(3) /* partition runs in the AArch64 execution state. */ #define FFA_PARTITION_AARCH64_EXEC BIT(8) +/* partition supports receipt of direct request2 */ +#define FFA_PARTITION_DIRECT_REQ2_RECV BIT(9) +/* partition can send direct request2. */ +#define FFA_PARTITION_DIRECT_REQ2_SEND BIT(10) u32 properties; uuid_t uuid; }; @@ -259,6 +263,10 @@ bool ffa_partition_check_property(struct ffa_device *dev, u32 property) #define ffa_partition_supports_direct_recv(dev) \ ffa_partition_check_property(dev, FFA_PARTITION_DIRECT_RECV) +#define ffa_partition_supports_direct_req2_recv(dev) \ + (ffa_partition_check_property(dev, FFA_PARTITION_DIRECT_REQ2_RECV) && \ + !dev->mode_32bit) + /* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP} which pass data via registers */ struct ffa_send_direct_data { unsigned long data0; /* w3/x3 */ From patchwork Fri Jan 31 11:24:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955291 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 E073EC0218D for ; Fri, 31 Jan 2025 11:39:52 +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=h4e1w0UiwzvS/VaZk95hJLBSvLj/pgI4SOYUrT2uJ/A=; b=u9x557Ol7qcxxOcS5P8wnjMov9 KuOfSlqnHp+qjwNyE3S1gPXRgH4WE5A6A4EHZ/c4UPhfD2DsA4nOidzuJUrkyPtp0Dr+luXGE0C+9 EbitknIaJWORuJeyDNxlrR2pTo9D7qSTpUD206MnAjwLAeL7pbBPuD6w8ugiYsWHYrah0i2F687Y/ fTbzgS8y9gTRzBvr24yM1Fgteg4/hdvJXcLTOKjz9Qj8Eiv2aZTjBoppLtUlu/rjaSTN4YF2frlof s1NEJbL95tctQEN+vMz6l0kV0LO9NdPsAJI7wiZIRQG8lc57mOSQAgdeQXh77Hcf/X1ts/3Gk93kI RK1VLubQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpNA-0000000AWlb-0rVc; Fri, 31 Jan 2025 11:39:44 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp9A-0000000ATpA-3NmK for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:17 +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 0BAA3FEC; Fri, 31 Jan 2025 03:25:42 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id DB23D3F63F; Fri, 31 Jan 2025 03:25:15 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:10 +0000 Subject: [PATCH v2 10/18] firmware: arm_ffa: Add support for passing UUID in FFA_MSG_SEND2 MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-10-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=2268; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=Zj2TkPNqsSsa5DJ2pfRSYerk4zU4yhZyjFL52P7Ncog=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMQKXoFWtleYV0WN6Euu77keN8tM7DdVu/7Z ISUrF9h052JAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEAAKCRAAQbq8MX7i mH7zD/4387ZIYz9YjJT4e7WGpbXh/Y3Pz6EFuvhCwZTbqZH5JYwGEgbu6SZnugGnjd0L20Rnlo/ ZcWxfYWHy6j8m3urj1cczv6nw7yagMVL8YUGC34f9ZDC8u77kvwgUw4UQDOgo4H1yxxJFDlhDwD b/3dvPCzKaxwb9tyOtsgKEdxMbD3EJ4d9Rhma9Kqko9BZk2RyhNG6ewzp7VdOxv4fGWA2RwjbFE 4LOnWyhpvjwUjLdT+96HsTJvXUprCmmPOZM3SMyLF1amYKG0KupF3W44MTbP62o4Ukox2taRues x8CFbUNR3nav/3Ozr7PCO7rEDplTS1bwyQtwdEgWUM32i+EaHft0SvNu8AYdwJD9R4KA7yquGfM fRf/uUiEnHdc3Xeex2ONaWaGdeR7YBW/c6NKXpbH4ElW0x0625y29/2c+I0PNMIQdaeJN0YXpeP n5iZsCfxh8IBHe7OEWTi9fcB1ALsw+Qn6mcd3Xs4IY0AUhxPKD+g/oWPFjrhPbuZtqu5W0nCv0N 7oTlM61I2LJPeUtxqN0mlWlDU2AfNqVqZHDUvX1we6RxwfPq4C7DATD0a/BMQrR7OUR/u+lNh/Q 6jBuDpGLzlYsCmS/fqu95HWmfqypzg47lwH4zkOdaew3hnt7CMNY76u5Ta343jRWJ4u1ZaA0G6+ ARJiK7NSKFaNNNg== 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-20250131_032516_941234_CE63E7FF X-CRM114-Status: GOOD ( 11.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 FF-A v1.2 introduces UUID field in partition message header used in FFA_MSG_SEND2 to enable partitions/endpoints exposing multiple UUIDs. Add the support for passing UUID in FFA_MSG_SEND2. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 7 ++++--- include/linux/arm_ffa.h | 1 + 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 1df1c28978a5e70c31d5136e43033635c515e261..cbe0fe5f22bd8c60f3070f5e45d8722e3c9c23c8 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -484,9 +484,9 @@ 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) +static int ffa_msg_send2(struct ffa_device *dev, u16 src_id, void *buf, size_t sz) { - u32 src_dst_ids = PACK_TARGET_INFO(src_id, dst_id); + u32 src_dst_ids = PACK_TARGET_INFO(src_id, dev->vm_id); struct ffa_indirect_msg_hdr *msg; ffa_value_t ret; int retval = 0; @@ -502,6 +502,7 @@ static int ffa_msg_send2(u16 src_id, u16 dst_id, void *buf, size_t sz) msg->offset = sizeof(*msg); msg->send_recv_id = src_dst_ids; msg->size = sz; + uuid_copy(&msg->uuid, &dev->uuid); memcpy((u8 *)msg + msg->offset, buf, sz); /* flags = 0, sender VMID = 0 works for both physical/virtual NS */ @@ -1054,7 +1055,7 @@ static int ffa_sync_send_receive(struct ffa_device *dev, 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); + return ffa_msg_send2(dev, drv_info->vm_id, buf, sz); } static int ffa_sync_send_receive2(struct ffa_device *dev, diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 761ea8fe3bb6080c893a5eb365358b62d6a4f3ff..bd78deeff284e2f46d42cfc7af218f4a0f3d1478 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -282,6 +282,7 @@ struct ffa_indirect_msg_hdr { u32 offset; u32 send_recv_id; u32 size; + uuid_t uuid; }; /* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP}2 which pass data via registers */ From patchwork Fri Jan 31 11:24:11 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955292 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 9DAF0C0218D for ; Fri, 31 Jan 2025 11:41:16 +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=pjUE4buMZD2GCrpVE3Modbxx/7T5nUWJycsT2BbzFws=; b=rscudllHoCUGcoRwylQcy+zhEv 8dWVsuGi4fRB/qu50C4AjdYf2siLXQl7RR99TXmp0jceZuf4lkafyfKmMovrQ+yTtErCv/cXdSaq8 xgws2tBCo6jLfp4RqVLhiD0X20ayrbrQ257Zkjfa6h0x/Ex5zJXgXFn2b2vk40L/H/5BkgESfWoeP RxnMGaalBayHGjGH7EaE2xKGmhjlN+qRljLwuq3E9RPuWlP1wWiwrccvWJzgfveg1kXbGLty1TTrE 7PljPqZFZobob29QsDbTi5E4T/0wIU76QCN91u6fKP8hSu/udYn8ILTXtS/mc89kMYFoCdV/cHQIE hZFVitDA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpOR-0000000AWz8-3Xx6; Fri, 31 Jan 2025 11:41:03 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp9B-0000000ATpp-3JhR for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:18 +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 11B401007; Fri, 31 Jan 2025 03:25:43 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E128E3F63F; Fri, 31 Jan 2025 03:25:16 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:11 +0000 Subject: [PATCH v2 11/18] firmware: arm_ffa: Upgrade FF-A version to v1.2 in the driver MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-11-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1372; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=eazUrEHzI9tgu7HGeZo00Su8OKcdX3GAHEGm8aY/0lo=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMQduI8J2ZBF/yjeq/uoVdCw7wEPbFdQjDr/ m5zy7spEcyJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEAAKCRAAQbq8MX7i mDfZD/0bKrdYu/vpeuu6kBgWsDBaaRfdKZ59GwkwC87iz0SXQYmWpu6tZWe71+TmJJhtx4HLwiX ElAQDv7+MvEjboXR2IcTgzMiAYg30ysRk5QYo4/M+QU25gM/APQhWoI/kZpuV65LI52532Jk/8C 2kWXvhJCwc6ZzKTZQVzlsvlUyZgOyQ1puX6p+JQYwRoVI2fug485dj9tHWsCrdgJ8kSDpPwAdrG j8SGnd0R8P9dPMy7OcQJz4fugW7aGzu8qqxDdBbzt75STbAZ2Tt+J7hOMU3q1xNgv16a2krB1Id MqkhdnzRljShO0oT7wpu0mPf9Iu1r9wukiIXtG7meCKv0SW+KGCkYYum8T9khTkpQejpUFem0DL uIZqhC9mZ92OYJhWSjRor6TsraeyfE30pWlg4PQUlCvIrc2rI6e1j0Qdx9bnS+j6S10c0MXdccU uWKGNMYx8T5l1ONQv2h0Y3hhAqbGhe5vC9Rp3J36pHDIFG2L7j36MqiFMxFidZR580SAE01szIS AtVEWIV2TaXDf0qYft8LaW5yrJ3591gWzXS80pc3jtJFKVXKRx4I8Ld9tIY3WSs1mDwGaIdxcC3 U1ksvimT3Or4xYoRsbg22O4PmajhypXQ/6rBuY2OWK40AFMfrKRXDUfculbF4NGkazus2CrN6Om 0OkIWNOtbWb4zjA== 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-20250131_032517_874936_CF9944C2 X-CRM114-Status: UNSURE ( 9.57 ) 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 The basic and mandatory features of FF-A v1.2 are all supported now. The driver supported version can be bumped from v1.1 to v1.2 Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 2 +- include/linux/arm_ffa.h | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index cbe0fe5f22bd8c60f3070f5e45d8722e3c9c23c8..8188c8dd3ed6ceb9e9966148b42ef2f88baa6dd3 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -44,7 +44,7 @@ #include "common.h" -#define FFA_DRIVER_VERSION FFA_VERSION_1_1 +#define FFA_DRIVER_VERSION FFA_VERSION_1_2 #define FFA_MIN_VERSION FFA_VERSION_1_0 #define SENDER_ID_MASK GENMASK(31, 16) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index bd78deeff284e2f46d42cfc7af218f4a0f3d1478..4fcbdc70cbc985eabb90733329c974384d229053 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -112,6 +112,7 @@ FIELD_PREP(FFA_MINOR_VERSION_MASK, (minor))) #define FFA_VERSION_1_0 FFA_PACK_VERSION_INFO(1, 0) #define FFA_VERSION_1_1 FFA_PACK_VERSION_INFO(1, 1) +#define FFA_VERSION_1_2 FFA_PACK_VERSION_INFO(1, 2) /** * FF-A specification mentions explicitly about '4K pages'. This should From patchwork Fri Jan 31 11:24:12 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955293 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 C69ACC0218D for ; Fri, 31 Jan 2025 11:42:34 +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=J6yaTCvuf266S3Vbr6sCPa+5pcMy9vqb5mSr/mPIMFs=; b=DNO4ibNs3vxtWPp14BsUUs97Tw GG31KURVIx2dsNHZGouEIyGhTUNkKTiXwCPZmFAFio3DVN5T8X27cDnSZ+wjXGOj0q4m84dTYUjZU q23Ubf02meprz0lHsdziC8JMCj17XDZ0fAcqwr9ESaNlcJQtpBoJQQy7nICgEK6P8JbtfZFQfNY3i Y1ZsYScwFQJ2FR3gJ4nZ+JG4Rpabl/wZP3Jvfky9teTg9cKjmh90BRanbJqFtOmesJIUouWHBAB1J PC4g+pPldrkjKFPidOOsWKg7RFHjbkXEeR0vk1IllJ005LMGbYtclstUAR/wMSCvockYHird97qWx CnRCFStg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpPj-0000000AX4A-2SAt; Fri, 31 Jan 2025 11:42:23 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp9C-0000000ATpA-3RTp for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:19 +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 1837AFEC; Fri, 31 Jan 2025 03:25:44 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E76ED3F63F; Fri, 31 Jan 2025 03:25:17 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:12 +0000 Subject: [PATCH v2 12/18] firmware: arm_ffa: Reject higher major version as incompatible MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-12-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1603; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=dn+DuSMwXmxU+1JfTRIj8nX1GA6XGv4XdKBQ+XxFVgQ=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMQqqizgtsYtZ73bbYEh3Wj6nROHylyl65QS auIrx9J3VqJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEAAKCRAAQbq8MX7i mJKpD/43GTqRDy1jK37kf+bolvnOdK/SY9f3bCx+Pudp3IvfrG/7kqhrU+jmHphcOpyvtjC0pI9 tfdamBHGY2NnoVT4IXeJI7a1hugCsv9p1RFDbhLwmFMK1n2iQxXvcrFlMECnVkNreknobgLNwhG /phr5q2w9RF1/MH3HjPooxNYUqlh+Z3XvDQoaVndoZhCkdEef+X8PKr+8jPkDT1sK7a65qDuLcc gb8D2P4TsJAuGyEdBFZwWx7kxYHSpzxMN5pHMmzV3Nc3y7GYFYdRDL3u7Md2+xd0nSb4nDuPMHo ayCGMj46nJ19F+HMGGdAHiGlOf8Rywm+NjQC0UJ60eUU7hNApnX/3oM9NYJBvkZrGsV2Zv0KDnq MTx6T7Eko8KcJ8Ej/LIyUQnkWLDwazPiBYJ78z0M8QVDZz4NtSM0jaszQrSUMUGrT2BrKhgMQlx erovKG93QaRU/NWNOcKQzR5/9Dj/oAU7N6qXJBgF0iYsJ+LfqHH8ylWDTnzHwRclPHPvf9Q2ZHh 3dWRoQxE9afol2H8RMa/rIE4OuYskjD8STMqPEUZ665qwoMyLEr/4n//LJzvyQAJG0nYx1aH2+0 4awiCuW2/PdvH2QjWiNxkpKwjASbISpe45ahDYyrKxG0cjX5Pni6+/gPLhP6bsE/NOCWo2BbxKY yr1JeYspMtSwf3Q== 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-20250131_032518_916230_6CCD2BE3 X-CRM114-Status: UNSURE ( 9.86 ) 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 When the firmware compatibility was handled previously in the commit 8e3f9da608f1 ("firmware: arm_ffa: Handle compatibility with different firmware versions"), we only addressed firmware versions that have higher minor versions compared to the driver version which is should be considered compatible unless the firmware returns NOT_SUPPORTED. However, if the firmware reports higher major version than the driver supported, we need to reject it. If the firmware can work in a compatible mode with the driver requested version, it must return the same major version as requested. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 8188c8dd3ed6ceb9e9966148b42ef2f88baa6dd3..1a0f2d1d7a2220e341d4e78240e799a2919fca30 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -150,6 +150,14 @@ static int ffa_version_check(u32 *version) return -EOPNOTSUPP; } + if (FFA_MAJOR_VERSION(ver.a0) > FFA_MAJOR_VERSION(FFA_DRIVER_VERSION)) { + pr_err("Incompatible v%d.%d! Latest supported v%d.%d\n", + FFA_MAJOR_VERSION(ver.a0), FFA_MINOR_VERSION(ver.a0), + FFA_MAJOR_VERSION(FFA_DRIVER_VERSION), + FFA_MINOR_VERSION(FFA_DRIVER_VERSION)); + return -EINVAL; + } + if (ver.a0 < FFA_MIN_VERSION) { pr_err("Incompatible v%d.%d! Earliest supported v%d.%d\n", FFA_MAJOR_VERSION(ver.a0), FFA_MINOR_VERSION(ver.a0), From patchwork Fri Jan 31 11:24:13 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955294 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 81A3CC0218D for ; Fri, 31 Jan 2025 11:43:53 +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=u8xmEFdYZQa3+MY7J1esdtNzTvF3Kk2N8sR/+VinCJU=; b=PgrBNCNtbivV/lnAC25zLZMJrL HjTl9M1KtCS4cSRnACfEKkTI5PmVymugG0ggXNpUWuzOKXXCAeCx5NXEkyjpUZViWb8QO3RmNgyyy GV9lFOy+iz/+wvFQRve3V3l+XtLcdYc2nc8tkPtD9HIWejnNILN07ZiDAOoNYzHkaSyrCGC1Jw9Kn 5AhtNYh9EHJvE7ClzYqt26RIevNOxbgU9StDdYRvV1wHWg6cnNQctP5Kth6/OPKj/W/S/GRvDNiC0 +x1GIhGPFkY/iqTM9SWV/vf/b9NWcX3sR/7RzOhcBEY2gHIkJQah2T7fTV0kbQ6RUJ8eLlZrJIopq VzB9r+FA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpR0-0000000AX9l-0mKD; Fri, 31 Jan 2025 11:43:42 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp9D-0000000ATpp-482i for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:21 +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 1E16E1007; Fri, 31 Jan 2025 03:25:45 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id ED9323F63F; Fri, 31 Jan 2025 03:25:18 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:13 +0000 Subject: [PATCH v2 13/18] firmware: arm_ffa: Remove unnecessary declaration of ffa_partitions_cleanup() MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-13-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1937; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=fdT5EChbtqfXYexU74FFsCYTiVeLlZGaxmgomF4gd0M=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMQOBs1P5wJN9+NbxEdLzIG52z4IW22B9MUv TXuIbZDDPOJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEAAKCRAAQbq8MX7i mJarEACZJglyJgDihrqANB0ymj1onxs9WJ4eVEY2KAllE930ajGcPPGYTxKEsfjQsn8DVyHCHUj OC9kdjXrtn+ZQuXMHUuV72ihaNfP+Rd//rYL3OSWD771lf5un8VKpdoecInkqqbhLajYFv5O9K7 DKfTLwzWaJVMQhjcWH+xSDSVdDy5ulYk2sktDZ2IrjU98UrIxhWblZbBp1sGbsVeXDjnmaNSm1/ Pw+ST8ED565dtE+jNxTqRsg53iYtnJYGNB7XDU+S+M7f4DkqoRmQACxYJdfh+THIl6czly3p4v7 KgsSwGlkyUyi2v5eys2q3uisA+rYPvmEo0qoziTfZfRPaBf2M1Y8NHGaS1K2LqtWBAKcRGxsf+S mDC4hNzCnas3s5C7OtxMswcS21Hxu1yw0d/m/ryiNujDEfz/NpzlBJTSTZ+g1Xm33/vrwp0KN9V iT1tmyK6VLlR++K9/74u+mCzisxVLdYGhtSbDLwHSnMVns/LSchSz+PWsjHDAPbMUJ+wvpRfjrQ SmtaFUpBFRQ1mRbO2lZ9xYO00ODSFZ+Lt0i0tQ46RZpr75uQ/pKGu5YI6Gapgelkzcnhj+Q1+Zr YxCzvEspw/liL+1HZmiX5Cj5H2M26BgNoH/7ViGKYY9cvWUJ4WTY9FvtRt+hfcNYg7io61g5uHY T80AgWMSqkUAhog== 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-20250131_032520_066783_0FEB66CA X-CRM114-Status: GOOD ( 10.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 In order to keep the uniformity, just move the ffa_partitions_cleanup() before it's first usage and drop the unnecessary forward declaration. No functional change. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 1a0f2d1d7a2220e341d4e78240e799a2919fca30..7282aeb3ee498b09010aa2867ef94bf3e0248008 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -114,7 +114,6 @@ struct ffa_drv_info { }; static struct ffa_drv_info *drv_info; -static void ffa_partitions_cleanup(void); /* * The driver must be able to support all the versions from the earliest @@ -1452,6 +1451,22 @@ static int ffa_xa_add_partition_info(int vm_id) return ret; } +static void ffa_partitions_cleanup(void) +{ + struct ffa_dev_part_info *info; + unsigned long idx; + + /* Clean up/free all registered devices */ + ffa_devices_unregister(); + + xa_for_each(&drv_info->partition_info, idx, info) { + xa_erase(&drv_info->partition_info, idx); + kfree(info); + } + + xa_destroy(&drv_info->partition_info); +} + static int ffa_setup_partitions(void) { int count, idx, ret; @@ -1510,22 +1525,6 @@ static int ffa_setup_partitions(void) return ret; } -static void ffa_partitions_cleanup(void) -{ - struct ffa_dev_part_info *info; - unsigned long idx; - - /* Clean up/free all registered devices */ - ffa_devices_unregister(); - - xa_for_each(&drv_info->partition_info, idx, info) { - xa_erase(&drv_info->partition_info, idx); - kfree(info); - } - - xa_destroy(&drv_info->partition_info); -} - /* FFA FEATURE IDs */ #define FFA_FEAT_NOTIFICATION_PENDING_INT (1) #define FFA_FEAT_SCHEDULE_RECEIVER_INT (2) From patchwork Fri Jan 31 11:24:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955298 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 D7C9BC0218D for ; Fri, 31 Jan 2025 11:45:09 +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=FQEMNq/Rq6w5U5wGhvlSYBxxKdWtCiBRvGFeAX0e0q4=; b=wQ0ZX4Ai4LG0REwj2BYLn1vhkI VgL8YclTVpz8/ab4ESCQtf3zgAqka5DD2XTqhfjF/QFru1tboj5QBXQBULlnWTTfIbVSFgx9JhxQf bpywMZQMPtJPd02yKr7wgQ5667I35vkpezZR6kerypQHwEtogHhKS7WUa7Y+vr9hHAjAH/GdEt4Sb x3eQDOm+7Ist45XojwqdiHDPOm5qTLakwUboof2osIXJMSJefA87JG6O9V/3wzyi4Omck4c+F7juN snL4vfmnJhkty4VY1d8d6YPC3UU8/0nwhn1YKRqoRnTHOPsRYU8EOiQ2oy0JEWKfTfKJG76FJNujz OGuGfLdQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpSG-0000000AXGF-3eiG; Fri, 31 Jan 2025 11:45:00 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp9E-0000000ATpA-3kEX for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:22 +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 24617497; Fri, 31 Jan 2025 03:25:46 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F3BBC3F63F; Fri, 31 Jan 2025 03:25:19 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:14 +0000 Subject: [PATCH v2 14/18] firmware: arm_ffa: Refactoring to prepare for framework notification support MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-14-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=4795; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=ZgcR4BPDkgJOhaFYnmGOT7W84Ut3jJpHa2LiCo3aynI=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMQsqAE30dOKy62jz2nUZR/oYdHf0sbSiENx g8B81NL/uyJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEAAKCRAAQbq8MX7i mFzhD/4qNj1Wd7+GkduNChQUy4XYLB2hxQxIfPfU35qn6Skmesb+jplAAx0k7saDEEIJYmbGIz2 4O4dLuyExjRXvTuCLNEVvFux0Lp5f53w56F7nxeBFd7/83bW/3sG+hwnUAJG1d3s4XanCZZdSRO hUbA3znldhzU6265D73ZOo9BW8YXUTmpSF2MFK4q3NjMpGhLh6juM1F+7lDoqwIzxRaH2HRebgv yRutLF9szg6TUAfeCH+W8i7JDa+BIM0tl2/urE8wrrum3arkPUG0S5H+d98sU6k7DADgArRiBTy cGuaAduP0JJ8AJw7zigtGwYM1XyoZHJX1wt/pfAfQq5WHZWj5SysbG9IWJ2FoXRok0Je7Vz8G1b xI6xU+XULj0dXXEINYf1GwvQ/SEGIwKiLrc9h78GzNnB5BPh53fcPRjJDERQwhGtaNPDdeGjQPh XuKfvx28/yvk5ymTmd8GcckoDM/CCTPAw/gy8k0mqVJ+WhAZoXOcc+CT4EMNSkMidxUbdSV5MDL 7/cl/oNBYW6Rx/p17PnyzdTZuiQUlxyGp0T7V/7X2OKtl2dIynLFJ1YwbXYbUXmGEAlaKbrqIEX FjDr2rjnWsx42lqwTXpNyNxVkppbSTF7g4Zq9f4/QLOw3zn51tOmlkJSkW7RhHNEGy/wqqMmMRA smSX6IlNj0Izp+w== 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-20250131_032521_024532_DA51CFA2 X-CRM114-Status: GOOD ( 14.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 Currently, the framework notifications are not supported at all. handle_notif_callbacks() doesn't handle them though it is called with framework bitmap. Make that explicit by adding checks for the same. Also, we need to further classify the framework notifications as Secure Partition Manager(SPM) and NonSecure Hypervisor(NS_HYP). Extend/change notify_type enumeration to accommodate all the 4 type and rejig the values so that it can be reused in the bitmap enable mask macros. While at this, move ffa_notify_type_get() so that it can be used in notifier_hash_node_get() in the future. No functional change. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 57 +++++++++++++++++++++++---------------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 7282aeb3ee498b09010aa2867ef94bf3e0248008..dc2d05bb361272b4100802503dd883c17f8900f3 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -807,6 +807,13 @@ static int ffa_notification_bitmap_destroy(void) return 0; } +enum notify_type { + SECURE_PARTITION, + NON_SECURE_VM, + SPM_FRAMEWORK, + NS_HYP_FRAMEWORK, +}; + #define NOTIFICATION_LOW_MASK GENMASK(31, 0) #define NOTIFICATION_HIGH_MASK GENMASK(63, 32) #define NOTIFICATION_BITMAP_HIGH(x) \ @@ -830,10 +837,17 @@ static int ffa_notification_bitmap_destroy(void) #define MAX_IDS_32 10 #define PER_VCPU_NOTIFICATION_FLAG BIT(0) -#define SECURE_PARTITION_BITMAP BIT(0) -#define NON_SECURE_VM_BITMAP BIT(1) -#define SPM_FRAMEWORK_BITMAP BIT(2) -#define NS_HYP_FRAMEWORK_BITMAP BIT(3) +#define SECURE_PARTITION_BITMAP_ENABLE BIT(SECURE_PARTITION) +#define NON_SECURE_VM_BITMAP_ENABLE BIT(NON_SECURE_VM) +#define SPM_FRAMEWORK_BITMAP_ENABLE BIT(SPM_FRAMEWORK) +#define NS_HYP_FRAMEWORK_BITMAP_ENABLE BIT(NS_HYP_FRAMEWORK) +#define FFA_BITMAP_ENABLE_MASK \ + (SECURE_PARTITION_BITMAP_ENABLE | SPM_FRAMEWORK_BITMAP_ENABLE) + +#define FFA_SECURE_PARTITION_ID_FLAG BIT(15) + +#define SPM_FRAMEWORK_BITMAP(x) NOTIFICATION_BITMAP_LOW(x) +#define NS_HYP_FRAMEWORK_BITMAP(x) NOTIFICATION_BITMAP_HIGH(x) static int ffa_notification_bind_common(u16 dst_id, u64 bitmap, u32 flags, bool is_bind) @@ -1098,16 +1112,8 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args) return ffa_memory_ops(FFA_MEM_LEND, args); } -#define FFA_SECURE_PARTITION_ID_FLAG BIT(15) - #define ffa_notifications_disabled() (!drv_info->notif_enabled) -enum notify_type { - NON_SECURE_VM, - SECURE_PARTITION, - FRAMEWORK, -}; - struct notifier_cb_info { struct hlist_node hnode; ffa_notifier_cb cb; @@ -1166,6 +1172,14 @@ static int ffa_notification_unbind(u16 dst_id, u64 bitmap) return ffa_notification_bind_common(dst_id, bitmap, 0, false); } +static enum notify_type ffa_notify_type_get(u16 vm_id) +{ + if (vm_id & FFA_SECURE_PARTITION_ID_FLAG) + return SECURE_PARTITION; + else + return NON_SECURE_VM; +} + /* Should be called while the notify_lock is taken */ static struct notifier_cb_info * notifier_hash_node_get(u16 notify_id, enum notify_type type) @@ -1209,14 +1223,6 @@ update_notifier_cb(int notify_id, enum notify_type type, ffa_notifier_cb cb, return 0; } -static enum notify_type ffa_notify_type_get(u16 vm_id) -{ - if (vm_id & FFA_SECURE_PARTITION_ID_FLAG) - return SECURE_PARTITION; - else - return NON_SECURE_VM; -} - static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) { int rc; @@ -1299,6 +1305,9 @@ static void handle_notif_callbacks(u64 bitmap, enum notify_type type) int notify_id; struct notifier_cb_info *cb_info = NULL; + if (type == SPM_FRAMEWORK || type == NS_HYP_FRAMEWORK) + return; + for (notify_id = 0; notify_id <= FFA_MAX_NOTIFICATIONS && bitmap; notify_id++, bitmap >>= 1) { if (!(bitmap & 1)) @@ -1318,16 +1327,18 @@ static void notif_get_and_handle(void *unused) int rc; struct ffa_notify_bitmaps bitmaps; - rc = ffa_notification_get(SECURE_PARTITION_BITMAP | - SPM_FRAMEWORK_BITMAP, &bitmaps); + rc = ffa_notification_get(FFA_BITMAP_ENABLE_MASK, &bitmaps); if (rc) { pr_err("Failed to retrieve notifications with %d!\n", rc); return; } + handle_notif_callbacks(SPM_FRAMEWORK_BITMAP(bitmaps.arch_map), + SPM_FRAMEWORK); + handle_notif_callbacks(NS_HYP_FRAMEWORK_BITMAP(bitmaps.arch_map), + NS_HYP_FRAMEWORK); handle_notif_callbacks(bitmaps.vm_map, NON_SECURE_VM); handle_notif_callbacks(bitmaps.sp_map, SECURE_PARTITION); - handle_notif_callbacks(bitmaps.arch_map, FRAMEWORK); } static void From patchwork Fri Jan 31 11:24:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955299 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 82712C0218F for ; Fri, 31 Jan 2025 11:46: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=ldvJVm8DDHv2/siFMd8ow7IVJX0qswtnl2VGE0oRHsQ=; b=b+Q6cJSYD0PZ7ZxVtLVLgJ4GzK NcFhG7ahq4mI7SvkU/TosNrfzh7yxOSpyrGfuF9nZHhPl+VPf76qYDnzPfqiYaTeXC0+Xi+c2scae BliCnDb15tCBSBop6WLSIj5jwgs49gfgMJjP0rAdiKMd4ZSP47SSkXAsK5hNxH632p8HhilnEyJoZ CpPloPB3s66jy0nquNIQ+KRnd7xkGy2EWi224v9OW2aoA/ZI261/hyHfE0etY/M9FfRWYcarJ7lIQ efKPoWYfpXsb8CqtZ2uEU27SN7vdTQfdJ0B5TeGJIuUSNGM+IK0rtNVklZA0Bkr8rHVpgBG5XmWKZ 0aycZ1pQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpTY-0000000AXU5-23Eb; Fri, 31 Jan 2025 11:46:20 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp9F-0000000ATpp-3tRC for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:23 +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 2A8D4FEC; Fri, 31 Jan 2025 03:25:47 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 05D823F63F; Fri, 31 Jan 2025 03:25:20 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:15 +0000 Subject: [PATCH v2 15/18] firmware: arm_ffa: Stash ffa_device instead of notify_type in notifier_cb_info MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-15-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3490; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=ppHCXWGMtBjYqasFlq5USxa8F65s3HoS/cBJa+OZxBc=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMRBuIh27ziuPfs8So1yLkq6OEw3A+xBlmlZ PbgP5yQQXuJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEQAKCRAAQbq8MX7i mKpDEAC+wz+pn3lmr5K+NgtpCsurmQj9U6ThCm0xmNbVsoYRdYuAoxX14DxTrXHgUJh2W1zK9Lv YgCBwijlkhcvzRHtRxTEa4z4H9Ef2yYPsjTsx8DiScEEC1eJAFXM9ldD4kuSITzX6BuxKmh+8LH 4FLD3iCvxcnDQiNmymplcEJZHrcJcAF+9rCP4OO1zLB3dMnGWuEbK1BCvM4gLLsIJawZGsO7JSE LIUNFNt3RhwCw+nDJuV8ZN2Sk5xt1R87fnzlYLyHCiOkIfZ2xGUeiEE+F07i9trKhaK3EOZm4ku aE3ipHhKAJ3TQ2k0EU8YoigSTB/vp0L7Ljfq2NRIExkAU+ScpUMwr3CH6WDhbo7nD2nWhuY7M79 eOl3EXZLLAEdNnhjtzK2EYPEF1invLtmw5uiDiQN5zWCUlehnDv0EXpuIE2+GLxdWY6vb+YXwnq 6brJS0YQ9BkxjTe2tDp1eAakGK90v0Eq6VQBCK7wkREY8seX335Ra4hmgyQjYwSlB/AhH70rlzp r7TckNpY092suOxThHwSBe1hmgEUwOTWE5GzkrPX2FLa3e3uQCyMVNqrHgJXRHDgyE3MGcn1uXq cxNDYRBSLembSdT/s96tqHr4Jh2ZsdK6Xm2kpHI2hVV3KsYoftaBRMp17N6VhILOh7PzADal96u 8t9YA02BYaqNBdw== 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-20250131_032522_067756_7A304ADF X-CRM114-Status: GOOD ( 12.29 ) 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 Currently, we store the type of the notification in the notifier_cb_info structure that is put into the hast list to identify if the notification block is for the secure partition or the non secure VM. In order to support framework notifications to reuse the hash list and to avoid creating one for each time, we need store the ffa_device pointer itself as the same notification ID in framework notifications can be registered by multiple FF-A devices. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index dc2d05bb361272b4100802503dd883c17f8900f3..86c0667ff8825ca5e70547e9056a28b73b8ab251 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1116,9 +1116,9 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args) struct notifier_cb_info { struct hlist_node hnode; + struct ffa_device *dev; ffa_notifier_cb cb; void *cb_data; - enum notify_type type; }; static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback, @@ -1187,17 +1187,18 @@ notifier_hash_node_get(u16 notify_id, enum notify_type type) struct notifier_cb_info *node; hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) - if (type == node->type) + if (type == ffa_notify_type_get(node->dev->vm_id)) return node; return NULL; } static int -update_notifier_cb(int notify_id, enum notify_type type, ffa_notifier_cb cb, +update_notifier_cb(struct ffa_device *dev, int notify_id, ffa_notifier_cb cb, void *cb_data, bool is_registration) { struct notifier_cb_info *cb_info = NULL; + enum notify_type type = ffa_notify_type_get(dev->vm_id); bool cb_found; cb_info = notifier_hash_node_get(notify_id, type); @@ -1211,7 +1212,7 @@ update_notifier_cb(int notify_id, enum notify_type type, ffa_notifier_cb cb, if (!cb_info) return -ENOMEM; - cb_info->type = type; + cb_info->dev = dev; cb_info->cb = cb; cb_info->cb_data = cb_data; @@ -1226,7 +1227,6 @@ update_notifier_cb(int notify_id, enum notify_type type, ffa_notifier_cb cb, static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) { int rc; - enum notify_type type = ffa_notify_type_get(dev->vm_id); if (ffa_notifications_disabled()) return -EOPNOTSUPP; @@ -1236,7 +1236,7 @@ static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) mutex_lock(&drv_info->notify_lock); - rc = update_notifier_cb(notify_id, type, NULL, NULL, false); + rc = update_notifier_cb(dev, notify_id, NULL, NULL, false); if (rc) { pr_err("Could not unregister notification callback\n"); mutex_unlock(&drv_info->notify_lock); @@ -1255,7 +1255,6 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, { int rc; u32 flags = 0; - enum notify_type type = ffa_notify_type_get(dev->vm_id); if (ffa_notifications_disabled()) return -EOPNOTSUPP; @@ -1274,7 +1273,7 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, return rc; } - rc = update_notifier_cb(notify_id, type, cb, cb_data, true); + rc = update_notifier_cb(dev, notify_id, cb, cb_data, true); if (rc) { pr_err("Failed to register callback for %d - %d\n", notify_id, rc); From patchwork Fri Jan 31 11:24:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955300 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 D7E67C0218F for ; Fri, 31 Jan 2025 11:47:49 +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=loL6LNW/stXncvJ4qkW8r0NmKOeP2g/rYPVeJjW0UHA=; b=E9TwCHMkSKcZKYNUIwqNjJiBOE fYf6D/EeqWr1GjVsbT1i1DSmjg9hLtHHpjj+J4wzDY76s1RHdDo37+bF/OUB1/ZDNdGubf0/f6V03 pgXKwVA8PvMceijUkfxbz25JdAMFKn5hCiqAIEEegWqJl4o3LOx0VGwH19r7PIHBBYNvbi7lAgsEs jkC5SCztqtX8WhB2z9m7808+2rVa/d4d3GoTYO0dB1pVRgaWWbh5RG+wxOvg0umOUkeV7BBrTT/q0 REu/KN0XL0d4T6KqD65+LLoe/U6JbAH9MhBShtj7uSf5gDRbjfFU3N3BQQNstSgeHTXtk76xSkSJ7 YHKzRuNQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpUq-0000000AXoN-0vGF; Fri, 31 Jan 2025 11:47:40 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp9G-0000000ATpA-3rON for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:24 +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 30C4A1007; Fri, 31 Jan 2025 03:25:48 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0C07F3F63F; Fri, 31 Jan 2025 03:25:21 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:16 +0000 Subject: [PATCH v2 16/18] firmware: arm_ffa: Add support for {un,}registration of framework notifications MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-16-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8692; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=zcyzebsWIlYLRHHpo1SJ3JoTTLC7QBrC9EzF3zvfDuI=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMRIIxP6ZVgWI/kvUHcecNEhfF/tPnrU55i/ cKAvDEoq/KJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEQAKCRAAQbq8MX7i mB1DEACP69rVjhWh3jbSTP7eVwviytHQsdurJRG8onMmAyp5ePmdisBOGsMtCCXBOu5mMRLlK7S /x1IQ8W2M11Q/LEj+Kt6hp6/wL7+LP1i0zbsw4VFsmfufMPvbodJ4t+Gd2cS+9VbzuhMRJw1rWz n/wFyw7/vabWL97ng2U0kIA7tnvsD+hgZDP4WI7vBrvETjqdMlDw8Cw/jXBSkCzhD+K+cSdEfNy 5MaoeDcph0kXcGBaGx6f8fq9FntsyeW1jHUdjD+HNjpzyEgK2XTQ/0TVJld+Eph5kK0pSPA/gsU CBZVuulTvWHndqUqBkqAvsHTBhC6kd8+ZgLXzTp56J0zTqPT5qvu9yBEJKuMKntm44HBA5wWbP0 x/OZfXWmX4XyaMvkGUreQQ4qvvCWLfDe4oxtRFznD/g3BwH/f/qsUs9vjigiNDzIR6i5+wI4pMV WYJKUqneoU9dVk1JZu+2tEGfum7z2S3FtmrzdDCKWfSYnljklxBZ2tws5QDxXXKvO0ZjCf/LY/6 PZzYz7mLnVg/jUs/Sght04Tlt+XkMle6jR0B/wADJMWadUvOcDfOfdBR8bct13HISIB58qaG5WG AjbhHEcqRI+jC+5B3toTP08ldUMSqaxItuKxh5zCCQoqWCIQKbj4fIDL8LaVQJbdC8IJqVdGsS+ cugempK5YWQLMcA== 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-20250131_032523_053581_B583ABB9 X-CRM114-Status: GOOD ( 17.27 ) 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 Framework notifications are doorbells that are rung by the partition managers to signal common events to an endpoint. These doorbells cannot be rung by an endpoint directly. A partition manager can signal a Framework notification in response to an FF-A ABI invocation by an endpoint. Two additional notify_ops interface is being added for any FF-A device/ driver to register and unregister for such a framework notifications. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 113 +++++++++++++++++++++++++++++++------- include/linux/arm_ffa.h | 5 ++ 2 files changed, 97 insertions(+), 21 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index 86c0667ff8825ca5e70547e9056a28b73b8ab251..f0e853584b51645cd7f590e4cb8d01ca1e7914dc 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1117,6 +1117,7 @@ static int ffa_memory_lend(struct ffa_mem_ops_args *args) struct notifier_cb_info { struct hlist_node hnode; struct ffa_device *dev; + ffa_fwk_notifier_cb fwk_cb; ffa_notifier_cb cb; void *cb_data; }; @@ -1180,28 +1181,61 @@ static enum notify_type ffa_notify_type_get(u16 vm_id) return NON_SECURE_VM; } -/* Should be called while the notify_lock is taken */ +/* notifier_hnode_get* should be called with notify_lock held */ static struct notifier_cb_info * -notifier_hash_node_get(u16 notify_id, enum notify_type type) +notifier_hnode_get_by_vmid(u16 notify_id, int vmid) { struct notifier_cb_info *node; hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) - if (type == ffa_notify_type_get(node->dev->vm_id)) + if (node->fwk_cb && vmid == node->dev->vm_id) + return node; + + return NULL; +} + +static struct notifier_cb_info * +notifier_hnode_get_by_vmid_uuid(u16 notify_id, int vmid, const uuid_t *uuid) +{ + struct notifier_cb_info *node; + + if (uuid_is_null(uuid)) + return notifier_hnode_get_by_vmid(notify_id, vmid); + + hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) + if (node->fwk_cb && vmid == node->dev->vm_id && + uuid_equal(&node->dev->uuid, uuid)) + return node; + + return NULL; +} + +static struct notifier_cb_info * +notifier_hnode_get_by_type(u16 notify_id, enum notify_type type) +{ + struct notifier_cb_info *node; + + hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) + if (node->cb && type == ffa_notify_type_get(node->dev->vm_id)) return node; return NULL; } static int -update_notifier_cb(struct ffa_device *dev, int notify_id, ffa_notifier_cb cb, - void *cb_data, bool is_registration) +update_notifier_cb(struct ffa_device *dev, int notify_id, void *cb, + void *cb_data, bool is_registration, bool is_framework) { struct notifier_cb_info *cb_info = NULL; enum notify_type type = ffa_notify_type_get(dev->vm_id); bool cb_found; - cb_info = notifier_hash_node_get(notify_id, type); + if (is_framework) + cb_info = notifier_hnode_get_by_vmid_uuid(notify_id, dev->vm_id, + &dev->uuid); + else + cb_info = notifier_hnode_get_by_type(notify_id, type); + cb_found = !!cb_info; if (!(is_registration ^ cb_found)) @@ -1213,8 +1247,11 @@ update_notifier_cb(struct ffa_device *dev, int notify_id, ffa_notifier_cb cb, return -ENOMEM; cb_info->dev = dev; - cb_info->cb = cb; cb_info->cb_data = cb_data; + if (is_framework) + cb_info->fwk_cb = cb; + else + cb_info->cb = cb; hash_add(drv_info->notifier_hash, &cb_info->hnode, notify_id); } else { @@ -1224,7 +1261,8 @@ update_notifier_cb(struct ffa_device *dev, int notify_id, ffa_notifier_cb cb, return 0; } -static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) +static int __ffa_notify_relinquish(struct ffa_device *dev, int notify_id, + bool is_framework) { int rc; @@ -1236,22 +1274,35 @@ static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) mutex_lock(&drv_info->notify_lock); - rc = update_notifier_cb(dev, notify_id, NULL, NULL, false); + rc = update_notifier_cb(dev, notify_id, NULL, NULL, false, + is_framework); if (rc) { pr_err("Could not unregister notification callback\n"); mutex_unlock(&drv_info->notify_lock); return rc; } - rc = ffa_notification_unbind(dev->vm_id, BIT(notify_id)); + if (!is_framework) + rc = ffa_notification_unbind(dev->vm_id, BIT(notify_id)); mutex_unlock(&drv_info->notify_lock); return rc; } -static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, - ffa_notifier_cb cb, void *cb_data, int notify_id) +static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) +{ + return __ffa_notify_relinquish(dev, notify_id, false); +} + +static int ffa_fwk_notify_relinquish(struct ffa_device *dev, int notify_id) +{ + return __ffa_notify_relinquish(dev, notify_id, true); +} + +static int __ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, + void *cb, void *cb_data, + int notify_id, bool is_framework) { int rc; u32 flags = 0; @@ -1264,26 +1315,44 @@ static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, mutex_lock(&drv_info->notify_lock); - if (is_per_vcpu) - flags = PER_VCPU_NOTIFICATION_FLAG; + if (!is_framework) { + if (is_per_vcpu) + flags = PER_VCPU_NOTIFICATION_FLAG; - rc = ffa_notification_bind(dev->vm_id, BIT(notify_id), flags); - if (rc) { - mutex_unlock(&drv_info->notify_lock); - return rc; + rc = ffa_notification_bind(dev->vm_id, BIT(notify_id), flags); + if (rc) { + mutex_unlock(&drv_info->notify_lock); + return rc; + } } - rc = update_notifier_cb(dev, notify_id, cb, cb_data, true); + rc = update_notifier_cb(dev, notify_id, cb, cb_data, true, + is_framework); if (rc) { pr_err("Failed to register callback for %d - %d\n", notify_id, rc); - ffa_notification_unbind(dev->vm_id, BIT(notify_id)); + if (!is_framework) + ffa_notification_unbind(dev->vm_id, BIT(notify_id)); } mutex_unlock(&drv_info->notify_lock); return rc; } +static int ffa_notify_request(struct ffa_device *dev, bool is_per_vcpu, + ffa_notifier_cb cb, void *cb_data, int notify_id) +{ + return __ffa_notify_request(dev, is_per_vcpu, cb, cb_data, notify_id, + false); +} + +static int +ffa_fwk_notify_request(struct ffa_device *dev, ffa_fwk_notifier_cb cb, + void *cb_data, int notify_id) +{ + return __ffa_notify_request(dev, false, cb, cb_data, notify_id, true); +} + static int ffa_notify_send(struct ffa_device *dev, int notify_id, bool is_per_vcpu, u16 vcpu) { @@ -1313,7 +1382,7 @@ static void handle_notif_callbacks(u64 bitmap, enum notify_type type) continue; mutex_lock(&drv_info->notify_lock); - cb_info = notifier_hash_node_get(notify_id, type); + cb_info = notifier_hnode_get_by_type(notify_id, type); mutex_unlock(&drv_info->notify_lock); if (cb_info && cb_info->cb) @@ -1386,6 +1455,8 @@ static const struct ffa_notifier_ops ffa_drv_notifier_ops = { .sched_recv_cb_unregister = ffa_sched_recv_cb_unregister, .notify_request = ffa_notify_request, .notify_relinquish = ffa_notify_relinquish, + .fwk_notify_request = ffa_fwk_notify_request, + .fwk_notify_relinquish = ffa_fwk_notify_relinquish, .notify_send = ffa_notify_send, }; diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 4fcbdc70cbc985eabb90733329c974384d229053..5bded24dc24fea8cdcbe42bf79c7c025c3fa5f4b 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -468,6 +468,7 @@ struct ffa_cpu_ops { typedef void (*ffa_sched_recv_cb)(u16 vcpu, bool is_per_vcpu, void *cb_data); typedef void (*ffa_notifier_cb)(int notify_id, void *cb_data); +typedef void (*ffa_fwk_notifier_cb)(int notify_id, void *cb_data, void *buf); struct ffa_notifier_ops { int (*sched_recv_cb_register)(struct ffa_device *dev, @@ -476,6 +477,10 @@ struct ffa_notifier_ops { int (*notify_request)(struct ffa_device *dev, bool per_vcpu, ffa_notifier_cb cb, void *cb_data, int notify_id); int (*notify_relinquish)(struct ffa_device *dev, int notify_id); + int (*fwk_notify_request)(struct ffa_device *dev, + ffa_fwk_notifier_cb cb, void *cb_data, + int notify_id); + int (*fwk_notify_relinquish)(struct ffa_device *dev, int notify_id); int (*notify_send)(struct ffa_device *dev, int notify_id, bool per_vcpu, u16 vcpu); }; From patchwork Fri Jan 31 11:24:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955301 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 ABE51C0218F for ; Fri, 31 Jan 2025 11:49:09 +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=lXokwiudd4fS/kOnu+pVm+nE1WeZugOSwkmGq2un8+Q=; b=pW7cxotOPc33Q1i8OFE4b3Rq72 dZm2WnXOKDj8WvMkrPzMqUMzIv1yTeBswkDWtn05tuS8T7+yEHS1NA0XMw3EM7M9damSvPK7d4PiC wWzEner651eJRoTdq9LbTc6QpZDUY9TL9/QvhpBMWQpUNomdh5Scs0Q6USYhIa5e8eePut8dpVEgl 9AkvwP151yQBChCN4jPyEQa3kJPlsSBK/xZoo2ae9YCNi/WI8XeeCXpIGB7ZKddjTB9LovymnTIol H1NIaul2DJZtA6EEOoQgzz09wDpFz/HGn9dcGQuJVBh8983LYpEy5MpZ06MMOBgOw2+n1YrjoRzh4 eeV2Ur/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpW6-0000000AXyQ-3TAk; Fri, 31 Jan 2025 11:48:58 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp9H-0000000ATpp-3wJv for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:25 +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 36FCFFEC; Fri, 31 Jan 2025 03:25:49 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 124173F63F; Fri, 31 Jan 2025 03:25:22 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:17 +0000 Subject: [PATCH v2 17/18] firmware: arm_ffa: Add support for handling framework notifications MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-17-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=3890; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=tKQtXeBcDSeq+ploR2WzRap4P0UUs9Qp+htINEVCR1o=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMRaBLHl9ojapsEGCM6b2KTz+ItevgFDZIDQ g1S8E9JRRGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEQAKCRAAQbq8MX7i mErdEACJ1il05A/YjFwK7OClKWTbrQKJfoMoYp/6nGQ4xmdevFT9uEaHdcSOnw8OfpvPO7Pq3Fl NX2H4NJUsvf++KeU7RdXwJASw6ZvOrnab/N/u85tTJWYN9nlaOStrtFx9lDxACy/xQ7oGWeNLA0 59N8lMfKkCf8hF3E/KX4iDftiAeCqWgAk3X0JSUktyTkd02+WI0D4RvTcazRvuqEu9O4+GBZ0C6 lQ4yFSxe2bgNPyWNqVl/+RlLBaaq+/8ubge8bnRsv50gGCCcksD+PfXarBoQlmJWFt0/JTv1KO7 5rdEbM70DS3QzjOwDIXP9s6ckkphFfl3U0nKWck04htjSLtRCqLCOz8/UxeQh4Xw+EfwzcgZtLI BKE460F5Dp/cxjCpDKg9TZxKqI1Z3wudPW/wLacFGuGnV1eSE5rRWqophcA79u0HpQKawO/Aijc 35X9DKkP8WZPP6zVjw2yJbIMzypmF7RebfQEwCqvwPjVOwZ93ZpMqMiZ1DPeAgLswqdu8oGzjUc oyxPmdZKeHl8/51VskArCJtlULpjus8r+assS8viiFd+H3TV8RhT5tNs/NUXxR3MVq3QmE1Dzid /aiM1EchQm0hI0d28y9Jsj16B0ESOxhaxVdIODlPavUuALVqSqfGvBQm2CWUa32t1FMPl3WiMGr Mg5Yg0oj8cjwPYQ== 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-20250131_032524_058585_6A37F93B X-CRM114-Status: GOOD ( 13.42 ) 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 Currently FF-A specification defines only one framework notification: RX buffer full notification. This notification is signaled by the partition manager during transmission of a partition message through indirect messaging to, 1. Notify an endpoint that it has a pending message in its Rx buffer. 2. Inform the message receiver’s scheduler via the schedule receiver interrupt that the receiver must be run. In response to an FFA_MSG_SEND2 invocation by a sender endpoint, the framework performs the following actions after the message is copied from the Tx buffer of the sender to the Rx buffer of the receiver: 1. The notification is pended in the framework notification bitmap of the receiver. 2. The partition manager of the endpoint that contains receiver’s scheduler pends the schedule receiver interrupt for this endpoint. The receiver receives the notification and copies out the message from its Rx buffer. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 50 +++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index f0e853584b51645cd7f590e4cb8d01ca1e7914dc..ab50836adc75ab4bdab3c2da7e23ec5d11826e8b 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -848,6 +848,7 @@ enum notify_type { #define SPM_FRAMEWORK_BITMAP(x) NOTIFICATION_BITMAP_LOW(x) #define NS_HYP_FRAMEWORK_BITMAP(x) NOTIFICATION_BITMAP_HIGH(x) +#define FRAMEWORK_NOTIFY_RX_BUFFER_FULL BIT(0) static int ffa_notification_bind_common(u16 dst_id, u64 bitmap, u32 flags, bool is_bind) @@ -1373,9 +1374,6 @@ static void handle_notif_callbacks(u64 bitmap, enum notify_type type) int notify_id; struct notifier_cb_info *cb_info = NULL; - if (type == SPM_FRAMEWORK || type == NS_HYP_FRAMEWORK) - return; - for (notify_id = 0; notify_id <= FFA_MAX_NOTIFICATIONS && bitmap; notify_id++, bitmap >>= 1) { if (!(bitmap & 1)) @@ -1390,6 +1388,46 @@ static void handle_notif_callbacks(u64 bitmap, enum notify_type type) } } +static void handle_fwk_notif_callbacks(u32 bitmap) +{ + void *buf; + uuid_t uuid; + int notify_id = 0, target; + struct ffa_indirect_msg_hdr *msg; + struct notifier_cb_info *cb_info = NULL; + + /* Only one framework notification defined and supported for now */ + if (!(bitmap & FRAMEWORK_NOTIFY_RX_BUFFER_FULL)) + return; + + mutex_lock(&drv_info->rx_lock); + + msg = drv_info->rx_buffer; + buf = kmalloc(msg->size, GFP_KERNEL); + if (!buf) { + mutex_unlock(&drv_info->rx_lock); + return; + } + memcpy(buf, (void *)msg + msg->offset, msg->size); + target = SENDER_ID(msg->send_recv_id); + if (msg->offset >= sizeof(*msg)) + uuid_copy(&uuid, &msg->uuid); + else + uuid_copy(&uuid, &uuid_null); + + mutex_unlock(&drv_info->rx_lock); + + ffa_rx_release(); + + mutex_lock(&drv_info->notify_lock); + cb_info = notifier_hnode_get_by_vmid_uuid(notify_id, target, &uuid); + mutex_unlock(&drv_info->notify_lock); + + if (cb_info && cb_info->fwk_cb) + cb_info->fwk_cb(notify_id, cb_info->cb_data, buf); + kfree(buf); +} + static void notif_get_and_handle(void *unused) { int rc; @@ -1401,10 +1439,8 @@ static void notif_get_and_handle(void *unused) return; } - handle_notif_callbacks(SPM_FRAMEWORK_BITMAP(bitmaps.arch_map), - SPM_FRAMEWORK); - handle_notif_callbacks(NS_HYP_FRAMEWORK_BITMAP(bitmaps.arch_map), - NS_HYP_FRAMEWORK); + handle_fwk_notif_callbacks(SPM_FRAMEWORK_BITMAP(bitmaps.arch_map)); + handle_fwk_notif_callbacks(NS_HYP_FRAMEWORK_BITMAP(bitmaps.arch_map)); handle_notif_callbacks(bitmaps.vm_map, NON_SECURE_VM); handle_notif_callbacks(bitmaps.sp_map, SECURE_PARTITION); } From patchwork Fri Jan 31 11:24:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sudeep Holla X-Patchwork-Id: 13955302 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 99BDCC02193 for ; Fri, 31 Jan 2025 11:50:26 +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=VagP84b1B3/WOGdRo61p825pQSxCX8wDZUEy5peJt8w=; b=d1SANoVdagwuzsMaktzirBiLKF a+gh3O4F1QAa8D36Lp176BeG8YO2O9V+NxZATSTBWIuENW0jn5V03fsseppACxl5YB9ZjBvvo5/F0 p9kr9muEzlrw8M/0IYsxzh5UMzL8zgw6kY0LIL8jJ1Nr0iKthkaKsNCmezl51lx9VaErm10ZOquqv QuyCnDShjS9KtjaYKG3+361J3Ij4n57VvjGFQKACiHsRODbiZ8pg4ODkyAIU8W5XG/UJJ8Ke+P+TB zN++6LDfUz3dnS8kOVeMVsxP5LHBokDOWZTNs7mHbpWxIXB5k2BcG3oevw2wPFDt6YJDTqLzITJ5q zqEUOepA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdpXN-0000000AY6s-1xcO; Fri, 31 Jan 2025 11:50:17 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tdp9I-0000000ATpA-44fz for linux-arm-kernel@lists.infradead.org; Fri, 31 Jan 2025 11:25:27 +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 3D274497; Fri, 31 Jan 2025 03:25:50 -0800 (PST) Received: from e133711.arm.com (e133711.arm.com [10.1.196.55]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 188DB3F63F; Fri, 31 Jan 2025 03:25:23 -0800 (PST) From: Sudeep Holla Date: Fri, 31 Jan 2025 11:24:18 +0000 Subject: [PATCH v2 18/18] firmware: arm_ffa: Allow multiple UUIDs per partition to register SRI callback MIME-Version: 1.0 Message-Id: <20250131-ffa_updates-v2-18-544ba4e35387@arm.com> References: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> In-Reply-To: <20250131-ffa_updates-v2-0-544ba4e35387@arm.com> To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sudeep Holla , Viresh Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=8199; i=sudeep.holla@arm.com; h=from:subject:message-id; bh=DhLeAPsZXmTLsWlQfRK5k/9Vj553i3U944841job/Ac=; b=owEBbQKS/ZANAwAIAQBBurwxfuKYAcsmYgBnnLMR4nDFKrZ1L7cAhNYpD5SLshn8MwGEZmMw7 opryuiluZGJAjMEAAEIAB0WIQS6ceUSBvMeskPdk+EAQbq8MX7imAUCZ5yzEQAKCRAAQbq8MX7i mA0rD/sFc/Jpprn1nw3Nk+1Y7K89S4Hb8c5bGnT4boiSq4ayK38jXfQ37kKDbrmP+UKMsgBRMo1 IiNhjPDKllip9Mfi2x9LoPu6/NmFeqgKQIg0qxXwKx7Irfu9uf7eS/qsScWMF3PmOWG8FpLucEf kfAfCceAeK2Q2mZ2isgkRuas4TctOsGXd6F4V/Y0CrTeSZ7P/MK1xOsWj2bb+FYkc4FlxTbXsqj 1XyU8gem4c5ssmxC6DO7NWvrRjsJ3CJCs2BS05nxW8vGr5uTCwcUBHmjQm2IXqp2dh0S5q6cTNd 1BzMUKuXIoVv9Ip3NGzIjVoY/H5g9iEAuQCg5CfudTUBf299K4449cXIH83j2TcLP9kdQB4aSe/ vxnGP4X06I+54jR/uhKgcWFx0GAhNWB9r0yiOYjdGl5sbQdvMG34AGS4c+hVEljJ5BWaOPaHU2t WgrBBoGUHZeDp6joL03a71W9c9rNmEsi5voAJpqDNi6Md3Sl6yOsjiVZFjesW27jsSpUVWWxFx5 K3qEc+q9poyBoqd4f6mQV1z/10z5ejy7VsvcT2loe+mWxW9vM7plCkrvlgbWRkQ3uX6I0X3oaxq l89Iw+7P0SCKo5M75+VYN+L9yUIf5RHUKDpoXfmlmqxuQRYlifxx/GlrQPIBEW1YjZ0haijx4Kb KWEAMa1PVCzeo/Q== 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-20250131_032525_107139_EDBC500B X-CRM114-Status: GOOD ( 21.85 ) 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 A partition can implement multiple UUIDs and currently we successfully register each UUID service as a FF-A device. However when adding the same partition info to the XArray which tracks the SRI callbacks more than once, it fails. In order to allow multiple UUIDs per partition to register SRI callbacks the partition information stored in the XArray needs to be extended to a listed list. A function to remove the list of partition information in the XArray is not added as there are no users at the time. All the partitions are added at probe/initialisation and removed at cleanup stage. Signed-off-by: Sudeep Holla --- drivers/firmware/arm_ffa/driver.c | 157 ++++++++++++++++++++++++++++---------- 1 file changed, 116 insertions(+), 41 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c index ab50836adc75ab4bdab3c2da7e23ec5d11826e8b..3c49ab3fe11861f5704ad92655705591bf0d2ee1 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -925,27 +925,32 @@ struct ffa_dev_part_info { ffa_sched_recv_cb callback; void *cb_data; rwlock_t rw_lock; + struct ffa_device *dev; + struct list_head node; }; static void __do_sched_recv_cb(u16 part_id, u16 vcpu, bool is_per_vcpu) { - struct ffa_dev_part_info *partition; + struct ffa_dev_part_info *partition = NULL, *tmp; ffa_sched_recv_cb callback; + struct list_head *phead; void *cb_data; - partition = xa_load(&drv_info->partition_info, part_id); - if (!partition) { + phead = xa_load(&drv_info->partition_info, part_id); + if (!phead) { pr_err("%s: Invalid partition ID 0x%x\n", __func__, part_id); return; } - read_lock(&partition->rw_lock); - callback = partition->callback; - cb_data = partition->cb_data; - read_unlock(&partition->rw_lock); + list_for_each_entry_safe(partition, tmp, phead, node) { + read_lock(&partition->rw_lock); + callback = partition->callback; + cb_data = partition->cb_data; + read_unlock(&partition->rw_lock); - if (callback) - callback(vcpu, is_per_vcpu, cb_data); + if (callback) + callback(vcpu, is_per_vcpu, cb_data); + } } static void ffa_notification_info_get(void) @@ -1123,18 +1128,29 @@ struct notifier_cb_info { void *cb_data; }; -static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback, - void *cb_data, bool is_registration) +static int +ffa_sched_recv_cb_update(struct ffa_device *dev, ffa_sched_recv_cb callback, + void *cb_data, bool is_registration) { - struct ffa_dev_part_info *partition; + struct ffa_dev_part_info *partition = NULL, *tmp; + struct list_head *phead; bool cb_valid; if (ffa_notifications_disabled()) return -EOPNOTSUPP; - partition = xa_load(&drv_info->partition_info, part_id); + phead = xa_load(&drv_info->partition_info, dev->vm_id); + if (!phead) { + pr_err("%s: Invalid partition ID 0x%x\n", __func__, dev->vm_id); + return -EINVAL; + } + + list_for_each_entry_safe(partition, tmp, phead, node) + if (partition->dev == dev) + break; + if (!partition) { - pr_err("%s: Invalid partition ID 0x%x\n", __func__, part_id); + pr_err("%s: No such partition ID 0x%x\n", __func__, dev->vm_id); return -EINVAL; } @@ -1156,12 +1172,12 @@ static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callback, static int ffa_sched_recv_cb_register(struct ffa_device *dev, ffa_sched_recv_cb cb, void *cb_data) { - return ffa_sched_recv_cb_update(dev->vm_id, cb, cb_data, true); + return ffa_sched_recv_cb_update(dev, cb, cb_data, true); } static int ffa_sched_recv_cb_unregister(struct ffa_device *dev) { - return ffa_sched_recv_cb_update(dev->vm_id, NULL, NULL, false); + return ffa_sched_recv_cb_update(dev, NULL, NULL, false); } static int ffa_notification_bind(u16 dst_id, u64 bitmap, u32 flags) @@ -1548,37 +1564,101 @@ static struct notifier_block ffa_bus_nb = { .notifier_call = ffa_bus_notifier, }; -static int ffa_xa_add_partition_info(int vm_id) +static int ffa_xa_add_partition_info(struct ffa_device *dev) { struct ffa_dev_part_info *info; - int ret; + struct list_head *head, *phead; + int ret = -ENOMEM; + + phead = xa_load(&drv_info->partition_info, dev->vm_id); + if (phead) { + head = phead; + list_for_each_entry(info, head, node) { + if (info->dev == dev) { + pr_err("%s: duplicate dev %p part ID 0x%x\n", + __func__, dev, dev->vm_id); + return -EEXIST; + } + } + } info = kzalloc(sizeof(*info), GFP_KERNEL); if (!info) - return -ENOMEM; + return ret; rwlock_init(&info->rw_lock); - ret = xa_insert(&drv_info->partition_info, vm_id, info, GFP_KERNEL); - if (ret) { - pr_err("%s: failed to save partition ID 0x%x - ret:%d. Abort.\n", - __func__, vm_id, ret); - kfree(info); + info->dev = dev; + + if (!phead) { + phead = kzalloc(sizeof(*phead), GFP_KERNEL); + if (!phead) + goto free_out; + + INIT_LIST_HEAD(phead); + + ret = xa_insert(&drv_info->partition_info, dev->vm_id, phead, + GFP_KERNEL); + if (ret) { + pr_err("%s: failed to save part ID 0x%x Ret:%d\n", + __func__, dev->vm_id, ret); + goto free_out; + } + } + list_add(&info->node, phead); + return 0; + +free_out: + kfree(phead); + kfree(info); + return ret; +} + +static int ffa_setup_host_partition(int vm_id) +{ + struct ffa_partition_info buf = { 0 }; + struct ffa_device *ffa_dev; + int ret; + + buf.id = vm_id; + ffa_dev = ffa_device_register(&buf, &ffa_drv_ops); + if (!ffa_dev) { + pr_err("%s: failed to register host partition ID 0x%x\n", + __func__, vm_id); + return -EINVAL; } + ret = ffa_xa_add_partition_info(ffa_dev); + if (ret) + return ret; + + if (ffa_notifications_disabled()) + return 0; + + ret = ffa_sched_recv_cb_update(ffa_dev, ffa_self_notif_handle, + drv_info, true); + if (ret) + pr_info("Failed to register driver sched callback %d\n", ret); + return ret; } static void ffa_partitions_cleanup(void) { - struct ffa_dev_part_info *info; + struct ffa_dev_part_info *info, *tmp; unsigned long idx; /* Clean up/free all registered devices */ ffa_devices_unregister(); xa_for_each(&drv_info->partition_info, idx, info) { + struct list_head *phead = (struct list_head *)idx; + xa_erase(&drv_info->partition_info, idx); - kfree(info); + list_for_each_entry_safe(info, tmp, phead, node) { + list_del(&info->node); + kfree(info); + } + kfree(phead); } xa_destroy(&drv_info->partition_info); @@ -1621,7 +1701,7 @@ static int ffa_setup_partitions(void) !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)) ffa_mode_32bit_set(ffa_dev); - if (ffa_xa_add_partition_info(ffa_dev->vm_id)) { + if (ffa_xa_add_partition_info(ffa_dev)) { ffa_device_unregister(ffa_dev); continue; } @@ -1630,12 +1710,16 @@ static int ffa_setup_partitions(void) kfree(pbuf); - /* Check if the host is already added as part of partition info */ + /* + * Check if the host is already added as part of partition info + * No multiple UUID possible for the host, so just checking if + * there is an entry will suffice + */ if (xa_load(&drv_info->partition_info, drv_info->vm_id)) return 0; /* Allocate for the host */ - ret = ffa_xa_add_partition_info(drv_info->vm_id); + ret = ffa_setup_host_partition(drv_info->vm_id); if (ret) ffa_partitions_cleanup(); @@ -1944,19 +2028,10 @@ static int __init ffa_init(void) ffa_notifications_setup(); ret = ffa_setup_partitions(); - if (ret) { - pr_err("failed to setup partitions\n"); - goto cleanup_notifs; - } - - ret = ffa_sched_recv_cb_update(drv_info->vm_id, ffa_self_notif_handle, - drv_info, true); - if (ret) - pr_info("Failed to register driver sched callback %d\n", ret); - - return 0; + if (!ret) + return ret; -cleanup_notifs: + pr_err("failed to setup partitions\n"); ffa_notifications_cleanup(); free_pages: if (drv_info->tx_buffer)