Patch "spi: sunxi: fix transfer timeout" has been added to the 4.6-stable tree
Subsystems (3)
This is a note to let you know that I've just added the patch titled
spi: sunxi: fix transfer timeout
to the 4.6-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
spi-sunxi-fix-transfer-timeout.patch
and it can be found in the queue-4.6 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From
719bd6542044efd9b338a53dba1bef45f40ca169Mon Sep 17 00:00:00 2001
From: Michal Suchanek <[email protected]>
Date: Mon, 13 Jun 2016 17:46:49 +0000
Subject: spi: sunxi: fix transfer timeout
From: Michal Suchanek <[email protected]>
commit 719bd6542044efd9b338a53dba1bef45f40ca169 upstream.
The trasfer timeout is fixed at 1000 ms. Reading a 4Mbyte flash over 1MHz SPI bus takes way longer than that. Calculate the timeout from the actual time the transfer is supposed to take and multiply by 2 for good measure.
--- drivers/spi/spi-sun4i.c | 10 +++++++++- drivers/spi/spi-sun6i.c | 10 +++++++++- 2 files changed, 18 insertions(+), 2 deletions(-)
drivers/spi/spi-sun4i.c +9 -1
@@ -173,6 +173,7 @@ static int sun4i_spi_transfer_one(struct {struct sun4i_spi *sspi =spi_master_get_devdata (master);unsigned int mclk_rate, div, timeout; +unsigned int start, end, tx_time;unsigned int tx_len =0 ;int ret =0 ;u32 reg;
@@ -279,9 +280,16 @@ static int sun4i_spi_transfer_one(struct reg =sun4i_spi_read (sspi,SUN4I_CTL_REG );sun4i_spi_write (sspi,SUN4I_CTL_REG , reg |SUN4I_CTL_XCH ); + tx_time =max (tfr->len *8 *2 / (tfr->speed_hz /1000 ),100U ); + start = jiffies; timeout =wait_for_completion_timeout (&sspi->done, -msecs_to_jiffies (1000 )); +msecs_to_jiffies (tx_time)); + end = jiffies;if (!timeout) { +dev_warn (&master->dev, +"%s: timeout transferring %u bytes@%iHz for %i(%i)ms" , +dev_name (&spi->dev), tfr->len, tfr->speed_hz, +jiffies_to_msecs (end - start), tx_time); ret = -ETIMEDOUT ; goto out; }
drivers/spi/spi-sun6i.c +9 -1
@@ -160,6 +160,7 @@ static int sun6i_spi_transfer_one(struct {struct sun6i_spi *sspi =spi_master_get_devdata (master);unsigned int mclk_rate, div, timeout; +unsigned int start, end, tx_time;unsigned int tx_len =0 ;int ret =0 ;u32 reg;
@@ -269,9 +270,16 @@ static int sun6i_spi_transfer_one(struct reg =sun6i_spi_read (sspi,SUN6I_TFR_CTL_REG );sun6i_spi_write (sspi,SUN6I_TFR_CTL_REG , reg |SUN6I_TFR_CTL_XCH ); + tx_time =max (tfr->len *8 *2 / (tfr->speed_hz /1000 ),100U ); + start = jiffies; timeout =wait_for_completion_timeout (&sspi->done, -msecs_to_jiffies (1000 )); +msecs_to_jiffies (tx_time)); + end = jiffies;if (!timeout) { +dev_warn (&master->dev, +"%s: timeout transferring %u bytes@%iHz for %i(%i)ms" , +dev_name (&spi->dev), tfr->len, tfr->speed_hz, +jiffies_to_msecs (end - start), tx_time); ret = -ETIMEDOUT ; goto out; }
Patches currently in stable-queue which might be from [email protected] are
queue-4.6/spi-sun4i-fix-fifo-limit.patchqueue-4.6/spi-sunxi-fix-transfer-timeout.patch