From nobody Fri Dec 19 04:54:31 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 249811DDC3D for ; Tue, 3 Dec 2024 14:31: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=1733236276; cv=none; b=r1zV4Npkx73cmypjQLC/sIBD0JuF+Uli+e+/AkCEVHP6BvFYj5nIKcaGUcOvqMM8FxRZw9Ymi2ZgnORYBlqXNCQmaaENt2FpLJN2bFviqgDk1qte/PwkiGm43QjITKqKCeEyTtcID6m3fmRUxh52bpLw2bm6KvAIDDNYAEmUlqM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236276; c=relaxed/simple; bh=aewdzpB1HHpbJtnu4nozNpYKGui4Tsj7YW3CwLDw6+E=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UkDUziuMgJ//fsE1z8TF4oUV9EQlLCXgqqR3iP/mGxKStCX/4M4ZefOZC9Hve9F6a9NuqP5WXxKH3QGP9ByMkf7LoPAzco3agrDfbuH9eTGRkFh5quagmtEosMF3q6sx8Uoxrt4AkIqJdDV1hTGohunEx1YaFVsCcl6EbiGK/Gs= 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 65FF7143D; Tue, 3 Dec 2024 06:31:41 -0800 (PST) Received: from e129823.cambridge.arm.com (e129823.arm.com [10.1.197.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 8BA433F71E; Tue, 3 Dec 2024 06:31:12 -0800 (PST) From: Yeoreum Yun To: sudeep.holla@arm.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, nd@arm.com, Levi Yun Subject: [PATCH v2 1/2] firmware/arm_ffa: change ffa_device_register()'s parameters and return Date: Tue, 3 Dec 2024 14:31:08 +0000 Message-Id: <20241203143109.1030514-2-yeoreum.yun@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241203143109.1030514-1-yeoreum.yun@arm.com> References: <20241203143109.1030514-1-yeoreum.yun@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Levi Yun Currently, ffa_dev->properties is set after ffa_device_register() in ffa_setup_partitions(). This means it couldn't validate partition's properties while probing ffa_device. Change parameter of ffa_device_register() to receive ffa_partition_info so that before device_register(), ffa_device->properties can be setup and any other data. Also, change return value of ffa_device_register() from NULL to ERR_PTR so that it passes error code. Signed-off-by: Yeoreum Yun --- drivers/firmware/arm_ffa/bus.c | 15 +++++++++++---- drivers/firmware/arm_ffa/driver.c | 7 +------ include/linux/arm_ffa.h | 12 ++++++++---- 3 files changed, 20 insertions(+), 14 deletions(-) diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index eb17d03b66fe..a4ab6d14afef 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -187,13 +187,18 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev) return valid; } =20 -struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id, - const struct ffa_ops *ops) +struct ffa_device *ffa_device_register( + const struct ffa_partition_info *part_info, + const struct ffa_ops *ops) { int id, ret; + uuid_t uuid; struct device *dev; struct ffa_device *ffa_dev; =20 + if (!part_info) + return NULL; + id =3D ida_alloc_min(&ffa_bus_id, 1, GFP_KERNEL); if (id < 0) return NULL; @@ -210,9 +215,11 @@ struct ffa_device *ffa_device_register(const uuid_t *u= uid, int vm_id, dev_set_name(&ffa_dev->dev, "arm-ffa-%d", id); =20 ffa_dev->id =3D id; - ffa_dev->vm_id =3D vm_id; + ffa_dev->vm_id =3D part_info->id; + ffa_dev->properties =3D part_info->properties; ffa_dev->ops =3D ops; - uuid_copy(&ffa_dev->uuid, uuid); + import_uuid(&uuid, (u8 *)part_info->uuid); + uuid_copy(&ffa_dev->uuid, &uuid); =20 ret =3D device_register(&ffa_dev->dev); if (ret) { diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/d= river.c index b14cbdae94e8..2c2ec3c35f15 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1387,7 +1387,6 @@ static struct notifier_block ffa_bus_nb =3D { static int ffa_setup_partitions(void) { int count, idx, ret; - uuid_t uuid; struct ffa_device *ffa_dev; struct ffa_dev_part_info *info; struct ffa_partition_info *pbuf, *tpbuf; @@ -1406,23 +1405,19 @@ static int ffa_setup_partitions(void) =20 xa_init(&drv_info->partition_info); for (idx =3D 0, tpbuf =3D pbuf; idx < count; idx++, tpbuf++) { - import_uuid(&uuid, (u8 *)tpbuf->uuid); - /* Note that if the UUID will be uuid_null, that will require * ffa_bus_notifier() to find the UUID of this partition id * with help of ffa_device_match_uuid(). FF-A v1.1 and above * provides UUID here for each partition as part of the * discovery API and the same is passed. */ - ffa_dev =3D ffa_device_register(&uuid, tpbuf->id, &ffa_drv_ops); + ffa_dev =3D ffa_device_register(tpbuf, &ffa_drv_ops); if (!ffa_dev) { pr_err("%s: failed to register partition ID 0x%x\n", __func__, tpbuf->id); continue; } =20 - ffa_dev->properties =3D tpbuf->properties; - if (drv_info->version > FFA_VERSION_1_0 && !(tpbuf->properties & FFA_PARTITION_AARCH64_EXEC)) ffa_mode_32bit_set(ffa_dev); diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index a28e2a6a13d0..3fb9c7a3453b 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -166,9 +166,12 @@ static inline void *ffa_dev_get_drvdata(struct ffa_dev= ice *fdev) return dev_get_drvdata(&fdev->dev); } =20 +struct ffa_partition_info; + #if IS_REACHABLE(CONFIG_ARM_FFA_TRANSPORT) -struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id, - const struct ffa_ops *ops); +struct ffa_device *ffa_device_register( + const struct ffa_partition_info *part_info, + const struct ffa_ops *ops); void ffa_device_unregister(struct ffa_device *ffa_dev); int ffa_driver_register(struct ffa_driver *driver, struct module *owner, const char *mod_name); @@ -177,8 +180,9 @@ bool ffa_device_is_valid(struct ffa_device *ffa_dev); =20 #else static inline -struct ffa_device *ffa_device_register(const uuid_t *uuid, int vm_id, - const struct ffa_ops *ops) +struct ffa_device *ffa_device_register( + const struct ffa_partition_info *part_info, + const struct ffa_ops *ops) { return NULL; } --=20 LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7} From nobody Fri Dec 19 04:54:31 2025 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 75D481F12FC for ; Tue, 3 Dec 2024 14:31: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=1733236277; cv=none; b=FhxB64UGBaT1NOAZx1rGzh9emgJXB4vB7Oi5uMQdU7gzeLag4BYrFsFkZ0GP0sNfUbro2/LQr822p/ZHGr4tZALQATjtrx1NGgA4gBWb+ULXDdN5dXu9uuiX16Pk9LAkktiEChhqSLSaTpS3y1CBT+9qKPH0dDmAummldirLaOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733236277; c=relaxed/simple; bh=LCdJDkwfotfhVqi8YzQZyilE8z5Bth4isfVxx4vU5kM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=u+mRIKlYMph8H1YED4SrNsSGhfxxV9YF3Daqcvm8aLsfyaEu/mKbMOFrGapRlqg22Wn2Iocld9PvM5XmK9nEXa0xr67Bt2//HCtTyEESCEqJRToNsWMVhHRAH1jNHeraQYA+QxH5xq+Dpz7pxzZV9HKyKAOo0KNF7Ai2on2jwhw= 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 8908A1C0A; Tue, 3 Dec 2024 06:31:42 -0800 (PST) Received: from e129823.cambridge.arm.com (e129823.arm.com [10.1.197.6]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id AE9C43F71E; Tue, 3 Dec 2024 06:31:13 -0800 (PST) From: Yeoreum Yun To: sudeep.holla@arm.com Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, nd@arm.com, Levi Yun Subject: [PATCH v2 2/2] firmware/arm_ffa: remove __le64_to_cpu() when set uuid for direct msg v2 Date: Tue, 3 Dec 2024 14:31:09 +0000 Message-Id: <20241203143109.1030514-3-yeoreum.yun@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241203143109.1030514-1-yeoreum.yun@arm.com> References: <20241203143109.1030514-1-yeoreum.yun@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Levi Yun UUID is saved in big endian format. i.e) For uuid "378daedc-f06b-4446-8314-40ab933c87a3", It should be saved in memory like: 37 8d ae dc f0 6b 44 46 83 14 40 ab 93 3c 87 a3 Accoding to FF-A specification[0] 15.4 FFA_MSG_SEND_DRIECT_REQ2, then UUID is saved in register: UUID Lo x2 Bytes[0...7] of UUID with byte 0 in the low-order bits. UUID Hi x3 Bytes[8...15] of UUID with byte 8 in the low-order bits. That means, we don't need to swap the uuid when it send via direct message request version 2, just send it as saved in memory. Remove le64_to_cpu() for uuid in direct message request version 2, and change uuid_regs' type to unsigned long. Link: https://developer.arm.com/documentation/den0077/latest [0] Signed-off-by: Yeoreum Yun --- drivers/firmware/arm_ffa/driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/d= river.c index 2c2ec3c35f15..8bfeca9d0d2a 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -483,13 +483,13 @@ static int ffa_msg_send_direct_req2(u16 src_id, u16 d= st_id, const uuid_t *uuid, u32 src_dst_ids =3D PACK_TARGET_INFO(src_id, dst_id); union { uuid_t uuid; - __le64 regs[2]; + unsigned long regs[2]; } uuid_regs =3D { .uuid =3D *uuid }; ffa_value_t ret, args =3D { .a0 =3D FFA_MSG_SEND_DIRECT_REQ2, .a1 =3D src_dst_ids, - .a2 =3D le64_to_cpu(uuid_regs.regs[0]), - .a3 =3D le64_to_cpu(uuid_regs.regs[1]), + .a2 =3D uuid_regs.regs[0], + .a3 =3D uuid_regs.regs[1], }; memcpy((void *)&args + offsetof(ffa_value_t, a4), data, sizeof(*data)); -- LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}