Skip to content

Commit

Permalink
spi/dw_spi: Fix too short timeout in spi polling loop
Browse files Browse the repository at this point in the history
The SPI polling loop timeout only works with HZ=100 as the loop was
actually too short.

Also add appropriate cpu_relax() in the busy wait loops...

Signed-off-by: Arjan van de Ven <arjan@linux.intel.com>
Signed-off-by: Alan Cox <alan@linux.intel.com>
Signed-off-by: Feng Tang <feng.tang@intel.com>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
  • Loading branch information
Feng Tang authored and Grant Likely committed Dec 24, 2010
1 parent 5e8b821 commit ebf45b7
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions drivers/spi/dw_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,20 +164,23 @@ 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(1000);
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 1000us after a read/write!\n");
"DW SPI: Status keeps busy for 5000us after a read/write!\n");
}

static void flush(struct dw_spi *dws)
{
while (dw_readw(dws, sr) & SR_RF_NOT_EMPT)
while (dw_readw(dws, sr) & SR_RF_NOT_EMPT) {
dw_readw(dws, dr);
cpu_relax();
}

wait_till_not_busy(dws);
}
Expand Down

0 comments on commit ebf45b7

Please sign in to comment.