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

Commit 73b6dc50 authored by Pratik Patel's avatar Pratik Patel Committed by Gerrit - the friendly Code Review server
Browse files

coresight: add header meta data for every ost packet sent via stm



Add header meta data carrying useful info like version, magic,
task name, cpu and kernel timestamp with every OST packet sent
using STM.

This will help provide additional info that can be used for STM
log analysis.

Change-Id: I8902f5529d62417ee8b4d6a21f3801c06edce972
Signed-off-by: default avatarPratik Patel <pratikp@codeaurora.org>
parent 25ccdb0a
Loading
Loading
Loading
Loading
+29 −4
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@
#include <linux/clk.h>
#include <linux/bitmap.h>
#include <linux/of.h>
#include <linux/sched.h>
#include <linux/of_coresight.h>
#include <linux/coresight.h>
#include <linux/coresight-stm.h>
@@ -95,6 +96,9 @@ do { \
#define OST_VERSION_PROP		(1)
#define OST_VERSION_MIPI1		(16)

#define STM_MAKE_VERSION(ma, mi)	((ma << 8) | mi)
#define STM_HEADER_MAGIC		(0x5953)

enum stm_pkt_type {
	STM_PKT_TYPE_DATA	= 0x98,
	STM_PKT_TYPE_FLAG	= 0xE8,
@@ -501,8 +505,7 @@ static int stm_send(void *addr, const void *data, uint32_t size)
}

static int stm_trace_ost_header(unsigned long ch_addr, uint32_t options,
				uint8_t entity_id, uint8_t proto_id,
				const void *payload_data, uint32_t payload_size)
				uint8_t entity_id, uint8_t proto_id)
{
	void *addr;
	uint32_t header;
@@ -523,15 +526,37 @@ static int stm_trace_ost_header(unsigned long ch_addr, uint32_t options,
	return stm_send(addr, &header, sizeof(header));
}

static int stm_trace_data_header(void *addr)
{
	char hdr[16];
	int len = 0;

	*(uint16_t *)(hdr) = STM_MAKE_VERSION(0, 1);
	*(uint16_t *)(hdr + 2) = STM_HEADER_MAGIC;
	*(uint32_t *)(hdr + 4) = raw_smp_processor_id();
	*(uint64_t *)(hdr + 8) = sched_clock();

	len += stm_send(addr, hdr, sizeof(hdr));
	len += stm_send(addr, current->comm, TASK_COMM_LEN);

	return len;
}

static int stm_trace_data(unsigned long ch_addr, uint32_t options,
			  const void *data, uint32_t size)
{
	void *addr;
	int len = 0;

	options &= ~STM_OPTION_TIMESTAMPED;
	addr = (void *)(ch_addr | stm_channel_off(STM_PKT_TYPE_DATA, options));

	return stm_send(addr, data, size);
	/* send the data header */
	len += stm_trace_data_header(addr);
	/* send the actual data */
	len += stm_send(addr, data, size);

	return len;
}

static int stm_trace_ost_tail(unsigned long ch_addr, uint32_t options)
@@ -569,7 +594,7 @@ static inline int __stm_trace(uint32_t options, uint8_t entity_id,
	} else {
		/* send the ost header */
		len += stm_trace_ost_header(ch_addr, options, entity_id,
					    proto_id, data, size);
					    proto_id);

		/* send the payload data */
		len += stm_trace_data(ch_addr, options, data, size);