Skip to contentSkip to conversation

ath9k_htc: don't use HZ for usb msg timeouts

PATCH In review Anthony Romano 4 participants 5 messages Nov 28, 2016 – Dec 1, 2016 Qualcomm Atheros ATH9K wireless driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ath9k_htc: don't use HZ for usb msg timeouts

The usb_*_msg() functions expect a timeout in msecs but are given HZ, which is ticks per second. If HZ=100, firmware download often times out when there is modest USB utilization and the device fails to initialize.

Replaces HZ in usb_*_msg timeouts with 1000 msec since HZ is one second for timeouts in jiffies.

---
 drivers/net/wireless/ath/ath9k/hif_usb.c | 9 +++++----
 drivers/net/wireless/ath/ath9k/hif_usb.h | 2 ++
 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +5 -4
index e1c338cb9cb5..de2d212f39ec 100644
@@ -997,7 +997,8 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
 		err = usb_control_msg(hif_dev->udev,
 				      usb_sndctrlpipe(hif_dev->udev, 0),
 				      FIRMWARE_DOWNLOAD, 0x40 | USB_DIR_OUT,
-				      addr >> 8, 0, buf, transfer, HZ);
+				      addr >> 8, 0, buf, transfer,
+				      USB_MSG_TIMEOUT);
 		if (err < 0) {
 			kfree(buf);
 			return err;
@@ -1020,7 +1021,7 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
 	err = usb_control_msg(hif_dev->udev, usb_sndctrlpipe(hif_dev->udev, 0),
 			      FIRMWARE_DOWNLOAD_COMP,
 			      0x40 | USB_DIR_OUT,
-			      firm_offset >> 8, 0, NULL, 0, HZ);
+			      firm_offset >> 8, 0, NULL, 0, USB_MSG_TIMEOUT);
 	if (err)
 		return -EIO;
 
@@ -1249,7 +1250,7 @@ static int send_eject_command(struct usb_interface *interface)
 
 	dev_info(&udev->dev, "Ejecting storage device...\n");
 	r = usb_bulk_msg(udev, usb_sndbulkpipe(udev, bulk_out_ep),
-		cmd, 31, NULL, 2000);
+		cmd, 31, NULL, 2 * USB_MSG_TIMEOUT);
 	kfree(cmd);
 	if (r)
 		return r;
@@ -1314,7 +1315,7 @@ static void ath9k_hif_usb_reboot(struct usb_device *udev)
 		return;
 
 	ret = usb_interrupt_msg(udev, usb_sndintpipe(udev, USB_REG_OUT_PIPE),
-			   buf, 4, NULL, HZ);
+			   buf, 4, NULL, USB_MSG_TIMEOUT);
 	if (ret)
 		dev_err(&udev->dev, "ath9k_htc: USB reboot failed\n");
 
drivers/net/wireless/ath/ath9k/hif_usb.h +2 -0
index 7c2ef7ecd98b..7846916aa01d 100644
@@ -71,6 +71,8 @@ extern int htc_use_dev_fw;
 #define USB_REG_IN_PIPE   3
 #define USB_REG_OUT_PIPE  4
 
+#define USB_MSG_TIMEOUT 1000 /* (ms) */
+
 #define HIF_USB_MAX_RXPIPES 2
 #define HIF_USB_MAX_TXPIPES 4
 
Signature · 1 line
2.11.0.rc2
#1 lore raw

PATCH 1/1 ath9k_htc: don't use HZ for usb msg timeouts

Hi Anthony,

Am 28.11.2016 um 05:27 schrieb Anthony Romano:

Quoted 6 lines

The usb_*_msg() functions expect a timeout in msecs but are given HZ, which is ticks per second. If HZ=100, firmware download often times out when there is modest USB utilization and the device fails to initialize.

Replaces HZ in usb_*_msg timeouts with 1000 msec since HZ is one second for timeouts in jiffies.

wow..
This fix allow you use 4 adapter at same time?

Quoted 53 lines
---
 drivers/net/wireless/ath/ath9k/hif_usb.c | 9 +++++----
 drivers/net/wireless/ath/ath9k/hif_usb.h | 2 ++
 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +5 -4
