Commit 6f755e85 authored by Suzuki K Poulose's avatar Suzuki K Poulose Committed by Greg Kroah-Hartman

coresight: Add helper for inserting synchronization packets

Right now we open code filling the trace buffer with synchronization
packets when the circular buffer wraps around in different drivers.
Move this to a common place. While at it, clean up the barrier_pkt
array to strip off the trailing '\0'.

Cc: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Mike Leach <mike.leach@linaro.org>
Signed-off-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent ef32df53
...@@ -195,7 +195,6 @@ static void etb_dump_hw(struct etb_drvdata *drvdata) ...@@ -195,7 +195,6 @@ static void etb_dump_hw(struct etb_drvdata *drvdata)
bool lost = false; bool lost = false;
int i; int i;
u8 *buf_ptr; u8 *buf_ptr;
const u32 *barrier;
u32 read_data, depth; u32 read_data, depth;
u32 read_ptr, write_ptr; u32 read_ptr, write_ptr;
u32 frame_off, frame_endoff; u32 frame_off, frame_endoff;
...@@ -226,19 +225,16 @@ static void etb_dump_hw(struct etb_drvdata *drvdata) ...@@ -226,19 +225,16 @@ static void etb_dump_hw(struct etb_drvdata *drvdata)
depth = drvdata->buffer_depth; depth = drvdata->buffer_depth;
buf_ptr = drvdata->buf; buf_ptr = drvdata->buf;
barrier = barrier_pkt;
for (i = 0; i < depth; i++) { for (i = 0; i < depth; i++) {
read_data = readl_relaxed(drvdata->base + read_data = readl_relaxed(drvdata->base +
ETB_RAM_READ_DATA_REG); ETB_RAM_READ_DATA_REG);
if (lost && *barrier) {
read_data = *barrier;
barrier++;
}
*(u32 *)buf_ptr = read_data; *(u32 *)buf_ptr = read_data;
buf_ptr += 4; buf_ptr += 4;
} }
if (lost)
coresight_insert_barrier_packet(drvdata->buf);
if (frame_off) { if (frame_off) {
buf_ptr -= (frame_endoff * 4); buf_ptr -= (frame_endoff * 4);
for (i = 0; i < frame_endoff; i++) { for (i = 0; i < frame_endoff; i++) {
...@@ -447,7 +443,7 @@ static void etb_update_buffer(struct coresight_device *csdev, ...@@ -447,7 +443,7 @@ static void etb_update_buffer(struct coresight_device *csdev,
buf_ptr = buf->data_pages[cur] + offset; buf_ptr = buf->data_pages[cur] + offset;
read_data = readl_relaxed(drvdata->base + read_data = readl_relaxed(drvdata->base +
ETB_RAM_READ_DATA_REG); ETB_RAM_READ_DATA_REG);
if (lost && *barrier) { if (lost && i < CORESIGHT_BARRIER_PKT_SIZE) {
read_data = *barrier; read_data = *barrier;
barrier++; barrier++;
} }
......
...@@ -57,7 +57,8 @@ static DEVICE_ATTR_RO(name) ...@@ -57,7 +57,8 @@ static DEVICE_ATTR_RO(name)
#define coresight_simple_reg64(type, name, lo_off, hi_off) \ #define coresight_simple_reg64(type, name, lo_off, hi_off) \
__coresight_simple_func(type, NULL, name, lo_off, hi_off) __coresight_simple_func(type, NULL, name, lo_off, hi_off)
extern const u32 barrier_pkt[5]; extern const u32 barrier_pkt[4];
#define CORESIGHT_BARRIER_PKT_SIZE (sizeof(barrier_pkt))
enum etm_addr_type { enum etm_addr_type {
ETM_ADDR_TYPE_NONE, ETM_ADDR_TYPE_NONE,
...@@ -91,6 +92,13 @@ struct cs_buffers { ...@@ -91,6 +92,13 @@ struct cs_buffers {
void **data_pages; void **data_pages;
}; };
static inline void coresight_insert_barrier_packet(void *buf)
{
if (buf)
memcpy(buf, barrier_pkt, CORESIGHT_BARRIER_PKT_SIZE);
}
static inline void CS_LOCK(void __iomem *addr) static inline void CS_LOCK(void __iomem *addr)
{ {
do { do {
......
...@@ -32,39 +32,28 @@ static void tmc_etb_enable_hw(struct tmc_drvdata *drvdata) ...@@ -32,39 +32,28 @@ static void tmc_etb_enable_hw(struct tmc_drvdata *drvdata)
static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata) static void tmc_etb_dump_hw(struct tmc_drvdata *drvdata)
{ {
bool lost = false;
char *bufp; char *bufp;
const u32 *barrier; u32 read_data, lost;
u32 read_data, status;
int i; int i;
/* /* Check if the buffer wrapped around. */
* Get a hold of the status register and see if a wrap around lost = readl_relaxed(drvdata->base + TMC_STS) & TMC_STS_FULL;
* has occurred.
*/
status = readl_relaxed(drvdata->base + TMC_STS);
if (status & TMC_STS_FULL)
lost = true;
bufp = drvdata->buf; bufp = drvdata->buf;
drvdata->len = 0; drvdata->len = 0;
barrier = barrier_pkt;
while (1) { while (1) {
for (i = 0; i < drvdata->memwidth; i++) { for (i = 0; i < drvdata->memwidth; i++) {
read_data = readl_relaxed(drvdata->base + TMC_RRD); read_data = readl_relaxed(drvdata->base + TMC_RRD);
if (read_data == 0xFFFFFFFF) if (read_data == 0xFFFFFFFF)
return; goto done;
if (lost && *barrier) {
read_data = *barrier;
barrier++;
}
memcpy(bufp, &read_data, 4); memcpy(bufp, &read_data, 4);
bufp += 4; bufp += 4;
drvdata->len += 4; drvdata->len += 4;
} }
} }
done:
if (lost)
coresight_insert_barrier_packet(drvdata->buf);
return;
} }
static void tmc_etb_disable_hw(struct tmc_drvdata *drvdata) static void tmc_etb_disable_hw(struct tmc_drvdata *drvdata)
......
...@@ -91,9 +91,7 @@ ssize_t tmc_etr_get_sysfs_trace(struct tmc_drvdata *drvdata, ...@@ -91,9 +91,7 @@ ssize_t tmc_etr_get_sysfs_trace(struct tmc_drvdata *drvdata,
static void tmc_etr_dump_hw(struct tmc_drvdata *drvdata) static void tmc_etr_dump_hw(struct tmc_drvdata *drvdata)
{ {
const u32 *barrier;
u32 val; u32 val;
u32 *temp;
u64 rwp; u64 rwp;
rwp = tmc_read_rwp(drvdata); rwp = tmc_read_rwp(drvdata);
...@@ -106,16 +104,7 @@ static void tmc_etr_dump_hw(struct tmc_drvdata *drvdata) ...@@ -106,16 +104,7 @@ static void tmc_etr_dump_hw(struct tmc_drvdata *drvdata)
if (val & TMC_STS_FULL) { if (val & TMC_STS_FULL) {
drvdata->buf = drvdata->vaddr + rwp - drvdata->paddr; drvdata->buf = drvdata->vaddr + rwp - drvdata->paddr;
drvdata->len = drvdata->size; drvdata->len = drvdata->size;
coresight_insert_barrier_packet(drvdata->buf);
barrier = barrier_pkt;
temp = (u32 *)drvdata->buf;
while (*barrier) {
*temp = *barrier;
temp++;
barrier++;
}
} else { } else {
drvdata->buf = drvdata->vaddr; drvdata->buf = drvdata->vaddr;
drvdata->len = rwp - drvdata->paddr; drvdata->len = rwp - drvdata->paddr;
......
...@@ -51,8 +51,7 @@ static struct list_head *stm_path; ...@@ -51,8 +51,7 @@ static struct list_head *stm_path;
* beginning of the data collected in a buffer. That way the decoder knows that * beginning of the data collected in a buffer. That way the decoder knows that
* it needs to look for another sync sequence. * it needs to look for another sync sequence.
*/ */
const u32 barrier_pkt[5] = {0x7fffffff, 0x7fffffff, const u32 barrier_pkt[4] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff};
0x7fffffff, 0x7fffffff, 0x0};
static int coresight_id_match(struct device *dev, void *data) static int coresight_id_match(struct device *dev, void *data)
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment