summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShawn Nematbakhsh <shawnn@chromium.org>2016-06-28 15:13:21 -0700
committerchrome-bot <chrome-bot@chromium.org>2016-06-29 21:32:03 -0700
commitf15216344cca5ed7ddc12fc38116ae1a3aa6e4b4 (patch)
tree47f0992d3fcfaecd42dd72ac045090ea71fce195
parent978c4961d605a2da7e79396b1f8db3d543db9059 (diff)
downloadchrome-ec-f15216344cca5ed7ddc12fc38116ae1a3aa6e4b4.tar.gz
npcx: shi: Use worst-case logic for applying 256B bypass
SHI_OBUF_VALID_OFFSET may wrap on buffer full, leaving us with an incorrect tally of bytes transmitted. Always assume the worst case, that SHI_OBUF_VALID_OFFSET is at maximum, when deciding to apply 256B bypass. BUG=chrome-os-partner:54566 BRANCH=None TEST=Manual on gru. Verify 'flashrom -p ec -r read.bin' does not produce CRC errors. Signed-off-by: Shawn Nematbakhsh <shawnn@chromium.org> Change-Id: I7c0ccc1b555838854584a3be8ced50057eaea961 Reviewed-on: https://chromium-review.googlesource.com/356771 Commit-Ready: Shawn N <shawnn@chromium.org> Tested-by: Shelley Chen <shchen@chromium.org> Tested-by: Shawn N <shawnn@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Mulin Chao <mlchao@nuvoton.com>
-rw-r--r--chip/npcx/shi.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/chip/npcx/shi.c b/chip/npcx/shi.c
index a843612f04..482d0b74b8 100644
--- a/chip/npcx/shi.c
+++ b/chip/npcx/shi.c
@@ -410,14 +410,13 @@ static void shi_write_first_pkg_outbuf(uint16_t szbytes)
uint16_t i;
uint16_t offset, size;
- offset = SHI_OBUF_VALID_OFFSET;
-
#ifdef NPCX_SHI_BYPASS_OVER_256B
/*
* If response package is across 256 bytes boundary,
* bypass needs to extend PROCESSING bytes after reaching the boundary.
*/
- if (shi_params.bytes_in_256b + offset + szbytes > SHI_BYPASS_BOUNDARY) {
+ if (shi_params.bytes_in_256b + SHI_OBUF_FULL_SIZE + szbytes
+ > SHI_BYPASS_BOUNDARY) {
state = SHI_STATE_WAIT_ALIGNMENT;
/* Set pointer of output buffer to the start address */
shi_params.tx_buf = SHI_OBUF_START_ADDR;
@@ -426,6 +425,7 @@ static void shi_write_first_pkg_outbuf(uint16_t szbytes)
}
#endif
+ offset = SHI_OBUF_VALID_OFFSET;
shi_params.tx_buf = SHI_OBUF_START_ADDR + offset;
/* Fill half output buffer */
size = MIN(SHI_OBUF_HALF_SIZE - (offset % SHI_OBUF_HALF_SIZE),