From nobody Sat Feb 7 07:31:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id DDD1319149E for ; Mon, 25 Nov 2024 09:52:56 +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=1732528378; cv=none; b=rDYOHCqyMrkiCnx7yrKSSuwRIAHVWgsit8Yr59cwaZL5A5S6rW6eMy4H71ZB9F+hcads80chqiNxLFSuGk3Nqa/NxU39WuguXZfkPcVsywsjU3hQjaK4OMYX4DqavtOmmxkt3dcgPPQnUclMnC/aNRfERbsuvrU9IkuThkPgTQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732528378; c=relaxed/simple; bh=53WojTmwlVZojvgsSuYNAmnO1TsOYQrHWcOQ5A51A6U=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EpzGU/4ejc/qD2cxx9RM8fXnpsO5YLKf8IeUfXjAw3SGNk7Gsknpq6b55pBoYAQqortmz69R7xQuIcVPD7xDIVMhNaHpzSx+J7VHiUwvzuKR2FsBv8EKdeTH4KBEZc2s5AZRd9uV9dz/fCRGffTs3en3ChxYZUkCabgzdKXdkIQ= 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 50D0E1756; Mon, 25 Nov 2024 01:53:26 -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 462103F5A1; Mon, 25 Nov 2024 01:52:55 -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 1/3] firmware/arm_ffa: change ffa_device_register()'s parameters and return Date: Mon, 25 Nov 2024 09:52:49 +0000 Message-Id: <20241125095251.366866-2-yeoreum.yun@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241125095251.366866-1-yeoreum.yun@arm.com> References: <20241125095251.366866-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 | 22 +++++++++++++++------- drivers/firmware/arm_ffa/driver.c | 12 ++++-------- include/linux/arm_ffa.h | 12 ++++++++---- 3 files changed, 27 insertions(+), 19 deletions(-) diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c index eb17d03b66fe..95c0e9518556 100644 --- a/drivers/firmware/arm_ffa/bus.c +++ b/drivers/firmware/arm_ffa/bus.c @@ -38,6 +38,7 @@ static int ffa_device_match(struct device *dev, const str= uct device_driver *drv) =20 if (uuid_equal(&ffa_dev->uuid, &id_table->uuid)) return 1; + id_table++; } =20 @@ -187,21 +188,26 @@ 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 ERR_PTR(-EINVAL); + id =3D ida_alloc_min(&ffa_bus_id, 1, GFP_KERNEL); if (id < 0) - return NULL; + return ERR_PTR(-ENOMEM); =20 ffa_dev =3D kzalloc(sizeof(*ffa_dev), GFP_KERNEL); if (!ffa_dev) { ida_free(&ffa_bus_id, id); - return NULL; + return ERR_PTR(-ENOMEM); } =20 dev =3D &ffa_dev->dev; @@ -210,16 +216,18 @@ struct ffa_device *ffa_device_register(const uuid_t *= uuid, 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) { dev_err(dev, "unable to register device %s err=3D%d\n", dev_name(dev), ret); put_device(dev); - return NULL; + return ERR_PTR(ret); } =20 return ffa_dev; diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/d= river.c index b14cbdae94e8..a3a9cdec7389 100644 --- a/drivers/firmware/arm_ffa/driver.c +++ b/drivers/firmware/arm_ffa/driver.c @@ -1406,23 +1406,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); - if (!ffa_dev) { - pr_err("%s: failed to register partition ID 0x%x\n", - __func__, tpbuf->id); + ffa_dev =3D ffa_device_register(tpbuf, &ffa_drv_ops); + if (IS_ERR_OR_NULL(ffa_dev)) { + pr_err("%s: failed to register partition ID 0x%x, error %ld\n", + __func__, tpbuf->id, PTR_ERR(ffa_dev)); 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 Sat Feb 7 07:31:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 235AE1922DC for ; Mon, 25 Nov 2024 09:52:57 +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=1732528379; cv=none; b=QHdoR93fAGQHjzDfesCxUL4nUYON4YRcJfA9MQlX1mh6ZtT1slmiypA9WQT25JY5cgErfcDVzrY6+TSjJuhER2HZdOHnV0hD4I4G8bnp1aVnXv6Pnc70o7d+2BkIizHx4aoe1rxQwjFKDHpk/K41FQKekzjf2qqwxgojgCkxC28= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732528379; c=relaxed/simple; bh=ubZ04BAzavQP2t/iuBNv8I/bCNuPwsYNnJT0ixXEHFw=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=jWekjZhexZGBzz7q4LiA2ykelgX+j20RZbX93d117V+nTXLqlq55JEtnNZKvidZSjJayc0Xh0KbnJZWzxAhwRIh7gaNX6hPiuzXnALbInL1YJq6Bv9JqJ7e8HcevejMvE8mceCIUEEW8mZRM/OVeMRgr4kq33maxAd7KREEF7a8= 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 A93C01692; Mon, 25 Nov 2024 01:53:27 -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 95C7F3F5A1; Mon, 25 Nov 2024 01:52:56 -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 2/3] arm_ffa.h: add properties bit related direct msg version 2 Date: Mon, 25 Nov 2024 09:52:50 +0000 Message-Id: <20241125095251.366866-3-yeoreum.yun@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241125095251.366866-1-yeoreum.yun@arm.com> References: <20241125095251.366866-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 According to FF-A specificaiton [0], There are flags to be used to check whether partition supports send/receive direct msg version 2. Add related flags. Link: https://developer.arm.com/documentation/den0077/latest [0] Signed-off-by: Yeoreum Yun --- include/linux/arm_ffa.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h index 3fb9c7a3453b..b697675c76ba 100644 --- a/include/linux/arm_ffa.h +++ b/include/linux/arm_ffa.h @@ -238,6 +238,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 requests version 2 */ +#define FFA_PARTITION_DIRECT_RECV_V2 BIT(9) +/* partition can send direct requests. */ +#define FFA_PARTITION_DIRECT_SEND_V2 BIT(10) u32 properties; u32 uuid[4]; }; --=20 LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7} From nobody Sat Feb 7 07:31:34 2026 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 97399192B62 for ; Mon, 25 Nov 2024 09:52:59 +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=1732528381; cv=none; b=LjDhAVLPhLs+Iuy1ZcZtzT8cstuvSQ3X+CJ9x7b/0Sf3zXYwpz88mFfZqnCLniKrZ++zPP6j96kbOpKwPJN6/IknsQ/38KshlAEB+MdhNK/bP2E88nEz+Drn/C8uRcBNmBFoF9hpZCIMCr4rDS2Pxz/dDVdNI3laK9LyxljgG2c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1732528381; c=relaxed/simple; bh=plYSePR17bUYbnIXW6ASTUU+nFubMYrI/KTOuQNQ8as=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QPCvwwibVxhqfeXMlosURolB6L8Pi9QyLcIFJB8BcnB2npKBCYPvQHYQaGohOogP4CuXtSNTetmA75q6EBaKTyvD83jxXHCxEE1ssXeRctl4kjNqVsf8sMHW4O47UswL9M5D6JcvZWu+y/ulCZNwTnLAsQlRt6t1i1fD4ZWgUbs= 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 04ABF1756; Mon, 25 Nov 2024 01:53:29 -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 EEC823F5A1; Mon, 25 Nov 2024 01:52:57 -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 3/3] firmware/arm_ffa: remove __le64_to_cpu() when set uuid for direct msg v2 Date: Mon, 25 Nov 2024 09:52:51 +0000 Message-Id: <20241125095251.366866-4-yeoreum.yun@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20241125095251.366866-1-yeoreum.yun@arm.com> References: <20241125095251.366866-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 __be64 because UUID is saved in network byte order. 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 a3a9cdec7389..4a6bc6520d25 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]; + __be64 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)); =20 --=20 LEVI:{C3F47F37-75D8-414A-A8BA-3980EC8A46D7}