Skip to content

Commit 97f6846

Browse files
committed
[ot] hw/opentitan: ot_spi_device: improve traces when entering error state
Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
1 parent 260f9b4 commit 97f6846

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

hw/opentitan/ot_spi_device.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -890,8 +890,9 @@ static void ot_spi_device_flash_change_state_line(
890890
SpiDeviceFlash *f, OtSpiFlashState state, int line)
891891
{
892892
if (f->state != state) {
893-
trace_ot_spi_device_flash_change_state(line, FLASH_STATE_NAME(state),
894-
state);
893+
trace_ot_spi_device_flash_change_state(line, FLASH_STATE_NAME(f->state),
894+
f->state,
895+
FLASH_STATE_NAME(state), state);
895896
f->state = state;
896897
}
897898
}
@@ -1628,6 +1629,7 @@ static uint8_t ot_spi_device_flash_transfer(OtSPIDeviceState *s, uint8_t rx)
16281629
break;
16291630
case SPI_FLASH_CMD_NONE:
16301631
/* this command cannot be processed, discard all remaining bytes */
1632+
trace_ot_spi_device_flash_unknown_command(rx);
16311633
FLASH_CHANGE_STATE(f, ERROR);
16321634
BUS_CHANGE_STATE(&s->bus, DISCARD);
16331635
break;

hw/opentitan/trace-events

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -436,7 +436,7 @@ ot_spi_device_bus_change_state(int line, const char *state, int stateval) "@%d:
436436
ot_spi_device_chr_cs_assert(unsigned count, bool release, char rx, char tx, const char *st) "0x%x bytes, /cs: %u, rx: %csb, tx: %csb, mode:%s"
437437
ot_spi_device_chr_error(const char *err) "%s"
438438
ot_spi_device_flash_byte_unexpected(uint8_t rx) "unexpected byte 0x%02x after completed command"
439-
ot_spi_device_flash_change_state(int line, const char *state, int stateval) "@%d: %s [%d]"
439+
ot_spi_device_flash_change_state(int line, const char *prev, int preval, const char *next, int nextval) "@%d: %s[%d] -> %s[%d]"
440440
ot_spi_device_flash_cross_buffer(const char *msg, uint32_t addr) "%s 0x%08x"
441441
ot_spi_device_flash_disabled_slot(uint8_t cmd, unsigned slot) "cmd 0x%02x matching disabled slot %u"
442442
ot_spi_device_flash_exec(const char *cmd) "%s"
@@ -449,6 +449,7 @@ ot_spi_device_flash_push_address(uint32_t address) "0x%08x"
449449
ot_spi_device_flash_set_read_addr(uint32_t addr) "0x%08x"
450450
ot_spi_device_flash_read_status(unsigned slot, uint8_t status) "sr[%u] 0x%02x"
451451
ot_spi_device_flash_read_threshold(uint32_t addr, uint32_t threshold) "0x%08x @ 0x%08x"
452+
ot_spi_device_flash_unknown_command(uint8_t opcode) "0x%02x"
452453
ot_spi_device_flash_upload(unsigned slot, uint32_t cmd_info, bool busy) "slot:%d info:0x%08x busy:%u"
453454
ot_spi_device_gen_fifo_error(const char *msg) "%s"
454455
ot_spi_device_gen_phase(const char *func, unsigned off, unsigned lim, bool phase) "%s off:0x%03x lim:0x%03x ph:%u"

0 commit comments

Comments
 (0)