linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup is flexible
@ 2015-06-24  6:54 Sunny Kumar
  2015-06-24 13:44 ` Alan Stern
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Sunny Kumar @ 2015-06-24  6:54 UTC (permalink / raw)
  To: mdharm-usb, gregkh, linux-usb, usb-storage, linux-kernel
  Cc: swt.sunny, Sunny Kumar

According to Documentation/timers/timers-howto.txt"
udelay() is only called once from a place where sleeping is allowed.
We can replace it with a call to usleep_range()
with a reasonable upper limit.

Signed-off-by: Sunny Kumar <sunny.kumar.roy@gmail.com>
---
 drivers/usb/storage/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 540add2..7cd45ac 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -1111,7 +1111,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
 	 * command phase and the data phase.  Some devices need a little
 	 * more than that, probably because of clock rate inaccuracies. */
 	if (unlikely(us->fflags & US_FL_GO_SLOW))
-		udelay(125);
+		usleep_range(100, 125);
 
 	if (transfer_length) {
 		unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup is flexible
  2015-06-24  6:54 [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup is flexible Sunny Kumar
@ 2015-06-24 13:44 ` Alan Stern
  2015-06-24 14:28 ` Sunny Kumar
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 6+ messages in thread
From: Alan Stern @ 2015-06-24 13:44 UTC (permalink / raw)
  To: Sunny Kumar
  Cc: mdharm-usb, gregkh, linux-usb, usb-storage, linux-kernel, swt.sunny

On Wed, 24 Jun 2015, Sunny Kumar wrote:

> According to Documentation/timers/timers-howto.txt"
> udelay() is only called once from a place where sleeping is allowed.
> We can replace it with a call to usleep_range()
> with a reasonable upper limit.
> 
> Signed-off-by: Sunny Kumar <sunny.kumar.roy@gmail.com>
> ---
>  drivers/usb/storage/transport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
> index 540add2..7cd45ac 100644
> --- a/drivers/usb/storage/transport.c
> +++ b/drivers/usb/storage/transport.c
> @@ -1111,7 +1111,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
>  	 * command phase and the data phase.  Some devices need a little
>  	 * more than that, probably because of clock rate inaccuracies. */
>  	if (unlikely(us->fflags & US_FL_GO_SLOW))
> -		udelay(125);
> +		usleep_range(100, 125);

You said you were going to use a reasonable upper limit.  Instead, you 
left the upper limit the same and decreased the lower limit, which 
could cause errors.

Alan Stern


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup is flexible
  2015-06-24  6:54 [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup is flexible Sunny Kumar
  2015-06-24 13:44 ` Alan Stern
@ 2015-06-24 14:28 ` Sunny Kumar
  2015-06-24 14:35   ` Alan Stern
  2015-06-24 15:45 ` Sunny Kumar
  2015-06-25 15:30 ` Sunny Kumar
  3 siblings, 1 reply; 6+ messages in thread
From: Sunny Kumar @ 2015-06-24 14:28 UTC (permalink / raw)
  To: mdharm-usb, gregkh, linux-usb, usb-storage, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1150 bytes --]

Ok so what about putting lower limit to 125 and increase upper limit 200


Sunny

