On Wed, 2 Mar 2011 10:41:18 +0800
"Tang, Feng" <[email protected]> wrote:
> Hi Venkat,
>
> If you disable the "mrst" earlyprintk, then there is no conflict.
>
> As I said in last email, if you still randomly see it, it's fine. The
> basic idea for the busy wait (code is listed here) is simple, after
> write/read the FIFO wait till the HW register tell us it's not busy
>
> static void wait_till_not_busy(struct dw_spi *dws)
> {
> unsigned long end = jiffies + 1 + usecs_to_jiffies(5000);
>
> while (time_before(jiffies, end)) {
> if (!(dw_readw(dws, sr) & SR_BUSY))
> return;
> cpu_relax();
> }
> dev_err(&dws->master->dev,
> "DW SPI: Status keeps busy for 5000us after a
> read/write!\n"); }
>
> 5000 us should be enough for dumping the DW spi controller's FIFO
> (which is 40 words deep) even for a low speed UART slave device at
> 115200 bps.
>
> If you still see lots of that message, can you enlarge that 5000 to
> 100000 to check if it's gone?
>
> Thanks,
> Feng
Venkat,
You can also try the attached debug patch, which adjust the wait time
dynamically.
----------------------------------------------------------
diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index 0f7ed08..e136897 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -164,7 +164,13 @@ static inline void mrst_spi_debugfs_remove(struct dw_spi
*dws)
static void wait_till_not_busy(struct dw_spi *dws)
{
- unsigned long end = jiffies + 1 + usecs_to_jiffies(5000);
+ int end, wait_us;
+
+ wait_us = dws->fifo_len * 16 * USEC_PER_SEC / dws->cur_chip->speed_hz;
+ /* Give it a 50% safe buffer */
+ wait_us += wait_us >> 1;
+
+ end = jiffies + 1 + usecs_to_jiffies(wait_us);
while (time_before(jiffies, end)) {
if (!(dw_readw(dws, sr) & SR_BUSY))
@@ -172,7 +178,8 @@ static void wait_till_not_busy(struct dw_spi *dws)
cpu_relax();
}
dev_err(&dws->master->dev,
- "DW SPI: Status keeps busy for 5000us after a read/write!\n");
+ "DW SPI: HW keeps busy for %d us after a read/write!\n",
+ wait_us);
}
static void flush(struct dw_spi *dws)
Thanks,
Feng
diff --git a/drivers/spi/dw_spi.c b/drivers/spi/dw_spi.c
index 0f7ed08..e136897 100644
--- a/drivers/spi/dw_spi.c
+++ b/drivers/spi/dw_spi.c
@@ -164,7 +164,13 @@ static inline void mrst_spi_debugfs_remove(struct dw_spi *dws)
static void wait_till_not_busy(struct dw_spi *dws)
{
- unsigned long end = jiffies + 1 + usecs_to_jiffies(5000);
+ int end, wait_us;
+
+ wait_us = dws->fifo_len * 16 * USEC_PER_SEC / dws->cur_chip->speed_hz;
+ /* Give it a 50% safe buffer */
+ wait_us += wait_us >> 1;
+
+ end = jiffies + 1 + usecs_to_jiffies(wait_us);
while (time_before(jiffies, end)) {
if (!(dw_readw(dws, sr) & SR_BUSY))
@@ -172,7 +178,8 @@ static void wait_till_not_busy(struct dw_spi *dws)
cpu_relax();
}
dev_err(&dws->master->dev,
- "DW SPI: Status keeps busy for 5000us after a read/write!\n");
+ "DW SPI: HW keeps busy for %d us after a read/write!\n",
+ wait_us);
}
static void flush(struct dw_spi *dws)
_______________________________________________
MeeGo-kernel mailing list
[email protected]
http://lists.meego.com/listinfo/meego-kernel