Skip to contentSkip to conversation

media: venus : hfi: add venus image info into smem

PATCH Superseded Dikshita Agarwal 2 participants 2 messages Mar 24, 2021

Subsystems (4)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 media: venus : hfi: add venus image info into smem

fill fw version info into smem to be printed as part of soc info.

---
 drivers/media/platform/qcom/venus/hfi_msgs.c | 36 ++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/hfi_msgs.c +34 -2
index 06a1908..0e94921 100644
@@ -6,6 +6,7 @@
 #include <linux/hash.h>
 #include <linux/list.h>
 #include <linux/slab.h>
+#include <linux/soc/qcom/smem.h>
 #include <media/videobuf2-v4l2.h>
 
 #include "core.h"
@@ -14,6 +15,8 @@
 #include "hfi_msgs.h"
 #include "hfi_parser.h"
 
+#define SMEM_IMAGE_VERSION_TABLE 469
+
 static void event_seq_changed(struct venus_core *core, struct venus_inst *inst,
 			      struct hfi_msg_event_notify_pkt *pkt)
 {
@@ -239,15 +242,44 @@ static void
 sys_get_prop_image_version(struct device *dev,
 			   struct hfi_msg_sys_property_info_pkt *pkt)
 {
+	u32 i = 0;
+	size_t smem_block_size = 0;
+	u8 *smem_table_ptr;
+	char version[256];
+	const u32 version_string_size = 128;
+	const u32 smem_image_index_venus = 14 * 128;
+	u8 *str_image_version;
 	int req_bytes;
 
 	req_bytes = pkt->hdr.size - sizeof(*pkt);
 
-	if (req_bytes < 128 || !pkt->data[1] || pkt->num_properties > 1)
+	if (req_bytes < version_string_size || !pkt->data[1] || pkt->num_properties > 1)
 		/* bad packet */
 		return;
 
-	dev_dbg(dev, VDBGL "F/W version: %s\n", (u8 *)&pkt->data[1]);
+	str_image_version = (u8 *)&pkt->data[1];
+
+	/*
+	 * The version string returned by firmware includes null
+	 * characters at the start and in between. Replace the null
+	 * characters with space, to print the version info.
+	 */
+	for (i = 0; i < version_string_size; i++) {
+		if (str_image_version[i] != '\0')
+			version[i] = str_image_version[i];
+		else
+			version[i] = ' ';
+	}
+
+	version[i] = '\0';
+	dev_dbg(dev, VDBGL "F/W version: %s\n", version);
+
+	smem_table_ptr = qcom_smem_get(QCOM_SMEM_HOST_ANY,
+				       SMEM_IMAGE_VERSION_TABLE, &smem_block_size);
+	if ((smem_image_index_venus + version_string_size) <= smem_block_size &&
+	    smem_table_ptr)
+		memcpy(smem_table_ptr + smem_image_index_venus,
+		       str_image_version, version_string_size);
 }
 
 static void hfi_sys_property_info(struct venus_core *core,
Signature · 1 line
2.7.4
#1 lore raw

Quoting Dikshita Agarwal (2021-03-23 22:40:57)

Quoted 1 line

fill fw version info into smem to be printed as part of

s/fill/Fill/

Quoted 12 lines

soc info.

---
 drivers/media/platform/qcom/venus/hfi_msgs.c | 36 ++++++++++++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)
drivers/media/platform/qcom/venus/hfi_msgs.c +0 -0
index 06a1908..0e94921 100644

drivers/media/platform/qcom/venus/hfi_msgs.c static void · line 250

Quoted 9 lines
drivers/media/platform/qcom/venus/hfi_msgs.c +6 -0
@@ -239,15 +242,44 @@ static void
 sys_get_prop_image_version(struct device *dev,
                           struct hfi_msg_sys_property_info_pkt *pkt)
 {
+       u32 i = 0;
+       size_t smem_block_size = 0;
+       u8 *smem_table_ptr;
+       char version[256];
+       const u32 version_string_size = 128;
+       const u32 smem_image_index_venus = 14 * 128;

Can these be #defines instead of local const variables?

drivers/media/platform/qcom/venus/hfi_msgs.c static void · line 250

Quoted 11 lines
drivers/media/platform/qcom/venus/hfi_msgs.c +2 -2
+       u8 *str_image_version;
        int req_bytes;
 
        req_bytes = pkt->hdr.size - sizeof(*pkt);
 
-       if (req_bytes < 128 || !pkt->data[1] || pkt->num_properties > 1)
+       if (req_bytes < version_string_size || !pkt->data[1] || pkt->num_properties > 1)
                /* bad packet */
                return;
 
-       dev_dbg(dev, VDBGL "F/W version: %s\n", (u8 *)&pkt->data[1]);

Why is pkt->data not already a u8?

Quoted 6 lines
drivers/media/platform/qcom/venus/hfi_msgs.c +6 -0
+       str_image_version = (u8 *)&pkt->data[1];
+
+       /*
+        * The version string returned by firmware includes null
+        * characters at the start and in between. Replace the null
+        * characters with space, to print the version info.

drivers/media/platform/qcom/venus/hfi_msgs.c static void · line 275

Quoted 10 lines
drivers/media/platform/qcom/venus/hfi_msgs.c +10 -0
+        */
+       for (i = 0; i < version_string_size; i++) {
+               if (str_image_version[i] != '\0')
+                       version[i] = str_image_version[i];
+               else
+                       version[i] = ' ';
+       }
+
+       version[i] = '\0';
+       dev_dbg(dev, VDBGL "F/W version: %s\n", version);

Instead of replacing the string with spaces can we find the first non-null character up to version_string_size and then stash a pointer to that and print it out with dev_dbg()? That would save 256 bytes on the stack for something that is presumably a string and will be NUL terminated.

drivers/media/platform/qcom/venus/hfi_msgs.c static void · line 282

Quoted 7 lines
drivers/media/platform/qcom/venus/hfi_msgs.c +7 -0
+
+       smem_table_ptr = qcom_smem_get(QCOM_SMEM_HOST_ANY,
+                                      SMEM_IMAGE_VERSION_TABLE, &smem_block_size);
+       if ((smem_image_index_venus + version_string_size) <= smem_block_size &&
+           smem_table_ptr)
+               memcpy(smem_table_ptr + smem_image_index_venus,
+                      str_image_version, version_string_size);

It would be nice to have shorter variable names so this was an

	if (condition1 && condition2)
		memcpy();