power: Add power signal interrupt storm detection

Power signal interrupt storms are difficult to detect without extensive
debugging, so add a config option to help detect them in SW.

BUG=chromium:557988
BRANCH=None
TEST=None

Change-Id: I590ac8883e7615d05fd326245abade212b79e297
Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/313170
Commit-Ready: Shawn N <shawnn@chromium.org>
Tested-by: Shawn N <shawnn@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
Shawn Nematbakhsh
2015-11-18 14:36:00 -08:00
committed by chrome-bot
parent 2c8817117a
commit 1aa75c17c7
2 changed files with 41 additions and 0 deletions

View File

@@ -1431,6 +1431,13 @@
/* Support stopping in S5 on shutdown */
#undef CONFIG_POWER_SHUTDOWN_PAUSE_IN_S5
/*
* Detect power signal interrupt storms, defined as more than
* CONFIG_POWER_SIGNAL_INTERRUPT_STORM_DETECT_THRESHOLD occurences of a single
* power signal interrupt within one second.
*/
#undef CONFIG_POWER_SIGNAL_INTERRUPT_STORM_DETECT_THRESHOLD
/* Use part of the EC's data EEPROM to hold persistent storage for the AP. */
#undef CONFIG_PSTORE

View File

@@ -456,8 +456,42 @@ static void siglog_add(enum gpio_signal signal)
#define SIGLOG(S)
#endif /* CONFIG_BRINGUP */
#ifdef CONFIG_POWER_SIGNAL_INTERRUPT_STORM_DETECT_THRESHOLD
/*
* Print an interrupt storm warning when we receive more than
* CONFIG_POWER_SIGNAL_INTERRUPT_STORM_DETECT_THRESHOLD interrupts of a
* single source within 1 second.
*/
static int power_signal_interrupt_count[POWER_SIGNAL_COUNT];
static void reset_power_signal_interrupt_count(void)
{
int i;
for (i = 0; i < POWER_SIGNAL_COUNT; ++i)
power_signal_interrupt_count[i] = 0;
}
DECLARE_HOOK(HOOK_SECOND,
reset_power_signal_interrupt_count,
HOOK_PRIO_DEFAULT);
#endif
void power_signal_interrupt(enum gpio_signal signal)
{
#ifdef CONFIG_POWER_SIGNAL_INTERRUPT_STORM_DETECT_THRESHOLD
int i;
/* Tally our interrupts and print a warning if necessary. */
for (i = 0; i < POWER_SIGNAL_COUNT; ++i) {
if (power_signal_list[i].gpio == signal) {
if (power_signal_interrupt_count[i]++ ==
CONFIG_POWER_SIGNAL_INTERRUPT_STORM_DETECT_THRESHOLD)
CPRINTS("Interrupt storm! Signal %d\n", i);
break;
}
}
#endif
SIGLOG(signal);
/* Shadow signals and compare with our desired signal state. */