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>
This commit is contained in:
Shawn Nematbakhsh
2016-08-22 14:49:59 -07:00
committed by chrome-bot
parent 8fd12a56f1
commit 072d333f10

View File

@@ -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)