mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/5] firmware: arm_ffa: Few updates and fixes
@ 2024-12-24 13:57 Sudeep Holla
  2024-12-24 13:57 ` [PATCH 1/5] firmware: arm_ffa: Replace SCMI by FF-A in the macro Sudeep Holla
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Sudeep Holla @ 2024-12-24 13:57 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, Sudeep Holla, Arnd Bergmann

This set of updates fixes big-endian support in couple of functions:
__ffa_partition_info_regs_get() and __ffa_partition_info_get().
Big-endian support is still not complete. Only these changes can be
verified at the moment without any additional application or testing
support changes.

It also fixes the mis-alignment with sync_send_receive{,2} function
prototypes.

It replaces UUID buffer to standard UUID format in the ffa_partition_info
structure and fixes a typo in some FF-A bus macros

Signed-off-by: Sudeep Holla <sudeep.holla@arm.com>
---
Sudeep Holla (5):
      firmware: arm_ffa: Replace SCMI by FF-A in the macro
      firmware: arm_ffa: Replace UUID buffer to standard UUID format
      firmware: arm_ffa: Align sync_send_receive{,2} function prototypes
      firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_get()
      firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_regs_get()

 drivers/firmware/arm_ffa/bus.c    | 10 +++-----
 drivers/firmware/arm_ffa/driver.c | 53 +++++++++++++++++++++++++++++++++------
 include/linux/arm_ffa.h           |  4 +--
 3 files changed, 52 insertions(+), 15 deletions(-)
---
base-commit: f07044dd0df0c9d0ad177c3098b62ccddb735a2d
change-id: 20241224-ffa_updates-106fd3df93d5

Best regards,
-- 
Regards,
Sudeep


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/5] firmware: arm_ffa: Replace SCMI by FF-A in the macro
  2024-12-24 13:57 [PATCH 0/5] firmware: arm_ffa: Few updates and fixes Sudeep Holla
@ 2024-12-24 13:57 ` Sudeep Holla
  2024-12-24 13:57 ` [PATCH 2/5] firmware: arm_ffa: Replace UUID buffer to standard UUID format Sudeep Holla
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sudeep Holla @ 2024-12-24 13:57 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, Sudeep Holla, Arnd Bergmann

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 <sudeep.holla@arm.com>
---
 drivers/firmware/arm_ffa/bus.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c
index dfda5ffc14db7208e8b622cdd648194c9cb1ef34..52b1f09209a0e51e321cd23a69aa7e4c4daa8dd1 100644
--- a/drivers/firmware/arm_ffa/bus.c
+++ b/drivers/firmware/arm_ffa/bus.c
@@ -15,7 +15,7 @@
 
 #include "common.h"
 
-#define SCMI_UEVENT_MODALIAS_FMT	"arm_ffa:%04x:%pUb"
+#define FFA_UEVENT_MODALIAS_FMT	"arm_ffa:%04x:%pUb"
 
 static DEFINE_IDA(ffa_bus_id);
 
@@ -68,7 +68,7 @@ static int ffa_device_uevent(const struct device *dev, struct kobj_uevent_env *e
 {
 	const struct ffa_device *ffa_dev = to_ffa_dev(dev);
 
-	return add_uevent_var(env, "MODALIAS=" SCMI_UEVENT_MODALIAS_FMT,
+	return add_uevent_var(env, "MODALIAS=" FFA_UEVENT_MODALIAS_FMT,
 			      ffa_dev->vm_id, &ffa_dev->uuid);
 }
 
@@ -77,7 +77,7 @@ static ssize_t modalias_show(struct device *dev,
 {
 	struct ffa_device *ffa_dev = to_ffa_dev(dev);
 
-	return sysfs_emit(buf, SCMI_UEVENT_MODALIAS_FMT, ffa_dev->vm_id,
+	return sysfs_emit(buf, FFA_UEVENT_MODALIAS_FMT, ffa_dev->vm_id,
 			  &ffa_dev->uuid);
 }
 static DEVICE_ATTR_RO(modalias);

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 2/5] firmware: arm_ffa: Replace UUID buffer to standard UUID format
  2024-12-24 13:57 [PATCH 0/5] firmware: arm_ffa: Few updates and fixes Sudeep Holla
  2024-12-24 13:57 ` [PATCH 1/5] firmware: arm_ffa: Replace SCMI by FF-A in the macro Sudeep Holla
