diff mbox series

[7/8] spi: spi-s3c64xx: Increase transfer timeout

Message ID 20200819123208.12337-8-l.stelmach@samsung.com (mailing list archive)
State Superseded
Headers show
Series Some fixes for spi-s3c64xx | expand

Commit Message

Łukasz Stelmach Aug. 19, 2020, 12:32 p.m. UTC
Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
---
 drivers/spi/spi-s3c64xx.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Krzysztof Kozlowski Aug. 19, 2020, 12:49 p.m. UTC | #1
On Wed, Aug 19, 2020 at 02:32:07PM +0200, Łukasz Stelmach wrote:
> Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>

Why? Everything works fine and suddenly minimum timeout is 100 ms?

Best regards,
Krzysztof

> ---
>  drivers/spi/spi-s3c64xx.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
> index 27d77600a820..27db1e0f6f32 100644
> --- a/drivers/spi/spi-s3c64xx.c
> +++ b/drivers/spi/spi-s3c64xx.c
> @@ -464,7 +464,8 @@ static int s3c64xx_wait_for_dma(struct s3c64xx_spi_driver_data *sdd,
>  
>  	/* millisecs to xfer 'len' bytes @ 'cur_speed' */
>  	ms = xfer->len * 8 * 1000 / sdd->cur_speed;
> -	ms += 10; /* some tolerance */
> +	ms = (ms * 10) + 30;    /* some tolerance */
> +	ms = max(ms, 100);      /* minimum timeout */
>  
>  	val = msecs_to_jiffies(ms) + 10;
>  	val = wait_for_completion_timeout(&sdd->xfer_completion, val);
> -- 
> 2.26.2
>
Łukasz Stelmach Aug. 19, 2020, 1:39 p.m. UTC | #2
It was <2020-08-19 śro 14:49>, when Krzysztof Kozlowski wrote:
> On Wed, Aug 19, 2020 at 02:32:07PM +0200, Łukasz Stelmach wrote:
>> Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
>
> Why? Everything works fine and suddenly minimum timeout is 100 ms?

Actually I am not 100% sure the max() call is required, maybe +30 is
enough. Definitely some minimum value is required because for small
tranfers (100s of bytes) ms is 0 after the first assignment.

>> ---
>>  drivers/spi/spi-s3c64xx.c | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>> 
>> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
>> index 27d77600a820..27db1e0f6f32 100644
>> --- a/drivers/spi/spi-s3c64xx.c
>> +++ b/drivers/spi/spi-s3c64xx.c
>> @@ -464,7 +464,8 @@ static int s3c64xx_wait_for_dma(struct s3c64xx_spi_driver_data *sdd,
>>  
>>  	/* millisecs to xfer 'len' bytes @ 'cur_speed' */
>>  	ms = xfer->len * 8 * 1000 / sdd->cur_speed;
>> -	ms += 10; /* some tolerance */
>> +	ms = (ms * 10) + 30;    /* some tolerance */
>> +	ms = max(ms, 100);      /* minimum timeout */
>>  
>>  	val = msecs_to_jiffies(ms) + 10;
>>  	val = wait_for_completion_timeout(&sdd->xfer_completion, val);
>> -- 
>> 2.26.2
>> 
>
>
Krzysztof Kozlowski Aug. 21, 2020, 7:10 a.m. UTC | #3
On Wed, Aug 19, 2020 at 03:39:56PM +0200, Lukasz Stelmach wrote:
> It was <2020-08-19 śro 14:49>, when Krzysztof Kozlowski wrote:
> > On Wed, Aug 19, 2020 at 02:32:07PM +0200, Łukasz Stelmach wrote:
> >> Signed-off-by: Łukasz Stelmach <l.stelmach@samsung.com>
> >
> > Why? Everything works fine and suddenly minimum timeout is 100 ms?
> 
> Actually I am not 100% sure the max() call is required, maybe +30 is
> enough. Definitely some minimum value is required because for small
> tranfers (100s of bytes) ms is 0 after the first assignment.

Sure, just please describe it all in commit msg. All these questions
"why?" came because of lack of explanation in commit msg.

I guess minimum timeout 100 ms for each transfer is quite high, so maybe
just bump the tolerance to 30 which also would be a minimum timeout.

Best regards,
Krzysztof


> 
> >> ---
> >>  drivers/spi/spi-s3c64xx.c | 3 ++-
> >>  1 file changed, 2 insertions(+), 1 deletion(-)
> >> 
> >> diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
> >> index 27d77600a820..27db1e0f6f32 100644
> >> --- a/drivers/spi/spi-s3c64xx.c
> >> +++ b/drivers/spi/spi-s3c64xx.c
> >> @@ -464,7 +464,8 @@ static int s3c64xx_wait_for_dma(struct s3c64xx_spi_driver_data *sdd,
> >>  
> >>  	/* millisecs to xfer 'len' bytes @ 'cur_speed' */
> >>  	ms = xfer->len * 8 * 1000 / sdd->cur_speed;
> >> -	ms += 10; /* some tolerance */
> >> +	ms = (ms * 10) + 30;    /* some tolerance */
> >> +	ms = max(ms, 100);      /* minimum timeout */
> >>  
> >>  	val = msecs_to_jiffies(ms) + 10;
> >>  	val = wait_for_completion_timeout(&sdd->xfer_completion, val);
> >> -- 
> >> 2.26.2
> >> 
> >
> >
> 
> -- 
> Łukasz Stelmach
> Samsung R&D Institute Poland
> Samsung Electronics
diff mbox series

Patch

diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 27d77600a820..27db1e0f6f32 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -464,7 +464,8 @@  static int s3c64xx_wait_for_dma(struct s3c64xx_spi_driver_data *sdd,
 
 	/* millisecs to xfer 'len' bytes @ 'cur_speed' */
 	ms = xfer->len * 8 * 1000 / sdd->cur_speed;
-	ms += 10; /* some tolerance */
+	ms = (ms * 10) + 30;    /* some tolerance */
+	ms = max(ms, 100);      /* minimum timeout */
 
 	val = msecs_to_jiffies(ms) + 10;
 	val = wait_for_completion_timeout(&sdd->xfer_completion, val);