From ed910689173561acf3a6998e1d671c84e22f5145 Mon Sep 17 00:00:00 2001 From: Shawn Nematbakhsh Date: Wed, 4 May 2016 18:21:15 -0700 Subject: npcx: shi: Fixes for REBOOT_EC host command handling - For REBOOT_EC and several other host commands, send_response may be called multiple times (once for early success notification, one for actual notification, if the handler exits cleanly). Ignore calls after the first. - During reboot / sysjump, we're not equipped to handle host commands, so disable the SHI interface altogether. BUG=chrome-os-partner:52878 TEST=Manual on kevin. Verify "ectool reboot_ec RO" (RO to RO = NOP) succeeds without error messages on EC console. Verify "ectool reboot_ec RW" causes sysjump without AP going down. BRANCH=None Change-Id: Iae83084e4f8d5218600be2a9da7f71dd7872d569 Signed-off-by: Shawn Nematbakhsh Reviewed-on: https://chromium-review.googlesource.com/342622 Commit-Ready: Shawn N Tested-by: Shawn N Reviewed-by: Mulin Chao Reviewed-by: Vincent Palatin --- chip/npcx/shi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/chip/npcx/shi.c b/chip/npcx/shi.c index ca5c4ac774..6512b2c636 100644 --- a/chip/npcx/shi.c +++ b/chip/npcx/shi.c @@ -194,16 +194,6 @@ static int shi_read_inbuf_wait(uint16_t szbytes); */ static void shi_send_response_packet(struct host_packet *pkt) { - /* Append our past-end byte, which we reserved space for. */ - ((uint8_t *) pkt->response)[pkt->response_size + 0] = EC_SPI_PAST_END; - - /* Computing sending bytes of response */ - shi_params.sz_response = pkt->response_size + SHI_PROTO3_OVERHEAD; - - /* - * Before the state is set to SENDING, any CS de-assertion would - * give up sending. - */ if (state == SHI_STATE_PROCESSING) { /* * Disable interrupts. This routine is not called from interrupt @@ -211,6 +201,15 @@ static void shi_send_response_packet(struct host_packet *pkt) * 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; + + /* Computing sending bytes of response */ + shi_params.sz_response = + pkt->response_size + SHI_PROTO3_OVERHEAD; + /* * Disable SHI interrupt until we have prepared * the first package to output @@ -246,7 +245,7 @@ static void shi_send_response_packet(struct host_packet *pkt) shi_reset_prepare(); DEBUG_CPRINTF("END\n"); } else - CPRINTS("Unexpected state %d in response handler\n", state); + DEBUG_CPRINTS("Unexpected state %d in response handler", state); } void shi_handle_host_package(void) @@ -747,6 +746,7 @@ static void shi_disable(void) gpio_config_module(MODULE_SPI, 0); } DECLARE_HOOK(HOOK_CHIPSET_SUSPEND, shi_disable, HOOK_PRIO_DEFAULT); +DECLARE_HOOK(HOOK_SYSJUMP, shi_disable, HOOK_PRIO_DEFAULT); static void shi_init(void) { -- cgit v1.2.1