From 22418428ed28d803bfca151623bbf017d1ba6bfc Mon Sep 17 00:00:00 2001 From: Nico Huber Date: Thu, 8 Mar 2018 16:14:15 +0100 Subject: linux_spi: Reduce maximum read chunksize It turned out that older kernels use a single buffer of `bufsiz` bytes for combined input and output data. So we have to account for the read command + max 4 address bytes. Change-Id: Ide50db38af1004fde09a70b15938e77f5e1285ac Signed-off-by: Nico Huber Tested-by: Julian von Mendel Reviewed-on: https://review.coreboot.org/25149 Tested-by: build bot (Jenkins) Reviewed-by: Julian von Mendel Reviewed-by: David Hendricks --- linux_spi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/linux_spi.c b/linux_spi.c index 1d3605aa..714e612e 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -221,8 +221,9 @@ static int linux_spi_send_command(struct flashctx *flash, unsigned int writecnt, static int linux_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len) { - /* Read buffer is fully utilized for data. */ - return spi_read_chunked(flash, buf, start, len, max_kernel_buf_size); + /* Older kernels use a single buffer for combined input and output + data. So account for longest possible command + address, too. */ + return spi_read_chunked(flash, buf, start, len, max_kernel_buf_size - 5); } static int linux_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len) -- cgit v1.2.3