diff mbox series

[1/2] spi: ich: Limit slave->max_read_size

Message ID 20210728102857.526170-1-bmeng.cn@gmail.com
State Accepted
Commit 4dc82797585d87b61ec7b11bf54f8d302532cd55
Delegated to: Bin Meng
Headers show
Series [1/2] spi: ich: Limit slave->max_read_size | expand

Commit Message

Bin Meng July 28, 2021, 10:28 a.m. UTC
Since commit 43c145b8b3ee ("spi: ich: Correct max-size bug in ich_spi_adjust_size()")
(in v2020.04-rc1), SPI flash read no longer works with ICH SPI controller
in software sequencer mode.

ICH controller can only transfer a small number of bytes at once.
Before commit 43c145b8b3ee, the logic happens to make sure data.nbytes
is limited to slave->max_write_size but after commit 43c145b8b3ee
data.nbytes is no longer limited because slave->max_read_size is not
initialized with a valid number.

Fixes: 43c145b8b3ee ("spi: ich: Correct max-size bug in ich_spi_adjust_size()")
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
---

 drivers/spi/ich.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Simon Glass July 29, 2021, 1:32 a.m. UTC | #1
On Wed, 28 Jul 2021 at 04:29, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Since commit 43c145b8b3ee ("spi: ich: Correct max-size bug in ich_spi_adjust_size()")
> (in v2020.04-rc1), SPI flash read no longer works with ICH SPI controller
> in software sequencer mode.
>
> ICH controller can only transfer a small number of bytes at once.
> Before commit 43c145b8b3ee, the logic happens to make sure data.nbytes
> is limited to slave->max_write_size but after commit 43c145b8b3ee
> data.nbytes is no longer limited because slave->max_read_size is not
> initialized with a valid number.
>
> Fixes: 43c145b8b3ee ("spi: ich: Correct max-size bug in ich_spi_adjust_size()")
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> ---
>
>  drivers/spi/ich.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Bin Meng July 29, 2021, 12:04 p.m. UTC | #2
On Thu, Jul 29, 2021 at 9:32 AM Simon Glass <sjg@chromium.org> wrote:
>
> On Wed, 28 Jul 2021 at 04:29, Bin Meng <bmeng.cn@gmail.com> wrote:
> >
> > Since commit 43c145b8b3ee ("spi: ich: Correct max-size bug in ich_spi_adjust_size()")
> > (in v2020.04-rc1), SPI flash read no longer works with ICH SPI controller
> > in software sequencer mode.
> >
> > ICH controller can only transfer a small number of bytes at once.
> > Before commit 43c145b8b3ee, the logic happens to make sure data.nbytes
> > is limited to slave->max_write_size but after commit 43c145b8b3ee
> > data.nbytes is no longer limited because slave->max_read_size is not
> > initialized with a valid number.
> >
> > Fixes: 43c145b8b3ee ("spi: ich: Correct max-size bug in ich_spi_adjust_size()")
> > Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> > ---
> >
> >  drivers/spi/ich.c | 6 ++++--
> >  1 file changed, 4 insertions(+), 2 deletions(-)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>

applied to u-boot-x86, thanks!
diff mbox series

Patch

diff --git a/drivers/spi/ich.c b/drivers/spi/ich.c
index 3d49c22a9d..08d54e86f4 100644
--- a/drivers/spi/ich.c
+++ b/drivers/spi/ich.c
@@ -918,12 +918,14 @@  static int ich_spi_child_pre_probe(struct udevice *dev)
 	struct spi_slave *slave = dev_get_parent_priv(dev);
 
 	/*
-	 * Yes this controller can only write a small number of bytes at
+	 * Yes this controller can only transfer a small number of bytes at
 	 * once! The limit is typically 64 bytes. For hardware sequencing a
 	 * a loop is used to get around this.
 	 */
-	if (!plat->hwseq)
+	if (!plat->hwseq) {
+		slave->max_read_size = priv->databytes;
 		slave->max_write_size = priv->databytes;
+	}
 	/*
 	 * ICH 7 SPI controller only supports array read command
 	 * and byte program command for SST flash