stm32: fix GPIO EXTINT masking

The external interrupts above 15 are not used for GPIO IRQ handling, but
for special purpose interrupts from internal peripherals (e.g. RTC,
comparator, wake-up ...). When processing the GPIO interrupts, we should
explicitly skip those interrupts, else if a GPIO interrupt happens
first followed by another EXTINT, the loop in gpio_interrupt() will try
to process it and do an out-of-bound read of the exti_events array.
This will retrieve a garbage handler triggering a memory fault.

Signed-off-by: Vincent Palatin <vpalatin@chromium.org>

BRANCH=none
BUG=chrome-os-partner:28296
TEST=on Firefly, press the buttons to trigger GPIO interrupts while
there are a bunch of comparator interrupt on EXTIN21 (due to on-going
USB PD communication). I no longer see HardFaults.

Change-Id: Id90fab30215b0f7f8060c19de63a7ca8418b7b3c
Reviewed-on: https://chromium-review.googlesource.com/197019
Commit-Queue: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vincent Palatin <vpalatin@chromium.org>
Reviewed-by: Vic Yang <victoryang@chromium.org>
This commit is contained in:
Vincent Palatin
2014-04-25 10:05:40 -07:00
committed by chrome-internal-fetch
parent 96ef35acba
commit cce53bed31
3 changed files with 6 additions and 3 deletions

View File

@@ -231,7 +231,8 @@ void gpio_interrupt(void)
{
int bit;
const struct gpio_info *g;
uint32_t pending = STM32_EXTI_PR;
/* process only GPIO EXTINTs (EXTINT0..15) not other EXTINTs */
uint32_t pending = STM32_EXTI_PR & 0xFFFF;
STM32_EXTI_PR = pending;

View File

@@ -232,7 +232,8 @@ void gpio_interrupt(void)
{
int bit;
const struct gpio_info *g;
uint32_t pending = STM32_EXTI_PR;
/* process only GPIO EXTINTs (EXTINT0..15) not other EXTINTs */
uint32_t pending = STM32_EXTI_PR & 0xFFFF;
STM32_EXTI_PR = pending;

View File

@@ -236,7 +236,8 @@ void gpio_interrupt(void)
{
int bit;
const struct gpio_info *g;
uint32_t pending = STM32_EXTI_PR;
/* process only GPIO EXTINTs (EXTINT0..15) not other EXTINTs */
uint32_t pending = STM32_EXTI_PR & 0xFFFF;
STM32_EXTI_PR = pending;