Skip to contentSkip to conversation

spi: core: Increase timeout value

PATCH Superseded Harini Katakam 3 participants 4 messages Apr 10, 2014 – Apr 11, 2014 SPI

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 spi: core: Increase timeout value

The existing timeout value in wait_for_completion_timeout is calculated from the transfer length and speed with tolerance of 10msec. This is too low because this is used for error conditions such as hardware hang etc.
The xfer->speed_hz considered may not be the actual speed set because the best clock divisor is chosen from a limited set such that the actual speed <= requested speed. This will lead to timeout being less than actual transfer time.
Considering acceptable latencies, this timeout can be set to a large value >= 1*HZ typically.
This patch adds a tolerance of 2000 msec in the core accordingly.

---
 drivers/spi/spi.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/spi.c +1 -1
index 4eb9bf0..3fdecfa 100644
@@ -775,7 +775,7 @@ static int spi_transfer_one_message(struct spi_master *master,
 		if (ret > 0) {
 			ret = 0;
 			ms = xfer->len * 8 * 1000 / xfer->speed_hz;
-			ms += 10; /* some tolerance */
+			ms += 2000; /* some tolerance */
 
 			ms = wait_for_completion_timeout(&master->xfer_completion,
 							 msecs_to_jiffies(ms));
Signature · 1 line
1.7.9.5
maintainer
#1 lore raw
Quoted 4 lines · Harini Katakam

Considering acceptable latencies, this timeout can be set to a large value >= 1*HZ typically.

This patch adds a tolerance of 2000 msec in the core accordingly.

That's too much, it's 2 seconds which gets to be incredibly painful when trying to debug problems - if you're sitting there waiting for a driver to time out some operations (and it may be more than one of them) so you can look at the diagnostics it can be quite aggrivating. That's why the delays are related to the expected runtime for the operation. Something like double the expected runtime plus something in the 100ms or so range perhaps?

Ideally we'd use the actual speed the device set rather than the requested one too, that'd help.

#2 lore raw

Hi Mark,

Quoted 7 lines · Mark Brown
Quoted 4 lines · Harini Katakam

Considering acceptable latencies, this timeout can be set to a large value >= 1*HZ typically.

This patch adds a tolerance of 2000 msec in the core accordingly.

Quoted 8 lines

That's too much, it's 2 seconds which gets to be incredibly painful when trying to debug problems - if you're sitting there waiting for a driver to time out some operations (and it may be more than one of them) so you can look at the diagnostics it can be quite aggrivating. That's why the delays are related to the expected runtime for the operation. Something like double the expected runtime plus something in the 100ms or so range perhaps?

OK.

Quoted 2 lines

Ideally we'd use the actual speed the device set rather than the requested one too, that'd help.

How would you propose to do that - driver should write back actual speed set to xfer->speed_hz?

Regards,
Harini
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

maintainer
#3 lore raw
Quoted 7 lines · Harini Katakam
Quoted 2 lines · Mark Brown

Ideally we'd use the actual speed the device set rather than the requested one too, that'd help.

How would you propose to do that - driver should write back actual speed set to xfer->speed_hz?

I'm thinking something more like having a variable in the driver struct for the current speed (like you do in your own and some others do).