index e1c338cb9cb5..de2d212f39ec 100644
@@ -997,7 +997,8 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
 		err = usb_control_msg(hif_dev->udev,
 				      usb_sndctrlpipe(hif_dev->udev, 0),
 				      FIRMWARE_DOWNLOAD, 0x40 | USB_DIR_OUT,
-				      addr >> 8, 0, buf, transfer, HZ);
+				      addr >> 8, 0, buf, transfer,
+				      USB_MSG_TIMEOUT);
 		if (err < 0) {
 			kfree(buf);
 			return err;
@@ -1020,7 +1021,7 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
 	err = usb_control_msg(hif_dev->udev, usb_sndctrlpipe(hif_dev->udev, 0),
 			      FIRMWARE_DOWNLOAD_COMP,
 			      0x40 | USB_DIR_OUT,
-			      firm_offset >> 8, 0, NULL, 0, HZ);
+			      firm_offset >> 8, 0, NULL, 0, USB_MSG_TIMEOUT);
 	if (err)
 		return -EIO;
 
@@ -1249,7 +1250,7 @@ static int send_eject_command(struct usb_interface *interface)
 
 	dev_info(&udev->dev, "Ejecting storage device...\n");
 	r = usb_bulk_msg(udev, usb_sndbulkpipe(udev, bulk_out_ep),
-		cmd, 31, NULL, 2000);
+		cmd, 31, NULL, 2 * USB_MSG_TIMEOUT);
 	kfree(cmd);
 	if (r)
 		return r;
@@ -1314,7 +1315,7 @@ static void ath9k_hif_usb_reboot(struct usb_device *udev)
 		return;
 
 	ret = usb_interrupt_msg(udev, usb_sndintpipe(udev, USB_REG_OUT_PIPE),
-			   buf, 4, NULL, HZ);
+			   buf, 4, NULL, USB_MSG_TIMEOUT);
 	if (ret)
 		dev_err(&udev->dev, "ath9k_htc: USB reboot failed\n");
 
drivers/net/wireless/ath/ath9k/hif_usb.h +0 -0
index 7c2ef7ecd98b..7846916aa01d 100644

drivers/net/wireless/ath/ath9k/hif_usb.h extern int htc_use_dev_fw; · line 78

Quoted 8 lines
drivers/net/wireless/ath/ath9k/hif_usb.h +2 -0
@@ -71,6 +71,8 @@ extern int htc_use_dev_fw;
 #define USB_REG_IN_PIPE   3
 #define USB_REG_OUT_PIPE  4
 
+#define USB_MSG_TIMEOUT 1000 /* (ms) */
+
 #define HIF_USB_MAX_RXPIPES 2
 #define HIF_USB_MAX_TXPIPES 4
 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: OpenPGP digital signature
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20161128/dae0a7aa/attachment.pgp

#2 lore raw

PATCH 1/1 ath9k_htc: don't use HZ for usb msg timeouts

Hi Oleksij,

I put 4 ar9271's on a 4 port hub into monitor mode for you and all interfaces are simultaneously collecting packets. My cheap USB power meter reads 4.37v@650mA between the hub and the host, so it's pushing the limit but appears stable.

Quoted 76 lines · Oleksij Rempel

Hi Anthony,

Am 28.11.2016 um 05:27 schrieb Anthony Romano:

Quoted 6 lines

The usb_*_msg() functions expect a timeout in msecs but are given HZ, which is ticks per second. If HZ=100, firmware download often times out when there is modest USB utilization and the device fails to initialize.

Replaces HZ in usb_*_msg timeouts with 1000 msec since HZ is one second for timeouts in jiffies.

wow..
This fix allow you use 4 adapter at same time?

Quoted 61 lines
---
 drivers/net/wireless/ath/ath9k/hif_usb.c | 9 +++++----
 drivers/net/wireless/ath/ath9k/hif_usb.h | 2 ++
 2 files changed, 7 insertions(+), 4 deletions(-)
