Commit 68ebc2e8 authored by Alessandro Rubini's avatar Alessandro Rubini

softpll: make "fifo log" optional and better.

If the Kconfig option is not set, there's no effect on code size.
If set, .bss increases by 256 bytes (the buffer) and .text by
another 200 bytes.

This adds timestamping support, so we know the duration of the
interrupt (because we found it's an important thing when problems
occur).
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent 1a18111c
......@@ -146,6 +146,15 @@ config CHECK_RESET
detects that it is re-executed and dumps a stack trace; it
then clears the stack (for next time) and restarts again.
config SPLL_FIFO_LOG
depends on DEVELOPER
bool "Add a circular buffer for spll logging, used by tools/wrpc-dump"
help
This option addrs 256 bytes to the wrpc bynary, to log
the DDMTD tags read from the fifos, the interrupts and the
related timing. The information is shown by tools/wrpc-dump
if present, no change/rebuild of the tool is needed.
choice
prompt "Implementation of pp_printf"
depends on DEVELOPER && WR_NODE
......
......@@ -85,7 +85,8 @@ SECTIONS
/* First location in stack is highest address in RAM (stack area) */
PROVIDE(_fstack = ORIGIN(stack) + LENGTH(stack) - 4);
/* We have no ppi_static in wrs builds */
/* We have no ppi_static nor fifo_log in wrs builds */
PROVIDE(ppi_static = 0);
PROVIDE(fifo_log = 0);
}
......@@ -64,4 +64,7 @@ SECTIONS
/* First location in stack is highest address in STACK */
PROVIDE(_fstack = ORIGIN(stack) + LENGTH(stack) - 4);
/* This may be missing, according to .config */
PROVIDE(fifo_log = 0);
}
......@@ -231,6 +231,8 @@ struct dump_info dump_info[] = {
DUMP_HEADER("pll_fifo"),
DUMP_FIELD(uint32_t, trr),
DUMP_FIELD(uint32_t, tstamp),
DUMP_FIELD(uint32_t, duration),
DUMP_FIELD(uint16_t, irq_count),
DUMP_FIELD(uint16_t, tag_count),
/* FIXME: aux_state and ptracker_state -- variable-len arrays */
......
......@@ -21,6 +21,14 @@
#include "irq.h"
#ifdef CONFIG_SPLL_FIFO_LOG
struct spll_fifo_log fifo_log[FIFO_LOG_LEN];
#define HAS_FIFO_LOG 1
#else
#define HAS_FIFO_LOG 0
extern struct spll_fifo_log *fifo_log;
#endif
volatile struct SPLL_WB *SPLL;
volatile struct PPSG_WB *PPSG;
......@@ -224,26 +232,34 @@ static inline void update_loops(struct softpll_state *s, int tag_value, int tag_
}
}
struct spll_fifo_log fifo_log[FIFO_LOG_LEN];
void _irq_entry(void)
{
struct softpll_state *s = (struct softpll_state *)&softpll;
uint32_t trr;
int i, tag_source, tag_value;
static uint16_t tag_count;
struct spll_fifo_log *l;
struct spll_fifo_log *l = NULL;
uint32_t enter_stamp;
/* check if there are more tags in the FIFO, and log them */
if (HAS_FIFO_LOG)
enter_stamp = (PPSG->CNTR_NSEC & 0xfffffff);
/* check if there are more tags in the FIFO, and log them if so configured to */
while (!(SPLL->TRR_CSR & SPLL_TRR_CSR_EMPTY)) {
trr = SPLL->TRR_R0;
/* save this to a circular buffer */
i = tag_count % FIFO_LOG_LEN;
l = fifo_log + i;
l->trr = trr;
l->irq_count = s->irq_count & 0xffff;
l->tag_count = tag_count++;
if (HAS_FIFO_LOG) {
/* save this to a circular buffer */
i = tag_count % FIFO_LOG_LEN;
l = fifo_log + i;
l->tstamp = (PPSG->CNTR_NSEC & 0xfffffff);
if (!enter_stamp)
enter_stamp = l->tstamp;
l->duration = 0;
l->trr = trr;
l->irq_count = s->irq_count & 0xffff;
l->tag_count = tag_count++;
}
/* And process the values */
tag_source = SPLL_TRR_R0_CHAN_ID_R(trr);
......@@ -253,6 +269,8 @@ void _irq_entry(void)
update_loops(s, tag_value, tag_source);
}
if (HAS_FIFO_LOG && l)
l->duration = (PPSG->CNTR_NSEC & 0xfffffff) - enter_stamp;
s->irq_count++;
clear_irq();
}
......
......@@ -195,6 +195,8 @@ struct softpll_state {
struct spll_fifo_log {
uint32_t trr;
uint32_t tstamp;
uint32_t duration;
uint16_t irq_count;
uint16_t tag_count;
};
......
......@@ -317,7 +317,9 @@ int main(int argc, char **argv)
printf("fifo log at 0x%lx\n", fifo_off);
for (i = 0; i < FIFO_LOG_LEN; i++)
dump_many_fields(mapaddr + fifo_off + i * 8, "pll_fifo");
dump_many_fields(mapaddr + fifo_off
+ i * sizeof(struct spll_fifo_log),
"pll_fifo");
}
if (!strcmp(dumpname, "ppg"))
ppg_off = offset;
......
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