summaryrefslogtreecommitdiff
path: root/drivers/net/wireless/mediatek/mt76/usb.c
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2019-11-29 15:32:26 +0300
committerFelix Fietkau <nbd@nbd.name>2020-02-14 12:06:01 +0300
commita6bfb6d13f3325fd5cc3646f558b67c40ea823d0 (patch)
tree66517fab84783b33d7574c6c12a69f18dfd8ff7e /drivers/net/wireless/mediatek/mt76/usb.c
parentd3cc4e7640cabb0100630093a0d07c266ea08c42 (diff)
downloadlinux-a6bfb6d13f3325fd5cc3646f558b67c40ea823d0.tar.xz
mt76: usb: use max packet length for m76u_copy
For transferring data over USB the optimal size is endpoint maxpacket. For my hardware maxpaket for control endpoint is 64 bytes and changing to this value from 128 bytes further shorten TBTT work time from 3ms to 1ms. Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com> Signed-off-by: Felix Fietkau <nbd@nbd.name>
Diffstat (limited to 'drivers/net/wireless/mediatek/mt76/usb.c')
-rw-r--r--drivers/net/wireless/mediatek/mt76/usb.c29
1 files changed, 19 insertions, 10 deletions
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index e89b38b0445c..22dacf040123 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -163,7 +163,7 @@ static void mt76u_copy(struct mt76_dev *dev, u32 offset,
mutex_lock(&usb->usb_ctrl_mtx);
while (i < len) {
- current_batch_size = min_t(int, sizeof(usb->data), len - i);
+ current_batch_size = min_t(int, usb->data_len, len - i);
memcpy(usb->data, val + i, current_batch_size);
ret = __mt76u_vendor_request(dev, MT_VEND_MULTI_WRITE,
USB_DIR_OUT | USB_TYPE_VENDOR,
@@ -950,6 +950,15 @@ static const struct mt76_queue_ops usb_queue_ops = {
.kick = mt76u_tx_kick,
};
+void mt76u_deinit(struct mt76_dev *dev)
+{
+ if (dev->usb.stat_wq) {
+ destroy_workqueue(dev->usb.stat_wq);
+ dev->usb.stat_wq = NULL;
+ }
+}
+EXPORT_SYMBOL_GPL(mt76u_deinit);
+
int mt76u_init(struct mt76_dev *dev,
struct usb_interface *intf)
{
@@ -973,6 +982,15 @@ int mt76u_init(struct mt76_dev *dev,
if (!usb->stat_wq)
return -ENOMEM;
+ usb->data_len = usb_maxpacket(udev, usb_sndctrlpipe(udev, 0), 1);
+ if (usb->data_len < 32)
+ usb->data_len = 32;
+ usb->data = devm_kmalloc(dev->dev, usb->data_len, GFP_KERNEL);
+ if (!usb->data) {
+ mt76u_deinit(dev);
+ return -ENOMEM;
+ }
+
mutex_init(&usb->mcu.mutex);
mutex_init(&usb->usb_ctrl_mtx);
@@ -987,14 +1005,5 @@ int mt76u_init(struct mt76_dev *dev,
}
EXPORT_SYMBOL_GPL(mt76u_init);
-void mt76u_deinit(struct mt76_dev *dev)
-{
- if (dev->usb.stat_wq) {
- destroy_workqueue(dev->usb.stat_wq);
- dev->usb.stat_wq = NULL;
- }
-}
-EXPORT_SYMBOL_GPL(mt76u_deinit);
-
MODULE_AUTHOR("Lorenzo Bianconi <lorenzo.bianconi83@gmail.com>");
MODULE_LICENSE("Dual BSD/GPL");