drivers/net/wireless/ath/ath9k/hif_usb.c +5 -4
index e1c338cb9cb5..de2d212f39ec 100644
@@ -997,7 +997,8 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
              err = usb_control_msg(hif_dev->udev,
                                    usb_sndctrlpipe(hif_dev->udev, 0),
                                    FIRMWARE_DOWNLOAD, 0x40 | USB_DIR_OUT,
-                                   addr >> 8, 0, buf, transfer, HZ);
+                                   addr >> 8, 0, buf, transfer,
+                                   USB_MSG_TIMEOUT);
              if (err < 0) {
                      kfree(buf);
                      return err;
@@ -1020,7 +1021,7 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
      err = usb_control_msg(hif_dev->udev, usb_sndctrlpipe(hif_dev->udev, 0),
                            FIRMWARE_DOWNLOAD_COMP,
                            0x40 | USB_DIR_OUT,
-                           firm_offset >> 8, 0, NULL, 0, HZ);
+                           firm_offset >> 8, 0, NULL, 0, USB_MSG_TIMEOUT);
      if (err)
              return -EIO;
 
@@ -1249,7 +1250,7 @@ static int send_eject_command(struct usb_interface *interface)
 
      dev_info(&udev->dev, "Ejecting storage device...\n");
      r = usb_bulk_msg(udev, usb_sndbulkpipe(udev, bulk_out_ep),
-             cmd, 31, NULL, 2000);
+             cmd, 31, NULL, 2 * USB_MSG_TIMEOUT);
      kfree(cmd);
      if (r)
              return r;
@@ -1314,7 +1315,7 @@ static void ath9k_hif_usb_reboot(struct usb_device *udev)
              return;
 
      ret = usb_interrupt_msg(udev, usb_sndintpipe(udev, USB_REG_OUT_PIPE),
-                        buf, 4, NULL, HZ);
+                        buf, 4, NULL, USB_MSG_TIMEOUT);
      if (ret)
              dev_err(&udev->dev, "ath9k_htc: USB reboot failed\n");
 
drivers/net/wireless/ath/ath9k/hif_usb.h +2 -0
index 7c2ef7ecd98b..7846916aa01d 100644
@@ -71,6 +71,8 @@ extern int htc_use_dev_fw;
 #define USB_REG_IN_PIPE   3
 #define USB_REG_OUT_PIPE  4
 
+#define USB_MSG_TIMEOUT 1000 /* (ms) */
+
 #define HIF_USB_MAX_RXPIPES 2
 #define HIF_USB_MAX_TXPIPES 4
 
#3 lore raw

PATCH 1/1 ath9k_htc: don't use HZ for usb msg timeouts

Am 29.11.2016 um 10:45 schrieb Anthony Romano:

Quoted 6 lines

Hi Oleksij,

I put 4 ar9271's on a 4 port hub into monitor mode for you and all interfaces are simultaneously collecting packets. My cheap USB power meter reads 4.37v at 650mA between the hub and the host, so it's pushing the limit but appears stable.

Great work, thank you!

Quoted 8 lines · Oleksij Rempel
Quoted 7 lines

Hi Anthony,

Am 28.11.2016 um 05:27 schrieb Anthony Romano:

Quoted 3 lines

The usb_*_msg() functions expect a timeout in msecs but are given HZ, which is ticks per second. If HZ=100, firmware download often times out when there is modest USB utilization and the device fails to initialize.

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

Replaces HZ in usb_*_msg timeouts with 1000 msec since HZ is one second for timeouts in jiffies.

wow..
This fix allow you use 4 adapter at same time?

Quoted 1 line
Signature · 10 lines
Regards,
Oleksij

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 213 bytes
Desc: OpenPGP digital signature
Url : http://lists.ath9k.org/pipermail/ath9k-devel/attachments/20161129/4e3f1ebf/attachment.pgp 
#4 lore raw
In reply to Anthony Romano
Quoted 9 lines · Anthony Romano

The usb_*_msg() functions expect a timeout in msecs but are given HZ, which is ticks per second. If HZ=100, firmware download often times out when there is modest USB utilization and the device fails to initialize.

Replaces HZ in usb_*_msg timeouts with 1000 msec since HZ is one second for timeouts in jiffies.

Patch applied to ath-next branch of ath.git, thanks.

982a6151f6f1 ath9k_htc: don't use HZ for usb msg timeouts

Signature · 6 lines
https://patchwork.kernel.org/patch/9449097/

Documentation about submitting wireless patches and checking status
from patchwork:

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches