Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2efca57e authored by Jeff Hugo's avatar Jeff Hugo
Browse files

msm: smd_debug: add support for parsing the secondary allocation table



SMD has both primary and secondary channel allocation tables where channels
can potentionally live.  The ch debugfs node only parses the primary table
which limits its usefulness in providing debugging information for issues
involving channels that exist in the secondary allocation table.

Add support to parse and output information about channels in the secondary
allocation table to assist debugging of channels that exist in that table.

Change-Id: Ib486ab05b646d03cea5e0c7db553ab30e04f8a6d
Signed-off-by: default avatarJeffrey Hugo <jhugo@codeaurora.org>
parent ff585cbf
Loading
Loading
Loading
Loading
+48 −16
Original line number Diff line number Diff line
@@ -205,15 +205,24 @@ static char *smd_xfer_type_to_str(uint32_t xfer_type)
}

/**
 * debug_ch - Print the current state of every valid SMD channel in a human
 *		readable formatted table.
 * print_smd_ch_table - Print the current state of every valid SMD channel in a
 *			specific SMD channel allocation table to a human
 *			readable formatted output.
 *
 * @s: the sequential file to print to
 * @tbl: a valid pointer to the channel allocation table to print from
 * @num_tbl_entries: total number of entries in the table referenced by @tbl
 * @ch_base_id: the SMEM item id corresponding to the array of channel
 *		structures for the channels found in @tbl
 * @fifo_base_id: the SMEM item id corresponding to the array of channel fifos
 *		for the channels found in @tbl
 */
static void debug_ch(struct seq_file *s)
static void print_smd_ch_table(struct seq_file *s,
				struct smd_alloc_elm *tbl,
				unsigned num_tbl_entries,
				unsigned ch_base_id,
				unsigned fifo_base_id)
{
	struct smd_alloc_elm *tbl;
	unsigned tbl_size;
	void *half_ch;
	unsigned half_ch_size;
	uint32_t ch_type;
@@ -221,13 +230,6 @@ static void debug_ch(struct seq_file *s)
	unsigned buffer_size;
	int n;

	tbl = smem_get_entry(ID_CH_ALLOC_TBL, &tbl_size);

	if (!tbl) {
		seq_puts(s, "Channel allocation table not found\n");
		return;
	}

/*
 * formatted, human readable channel state output, ie:
ID|CHANNEL NAME       |T|PROC |STATE  |FIFO SZ|RDPTR  |WRPTR  |FLAGS   |DATAPEN
@@ -250,7 +252,7 @@ ID|CHANNEL NAME |T|PROC |STATE |FIFO SZ|RDPTR |WRPTR |FLAGS |DATAPEN
								"DATAPEN");
	seq_puts(s,
		"-------------------------------------------------------------------------------\n");
	for (n = 0; n < tbl_size / sizeof(*tbl); ++n) {
	for (n = 0; n < num_tbl_entries; ++n) {
		if (strlen(tbl[n].name) == 0)
			continue;

@@ -263,9 +265,8 @@ ID|CHANNEL NAME |T|PROC |STATE |FIFO SZ|RDPTR |WRPTR |FLAGS |DATAPEN
		else
			half_ch_size = sizeof(struct smd_half_channel);

		half_ch = smem_find(ID_SMD_CHANNELS + n, 2 * half_ch_size);
		buffer = smem_get_entry(SMEM_SMD_FIFO_BASE_ID + n,
								&buffer_size);
		half_ch = smem_find(ch_base_id + n, 2 * half_ch_size);
		buffer = smem_get_entry(fifo_base_id + n, &buffer_size);
		if (half_ch && buffer)
			print_half_ch_state(s,
					half_ch,
@@ -289,6 +290,37 @@ ID|CHANNEL NAME |T|PROC |STATE |FIFO SZ|RDPTR |WRPTR |FLAGS |DATAPEN
	}
}

/**
 * debug_ch - Print the current state of every valid SMD channel in a human
 *		readable formatted table.
 *
 * @s: the sequential file to print to
 */
static void debug_ch(struct seq_file *s)
{
	struct smd_alloc_elm *tbl;
	unsigned tbl_size;

	tbl = smem_get_entry(ID_CH_ALLOC_TBL, &tbl_size);

	if (!tbl) {
		seq_puts(s, "Channel allocation table not found\n");
		return;
	}

	seq_puts(s, "Primary allocation table:\n");
	print_smd_ch_table(s, tbl, tbl_size / sizeof(*tbl), ID_SMD_CHANNELS,
							SMEM_SMD_FIFO_BASE_ID);

	tbl = smem_get_entry(SMEM_CHANNEL_ALLOC_TBL_2, &tbl_size);
	if (tbl) {
		seq_puts(s, "\n\nSecondary allocation table:\n");
		print_smd_ch_table(s, tbl, tbl_size / sizeof(*tbl),
						SMEM_SMD_BASE_ID_2,
						SMEM_SMD_FIFO_BASE_ID_2);
	}
}

static int debugfs_show(struct seq_file *s, void *data)
{
	void (*show)(struct seq_file *) = s->private;