* [PATCH] rt2x00: BUG: remove double loop on REGISTER_BUSY_COUNT
@ 2014-04-03 14:12 Richard Genoud
2014-04-03 15:37 ` Jakub Kiciński
0 siblings, 1 reply; 7+ messages in thread
From: Richard Genoud @ 2014-04-03 14:12 UTC (permalink / raw)
To: Ivo van Doorn
Cc: Gertjan van Wingerde, Helmut Schaa, John W. Linville,
linux-wireless, linux-kernel, 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.
Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
---
drivers/net/wireless/rt2x00/rt2x00usb.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.c b/drivers/net/wireless/rt2x00/rt2x00usb.c
index 10572452cc21..14142b099019 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.c
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.c
@@ -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);
--
1.8.5.5
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH] rt2x00: BUG: remove double loop on REGISTER_BUSY_COUNT
2014-04-03 14:12 [PATCH] rt2x00: BUG: remove double loop on REGISTER_BUSY_COUNT Richard Genoud
@ 2014-04-03 15:37 ` Jakub Kiciński
2014-04-03 15:46 ` Richard Genoud
2014-04-04 8:19 ` Stanislaw Gruszka
0 siblings, 2 replies; 7+ messages in thread
From: Jakub Kiciński @ 2014-04-03 15:37 UTC (permalink / raw)
To: Richard Genoud
Cc: Ivo van Doorn, Gertjan van Wingerde, Helmut Schaa,
John W. Linville, linux-wireless, linux-kernel
On Thu, 3 Apr 2014 16:12:07 +0200, Richard Genoud wrote:
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rt2x00: BUG: remove double loop on REGISTER_BUSY_COUNT
2014-04-03 15:37 ` Jakub Kiciński
@ 2014-04-03 15:46 ` Richard Genoud
2014-04-04 8:19 ` Stanislaw Gruszka
1 sibling, 0 replies; 7+ messages in thread
From: Richard Genoud @ 2014-04-03 15:46 UTC (permalink / raw)
To: Jakub Kiciński
Cc: Ivo van Doorn, Gertjan van Wingerde, Helmut Schaa,
John W. Linville, linux-wireless, linux-kernel@vger.kernel.org
2014-04-03 17:37 GMT+02:00 Jakub Kiciński <moorray3@wp.pl>:
> On Thu, 3 Apr 2014 16:12:07 +0200, Richard Genoud wrote:
>> 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?
Ok, you're right.
Just forget about this patch...
Richard
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rt2x00: BUG: remove double loop on REGISTER_BUSY_COUNT
2014-04-03 15:37 ` Jakub Kiciński
2014-04-03 15:46 ` Richard Genoud
@ 2014-04-04 8:19 ` Stanislaw Gruszka
2014-04-04 9:01 ` Jakub Kiciński
1 sibling, 1 reply; 7+ messages in thread
From: Stanislaw Gruszka @ 2014-04-04 8:19 UTC (permalink / raw)
To: Jakub Kiciński
Cc: Richard Genoud, Ivo van Doorn, Gertjan van Wingerde, Helmut Schaa,
John W. Linville, linux-wireless, linux-kernel
On Thu, Apr 03, 2014 at 05:37:01PM +0200, Jakub Kiciński wrote:
> On Thu, 3 Apr 2014 16:12:07 +0200, Richard Genoud wrote:
> > 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rt2x00: BUG: remove double loop on REGISTER_BUSY_COUNT
2014-04-04 8:19 ` Stanislaw Gruszka
@ 2014-04-04 9:01 ` Jakub Kiciński
2014-04-04 14:06 ` Stanislaw Gruszka
0 siblings, 1 reply; 7+ messages in thread
From: Jakub Kiciński @ 2014-04-04 9:01 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: Richard Genoud, Ivo van Doorn, Gertjan van Wingerde, Helmut Schaa,
John W. Linville, linux-wireless, linux-kernel
On Fri, 4 Apr 2014 10:19:09 +0200, Stanislaw Gruszka wrote:
> On Thu, Apr 03, 2014 at 05:37:01PM +0200, Jakub Kiciński wrote:
> > On Thu, 3 Apr 2014 16:12:07 +0200, Richard Genoud wrote:
> > > 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.
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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rt2x00: BUG: remove double loop on REGISTER_BUSY_COUNT
2014-04-04 9:01 ` Jakub Kiciński
@ 2014-04-04 14:06 ` Stanislaw Gruszka
2014-04-04 14:17 ` Richard Genoud
0 siblings, 1 reply; 7+ messages in thread
From: Stanislaw Gruszka @ 2014-04-04 14:06 UTC (permalink / raw)
To: Jakub Kiciński
Cc: Richard Genoud, Ivo van Doorn, Gertjan van Wingerde, Helmut Schaa,
John W. Linville, linux-wireless, linux-kernel
On Fri, Apr 04, 2014 at 11:01:06AM +0200, Jakub Kiciński wrote:
> On Fri, 4 Apr 2014 10:19:09 +0200, Stanislaw Gruszka wrote:
> > On Thu, Apr 03, 2014 at 05:37:01PM +0200, Jakub Kiciński wrote:
> > > On Thu, 3 Apr 2014 16:12:07 +0200, Richard Genoud wrote:
> > > > 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.
>
> 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)
> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] rt2x00: BUG: remove double loop on REGISTER_BUSY_COUNT
2014-04-04 14:06 ` Stanislaw Gruszka
@ 2014-04-04 14:17 ` Richard Genoud
0 siblings, 0 replies; 7+ messages in thread
From: Richard Genoud @ 2014-04-04 14:17 UTC (permalink / raw)
To: Stanislaw Gruszka
Cc: Jakub Kiciński, Ivo van Doorn, Gertjan van Wingerde,
Helmut Schaa, John W. Linville, linux-wireless,
linux-kernel@vger.kernel.org
2014-04-04 16:06 GMT+02:00 Stanislaw Gruszka <sgruszka@redhat.com>:
> On Fri, Apr 04, 2014 at 11:01:06AM +0200, Jakub Kiciński wrote:
>> On Fri, 4 Apr 2014 10:19:09 +0200, Stanislaw Gruszka wrote:
>> > On Thu, Apr 03, 2014 at 05:37:01PM +0200, Jakub Kiciński wrote:
>> > > On Thu, 3 Apr 2014 16:12:07 +0200, Richard Genoud wrote:
>> > > > 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.
>>
>> 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.
>> 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
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2014-04-04 14:17 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-03 14:12 [PATCH] rt2x00: BUG: remove double loop on REGISTER_BUSY_COUNT Richard Genoud
2014-04-03 15:37 ` Jakub Kiciński
2014-04-03 15:46 ` Richard Genoud
2014-04-04 8:19 ` Stanislaw Gruszka
2014-04-04 9:01 ` Jakub Kiciński
2014-04-04 14:06 ` Stanislaw Gruszka
2014-04-04 14:17 ` Richard Genoud
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).