Skip to contentSkip to conversation

rt2x00: BUG: remove double loop on REGISTER_BUSY_COUNT

PATCH In review Richard Genoud 3 participants 7 messages Apr 3, 2014 – Apr 4, 2014 Networking drivers (wireless)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rt2x00: BUG: remove double loop on REGISTER_BUSY_COUNT

rt2x00usb_register_read_lock() calls rt2x00usb_vendor_req_buff_lock() that calls rt2x00usb_vendor_request() which is already looping up to REGISTER_BUSY_COUNT times.

So this loop is not needed.

---
 drivers/net/wireless/rt2x00/rt2x00usb.c | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/net/wireless/rt2x00/rt2x00usb.c +3 -6
index 10572452cc21..14142b099019 100644
@@ -148,12 +148,9 @@ int rt2x00usb_regbusy_read(struct rt2x00_dev *rt2x00dev,
 	if (!test_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags))
 		return -ENODEV;
 
-	for (i = 0; i < REGISTER_BUSY_COUNT; i++) {
-		rt2x00usb_register_read_lock(rt2x00dev, offset, reg);
-		if (!rt2x00_get_field32(*reg, field))
-			return 1;
-		udelay(REGISTER_BUSY_DELAY);
-	}
+	rt2x00usb_register_read_lock(rt2x00dev, offset, reg);
+	if (!rt2x00_get_field32(*reg, field))
+		return 1;
 
 	rt2x00_err(rt2x00dev, "Indirect register access failed: offset=0x%.08x, value=0x%.08x\n",
 		   offset, *reg);
Signature · 1 line
1.8.5.5
#1 lore raw
Quoted 5 lines · Richard Genoud

rt2x00usb_register_read_lock() calls rt2x00usb_vendor_req_buff_lock() that calls rt2x00usb_vendor_request() which is already looping up to REGISTER_BUSY_COUNT times.

So this loop is not needed.

Not true. rt2x00usb_vendor_request() busy-waits for usb_control_msg() to succeed, rt2x00usb_register_read_lock() busy-waits for the register field itself to become 0.

Also, how would this be a BUG?

	-- kuba
#2 lore raw

2014-04-03 17:37 GMT+02:00 Jakub Kiciński <[email protected]>:

Quoted 5 lines · Richard Genoud
Quoted 4 lines

rt2x00usb_register_read_lock() calls rt2x00usb_vendor_req_buff_lock() that calls rt2x00usb_vendor_request() which is already looping up to REGISTER_BUSY_COUNT times.

Quoted 7 lines
Quoted 1 line

So this loop is not needed.

Not true. rt2x00usb_vendor_request() busy-waits for usb_control_msg() to succeed, rt2x00usb_register_read_lock() busy-waits for the register field itself to become 0.

Also, how would this be a BUG?

Ok, you're right.
Just forget about this patch...

Richard

#3 lore raw
In reply to Jakub Kiciński
Quoted 10 lines · Jakub Kiciński
Quoted 5 lines · Richard Genoud

rt2x00usb_register_read_lock() calls rt2x00usb_vendor_req_buff_lock() that calls rt2x00usb_vendor_request() which is already looping up to REGISTER_BUSY_COUNT times.

So this loop is not needed.

Not true. rt2x00usb_vendor_request() busy-waits for usb_control_msg() to succeed, rt2x00usb_register_read_lock() busy-waits for the register field itself to become 0.

Yeah, but still we are looping REGISTER_BUSY_COUNT*REGISTER_BUSY_COUNT what seems to be far too long.

Stanislaw

#4 lore raw
Quoted 6 lines · Stanislaw Gruszka
Quoted 5 lines · Jakub Kiciński
Quoted 4 lines · Richard Genoud

rt2x00usb_register_read_lock() calls rt2x00usb_vendor_req_buff_lock() that calls rt2x00usb_vendor_request() which is already looping up to REGISTER_BUSY_COUNT times.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

So this loop is not needed.