On Wed, Jun 24, 2015 at 12:24:29PM +0530, Sunny Kumar wrote:
> According to Documentation/timers/timers-howto.txt"
> udelay() is only called once from a place where sleeping is allowed.
> We can replace it with a call to usleep_range()
> with a reasonable upper limit.
> 
> Signed-off-by: Sunny Kumar <sunny.kumar.roy@gmail.com>
> ---
>  drivers/usb/storage/transport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
> index 540add2..7cd45ac 100644
> --- a/drivers/usb/storage/transport.c
> +++ b/drivers/usb/storage/transport.c
> @@ -1111,7 +1111,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
>  	 * command phase and the data phase.  Some devices need a little
>  	 * more than that, probably because of clock rate inaccuracies. */
>  	if (unlikely(us->fflags & US_FL_GO_SLOW))
> -		udelay(125);
> +		usleep_range(100, 125);
>  
>  	if (transfer_length) {
>  		unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 
> -- 
> 2.1.4
> 

[-- Attachment #2: 0001-usb-usleep_range-is-preferred-over-udelay-where-wake.patch --]
[-- Type: text/x-diff, Size: 1202 bytes --]

>From 89648c1532e860b986fc5286245c404ddbe45b35 Mon Sep 17 00:00:00 2001
From: Sunny Kumar <sunny.kumar.roy@gmail.com>
Date: Wed, 24 Jun 2015 19:50:30 +0530
Subject: [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup
 is flexible

According to Documentation/timers/timers-howto.txt"
udelay() is only called once from a place where sleeping is allowed.
We can replace it with a call to usleep_range()
with a reasonable upper limit.

Signed-off-by: Sunny Kumar <sunny.kumar.roy@gmail.com>
---
 drivers/usb/storage/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 540add2..7e397f8 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -1111,7 +1111,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
 	 * command phase and the data phase.  Some devices need a little
 	 * more than that, probably because of clock rate inaccuracies. */
 	if (unlikely(us->fflags & US_FL_GO_SLOW))
-		udelay(125);
+		usleep_range(125, 200);
 
 	if (transfer_length) {
 		unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 
-- 
2.1.4


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup is flexible
  2015-06-24 14:28 ` Sunny Kumar
@ 2015-06-24 14:35   ` Alan Stern
  0 siblings, 0 replies; 6+ messages in thread
From: Alan Stern @ 2015-06-24 14:35 UTC (permalink / raw)
  To: Sunny Kumar; +Cc: mdharm-usb, gregkh, linux-usb, usb-storage, linux-kernel

Please don't top-post.

On Wed, 24 Jun 2015, Sunny Kumar wrote:

> Ok so what about putting lower limit to 125 and increase upper limit 200

Or even just 150.  That would be fine.

Alan Stern


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup is flexible
  2015-06-24  6:54 [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup is flexible Sunny Kumar
  2015-06-24 13:44 ` Alan Stern
  2015-06-24 14:28 ` Sunny Kumar
@ 2015-06-24 15:45 ` Sunny Kumar
  2015-06-25 15:30 ` Sunny Kumar
  3 siblings, 0 replies; 6+ messages in thread
From: Sunny Kumar @ 2015-06-24 15:45 UTC (permalink / raw)
  To: mdharm-usb, gregkh, linux-usb, usb-storage, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1144 bytes --]

Ok then,
This might be the final lower and upper limit value.

Sunny Kumar

On Wed, Jun 24, 2015 at 12:24:29PM +0530, Sunny Kumar wrote:
> According to Documentation/timers/timers-howto.txt"
> udelay() is only called once from a place where sleeping is allowed.
> We can replace it with a call to usleep_range()
> with a reasonable upper limit.
> 
> Signed-off-by: Sunny Kumar <sunny.kumar.roy@gmail.com>
> ---
>  drivers/usb/storage/transport.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
> index 540add2..7cd45ac 100644
> --- a/drivers/usb/storage/transport.c
> +++ b/drivers/usb/storage/transport.c
> @@ -1111,7 +1111,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
>  	 * command phase and the data phase.  Some devices need a little
>  	 * more than that, probably because of clock rate inaccuracies. */
>  	if (unlikely(us->fflags & US_FL_GO_SLOW))
> -		udelay(125);
> +		usleep_range(100, 125);
>  
>  	if (transfer_length) {
>  		unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 
> -- 
> 2.1.4
> 

[-- Attachment #2: 0001-usb-usleep_range-is-preferred-over-udelay-where-wake.patch --]
[-- Type: text/x-diff, Size: 1202 bytes --]

>From 62bc3514ec4da51e7e766199d00de0594b17d23b Mon Sep 17 00:00:00 2001
From: Sunny Kumar <sunny.kumar.roy@gmail.com>
Date: Wed, 24 Jun 2015 21:07:18 +0530
Subject: [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup
 is flexible

According to Documentation/timers/timers-howto.txt"
udelay() is only called once from a place where sleeping is allowed.
We can replace it with a call to usleep_range()
with a reasonable upper limit.

Signed-off-by: Sunny Kumar <sunny.kumar.roy@gmail.com>
---
 drivers/usb/storage/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 540add2..5e67f63 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -1111,7 +1111,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
 	 * command phase and the data phase.  Some devices need a little
 	 * more than that, probably because of clock rate inaccuracies. */
 	if (unlikely(us->fflags & US_FL_GO_SLOW))
-		udelay(125);
+		usleep_range(125, 150);
 
 	if (transfer_length) {
 		unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup is flexible
  2015-06-24  6:54 [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup is flexible Sunny Kumar
                   ` (2 preceding siblings ...)
  2015-06-24 15:45 ` Sunny Kumar
@ 2015-06-25 15:30 ` Sunny Kumar
  3 siblings, 0 replies; 6+ messages in thread
From: Sunny Kumar @ 2015-06-25 15:30 UTC (permalink / raw)
  To: mdharm-usb, gregkh, linux-usb, usb-storage, linux-kernel; +Cc: Sunny Kumar

According to Documentation/timers/timers-howto.txt"
udelay() is only called once from a place where sleeping is allowed.
We can replace it with a call to usleep_range()
with a reasonable upper limit.

Signed-off-by: Sunny Kumar <sunny.kumar.roy@gmail.com>
---
 drivers/usb/storage/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 540add2..5e67f63 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -1111,7 +1111,7 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
 	 * command phase and the data phase.  Some devices need a little
 	 * more than that, probably because of clock rate inaccuracies. */
 	if (unlikely(us->fflags & US_FL_GO_SLOW))
-		udelay(125);
+		usleep_range(125, 150);
 
 	if (transfer_length) {
 		unsigned int pipe = srb->sc_data_direction == DMA_FROM_DEVICE ? 
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2015-06-25 15:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-24  6:54 [PATCH 1/1] usb: usleep_range is preferred over udelay where wakeup is flexible Sunny Kumar
2015-06-24 13:44 ` Alan Stern
2015-06-24 14:28 ` Sunny Kumar
2015-06-24 14:35   ` Alan Stern
2015-06-24 15:45 ` Sunny Kumar
2015-06-25 15:30 ` Sunny Kumar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).