summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-06-27 12:42:57 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-06-28 19:27:57 -0700
commit369fbaf052dd76e74c3805302dd27f11c7e865bf (patch)
treef0390a38b768d918765980371af86c1b7e78d2c3 /chip
parentb9e9f7b8630f25f643e930972635775c1bb4512e (diff)
downloadchrome-ec-369fbaf052dd76e74c3805302dd27f11c7e865bf.tar.gz
npcx: shi: Avoid 'unexpected state' console spam
If SHI finds itself in an unexpected state, we may try to print an error message for each IBF / IBHF interrupt, which is excessively spammy and may even lead to EC watchdog. Avoid console spam by not duplicating IBF / IBHF / IBEOR error prints, if our state doesn't change. BUG=chrome-os-partner:54502 BRANCH=None TEST=Manual on gru. Verify only one print is seen when SHI fails due to missed initialization. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I331c64c24fa3a68d7c17e052240691076d3532cc Reviewed-on: https://chromium-review.googlesource.com/356239 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Mary Ruthven <mruthven@chromium.org>
Diffstat (limited to 'chip')
-rw-r--r--chip/npcx/shi.c26
1 files changed, 21 insertions, 5 deletions
diff --git a/chip/npcx/shi.c b/chip/npcx/shi.c
index 4d69220893..a843612f04 100644
--- a/chip/npcx/shi.c
+++ b/chip/npcx/shi.c
@@ -490,7 +490,7 @@ static void shi_bad_received_data(void)
shi_fill_out_status(EC_SPI_RX_BAD_DATA);
state = SHI_STATE_BAD_RECEIVED_DATA;
- CPRINTS("BAD-");
+ CPRINTF("BAD-");
CPRINTF("in_msg=[");
for (i = 0; i < shi_params.sz_received; i++)
CPRINTF("%02x ", in_msg[i]);
@@ -503,6 +503,21 @@ static void shi_bad_received_data(void)
task_enable_irq(NPCX_IRQ_SHI);
}
+/*
+ * Avoid spamming the console with prints every IBF / IBHF interrupt, if
+ * we find ourselves in an unexpected state.
+ */
+static int last_error_state = -1;
+
+static void log_unexpected_state(char *isr_name)
+{
+#if !(DEBUG_SHI)
+ if (state != last_error_state)
+ CPRINTS("Unexpected state %d in %s ISR", state, isr_name);
+#endif
+ last_error_state = state;
+}
+
/* This routine handles all interrupts of this module */
void shi_int_handler(void)
{
@@ -542,7 +557,7 @@ void shi_int_handler(void)
/* Error state for checking*/
if (state != SHI_STATE_SENDING)
- CPRINTS("Unexpected state %d in IBEOR ISR\n", state);
+ log_unexpected_state("IBEOR");
/* reset SHI and prepare to next transaction again */
shi_reset_prepare();
@@ -587,7 +602,7 @@ void shi_int_handler(void)
#endif
else
/* Unexpected status */
- CPRINTS("Unexpected state %d in IBHF ISR\n", state);
+ log_unexpected_state("IBHF");
}
/*
@@ -622,7 +637,7 @@ void shi_int_handler(void)
return;
else
/* Unexpected status */
- CPRINTS("Unexpected state %d in IBF ISR\n", state);
+ log_unexpected_state("IBF");
}
}
/*
@@ -657,7 +672,7 @@ void shi_cs_event(enum gpio_signal signal)
/* Chip select is low = asserted */
if (state != SHI_STATE_READY_TO_RECV) {
/* State machine should be reset in EVSTAT_EOR ISR */
- CPRINTS("Unexpected state %d in CS ISR\n", state);
+ CPRINTS("Unexpected state %d in CS ISR", state);
return;
}
@@ -706,6 +721,7 @@ static void shi_reset_prepare(void)
/* Ready to receive */
state = SHI_STATE_READY_TO_RECV;
+ last_error_state = -1;
DEBUG_CPRINTF("RDY-");
}