Prechádzať zdrojové kódy

ipa: Add debugfs for header table offsets

Print used and free offset sizes in the header table debugfs

Change-Id: I56ab0a9f607dc45d3a83a4e3749370b02caf7a0a
Signed-off-by: Ilia Lin <[email protected]>
Ilia Lin 3 rokov pred
rodič
commit
e3ce2f25dc

+ 34 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_debugfs.c

@@ -610,6 +610,8 @@ static ssize_t ipa3_read_hdr(struct file *file, char __user *ubuf, size_t count,
 	int i = 0;
 	struct ipa3_hdr_entry *entry;
 	enum hdr_tbl_storage hdr_tbl;
+	struct ipa_hdr_offset_entry *offset_entry;
+	unsigned int offset_count;
 
 	mutex_lock(&ipa3_ctx->lock);
 
@@ -619,6 +621,38 @@ static ssize_t ipa3_read_hdr(struct file *file, char __user *ubuf, size_t count,
 		else
 			pr_err("Table on system (ddr) memory:\n");
 
+		nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN, "Used offsets: ");
+		for (i = 0; i < IPA_HDR_BIN_MAX; i++){
+			offset_count = 0;
+			list_for_each_entry(offset_entry,
+					    &ipa3_ctx->hdr_tbl[hdr_tbl].head_offset_list[i],
+					    link)
+				offset_count++;
+			if (offset_count)
+				nbytes += scnprintf(dbg_buff + nbytes,
+						    IPA_MAX_MSG_LEN - nbytes,
+						    "%u * %u bytes, ",
+						    offset_count,
+						    ipa3_get_hdr_bin_size(i));
+		}
+		pr_err("%s", dbg_buff);
+
+		nbytes = scnprintf(dbg_buff, IPA_MAX_MSG_LEN, "Free offsets: ");
+		for (i = 0; i < IPA_HDR_BIN_MAX; i++){
+			offset_count = 0;
+			list_for_each_entry(offset_entry,
+					    &ipa3_ctx->hdr_tbl[hdr_tbl].head_free_offset_list[i],
+					    link)
+				offset_count++;
+			if (offset_count)
+				nbytes += scnprintf(dbg_buff + nbytes,
+						    IPA_MAX_MSG_LEN - nbytes,
+						    "%u * %u bytes, ",
+						    offset_count,
+						    ipa3_get_hdr_bin_size(i));
+		}
+		pr_err("%s", dbg_buff);
+
 		list_for_each_entry(entry, &ipa3_ctx->hdr_tbl[hdr_tbl].head_hdr_entry_list,
 				link) {
 			if (entry->cookie != IPA_HDR_COOKIE)

+ 14 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_hdr.c

@@ -1389,3 +1389,17 @@ int ipa3_copy_hdr(struct ipa_ioc_copy_hdr *copy)
 
 	return result;
 }
+
+/**
+ * ipa3_get_hdr_bin_size() - Get header bin size from specified index
+ *
+ * @index:	[in] index in the bin sizes array
+ *
+ * Returns:	bin size on success, MAX_UINT32 on failure
+ */
+u32 ipa3_get_hdr_bin_size(int index)
+{
+	if (index < 0 || index >= IPA_HDR_BIN_MAX)
+		return U32_MAX;
+	return ipa_hdr_bin_sz[index];
+}

+ 2 - 0
drivers/platform/msm/ipa/ipa_v3/ipa_i.h

@@ -2690,6 +2690,8 @@ int ipa3_put_hdr(u32 hdr_hdl);
 
 int ipa3_copy_hdr(struct ipa_ioc_copy_hdr *copy);
 
+u32 ipa3_get_hdr_bin_size(int index);
+
 /*
  * Header Processing Context
  */