netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] rt2800usb: Fix support for USB 057c:8501
@ 2014-06-01 17:52 Michael Braun
  2014-06-01 17:52 ` [PATCH 1/2] rt2800usb:fix efuse detection Michael Braun
  2014-06-01 17:52 ` [PATCH 2/2] rt2800usb:fix hang during firmware load Michael Braun
  0 siblings, 2 replies; 6+ messages in thread
From: Michael Braun @ 2014-06-01 17:52 UTC (permalink / raw)
  To: Ivo van Doorn, Helmut Schaa
  Cc: netdev, users, linux-wireless, John W. Linville, linux-kernel

The usb wifi device AVM Fritz Stick N v2b (USB 057c:8501) is listed as supported by rt2800usb, but loading the driver fails for me (kernel 3.15-rc7 and older).

 ieee80211 phy0: rt2x00_set_rt: Info - RT chipset 5592, rev 0222 detected
 ieee80211 phy0: rt2x00usb_vendor_request: Error - Vendor Request 0x09 failed for offset 0x0000 with error -32
 ieee80211 phy0: rt2x00lib_probe_dev: Error - Failed to allocate device
 rt2800usb: probe of 1-1.3:1.0 failed with error -32
 usbcore: registered new interface driver rt2800usb

>From searching the web, it looks like other users using the same device are hit by this error too, and some users of similar devices using the same driver experience similar errors.

I've tested these patches using a USB 057c:8501 wifi device in client mode (scanning + connect to WPA protected BSS + network access). With the patches applied, the device works fine. Without, it fails.
I've also tested that USB 148f:5370 (which is another usb wifi device using the same driver), which worked also without these patches applied, still works after applying these patches.

Regards,
 M. Braun
---

Michael Braun (2):
      rt2800usb:fix efuse detection
      rt2800usb:fix hang during firmware load


 drivers/net/wireless/rt2x00/rt2800usb.c |   30 +++++++++++++++++++++++++++---
 1 file changed, 27 insertions(+), 3 deletions(-)

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

* [PATCH 1/2] rt2800usb:fix efuse detection
  2014-06-01 17:52 [PATCH 0/2] rt2800usb: Fix support for USB 057c:8501 Michael Braun
@ 2014-06-01 17:52 ` Michael Braun
  2014-06-01 19:06   ` Sergei Shtylyov
  2014-06-01 17:52 ` [PATCH 2/2] rt2800usb:fix hang during firmware load Michael Braun
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Braun @ 2014-06-01 17:52 UTC (permalink / raw)
  To: Ivo van Doorn, Helmut Schaa
  Cc: netdev, users, linux-wireless, John W. Linville, linux-kernel

The device 057c:8501 (AVM Fritz! WLAN v2 rev. B) currently does not
load. One thing observed is that the vendors driver detects EFUSE mode
for this device, but rt2800usb does not. This is due to rt2800usb
lacking a check for the firmware mode present in the vendors driver,
that this patch adopts for rt2800usb.

With this patch applied, the 'RF chipset' detection does no longer fail.

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
---
 drivers/net/wireless/rt2x00/rt2800usb.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index a49c3d7..b601422 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -735,11 +735,25 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
 /*
  * Device probe functions.
  */
+static int rt2800usb_efuse_detect(struct rt2x00_dev *rt2x00dev)
+{
+	__le32 fwMode;
+
+	rt2x00usb_vendor_request(rt2x00dev, USB_DEVICE_MODE,
+				 USB_VENDOR_REQUEST_IN, 0, 0x11, &fwMode,
+				 sizeof(fwMode), REGISTER_TIMEOUT_FIRMWARE);
+
+	if ((fwMode & 0x00000003) == 2)
+		return 1;
+
+	return rt2800_efuse_detect(rt2x00dev);
+}
+
 static int rt2800usb_read_eeprom(struct rt2x00_dev *rt2x00dev)
 {
 	int retval;
 
-	if (rt2800_efuse_detect(rt2x00dev))
+	if (rt2800usb_efuse_detect(rt2x00dev))
 		retval = rt2800_read_eeprom_efuse(rt2x00dev);
 	else
 		retval = rt2x00usb_eeprom_read(rt2x00dev, rt2x00dev->eeprom,

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

* [PATCH 2/2] rt2800usb:fix hang during firmware load
  2014-06-01 17:52 [PATCH 0/2] rt2800usb: Fix support for USB 057c:8501 Michael Braun
  2014-06-01 17:52 ` [PATCH 1/2] rt2800usb:fix efuse detection Michael Braun
