Skip to contentSkip to conversation

usb: usleep_range is preferred over udelay where wakeup is flexible

PATCH Superseded Sunny Kumar 2 participants 6 messages Jun 24, 2015 – Jun 25, 2015

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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.

---
 drivers/usb/storage/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/transport.c +1 -1
index 540add2..7cd45ac 100644
@@ -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 ? 
Signature · 1 line
2.1.4
maintainer
#1 lore raw
Quoted 15 lines · 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.

---
 drivers/usb/storage/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/transport.c +0 -0
index 540add2..7cd45ac 100644

drivers/usb/storage/transport.c int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us) · line 1114

Quoted 5 lines
drivers/usb/storage/transport.c +1 -1
@@ -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

#2 lore raw
In reply to Sunny Kumar

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

Sunny

Quoted 27 lines · 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.

---
 drivers/usb/storage/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/transport.c +1 -1
index 540add2..7cd45ac 100644
@@ -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 ? 
Signature · 3 lines
2.1.4

From 89648c1532e860b986fc5286245c404ddbe45b35 Mon Sep 17 00:00:00 2001

From: Sunny Kumar <[email protected]>
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.

---
 drivers/usb/storage/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/transport.c +1 -1
index 540add2..7e397f8 100644
@@ -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 ? 
Signature · 1 line
2.1.4
maintainer
#3 lore raw

Please don't top-post.

Quoted 1 line · Sunny Kumar

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

Or even just 150. That would be fine.

Alan Stern

#4 lore raw
In reply to Sunny Kumar

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

Sunny Kumar

Quoted 27 lines · 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.

---
 drivers/usb/storage/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/transport.c +1 -1
index 540add2..7cd45ac 100644
@@ -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 ? 
Signature · 3 lines
2.1.4

From 62bc3514ec4da51e7e766199d00de0594b17d23b Mon Sep 17 00:00:00 2001

From: Sunny Kumar <[email protected]>
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.

---
 drivers/usb/storage/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/transport.c +1 -1
index 540add2..5e67f63 100644
@@ -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 ? 
Signature · 1 line
1.9.1
#5 lore raw

PATCH 1/1 usb: usleep_range is preferred over udelay where wakeup is flexible

In reply to 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.

---
 drivers/usb/storage/transport.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/storage/transport.c +1 -1
index 540add2..5e67f63 100644
@@ -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 ? 
Signature · 1 line
1.9.1