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.

Signed-off-by: Anthony Romano <anthony.romano@coreos.com>
Acked-by: Oleksij Rempel <linux@rempel-privat.de>
Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
This commit is contained in:
Anthony Romano 2016-11-27 20:27:57 -08:00 committed by Kalle Valo
parent 8ca5a6078d
commit 982a6151f6
2 changed files with 7 additions and 4 deletions

View File

@ -997,7 +997,8 @@ static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
err = usb_control_msg(hif_dev->udev, err = usb_control_msg(hif_dev->udev,
usb_sndctrlpipe(hif_dev->udev, 0), usb_sndctrlpipe(hif_dev->udev, 0),
FIRMWARE_DOWNLOAD, 0x40 | USB_DIR_OUT, FIRMWARE_DOWNLOAD, 0x40 | USB_DIR_OUT,
addr >> 8, 0, buf, transfer, HZ); addr >> 8, 0, buf, transfer,
USB_MSG_TIMEOUT);
if (err < 0) { if (err < 0) {
kfree(buf); kfree(buf);
return err; 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), err = usb_control_msg(hif_dev->udev, usb_sndctrlpipe(hif_dev->udev, 0),
FIRMWARE_DOWNLOAD_COMP, FIRMWARE_DOWNLOAD_COMP,
0x40 | USB_DIR_OUT, 0x40 | USB_DIR_OUT,
firm_offset >> 8, 0, NULL, 0, HZ); firm_offset >> 8, 0, NULL, 0, USB_MSG_TIMEOUT);
if (err) if (err)
return -EIO; return -EIO;
@ -1249,7 +1250,7 @@ static int send_eject_command(struct usb_interface *interface)
dev_info(&udev->dev, "Ejecting storage device...\n"); dev_info(&udev->dev, "Ejecting storage device...\n");
r = usb_bulk_msg(udev, usb_sndbulkpipe(udev, bulk_out_ep), r = usb_bulk_msg(udev, usb_sndbulkpipe(udev, bulk_out_ep),
cmd, 31, NULL, 2000); cmd, 31, NULL, 2 * USB_MSG_TIMEOUT);
kfree(cmd); kfree(cmd);
if (r) if (r)
return r; return r;
@ -1314,7 +1315,7 @@ static void ath9k_hif_usb_reboot(struct usb_device *udev)
return; return;
ret = usb_interrupt_msg(udev, usb_sndintpipe(udev, USB_REG_OUT_PIPE), ret = usb_interrupt_msg(udev, usb_sndintpipe(udev, USB_REG_OUT_PIPE),
buf, 4, NULL, HZ); buf, 4, NULL, USB_MSG_TIMEOUT);
if (ret) if (ret)
dev_err(&udev->dev, "ath9k_htc: USB reboot failed\n"); dev_err(&udev->dev, "ath9k_htc: USB reboot failed\n");

View File

@ -71,6 +71,8 @@ extern int htc_use_dev_fw;
#define USB_REG_IN_PIPE 3 #define USB_REG_IN_PIPE 3
#define USB_REG_OUT_PIPE 4 #define USB_REG_OUT_PIPE 4
#define USB_MSG_TIMEOUT 1000 /* (ms) */
#define HIF_USB_MAX_RXPIPES 2 #define HIF_USB_MAX_RXPIPES 2
#define HIF_USB_MAX_TXPIPES 4 #define HIF_USB_MAX_TXPIPES 4