@ 2014-06-01 17:52 ` Michael Braun
  2014-06-01 19:09   ` Sergei Shtylyov
  1 sibling, 1 reply; 6+ messages in thread
From: Michael Braun @ 2014-06-01 17:52 UTC (permalink / raw)
  To: Ivo van Doorn, Helmut Schaa
  Cc: netdev, users, linux-wireless, John W. Linville, linux-kernel

The device 057c:8501 (AVM Fritz! WLAN v2 rev. B) boots into a state that does not actually require loading a firmware file.
The vendors driver finds out about this by checking a firmware state
register, so this patch adopts this here.

Finally, with this patch applied, my wifi dongle actually becomes
usefull (scan + connect to wpa network works).

Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
---
 drivers/net/wireless/rt2x00/rt2800usb.c |   14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
index b601422..71bf101 100644
--- a/drivers/net/wireless/rt2x00/rt2800usb.c
+++ b/drivers/net/wireless/rt2x00/rt2800usb.c
@@ -240,6 +240,7 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
 	int status;
 	u32 offset;
 	u32 length;
+	__le32 fwMode;
 
 	/*
 	 * Check which section of the firmware we need.
@@ -257,8 +258,17 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
 	/*
 	 * Write firmware to device.
 	 */
-	rt2x00usb_register_multiwrite(rt2x00dev, FIRMWARE_IMAGE_BASE,
-				      data + offset, length);
+	rt2x00usb_vendor_request(rt2x00dev, USB_DEVICE_MODE,
+				 USB_VENDOR_REQUEST_IN, 0, 0x11, &fwMode,
+				 sizeof(fwMode), REGISTER_TIMEOUT_FIRMWARE);
+
+	if ((fwMode & 0x00000003) == 2) {
+		rt2x00_info(rt2x00dev,
+		      "Firmware loading not required - NIC in AutoRun mode\n");
+	} else {
+		rt2x00usb_register_multiwrite(rt2x00dev, FIRMWARE_IMAGE_BASE,
+					      data + offset, length);
+	}
 
 	rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_CID, ~0);
 	rt2x00usb_register_write(rt2x00dev, H2M_MAILBOX_STATUS, ~0);

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

* Re: [PATCH 1/2] rt2800usb:fix efuse detection
  2014-06-01 17:52 ` [PATCH 1/2] rt2800usb:fix efuse detection Michael Braun
@ 2014-06-01 19:06   ` Sergei Shtylyov
  2014-06-02 13:06     ` Stanislaw Gruszka
  0 siblings, 1 reply; 6+ messages in thread
From: Sergei Shtylyov @ 2014-06-01 19:06 UTC (permalink / raw)
  To: Michael Braun, Ivo van Doorn, Helmut Schaa
  Cc: netdev, users, linux-wireless, John W. Linville, linux-kernel

Hello.

On 06/01/2014 09:52 PM, Michael Braun wrote:

> The device 057c:8501 (AVM Fritz! WLAN v2 rev. B) currently does not
> load. One thing observed is that the vendors driver detects EFUSE mode
> for this device, but rt2800usb does not. This is due to rt2800usb
> lacking a check for the firmware mode present in the vendors driver,
> that this patch adopts for rt2800usb.

> With this patch applied, the 'RF chipset' detection does no longer fail.

> Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
> ---
>   drivers/net/wireless/rt2x00/rt2800usb.c |   16 +++++++++++++++-
>   1 file changed, 15 insertions(+), 1 deletion(-)

> diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
> index a49c3d7..b601422 100644
> --- a/drivers/net/wireless/rt2x00/rt2800usb.c
> +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
> @@ -735,11 +735,25 @@ static void rt2800usb_fill_rxdone(struct queue_entry *entry,
>   /*
>    * Device probe functions.
>    */
> +static int rt2800usb_efuse_detect(struct rt2x00_dev *rt2x00dev)
> +{
> +	__le32 fwMode;
> +
> +	rt2x00usb_vendor_request(rt2x00dev, USB_DEVICE_MODE,
> +				 USB_VENDOR_REQUEST_IN, 0, 0x11, &fwMode,
> +				 sizeof(fwMode), REGISTER_TIMEOUT_FIRMWARE);
> +
> +	if ((fwMode & 0x00000003) == 2)

    Operating directly on '__le32'? That doesn't look right.

> +		return 1;
> +
> +	return rt2800_efuse_detect(rt2x00dev);
> +}
> +

WBR, Sergei

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

* Re: [PATCH 2/2] rt2800usb:fix hang during firmware load
  2014-06-01 17:52 ` [PATCH 2/2] rt2800usb:fix hang during firmware load Michael Braun
