summaryrefslogtreecommitdiff
path: root/chip
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-08-22 14:49:59 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-08-23 15:36:31 -0700
commit072d333f100f29b696e8b6be14babfae063bfcbc (patch)
tree2a7ca802bc4b518924738b10b84a4b93473088fa /chip
parent8fd12a56f171ddc54158eace07df6b8cf79a7c3a (diff)
downloadchrome-ec-072d333f100f29b696e8b6be14babfae063bfcbc.tar.gz
npcx: shi: Properly disable interrupts throughout sending of HC response
Expand interrupt disable to include checking of our SHI state in case preemption occurs immediately afterward. BUG=chrome-os-partner:55795 BRANCH=None TEST=Manual on kevin, verify no errors through 700+ sysjumps. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: Icb8a5bdd03dbf87f6a25b4175f73c932d48db726 Reviewed-on: https://chromium-review.googlesource.com/374021 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Aseda Aboagye <aaboagye@chromium.org> Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
Diffstat (limited to 'chip')
-rw-r--r--chip/npcx/shi.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/chip/npcx/shi.c b/chip/npcx/shi.c
index 6cf030cf7c..76118abaa7 100644
--- a/chip/npcx/shi.c
+++ b/chip/npcx/shi.c
@@ -195,14 +195,15 @@ static uint8_t shi_read_buf_pointer(void);
*/
static void shi_send_response_packet(struct host_packet *pkt)
{
+ /*
+ * Disable interrupts. This routine is not called from interrupt
+ * context and buffer underrun will likely occur if it is
+ * preempted after writing its initial reply byte. Also, we must be
+ * sure our state doesn't unexpectedly change, in case we're expected
+ * to take RESP_NOT_RDY actions.
+ */
+ interrupt_disable();
if (state == SHI_STATE_PROCESSING) {
- /*
- * Disable interrupts. This routine is not called from interrupt
- * context and buffer underrun will likely occur if it is
- * preempted after writing its initial reply byte.
- */
- interrupt_disable();
-
/* Append our past-end byte, which we reserved space for. */
((uint8_t *) pkt->response)[pkt->response_size + 0] =
EC_SPI_PAST_END;
@@ -226,8 +227,6 @@ static void shi_send_response_packet(struct host_packet *pkt)
#ifdef NPCX_SHI_BYPASS_OVER_256B
}
#endif
-
- interrupt_enable();
}
/*
* If we're not processing, then the AP has already terminated the
@@ -239,6 +238,7 @@ static void shi_send_response_packet(struct host_packet *pkt)
DEBUG_CPRINTF("END\n");
} else
DEBUG_CPRINTS("Unexpected state %d in response handler", state);
+ interrupt_enable();
}
void shi_handle_host_package(void)