@ 2024-12-24 13:57 ` Sudeep Holla
  2024-12-24 13:57 ` [PATCH 3/5] firmware: arm_ffa: Align sync_send_receive{,2} function prototypes Sudeep Holla
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Sudeep Holla @ 2024-12-24 13:57 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, Sudeep Holla, Arnd Bergmann

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 <sudeep.holla@arm.com>
---
 drivers/firmware/arm_ffa/bus.c | 4 +---
 include/linux/arm_ffa.h        | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/firmware/arm_ffa/bus.c b/drivers/firmware/arm_ffa/bus.c
index 52b1f09209a0e51e321cd23a69aa7e4c4daa8dd1..a90e2faa990219574ff20b8f573dbb7ca76137d9 100644
--- a/drivers/firmware/arm_ffa/bus.c
+++ b/drivers/firmware/arm_ffa/bus.c
@@ -192,7 +192,6 @@ ffa_device_register(const struct ffa_partition_info *part_info,
 		    const struct ffa_ops *ops)
 {
 	int id, ret;
-	uuid_t uuid;
 	struct device *dev;
 	struct ffa_device *ffa_dev;
 
@@ -218,8 +217,7 @@ ffa_device_register(const struct ffa_partition_info *part_info,
 	ffa_dev->vm_id = part_info->id;
 	ffa_dev->properties = part_info->properties;
 	ffa_dev->ops = ops;
-	import_uuid(&uuid, (u8 *)part_info->uuid);
-	uuid_copy(&ffa_dev->uuid, &uuid);
+	uuid_copy(&ffa_dev->uuid, &part_info->uuid);
 
 	ret = device_register(&ffa_dev->dev);
 	if (ret) {
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index 74169dd0f65948b05991732358855cdc31b54adb..abd0208f0f74c15ef4ee4c81de81eb7800a0eb1d 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -238,7 +238,7 @@ struct ffa_partition_info {
 /* partition runs in the AArch64 execution state. */
 #define FFA_PARTITION_AARCH64_EXEC	BIT(8)
 	u32 properties;
-	u32 uuid[4];
+	uuid_t uuid;
 };
 
 static inline

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 3/5] firmware: arm_ffa: Align sync_send_receive{,2} function prototypes
  2024-12-24 13:57 [PATCH 0/5] firmware: arm_ffa: Few updates and fixes Sudeep Holla
  2024-12-24 13:57 ` [PATCH 1/5] firmware: arm_ffa: Replace SCMI by FF-A in the macro Sudeep Holla
  2024-12-24 13:57 ` [PATCH 2/5] firmware: arm_ffa: Replace UUID buffer to standard UUID format Sudeep Holla
@ 2024-12-24 13:57 ` Sudeep Holla
  2024-12-24 13:57 ` [PATCH 4/5] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_get() Sudeep Holla
  2024-12-24 13:57 ` [PATCH 5/5] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_regs_get() Sudeep Holla
  4 siblings, 0 replies; 6+ messages in thread
From: Sudeep Holla @ 2024-12-24 13:57 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, Sudeep Holla, Arnd Bergmann

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 <sudeep.holla@arm.com>
---
 drivers/firmware/arm_ffa/driver.c | 4 ++--
 include/linux/arm_ffa.h           | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 2c2ec3c35f15612168cdf0ef94022e00c08677b5..037e0d684994fd30971f40bf139367d1e45c1bf0 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -1018,14 +1018,14 @@ static int ffa_indirect_msg_send(struct ffa_device *dev, void *buf, size_t sz)
 	return ffa_msg_send2(drv_info->vm_id, dev->vm_id, buf, sz);
 }
 
-static int ffa_sync_send_receive2(struct ffa_device *dev, const uuid_t *uuid,
+static int ffa_sync_send_receive2(struct ffa_device *dev,
 				  struct ffa_send_direct_data2 *data)
 {
 	if (!drv_info->msg_direct_req2_supp)
 		return -EOPNOTSUPP;
 
 	return ffa_msg_send_direct_req2(drv_info->vm_id, dev->vm_id,
-					uuid, data);
+					&dev->uuid, data);
 }
 
 static int ffa_memory_share(struct ffa_mem_ops_args *args)
diff --git a/include/linux/arm_ffa.h b/include/linux/arm_ffa.h
index abd0208f0f74c15ef4ee4c81de81eb7800a0eb1d..e8b8ae8b192ab11d5550c16fd33fa9d192b07f67 100644
--- a/include/linux/arm_ffa.h
+++ b/include/linux/arm_ffa.h
@@ -439,7 +439,7 @@ struct ffa_msg_ops {
 	int (*sync_send_receive)(struct ffa_device *dev,
 				 struct ffa_send_direct_data *data);
 	int (*indirect_send)(struct ffa_device *dev, void *buf, size_t sz);
-	int (*sync_send_receive2)(struct ffa_device *dev, const uuid_t *uuid,
+	int (*sync_send_receive2)(struct ffa_device *dev,
 				  struct ffa_send_direct_data2 *data);
 };
 

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 4/5] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_get()
  2024-12-24 13:57 [PATCH 0/5] firmware: arm_ffa: Few updates and fixes Sudeep Holla
                   ` (2 preceding siblings ...)
  2024-12-24 13:57 ` [PATCH 3/5] firmware: arm_ffa: Align sync_send_receive{,2} function prototypes Sudeep Holla
@ 2024-12-24 13:57 ` Sudeep Holla
  2024-12-24 13:57 ` [PATCH 5/5] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_regs_get() Sudeep Holla
  4 siblings, 0 replies; 6+ messages in thread
From: Sudeep Holla @ 2024-12-24 13:57 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, Sudeep Holla, Arnd Bergmann

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 <sudeep.holla@arm.com>
---
 drivers/firmware/arm_ffa/driver.c | 18 +++++++++++++++---
 1 file changed, 15 insertions(+), 3 deletions(-)

diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index 037e0d684994fd30971f40bf139367d1e45c1bf0..bc6ffd25ad2e2fea0fe3610cf896718dbed8f0ad 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -276,9 +276,21 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
 	}
 
 	if (buffer && count <= num_partitions)
-		for (idx = 0; idx < count; idx++)
-			memcpy(buffer + idx, drv_info->rx_buffer + idx * sz,
-			       buf_sz);
+		for (idx = 0; idx < count; idx++) {
+			struct ffa_partition_info_le {
+				__le16 id;
+				__le16 exec_ctxt;
+				__le32 properties;
+				uuid_t uuid;
+			} *rx_buf = drv_info->rx_buffer + idx * sz;
+			struct ffa_partition_info *buf = buffer + idx;
+
+			buf->id = le16_to_cpu(rx_buf->id);
+			buf->exec_ctxt = le16_to_cpu(rx_buf->exec_ctxt);
+			buf->properties = le32_to_cpu(rx_buf->properties);
+			if (buf_sz > 8)
+				import_uuid(&buf->uuid, (u8 *)&rx_buf->uuid);
+		}
 
 	ffa_rx_release();
 

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 5/5] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_regs_get()
  2024-12-24 13:57 [PATCH 0/5] firmware: arm_ffa: Few updates and fixes Sudeep Holla
                   ` (3 preceding siblings ...)
  2024-12-24 13:57 ` [PATCH 4/5] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_get() Sudeep Holla
@ 2024-12-24 13:57 ` Sudeep Holla
  4 siblings, 0 replies; 6+ messages in thread
From: Sudeep Holla @ 2024-12-24 13:57 UTC (permalink / raw)
  To: linux-arm-kernel, linux-kernel, Sudeep Holla, Arnd Bergmann

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 <sudeep.holla@arm.com>
---
 drivers/firmware/arm_ffa/driver.c | 31 +++++++++++++++++++++++++++++--
 1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/drivers/firmware/arm_ffa/driver.c b/drivers/firmware/arm_ffa/driver.c
index bc6ffd25ad2e2fea0fe3610cf896718dbed8f0ad..87e106c728b89f3ce7c11219cf7cad9cc166dda2 100644
--- a/drivers/firmware/arm_ffa/driver.c
+++ b/drivers/firmware/arm_ffa/driver.c
@@ -307,14 +307,24 @@ __ffa_partition_info_get(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
 #define CURRENT_INDEX(x)	((u16)(FIELD_GET(CURRENT_INDEX_MASK, (x))))
 #define UUID_INFO_TAG(x)	((u16)(FIELD_GET(UUID_INFO_TAG_MASK, (x))))
 #define PARTITION_INFO_SZ(x)	((u16)(FIELD_GET(PARTITION_INFO_SZ_MASK, (x))))
+#define PART_INFO_ID_MASK	GENMASK(15, 0)
+#define PART_INFO_EXEC_CXT_MASK	GENMASK(31, 16)
+#define PART_INFO_PROPS_MASK	GENMASK(63, 32)
+#define PART_INFO_ID(x)		((u16)(FIELD_GET(PART_INFO_ID_MASK, (x))))
+#define PART_INFO_EXEC_CXT(x)	((u16)(FIELD_GET(PART_INFO_EXEC_CXT_MASK, (x))))
+#define PART_INFO_PROPERTIES(x)	((u32)(FIELD_GET(PART_INFO_PROPS_MASK, (x))))
 static int
 __ffa_partition_info_get_regs(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
 			      struct ffa_partition_info *buffer, int num_parts)
 {
 	u16 buf_sz, start_idx, cur_idx, count = 0, prev_idx = 0, tag = 0;
+	struct ffa_partition_info *buf = buffer;
 	ffa_value_t partition_info;
 
 	do {
+		__le64 *regs;
+		int idx;
+
 		start_idx = prev_idx ? prev_idx + 1 : 0;
 
 		invoke_ffa_fn((ffa_value_t){
@@ -338,8 +348,25 @@ __ffa_partition_info_get_regs(u32 uuid0, u32 uuid1, u32 uuid2, u32 uuid3,
 		if (buf_sz > sizeof(*buffer))
 			buf_sz = sizeof(*buffer);
 
-		memcpy(buffer + prev_idx * buf_sz, &partition_info.a3,
-		       (cur_idx - start_idx + 1) * buf_sz);
+		regs = (void *)&partition_info.a3;
+		for (idx = 0; idx < cur_idx - start_idx + 1; idx++, buf++) {
+			union {
+				uuid_t uuid;
+				u64 regs[2];
+			} uuid_regs = {
+				.regs = {
+					le64_to_cpu(*(regs + 1)),
+					le64_to_cpu(*(regs + 2)),
+					}
+			};
+			u64 val = *(u64 *)regs;
+
+			buf->id = PART_INFO_ID(val);
+			buf->exec_ctxt = PART_INFO_EXEC_CXT(val);
+			buf->properties = PART_INFO_PROPERTIES(val);
+			uuid_copy(&buf->uuid, &uuid_regs.uuid);
+			regs += 3;
+		}
 		prev_idx = cur_idx;
 
 	} while (cur_idx < (count - 1));

-- 
2.34.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-12-24 14:01 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-12-24 13:57 [PATCH 0/5] firmware: arm_ffa: Few updates and fixes Sudeep Holla
2024-12-24 13:57 ` [PATCH 1/5] firmware: arm_ffa: Replace SCMI by FF-A in the macro Sudeep Holla
2024-12-24 13:57 ` [PATCH 2/5] firmware: arm_ffa: Replace UUID buffer to standard UUID format Sudeep Holla
2024-12-24 13:57 ` [PATCH 3/5] firmware: arm_ffa: Align sync_send_receive{,2} function prototypes Sudeep Holla
2024-12-24 13:57 ` [PATCH 4/5] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_get() Sudeep Holla
2024-12-24 13:57 ` [PATCH 5/5] firmware: arm_ffa: Fix big-endian support in __ffa_partition_info_regs_get() Sudeep Holla

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®