@ 2014-06-01 19:09   ` Sergei Shtylyov
  0 siblings, 0 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2014-06-01 19:09 UTC (permalink / raw)
  To: Michael Braun, Ivo van Doorn, Helmut Schaa
  Cc: netdev, users, linux-wireless, John W. Linville, linux-kernel

On 06/01/2014 09:52 PM, Michael Braun wrote:

> The device 057c:8501 (AVM Fritz! WLAN v2 rev. B) boots into a state that does not actually require loading a firmware file.

    Wrap the changelog lines on at least 80 chars please.

> The vendors driver finds out about this by checking a firmware state
> register, so this patch adopts this here.

> Finally, with this patch applied, my wifi dongle actually becomes
> usefull (scan + connect to wpa network works).

    s/usefull/useful/.

> Signed-off-by: Michael Braun <michael-dev@fami-braun.de>
> ---
>   drivers/net/wireless/rt2x00/rt2800usb.c |   14 ++++++++++++--
>   1 file changed, 12 insertions(+), 2 deletions(-)

> diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c
> index b601422..71bf101 100644
> --- a/drivers/net/wireless/rt2x00/rt2800usb.c
> +++ b/drivers/net/wireless/rt2x00/rt2800usb.c
> @@ -240,6 +240,7 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
>   	int status;
>   	u32 offset;
>   	u32 length;
> +	__le32 fwMode;
>
>   	/*
>   	 * Check which section of the firmware we need.
> @@ -257,8 +258,17 @@ static int rt2800usb_write_firmware(struct rt2x00_dev *rt2x00dev,
>   	/*
>   	 * Write firmware to device.
>   	 */
> -	rt2x00usb_register_multiwrite(rt2x00dev, FIRMWARE_IMAGE_BASE,
> -				      data + offset, length);
> +	rt2x00usb_vendor_request(rt2x00dev, USB_DEVICE_MODE,
> +				 USB_VENDOR_REQUEST_IN, 0, 0x11, &fwMode,
> +				 sizeof(fwMode), REGISTER_TIMEOUT_FIRMWARE);
> +
> +	if ((fwMode & 0x00000003) == 2) {

    Same comment as for the patch #1.

> +		rt2x00_info(rt2x00dev,
> +		      "Firmware loading not required - NIC in AutoRun mode\n");

    This line should start under 'rt2xx00dev', like below.

> +	} else {
> +		rt2x00usb_register_multiwrite(rt2x00dev, FIRMWARE_IMAGE_BASE,
> +					      data + offset, length);
> +	}

WBR, Sergei

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

* Re: [PATCH 1/2] rt2800usb:fix efuse detection
  2014-06-01 19:06   ` Sergei Shtylyov
@ 2014-06-02 13:06     ` Stanislaw Gruszka
  0 siblings, 0 replies; 6+ messages in thread
From: Stanislaw Gruszka @ 2014-06-02 13:06 UTC (permalink / raw)
  To: Sergei Shtylyov, Michael Braun
  Cc: Ivo van Doorn, Helmut Schaa, netdev, users, linux-wireless,
	John W. Linville, linux-kernel

On Sun, Jun 01, 2014 at 11:06:11PM +0400, Sergei Shtylyov wrote:
> >+	rt2x00usb_vendor_request(rt2x00dev, USB_DEVICE_MODE,
> >+				 USB_VENDOR_REQUEST_IN, 0, 0x11, &fwMode,
> >+				 sizeof(fwMode), REGISTER_TIMEOUT_FIRMWARE);
> >+
> >+	if ((fwMode & 0x00000003) == 2)
> 
>    Operating directly on '__le32'? That doesn't look right.

rt2x00usb_register_read() helper can be used to do conversion. I also
dislike using 0x11 number instead of register name and prefer kernel
like variable names (i.e. fw_mode instead of fwMode).

Thanks
Stanislaw

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

end of thread, other threads:[~2014-06-02 13:06 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-01 17:52 [PATCH 0/2] rt2800usb: Fix support for USB 057c:8501 Michael Braun
2014-06-01 17:52 ` [PATCH 1/2] rt2800usb:fix efuse detection Michael Braun
2014-06-01 19:06   ` Sergei Shtylyov
2014-06-02 13:06     ` Stanislaw Gruszka
2014-06-01 17:52 ` [PATCH 2/2] rt2800usb:fix hang during firmware load Michael Braun
2014-06-01 19:09   ` Sergei Shtylyov

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).