diff mbox

[1/3] rt2x00usb: initialize the read value in case of failure

Message ID 1426170946-13918-1-git-send-email-bigeasy@linutronix.de (mailing list archive)
State Accepted
Delegated to: Kalle Valo
Headers show

Commit Message

Sebastian Andrzej Siewior March 12, 2015, 2:35 p.m. UTC
My understanding ist that rt2x00usb_register_read() is void and so the
reader is unaware of read errors and assumes that whatever was on the
stack as it was about to read.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
---
 drivers/net/wireless/rt2x00/rt2x00usb.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Kalle Valo March 16, 2015, 4:06 p.m. UTC | #1
> My understanding ist that rt2x00usb_register_read() is void and so the
> reader is unaware of read errors and assumes that whatever was on the
> stack as it was about to read.
> 
> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>

Thanks, 3 patches applied to wireless-drivers-next.git:

e4fcfaf802bf rt2x00usb: initialize the read value in case of failure
92d5e2456d39 rt2x00usb: check USB's request error code in rt2800usb_autorun_detect()
7daa54b747dd rt2x00usb: drop rt2x00usb_disable_radio() from rt2800usb_disable_radio()

Kalle Valo
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sebastian Andrzej Siewior March 16, 2015, 4:41 p.m. UTC | #2
* Kalle Valo | 2015-03-16 16:06:52 [+0000]:

>Thanks, 3 patches applied to wireless-drivers-next.git:

Thanks. Do you guys have any kind of further documentation? Where did 
you get the firmware from? Is it the vendor driver in better shape and
firmware excracted from header files?
The reason I'm asking is that I have a small script that switches
between AP & Managed mode and after a while the show ends with:

|wlan0: authenticate with XX
|wlan0: send auth to XX (try 1/3)
|wlan0: authenticated
|wlan0: associate with XX (try 1/3)
|wlan0: RX AssocResp fromXX (capab=0x1411 status=0 aid=3)
|IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
|wlan0: associated
|wlan0: dropped frame to XX (unauthorized port)
Managed mode complete.

|wlan0: deauthenticating from XX by local choice (Reason: 3=DEAUTH_LEAVING)
|cfg80211: Calling CRDA to update world regulatory domain
|ieee80211 phy0: rt2800usb_write_firmware: Info - Firmware loading not required - NIC in AutoRun mode
|IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
|IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
switch to AP mode done.

And this should be where it switches back to managed mode
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x06 failed for offset 0x3200 with error -110 val: 0 type 40
|ieee80211 phy0: rt2800usb_write_firmware: Info - Firmware is written.
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x06 failed for offset 0x7014 with error -110 val: 0 type 40
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x06 failed for offset 0x701c with error -110 val: 0 type 40
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x01 failed for offset 0x0000 with error -110 val: 8 type 40
|ieee80211 phy0: rt2800usb_write_firmware: Error - Failed to write Firmware to device
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x07 failed for offset 0x0400 with error -110 val: 0 type c0
… mode of these…
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x07 failed for offset 0x0400 with error -110 val: 0 type c0
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x07 failed for offset 0x0400 with error -110 val: 0 type c0
|ieee80211 phy0: rt2800_load_firmware: Error - PBF system register not ready
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x07 failed for offset 0x7010 with error -110 val: 0 type c0
… mode of these…
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x06 failed for offset 0x7010 with error -110 val: 0 type 40
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x06 failed for offset 0x0404 with error -110 val: 0 type 40
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x07 failed for offset 0x1000 with error -110 val: 0 type c0
|ieee80211 phy0: rt2800_wait_csr_ready: Error - Unstable hardware 
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x07 failed for offset 0x7010 with error -110 val: 0 type c0
|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x06 failed for offset 0x7010 with error -110 val: 0 type 40

at this point the stick is dead. Dead as in I think I get -110 for every
USB reqeust. The only thing that helps is to replug the USB stick since
it does not even accept a new device number after a USB-reset.
Since the error happens by the time the firmware is written could it be
that the firmware was not yet ready to receive a new one? Since it does
not answer at all I think it blue screened :)

