From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4D6751581EE for ; Fri, 31 Jan 2025 11:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322710; cv=none; b=gZFSonCVg5lWaKAW351NNP7fAsW/7vqVXD1JIPj36l2OUfArfWqJRuWtjVNWj6JM70PuDXhZlKJ64m8AX+xvkD04ilXdKGcISMH5Bq4iWddd4TvX9Z64vYWp+q5q5QZ0ercs8oKcmrvYa1djJxvkaLEU/suDFpDsqp/1LkHgOdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322710; c=relaxed/simple; bh=F0mUi+DToOzDCZQ+Cn7ewDbLcZibROUf9A/AQezLWS0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=Rb0D0CYkmWmKEz1dXhTXRVG5WvK1a3KeUGv4eRGv18GaVgTcOiFkiQhyZmeDgp6EmiFbZHBnNQHf9bLKt2yJcMTwGRtHBORHef+lUPJKo84Lz3E3xvWvY2ftdjxFNNuQMijGhFPYrB0VDwJNteWDgfy3Hepf8OyhzT7g/1hE9no= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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..52b1f09209a0e51e321cd23a69a= a7e4c4daa8dd1 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -15,7 +15,7 @@ =20 #include "common.h" =20 -#define SCMI_UEVENT_MODALIAS_FMT "arm_ffa:%04x:%pUb" +#define FFA_UEVENT_MODALIAS_FMT "arm_ffa:%04x:%pUb" =20 static DEFINE_IDA(ffa_bus_id); =20 @@ -68,7 +68,7 @@ static int ffa_device_uevent(const struct device *dev, st= ruct kobj_uevent_env *e { const struct ffa_device *ffa_dev =3D to_ffa_dev(dev); =20 - return add_uevent_var(env, "MODALIAS=3D" SCMI_UEVENT_MODALIAS_FMT, + return add_uevent_var(env, "MODALIAS=3D" FFA_UEVENT_MODALIAS_FMT, ffa_dev->vm_id, &ffa_dev->uuid); } =20 @@ -77,7 +77,7 @@ static ssize_t modalias_show(struct device *dev, { struct ffa_device *ffa_dev =3D to_ffa_dev(dev); =20 - 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); --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CA5D1C07F5 for ; Fri, 31 Jan 2025 11:25:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322710; cv=none; b=t4f07xv97x36fRkO4IdCNVkJwGg27frPeX5QdXOHb4o+NJFi/azNtfDC80IxwnM5zbbucopkh4PFK79xW60AGXjYi7h9oY/u9tlzLV5zgtps9cDz+CVOi0ya5gjZxTF0KPCjfR8tr+paGa3PN7DDswsPrd1jArxzu4/zbFRHdWA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322710; c=relaxed/simple; bh=an0T8BaHmmjnOIWFrg0XcNclda/TDCEpL5ml8sjKwio=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=S7ECavCd8ms11dAMb+avs8hdxxvZEwcNI8wRCQKcBDiuJyigm/O24iQ58iZEqDm+mzb1Aj6V7sEiijMQgl/VFQsRue3+BEAbGC1GNA/9k065pFD+Eu9Ktbj+g5djQUgvoo05hnXCQ37uZ5o3mlNyvLty5oWWTCeBgCnztUk4Y+U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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..a90e2faa990219574ff20b8f573= dbb7ca76137d9 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 *pa= rt_info, const struct ffa_ops *ops) { int id, ret; - uuid_t uuid; struct device *dev; struct ffa_device *ffa_dev; =20 @@ -218,8 +217,7 @@ ffa_device_register(const struct ffa_partition_info *pa= rt_info, ffa_dev->vm_id =3D part_info->id; ffa_dev->properties =3D part_info->properties; ffa_dev->ops =3D ops; - import_uuid(&uuid, (u8 *)part_info->uuid); - uuid_copy(&ffa_dev->uuid, &uuid); + uuid_copy(&ffa_dev->uuid, &part_info->uuid); =20 ret =3D device_register(&ffa_dev->dev); if (ret) { diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 74169dd0f65948b05991732358855cdc31b54adb..abd0208f0f74c15ef4ee4c81de8= 1eb7800a0eb1d 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; }; =20 static inline --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2A7741C07D8 for ; Fri, 31 Jan 2025 11:25:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322711; cv=none; b=N1uw5AH1RjBr6JMSDvdq/q7y4lGGa7hX1k5hNipYz8/TL/PqfbF+otgtaWmHr/n4rVI/n7WbT4LEpfR9iBqWJXKIeBVFNybEdV9aTG16nxPJstPCHJtrnEQ714jHMlR+BOdloulKpAVMb2FsL8ul/YbqT7ZtPjQzDukknCs8Pm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322711; c=relaxed/simple; bh=llehAUqDTyE8tsnbqX0XKeEGbtFXiSKUAGLSD+1hoi8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=OCFLBi+Q23SOSbwC3WV2AUVPgAfinjGFKLYNrIm441MK46EIPqXOtqo71mz/3bnsI1+if1/qQNTpLdkTaQdIEsioOmuTd5JjzXZVuzV1PjVup9iwHGLHnezDkFCf8LIhW6mqT9vLea2jDALIOpuTti4YYFO4jHNRuyNoFqFw+o4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index 2c2ec3c35f15612168cdf0ef94022e00c08677b5..037e0d684994fd30971f40bf139= 367d1e45c1bf0 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); } =20 -static int ffa_sync_send_receive2(struct ffa_device *dev, const uuid_t *uu= id, +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; =20 return ffa_msg_send_direct_req2(drv_info->vm_id, dev->vm_id, - uuid, data); + &dev->uuid, data); } =20 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..e8b8ae8b192ab11d5550c16fd33= fa9d192b07f67 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); }; =20 --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C9D501C243D for ; Fri, 31 Jan 2025 11:25:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322712; cv=none; b=Lr1zc0xjNsJNNtgzjptVJhcHlTsv+XtR1/r7+uJMhY1jvACKB25ThMxtErNkDWHIaj+sHdprG2WyD6+Be9AZZxmSzaXrt0TYjGaVd+v5i0VLHyFDugRRZovkbWcX0GQKlkDHWwEkbU6um3blzY7eP/cHbx/lfiXUljk7W+GsoE4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322712; c=relaxed/simple; bh=2q64Jp03o3t6jzZXlU/yVP9FQTQM5OdzbtR25jurl9s=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=o1c91AEn3vqRyYjW5uoAHUY+I4mdejwwf3YgTBr3qc5Ae0GIyOSuwdRQEVJyGEofoIDeg6ZB42laB25DB8dLZVdiyvoRGqgJtfkgyoMCdQqvXWmHVAQ0yicLNfG8/1Qo9xBvWqDT/qh8RMbEyeHOGUQnTB3A9OzrWcGaWkV6LXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index 037e0d684994fd30971f40bf139367d1e45c1bf0..bc6ffd25ad2e2fea0fe3610cf89= 6718dbed8f0ad 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 uui= d2, u32 uuid3, } =20 if (buffer && count <=3D num_partitions) - for (idx =3D 0; idx < count; idx++) - memcpy(buffer + idx, drv_info->rx_buffer + idx * sz, - buf_sz); + for (idx =3D 0; idx < count; idx++) { + struct ffa_partition_info_le { + __le16 id; + __le16 exec_ctxt; + __le32 properties; + uuid_t uuid; + } *rx_buf =3D drv_info->rx_buffer + idx * sz; + struct ffa_partition_info *buf =3D buffer + idx; + + buf->id =3D le16_to_cpu(rx_buf->id); + buf->exec_ctxt =3D le16_to_cpu(rx_buf->exec_ctxt); + buf->properties =3D le32_to_cpu(rx_buf->properties); + if (buf_sz > 8) + import_uuid(&buf->uuid, (u8 *)&rx_buf->uuid); + } =20 ffa_rx_release(); =20 --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1EF671581EE for ; Fri, 31 Jan 2025 11:25:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322713; cv=none; b=HNRUKs3BQlH2AieG59OakUlrVm6n/4kVzjp3CnikJS42x9qNFWTE0IrtSn5mQIFN7CzG23qdyAn8+UGjWsshFLp/rgybGcg2aoP04FUaQwSSDmBt++6kNMjR1B3h9bN+Dit+QEjfmLNmhjGsE9uceNzTNdeDu/YPSP76OjkoWiA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322713; c=relaxed/simple; bh=8PoYp80YnxCA99g/OmQlLeeIzCDfYeP4snzLnAUmwtk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=UU25oB3unTSS2/959iUdrssVOP1oDm7kL66P3zJuuhkkPat6wrTgKM6ZlRpvF09mpAg4eFXxYukiqyup9ZDRvYMxJS8RD3NV9vIIKBGF6REYjCL11oAM29g/Mzz4yhLaIJpN9+30UzVGE9FKSYG9qxUmOS922EO5dcqHNxVJq20= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index bc6ffd25ad2e2fea0fe3610cf896718dbed8f0ad..87e106c728b89f3ce7c11219cf7= cad9cc166dda2 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 uu= id2, 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 =3D 0, prev_idx =3D 0, tag =3D 0; + struct ffa_partition_info *buf =3D buffer; ffa_value_t partition_info; =20 do { + __le64 *regs; + int idx; + start_idx =3D prev_idx ? prev_idx + 1 : 0; =20 invoke_ffa_fn((ffa_value_t){ @@ -338,8 +348,25 @@ __ffa_partition_info_get_regs(u32 uuid0, u32 uuid1, u3= 2 uuid2, u32 uuid3, if (buf_sz > sizeof(*buffer)) buf_sz =3D sizeof(*buffer); =20 - memcpy(buffer + prev_idx * buf_sz, &partition_info.a3, - (cur_idx - start_idx + 1) * buf_sz); + regs =3D (void *)&partition_info.a3; + for (idx =3D 0; idx < cur_idx - start_idx + 1; idx++, buf++) { + union { + uuid_t uuid; + u64 regs[2]; + } uuid_regs =3D { + .regs =3D { + le64_to_cpu(*(regs + 1)), + le64_to_cpu(*(regs + 2)), + } + }; + u64 val =3D *(u64 *)regs; + + buf->id =3D PART_INFO_ID(val); + buf->exec_ctxt =3D PART_INFO_EXEC_CXT(val); + buf->properties =3D PART_INFO_PROPERTIES(val); + uuid_copy(&buf->uuid, &uuid_regs.uuid); + regs +=3D 3; + } prev_idx =3D cur_idx; =20 } while (cur_idx < (count - 1)); --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AFDD91C5490 for ; Fri, 31 Jan 2025 11:25:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322714; cv=none; b=hA2q6Gly08gf+JQHQXlcry1+qYN9qmDH4XAw6lb49TbSwdWp4jKLKkHnZxDyu3hTkOoh2xrjwmxE/uNM4QhXoTBZwdIoP2aN5GX9Em/BNQ9LA1j0S/JZZ9CUgokRlwpVKtRyE24ua9AS7dikOcZGcl73PyDrbQNAkHWsqolxl9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322714; c=relaxed/simple; bh=ouvnBny0SQGOggs23P7ihZ85I1OGF92GzaRYwdFdkdA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=saTtUQfcatjWd9Qz+zQg4HNFGxdb0Aonk6j0TmSmQij1t60/XKkU7cxv2hkSK5IkwrF21t65IcNtsUYump+h9blUV6ibhARWvn/BL8dW/lxvFakkUitYDEGl4slOkTgVyhm4+72FQEcaqWASR6dfGtSsHIZewqLriZwczqk+7lU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index 87e106c728b89f3ce7c11219cf7cad9cc166dda2..67d5be261d83633805c81dd84fd= fc2b5c702f3ca 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 =3D { .notifier_call =3D ffa_bus_notifier, }; =20 +static int ffa_xa_add_partition_info(int vm_id) +{ + struct ffa_dev_part_info *info; + int ret; + + info =3D kzalloc(sizeof(*info), GFP_KERNEL); + if (!info) + return -ENOMEM; + + rwlock_init(&info->rw_lock); + ret =3D 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; =20 if (drv_info->version =3D=3D 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); =20 - info =3D 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 =3D 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); - } + } =20 kfree(pbuf); =20 /* Allocate for the host */ - info =3D 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 =3D xa_insert(&drv_info->partition_info, drv_info->vm_id, - info, GFP_KERNEL); + ret =3D 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(); } --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 27E651C760A for ; Fri, 31 Jan 2025 11:25:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322716; cv=none; b=mHsoGWKwkvm0ne/43ChYVPwgTCDs2ImythsQEbWnNoh9KTV3/wU6bw7y3Tw+B+6n5S37VLj2Zt2dmdph7S33I96wwhC8kpoiz13Cu9LsMDs6PO3fonay2aky23J1ODgxpTfmfP70lLNKf4nPcwlOJbdG9IyoywYhjEEQgbupXck= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322716; c=relaxed/simple; bh=NzKYKTJax7pPW/1p5r9wLFeoyYWNp6T+H8b/gc+oDek=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=jWbz/NCftazgP6iZ1gJwXgj1Lbh3dqinn+pbBa6+Vd3UTiRuV6Lg3/ORmFHYj3XUl5HPpnuLX/iNALlZFZ9YBsNlIma+BWUxqdFzYFzFtgKu0beLKGNsjNeLWYHSw/H6++VQsQvqaZ3pr3vOEFEtRLBToTiP0/xzmPU/0Ja9cI0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index 67d5be261d83633805c81dd84fdfc2b5c702f3ca..54777055d54f5bf2dba1128e6a9= 1bd1c0ece04fc 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) =20 kfree(pbuf); =20 + /* 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 =3D ffa_xa_add_partition_info(drv_info->vm_id); if (ret) { --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BD5DD1C5F2F for ; Fri, 31 Jan 2025 11:25:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322716; cv=none; b=EEZJt1ffS7JuRV6m+Uc6T5U5PtbXOW5J1y4Uyc+ax0UIIGMxnrYjUVuV4wEvz3mtIT1AQ+0zLrVzvNjoX/dTzjLWuxd2RWHVhTPMBrtRusyC1CFuzzfmZ+dDvNEiLpjFlQYD0hvL+yspQptwfHuo1gmgum6nss6mveh8HjfsmR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322716; c=relaxed/simple; bh=UyvgBew/9tfLcZTn4CJGNUBHLEV5T/tT9Fwl0cys6ss=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=BTxRzcHKr63MZULpm2hor0RSmlxGELyeXWS218OTt6X1YRoFtP8QCphQGnGY6lEBf5t8pWD0qLWi9XYHnsV3MIXcZsAOLqBVgIkS0yQ4Rx93kySV4pWDMhOtu41WZq4OUUquYcaWpYrRmW5nNKwyT7eim+sov1AT2xNzgP2tex8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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..98118823cf84969480fc25c9378= 81f9b773a38c2 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 *de= v, void *data) return 0; } =20 -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); =20 bool ffa_device_is_valid(struct ffa_device *ffa_dev) { diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/d= river.c index 54777055d54f5bf2dba1128e6a91bd1c0ece04fc..1df1c28978a5e70c31d5136e430= 33635c515e261 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) =20 /* Allocate for the host */ ret =3D ffa_xa_add_partition_info(drv_info->vm_id); - if (ret) { - /* Already registered devices are freed on bus_exit */ + if (ret) ffa_partitions_cleanup(); - } =20 return ret; } @@ -1508,6 +1506,9 @@ static void ffa_partitions_cleanup(void) struct ffa_dev_part_info *info; unsigned long idx; =20 + /* 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..ca2ad5b0ac4309052d55dcf546d= 29423bbd40a67 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); =20 #else @@ -188,6 +189,8 @@ ffa_device_register(const struct ffa_partition_info *pa= rt_info, =20 static inline void ffa_device_unregister(struct ffa_device *dev) {} =20 +static inline void ffa_devices_unregister(void) {} + static inline int ffa_driver_register(struct ffa_driver *driver, struct module *owner, const char *mod_name) --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EEA471C9DE5 for ; Fri, 31 Jan 2025 11:25:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322717; cv=none; b=S97PcgRiekpMMZo614E2GuaCKJeQoUeq+9DZlQf3v/pxrag81OOenAktAwD8F+4re139+r5D13ssHpl9hqkWXvZoveYT0pQbxtJtbfoCVYHHU9N6AZjAteNDTroT+oHGYkG+szR6RAWUFE+r/wCrC3OlNFdGHY6wSgmVd2zWTpw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322717; c=relaxed/simple; bh=G64rfImpbF1FYzyYP/gR8hcx9nPoEHeOmwT4HxZwJJs=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=Z5QXwmQKl4xvSZo8dekUIVBGU3wSf2AL2/KiirldcZJzoeAinujdS4NnLEfncRrr1EsChAV34rNdxZbRysMMT1s8td/c93pPLc2Vpe76ebnAvETMkV6zRsW7lzfna2kHc5v+3L8eo9DoI5VT1gw+Z9tdtakQ85tF+Md9DadXhQU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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..761ea8fe3bb6080c893a5eb3653= 58b62d6a4f3ff 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 *d= ev, u32 property) #define ffa_partition_supports_direct_recv(dev) \ ffa_partition_check_property(dev, FFA_PARTITION_DIRECT_RECV) =20 +#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 registe= rs */ struct ffa_send_direct_data { unsigned long data0; /* w3/x3 */ --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CA24B1CAA89 for ; Fri, 31 Jan 2025 11:25:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322718; cv=none; b=rlxYbTfhR/MpaZJKBJJSQ6FMslSLfx5Kr49v56j5wGojr96dXnz26vGTFCmnjca+kkCFFAicMVzLpdQkntOCJMkId9om1OoU8Nk3GPgXn8wQu7+uoUkKNDAnqKacbPgBc88n/d/f/r+6MLiBdT+57l6hs8f2DmAZrvz/ZoY+z5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322718; c=relaxed/simple; bh=Zj2TkPNqsSsa5DJ2pfRSYerk4zU4yhZyjFL52P7Ncog=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=rJuQGqR04fgjspVgAGhwPsj0Oy3b68DoVW1ttUwABC3PLZC03aKjLiIHHZSJ0ok16BI5aJXCYe1y8zPe2IrnnUmCYOGNnIAs2wRLLmfqNkCRjnPmwbNqIup4Cj56uCQ3vKTYSP4ShH7RUuJLx8c792qzyHTQaOz6CUDRcnBX0HQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index 1df1c28978a5e70c31d5136e43033635c515e261..cbe0fe5f22bd8c60f3070f5e45d= 8722e3c9c23c8 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; } =20 -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, si= ze_t sz) { - u32 src_dst_ids =3D PACK_TARGET_INFO(src_id, dst_id); + u32 src_dst_ids =3D PACK_TARGET_INFO(src_id, dev->vm_id); struct ffa_indirect_msg_hdr *msg; ffa_value_t ret; int retval =3D 0; @@ -502,6 +502,7 @@ static int ffa_msg_send2(u16 src_id, u16 dst_id, void *= buf, size_t sz) msg->offset =3D sizeof(*msg); msg->send_recv_id =3D src_dst_ids; msg->size =3D sz; + uuid_copy(&msg->uuid, &dev->uuid); memcpy((u8 *)msg + msg->offset, buf, sz); =20 /* flags =3D 0, sender VMID =3D 0 works for both physical/virtual NS */ @@ -1054,7 +1055,7 @@ static int ffa_sync_send_receive(struct ffa_device *d= ev, =20 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); } =20 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..bd78deeff284e2f46d42cfc7af2= 18f4a0f3d1478 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; }; =20 /* For use with FFA_MSG_SEND_DIRECT_{REQ,RESP}2 which pass data via regist= ers */ --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C6EE91CEE8D for ; Fri, 31 Jan 2025 11:25:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322719; cv=none; b=gA+tbTlCVgzOgF0BL4Yf4LJp5gJHf3Gum9I3XQndWasSxDPpyZjTvB+4wIAJkuYCopqnH7HRxMZ3XoprlCMCg46orxS8W3Fe5CdN95RH6NQfI7JonCxgkd5FBrYG+syWncxvdZnTPcpfXGqC0tN8FmD1G4zuG7tHaAvTQwpRy6Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322719; c=relaxed/simple; bh=eazUrEHzI9tgu7HGeZo00Su8OKcdX3GAHEGm8aY/0lo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=IZd+mKLCu4XaqBQ0Hm2ScMOJ+9F+cUbrLYkBsIZ3efUdzp7g18Q4jzZVhTDdizY/tg0PM5aNTJxrpCKOqsjsPshfLnixp/yF759QVJJ/GtwmUWeLNneXdimT1c1cZsTfWazTaWMqe8HPpwNIfHvdWeu+enMEiWKGN/ylO8Zp0Pg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index cbe0fe5f22bd8c60f3070f5e45d8722e3c9c23c8..8188c8dd3ed6ceb9e9966148b42= ef2f88baa6dd3 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -44,7 +44,7 @@ =20 #include "common.h" =20 -#define FFA_DRIVER_VERSION FFA_VERSION_1_1 +#define FFA_DRIVER_VERSION FFA_VERSION_1_2 #define FFA_MIN_VERSION FFA_VERSION_1_0 =20 #define SENDER_ID_MASK GENMASK(31, 16) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index bd78deeff284e2f46d42cfc7af218f4a0f3d1478..4fcbdc70cbc985eabb90733329c= 974384d229053 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) =20 /** * FF-A specification mentions explicitly about '4K pages'. This should --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CC0761E2821 for ; Fri, 31 Jan 2025 11:25:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322720; cv=none; b=I1k1dZpoZo0nc8HgJtcMhLRWWc2HCuMO/fYsXxaB3ENVd2gTzOW8MGHAHZTqdpkOFS7mICoWrMz2UIhYnE/58VPqY8n1lSY9AbQ1n416rWSRMR4QkUqdufO8KKifsZANZki0bLeaKX7ohx/VH+m4ddl+iyTcekYS2mQ25kCte1E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322720; c=relaxed/simple; bh=dn+DuSMwXmxU+1JfTRIj8nX1GA6XGv4XdKBQ+XxFVgQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=HKkUvK+AD7gwWE+J21lHlE6zkoApO1mXzXNYNAqLcldUKsW6/aTz1ZZVcAHs1EeGgYM+4HpsNcmozQo4UP6g51BECMk0QBlFYNm2mdLYhfbVZ7b9GVpcf7wMqgUIkow7Lt0mYbkfZivzNgxWLD5dpcJUsKjRGCLPXhnho8zQlqw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 When the firmware compatibility was handled previously in the commit 8e3f9da608f1 ("firmware: arm_ffa: Handle compatibility with different firmw= are 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 Tested-by: Viresh Kumar --- 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/d= river.c index 8188c8dd3ed6ceb9e9966148b42ef2f88baa6dd3..1a0f2d1d7a2220e341d4e78240e= 799a2919fca30 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; } =20 + 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), --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D230E1E492D for ; Fri, 31 Jan 2025 11:25:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322721; cv=none; b=enJIpG+3YTR//YJk5fevdYyGwMHw10Er4qnLDKTVErk/sdLwiesBjh8f2JxJGk1HuybwnVWSw1354NdBz43ofD3sSJUUU4pFULlP0H4S3pGTW6VeD0rJhm+5x7wq1kjhEXQpMGu1XmXaPZCPhQ4APccf5BwdZELdydchFHry8Yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322721; c=relaxed/simple; bh=fdT5EChbtqfXYexU74FFsCYTiVeLlZGaxmgomF4gd0M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=eLp5Gc4nicg4f6jkfYpcyXz3tLDBn+6uZxhnhMjFbVQ0pvBdDV49kcKylZKzX6WCQKWbB5eOXjAsrM16/DdbOykWZP+4obL472uQQO4r+d85eIUICIZ56p49Z3zCq3TisAprzt/I5cG1sYRN0PfyPJtPaNWVixKJxeB4daJtogE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index 1a0f2d1d7a2220e341d4e78240e799a2919fca30..7282aeb3ee498b09010aa2867ef= 94bf3e0248008 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -114,7 +114,6 @@ struct ffa_drv_info { }; =20 static struct ffa_drv_info *drv_info; -static void ffa_partitions_cleanup(void); =20 /* * 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; } =20 +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; } =20 -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) --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E671E1E98FD for ; Fri, 31 Jan 2025 11:25:20 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322722; cv=none; b=aY9K3v8v92MFFqJkCSWiBhmg4pRpN3R0vAQe+E8Oq4W7D7FaFFacF6uDkIUmzEp8G6cLG4YvlaGfcy4AJVStjICWKwxgVvnvhWHWJQrW3ih+eHbBZAsQ7jlJzyLL2friwVeGN7h4OVLDbUlT9Kc1u0CLDjK20c4Wh92w76fHXAg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322722; c=relaxed/simple; bh=ZgcR4BPDkgJOhaFYnmGOT7W84Ut3jJpHa2LiCo3aynI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=WmX8qHLV6S18rR2Mlo8NWTQ83EkKtyzIduEDDdRH8TDJdKqphs91GrCvzaTuC6uc1JPUAF1qTceEtrdhEbCsvYgpJFMhY3FLcgzp9Vq+8uHT/p8+iT/gJnxn6jjHFE9srgF6O4YwgWA5Xi7eCMW6P3b0eY7RnnZFXk3P8Y6Kxxs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index 7282aeb3ee498b09010aa2867ef94bf3e0248008..dc2d05bb361272b4100802503dd= 883c17f8900f3 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; } =20 +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 =20 #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) =20 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); } =20 -#define FFA_SECURE_PARTITION_ID_FLAG BIT(15) - #define ffa_notifications_disabled() (!drv_info->notif_enabled) =20 -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 b= itmap) return ffa_notification_bind_common(dst_id, bitmap, 0, false); } =20 +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 t= ype, ffa_notifier_cb cb, return 0; } =20 -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 n= otify_type type) int notify_id; struct notifier_cb_info *cb_info =3D NULL; =20 + if (type =3D=3D SPM_FRAMEWORK || type =3D=3D NS_HYP_FRAMEWORK) + return; + for (notify_id =3D 0; notify_id <=3D FFA_MAX_NOTIFICATIONS && bitmap; notify_id++, bitmap >>=3D 1) { if (!(bitmap & 1)) @@ -1318,16 +1327,18 @@ static void notif_get_and_handle(void *unused) int rc; struct ffa_notify_bitmaps bitmaps; =20 - rc =3D ffa_notification_get(SECURE_PARTITION_BITMAP | - SPM_FRAMEWORK_BITMAP, &bitmaps); + rc =3D ffa_notification_get(FFA_BITMAP_ENABLE_MASK, &bitmaps); if (rc) { pr_err("Failed to retrieve notifications with %d!\n", rc); return; } =20 + 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); } =20 static void --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC3E71EBA19 for ; Fri, 31 Jan 2025 11:25:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322723; cv=none; b=IrQekbxSi0djr6larYTrqUhwLwdut9pn2TNUSWc7dmECrK64FM4MHKOYjA5s1Vxc/VVQgGuBEp42kr7XHzwGRIEiAw2WeyI5HJAm3LAhWPYDl70Xi0PdqJ98iN18VXScQzQ5q42EROltv2NNKdpX2rVu5mHCTxzvGmBds1u+Mj0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322723; c=relaxed/simple; bh=ppHCXWGMtBjYqasFlq5USxa8F65s3HoS/cBJa+OZxBc=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=RAi3naYr9V7VMjnUFpfV3AKil3CyO5mmID2/UMwLfhRwwIByevzM4Ua+lp0jFOhhIwC0lL+N6jfJ4A42Il7JCVnX0K/ssQTMeuNTCrcfHfquzV+h7iJahyv5nBUWLf4g3Hkn7WLdy76PCnQIBU+N3eils0X2KBVbuKZoPKr7aAo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index dc2d05bb361272b4100802503dd883c17f8900f3..86c0667ff8825ca5e70547e9056= a28b73b8ab251 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 *a= rgs) =20 struct notifier_cb_info { struct hlist_node hnode; + struct ffa_device *dev; ffa_notifier_cb cb; void *cb_data; - enum notify_type type; }; =20 static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callbac= k, @@ -1187,17 +1187,18 @@ notifier_hash_node_get(u16 notify_id, enum notify_t= ype type) struct notifier_cb_info *node; =20 hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) - if (type =3D=3D node->type) + if (type =3D=3D ffa_notify_type_get(node->dev->vm_id)) return node; =20 return NULL; } =20 static int -update_notifier_cb(int notify_id, enum notify_type type, ffa_notifier_cb c= b, +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 =3D NULL; + enum notify_type type =3D ffa_notify_type_get(dev->vm_id); bool cb_found; =20 cb_info =3D notifier_hash_node_get(notify_id, type); @@ -1211,7 +1212,7 @@ update_notifier_cb(int notify_id, enum notify_type ty= pe, ffa_notifier_cb cb, if (!cb_info) return -ENOMEM; =20 - cb_info->type =3D type; + cb_info->dev =3D dev; cb_info->cb =3D cb; cb_info->cb_data =3D cb_data; =20 @@ -1226,7 +1227,6 @@ update_notifier_cb(int notify_id, enum notify_type ty= pe, ffa_notifier_cb cb, static int ffa_notify_relinquish(struct ffa_device *dev, int notify_id) { int rc; - enum notify_type type =3D ffa_notify_type_get(dev->vm_id); =20 if (ffa_notifications_disabled()) return -EOPNOTSUPP; @@ -1236,7 +1236,7 @@ static int ffa_notify_relinquish(struct ffa_device *d= ev, int notify_id) =20 mutex_lock(&drv_info->notify_lock); =20 - rc =3D update_notifier_cb(notify_id, type, NULL, NULL, false); + rc =3D 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 =3D 0; - enum notify_type type =3D ffa_notify_type_get(dev->vm_id); =20 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; } =20 - rc =3D update_notifier_cb(notify_id, type, cb, cb_data, true); + rc =3D 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); --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EE9701EE03C for ; Fri, 31 Jan 2025 11:25:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322724; cv=none; b=MOsxcmj/u4r8lTY+dQ2a/vAYiOVb4BrQsWhPe7azuaDx9PoPPEvbPYSwGcw2iTlbdihfW/GQhmsb01/BDpWT9wnXkizfE3HfmpVUCQ4iyLrHPR3SFQfzDUwo91Yct95/80CpK50NRiRDZqSRu86BEnyUxRL5m/qp1dHoKqavM7I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322724; c=relaxed/simple; bh=zcyzebsWIlYLRHHpo1SJ3JoTTLC7QBrC9EzF3zvfDuI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=LNY26fhVnkawDrgUguRWLtY5aOuWPHI9px38B+ogChRFNauHzhsutmYZre4Z8k9ZW+TpB31gHc9mnNxgvqIZxKgwobsxCjGBtAUEr+j208c744n9dgOI2RJZ6Xwkx9NDnhLoBkvEmzM67eMrUa3Rg70fypYxvSrj8k6xlavuCRs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index 86c0667ff8825ca5e70547e9056a28b73b8ab251..f0e853584b51645cd7f590e4cb8= d01ca1e7914dc 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 *a= rgs) 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; } =20 -/* 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; =20 hash_for_each_possible(drv_info->notifier_hash, node, hnode, notify_id) - if (type =3D=3D ffa_notify_type_get(node->dev->vm_id)) + if (node->fwk_cb && vmid =3D=3D 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 *uui= d) +{ + 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 =3D=3D 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 =3D=3D ffa_notify_type_get(node->dev->vm_id)) return node; =20 return NULL; } =20 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 =3D NULL; enum notify_type type =3D ffa_notify_type_get(dev->vm_id); bool cb_found; =20 - cb_info =3D notifier_hash_node_get(notify_id, type); + if (is_framework) + cb_info =3D notifier_hnode_get_by_vmid_uuid(notify_id, dev->vm_id, + &dev->uuid); + else + cb_info =3D notifier_hnode_get_by_type(notify_id, type); + cb_found =3D !!cb_info; =20 if (!(is_registration ^ cb_found)) @@ -1213,8 +1247,11 @@ update_notifier_cb(struct ffa_device *dev, int notif= y_id, ffa_notifier_cb cb, return -ENOMEM; =20 cb_info->dev =3D dev; - cb_info->cb =3D cb; cb_info->cb_data =3D cb_data; + if (is_framework) + cb_info->fwk_cb =3D cb; + else + cb_info->cb =3D cb; =20 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; } =20 -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; =20 @@ -1236,22 +1274,35 @@ static int ffa_notify_relinquish(struct ffa_device = *dev, int notify_id) =20 mutex_lock(&drv_info->notify_lock); =20 - rc =3D update_notifier_cb(dev, notify_id, NULL, NULL, false); + rc =3D 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; } =20 - rc =3D ffa_notification_unbind(dev->vm_id, BIT(notify_id)); + if (!is_framework) + rc =3D ffa_notification_unbind(dev->vm_id, BIT(notify_id)); =20 mutex_unlock(&drv_info->notify_lock); =20 return rc; } =20 -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 =3D 0; @@ -1264,26 +1315,44 @@ static int ffa_notify_request(struct ffa_device *de= v, bool is_per_vcpu, =20 mutex_lock(&drv_info->notify_lock); =20 - if (is_per_vcpu) - flags =3D PER_VCPU_NOTIFICATION_FLAG; + if (!is_framework) { + if (is_per_vcpu) + flags =3D PER_VCPU_NOTIFICATION_FLAG; =20 - rc =3D ffa_notification_bind(dev->vm_id, BIT(notify_id), flags); - if (rc) { - mutex_unlock(&drv_info->notify_lock); - return rc; + rc =3D ffa_notification_bind(dev->vm_id, BIT(notify_id), flags); + if (rc) { + mutex_unlock(&drv_info->notify_lock); + return rc; + } } =20 - rc =3D update_notifier_cb(dev, notify_id, cb, cb_data, true); + rc =3D 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); =20 return rc; } =20 +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 n= otify_type type) continue; =20 mutex_lock(&drv_info->notify_lock); - cb_info =3D notifier_hash_node_get(notify_id, type); + cb_info =3D notifier_hnode_get_by_type(notify_id, type); mutex_unlock(&drv_info->notify_lock); =20 if (cb_info && cb_info->cb) @@ -1386,6 +1455,8 @@ static const struct ffa_notifier_ops ffa_drv_notifier= _ops =3D { .sched_recv_cb_unregister =3D ffa_sched_recv_cb_unregister, .notify_request =3D ffa_notify_request, .notify_relinquish =3D ffa_notify_relinquish, + .fwk_notify_request =3D ffa_fwk_notify_request, + .fwk_notify_relinquish =3D ffa_fwk_notify_relinquish, .notify_send =3D ffa_notify_send, }; =20 diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 4fcbdc70cbc985eabb90733329c974384d229053..5bded24dc24fea8cdcbe42bf79c= 7c025c3fa5f4b 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -468,6 +468,7 @@ struct ffa_cpu_ops { =20 typedef void (*ffa_sched_recv_cb)(u16 vcpu, bool is_per_vcpu, void *cb_dat= a); typedef void (*ffa_notifier_cb)(int notify_id, void *cb_data); +typedef void (*ffa_fwk_notifier_cb)(int notify_id, void *cb_data, void *bu= f); =20 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); }; --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EC9601BD9FF for ; Fri, 31 Jan 2025 11:25:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322726; cv=none; b=GRPwuPInPya+owWJhrC6tVATijgKVx4EvdzLJIxZXPN9M0QkNFZYJL+BW/O3GsZKu2Fc6XmvqR8qdvzCH/pTCOYW/Lus5MWvN66UReFN7LxahsKvQ8MS2nxuWDeSezeKfUPbKLW6kKSbf4wzjEtk4WTiO3BN/YSTk1KEpMFfOQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322726; c=relaxed/simple; bh=tKQtXeBcDSeq+ploR2WzRap4P0UUs9Qp+htINEVCR1o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=oDZVMfrxOFrWb6f6zxT+XdBpfVSBCKPb6t6Va7/JAtsXuxpsX3VkdVZSIV8TOpBFtMMaud4O0YEq7U/AADhtGioagJlr2ehmCqNFZ49wUuyaDdamxroa3YYwre4WibMW0Mgza4CTHPXpnetb/xkE8BZiDsfIL6tkqplY9cOViuM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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=E2=80=99s 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=E2=80=99s 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 Tested-by: Viresh Kumar --- 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/d= river.c index f0e853584b51645cd7f590e4cb8d01ca1e7914dc..ab50836adc75ab4bdab3c2da7e2= 3ec5d11826e8b 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -848,6 +848,7 @@ enum notify_type { =20 #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) =20 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 n= otify_type type) int notify_id; struct notifier_cb_info *cb_info =3D NULL; =20 - if (type =3D=3D SPM_FRAMEWORK || type =3D=3D NS_HYP_FRAMEWORK) - return; - for (notify_id =3D 0; notify_id <=3D FFA_MAX_NOTIFICATIONS && bitmap; notify_id++, bitmap >>=3D 1) { if (!(bitmap & 1)) @@ -1390,6 +1388,46 @@ static void handle_notif_callbacks(u64 bitmap, enum = notify_type type) } } =20 +static void handle_fwk_notif_callbacks(u32 bitmap) +{ + void *buf; + uuid_t uuid; + int notify_id =3D 0, target; + struct ffa_indirect_msg_hdr *msg; + struct notifier_cb_info *cb_info =3D 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 =3D drv_info->rx_buffer; + buf =3D kmalloc(msg->size, GFP_KERNEL); + if (!buf) { + mutex_unlock(&drv_info->rx_lock); + return; + } + memcpy(buf, (void *)msg + msg->offset, msg->size); + target =3D SENDER_ID(msg->send_recv_id); + if (msg->offset >=3D 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 =3D 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; } =20 - 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); } --=20 2.34.1 From nobody Mon Feb 9 15:09:42 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 24F321F0E24 for ; Fri, 31 Jan 2025 11:25:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322726; cv=none; b=ltXk/tl9NqK1sYt/XSv56NuF4roDlaMwkz6mLwgjeKl8AByBycZJ/Ex8awmmjIPtm+kgAIajgvHc4ncHbGR9Ocgjc4VkYT4GShVUyQrIC3aAvGfTsebxeaPq3oTRdR0ZxB2HL12zFakNug+RJ1ymuAAxIg+lbuN7GGBftEQkXRA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1738322726; c=relaxed/simple; bh=DhLeAPsZXmTLsWlQfRK5k/9Vj553i3U944841job/Ac=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To; b=VuhK6s8vgV2Zd8wk9CouLtuEZjXXF9KQppakFEflssr7GsZFm4aWBBfnfMtvLCM0xUGBd2r4nJ9li0zr33C3Jv0d27Pmzokf4zyHhBAgoYWKryFSXK3FZsH2nPVpv9f02PHQtijqshkSb922ZIoQ1vil82tE4fSIV+NU5ajDGi0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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 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 Tested-by: Viresh Kumar --- 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/d= river.c index ab50836adc75ab4bdab3c2da7e23ec5d11826e8b..3c49ab3fe11861f5704ad926557= 05591bf0d2ee1 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; }; =20 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 =3D NULL, *tmp; ffa_sched_recv_cb callback; + struct list_head *phead; void *cb_data; =20 - partition =3D xa_load(&drv_info->partition_info, part_id); - if (!partition) { + phead =3D xa_load(&drv_info->partition_info, part_id); + if (!phead) { pr_err("%s: Invalid partition ID 0x%x\n", __func__, part_id); return; } =20 - read_lock(&partition->rw_lock); - callback =3D partition->callback; - cb_data =3D partition->cb_data; - read_unlock(&partition->rw_lock); + list_for_each_entry_safe(partition, tmp, phead, node) { + read_lock(&partition->rw_lock); + callback =3D partition->callback; + cb_data =3D partition->cb_data; + read_unlock(&partition->rw_lock); =20 - if (callback) - callback(vcpu, is_per_vcpu, cb_data); + if (callback) + callback(vcpu, is_per_vcpu, cb_data); + } } =20 static void ffa_notification_info_get(void) @@ -1123,18 +1128,29 @@ struct notifier_cb_info { void *cb_data; }; =20 -static int ffa_sched_recv_cb_update(u16 part_id, ffa_sched_recv_cb callbac= k, - void *cb_data, bool is_registration) +static int +ffa_sched_recv_cb_update(struct ffa_device *dev, ffa_sched_recv_cb callbac= k, + void *cb_data, bool is_registration) { - struct ffa_dev_part_info *partition; + struct ffa_dev_part_info *partition =3D NULL, *tmp; + struct list_head *phead; bool cb_valid; =20 if (ffa_notifications_disabled()) return -EOPNOTSUPP; =20 - partition =3D xa_load(&drv_info->partition_info, part_id); + phead =3D 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 =3D=3D 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; } =20 @@ -1156,12 +1172,12 @@ static int ffa_sched_recv_cb_update(u16 part_id, ff= a_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); } =20 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); } =20 static int ffa_notification_bind(u16 dst_id, u64 bitmap, u32 flags) @@ -1548,37 +1564,101 @@ static struct notifier_block ffa_bus_nb =3D { .notifier_call =3D ffa_bus_notifier, }; =20 -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 =3D -ENOMEM; + + phead =3D xa_load(&drv_info->partition_info, dev->vm_id); + if (phead) { + head =3D phead; + list_for_each_entry(info, head, node) { + if (info->dev =3D=3D dev) { + pr_err("%s: duplicate dev %p part ID 0x%x\n", + __func__, dev, dev->vm_id); + return -EEXIST; + } + } + } =20 info =3D kzalloc(sizeof(*info), GFP_KERNEL); if (!info) - return -ENOMEM; + return ret; =20 rwlock_init(&info->rw_lock); - ret =3D 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 =3D dev; + + if (!phead) { + phead =3D kzalloc(sizeof(*phead), GFP_KERNEL); + if (!phead) + goto free_out; + + INIT_LIST_HEAD(phead); + + ret =3D 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 =3D { 0 }; + struct ffa_device *ffa_dev; + int ret; + + buf.id =3D vm_id; + ffa_dev =3D 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; } =20 + ret =3D ffa_xa_add_partition_info(ffa_dev); + if (ret) + return ret; + + if (ffa_notifications_disabled()) + return 0; + + ret =3D 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; } =20 static void ffa_partitions_cleanup(void) { - struct ffa_dev_part_info *info; + struct ffa_dev_part_info *info, *tmp; unsigned long idx; =20 /* Clean up/free all registered devices */ ffa_devices_unregister(); =20 xa_for_each(&drv_info->partition_info, idx, info) { + struct list_head *phead =3D (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); } =20 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); =20 - 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) =20 kfree(pbuf); =20 - /* 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; =20 /* Allocate for the host */ - ret =3D ffa_xa_add_partition_info(drv_info->vm_id); + ret =3D ffa_setup_host_partition(drv_info->vm_id); if (ret) ffa_partitions_cleanup(); =20 @@ -1944,19 +2028,10 @@ static int __init ffa_init(void) ffa_notifications_setup(); =20 ret =3D ffa_setup_partitions(); - if (ret) { - pr_err("failed to setup partitions\n"); - goto cleanup_notifs; - } - - ret =3D 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; =20 -cleanup_notifs: + pr_err("failed to setup partitions\n"); ffa_notifications_cleanup(); free_pages: if (drv_info->tx_buffer) --=20 2.34.1