Not true. rt2x00usb_vendor_request() busy-waits for usb_control_msg() to succeed, rt2x00usb_register_read_lock() busy-waits for the register field itself to become 0.

Yeah, but still we are looping REGISTER_BUSY_COUNT*REGISTER_BUSY_COUNT what seems to be far too long.

Yes, the busy waiting itself takes roughly 1s (100*100*100us) and then there are transfer times, so it might be too long indeed. Vendor driver waits only 10 * 5ms in RTUSB_VendorRequest() so rt2x00usb_vendor_request() seems like a better place to cut down the number of loops.

Alternatively we could make rt2x00usb_regbusy_read() check the retval from rt2x00usb_vendor_request() and exit early?

	-- kuba
#5 lore raw
Quoted 13 lines · Jakub Kiciński
Quoted 12 lines · Stanislaw Gruszka
Quoted 10 lines · Jakub Kiciński
Quoted 5 lines · Richard Genoud

rt2x00usb_register_read_lock() calls rt2x00usb_vendor_req_buff_lock() that calls rt2x00usb_vendor_request() which is already looping up to REGISTER_BUSY_COUNT times.

So this loop is not needed.

Not true. rt2x00usb_vendor_request() busy-waits for usb_control_msg() to succeed, rt2x00usb_register_read_lock() busy-waits for the register field itself to become 0.

Quoted 6 lines
Quoted 2 lines

Yeah, but still we are looping REGISTER_BUSY_COUNT*REGISTER_BUSY_COUNT what seems to be far too long.

Yes, the busy waiting itself takes roughly 1s (100*100*100us) and then there are transfer times, so it might be too long indeed. Vendor driver waits only 10 * 5ms in RTUSB_VendorRequest() so

We use "timeout" argument which is set to 500ms , so perhaps that could be the reason why Richard sees "infinite" loop i.e. 100*100*(500ms + 100us)

Quoted 5 lines

rt2x00usb_vendor_request() seems like a better place to cut down the number of loops.

Alternatively we could make rt2x00usb_regbusy_read() check the retval from rt2x00usb_vendor_request() and exit early?

Make sense, but I think we should review the area and make some more changes to fine tune the timeout of USB reg reading functions.

Stanislaw

#6 lore raw

2014-04-04 16:06 GMT+02:00 Stanislaw Gruszka <[email protected]>:

Quoted 17 lines · Jakub Kiciński
Quoted 16 lines · Stanislaw Gruszka
Quoted 14 lines · Jakub Kiciński
Quoted 10 lines · Richard Genoud
Quoted 5 lines

rt2x00usb_register_read_lock() calls rt2x00usb_vendor_req_buff_lock() that calls rt2x00usb_vendor_request() which is already looping up to REGISTER_BUSY_COUNT times.

So this loop is not needed.

Not true. rt2x00usb_vendor_request() busy-waits for usb_control_msg() to succeed, rt2x00usb_register_read_lock() busy-waits for the register field itself to become 0.

Yeah, but still we are looping REGISTER_BUSY_COUNT*REGISTER_BUSY_COUNT what seems to be far too long.

Quoted 7 lines
Quoted 3 lines

Yes, the busy waiting itself takes roughly 1s (100*100*100us) and then there are transfer times, so it might be too long indeed. Vendor driver waits only 10 * 5ms in RTUSB_VendorRequest() so

We use "timeout" argument which is set to 500ms , so perhaps that could be the reason why Richard sees "infinite" loop i.e. 100*100*(500ms + 100us)

That's what I thougth at the begining, so I applied this patch, but it was still looping on errors -EPROTO.

Quoted 10 lines
Quoted 5 lines

rt2x00usb_vendor_request() seems like a better place to cut down the number of loops.

Alternatively we could make rt2x00usb_regbusy_read() check the retval from rt2x00usb_vendor_request() and exit early?

Make sense, but I think we should review the area and make some more changes to fine tune the timeout of USB reg reading functions.

Stanislaw