>
>Kalle Valo

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Sebastian Andrzej Siewior March 17, 2015, 8:34 a.m. UTC | #3
* Sebastian Andrzej Siewior | 2015-03-16 17:41:00 [+0100]:

Just an update:
…
>|ieee80211 phy0: rt2800usb_write_firmware: Info - Firmware loading not required - NIC in AutoRun mode
>|IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
>|IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
>switch to AP mode done.
>
>And this should be where it switches back to managed mode
>|ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x06 failed for offset 0x3200 with error -110 val: 0 type 40
>|ieee80211 phy0: rt2800usb_write_firmware: Info - Firmware is written.

so the difference is that I don't see "NIC in AutoRun mode". So
rt2800usb_autorun_detect() does not return 1 for some reason but 0
instead and whatever comes next kills the stick. Maybe it was tired of
of the wpa <-> hostapd mode switch for no reason.

So I told rt2800usb_autorun_detect() to always return 1 and not to care
what the stick says. The stick now runs for 12.5h in test without a
problem (that means it is able to connect to the AP and hostapd does not
complain, too). After around 11h I saw the message that it would write
the firmware (but it got ignored instead). So the workaround seems to
work.

I have no idea what AutoRun mode is (it seems that the stick already
has a firmware and is happy with it) and I have no clue why the firmware
decides to lie about it. I looked at the vendor driver I found at github
(which seems to be from 2012-10-22, DPO_RT5572_LinuxSTA_2.6.1.3) and
well, I look again if someone says it is worth looking… They seem to do
some kind "firmware is comming" magic which might be already done in the
current driver at a different spot but I think the main question is why
request is answered wrong. I *think* the vendor driver sends the
USB_MODE_AUTORUN request only once but it is hard to tell…

>>Kalle Valo

Sebastian
--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Stanislaw Gruszka March 18, 2015, 12:48 p.m. UTC | #4
On Mon, Mar 16, 2015 at 05:41:00PM +0100, Sebastian Andrzej Siewior wrote:
> * Kalle Valo | 2015-03-16 16:06:52 [+0000]:
> 
> >Thanks, 3 patches applied to wireless-drivers-next.git:
> 
> Thanks. Do you guys have any kind of further documentation? Where did 
There is doc describing MAC registers, it was provided under NDA to
rt2x00 developers. However you can google for "MT7620_ProgrammingGuide.pdf"
and get similar doc. It does not describe radio/broadband registers, we
only have vendor driver as source for those.

> you get the firmware from?
linux-firmware contains firmware posed by Ralink developers. Vendor
driver ships new firmware versions, it is binnary file common/rt2870.bin

> Is it the vendor driver in better shape and
> firmware excracted from header files?
For some users vendor driver works better.

Stanislaw

--
To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wireless/rt2x00/rt2x00usb.h b/drivers/net/wireless/rt2x00/rt2x00usb.h
index 8f85fbd5f237..569363da00a2 100644
--- a/drivers/net/wireless/rt2x00/rt2x00usb.h
+++ b/drivers/net/wireless/rt2x00/rt2x00usb.h
@@ -199,7 +199,7 @@  static inline void rt2x00usb_register_read(struct rt2x00_dev *rt2x00dev,
 					   const unsigned int offset,
 					   u32 *value)
 {
-	__le32 reg;
+	__le32 reg = 0;
 	rt2x00usb_vendor_request_buff(rt2x00dev, USB_MULTI_READ,
 				      USB_VENDOR_REQUEST_IN, offset,
 				      &reg, sizeof(reg));
@@ -219,7 +219,7 @@  static inline void rt2x00usb_register_read_lock(struct rt2x00_dev *rt2x00dev,
 						const unsigned int offset,
 						u32 *value)
 {
-	__le32 reg;
+	__le32 reg = 0;
 	rt2x00usb_vendor_req_buff_lock(rt2x00dev, USB_MULTI_READ,
 				       USB_VENDOR_REQUEST_IN, offset,
 				       &reg, sizeof(reg), REGISTER_TIMEOUT);