From: Markus Theil <markus.theil@tu-ilmenau.de>
To: nbd@nbd.name
Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com,
Stanislaw Gruszka <sgruszka@redhat.com>,
Markus Theil <markus.theil@tu-ilmenau.de>
Subject: [PATCH v9 5/6] mt76: speed up usb bulk copy
Date: Tue, 26 Nov 2019 22:47:03 +0100 [thread overview]
Message-ID: <20191126214704.27297-6-markus.theil@tu-ilmenau.de> (raw)
In-Reply-To: <20191126214704.27297-1-markus.theil@tu-ilmenau.de>
Use larger batches for usb copy to speed this operation up. Otherwise it
would be too slow for copying new beacons or broadcast frames over usb.
Assure, that always a multiple of 4 Bytes is copied, as outlined in
850e8f6fbd "mt76: round up length on mt76_wr_copy" from Felix Fietkau.
Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
---
drivers/net/wireless/mediatek/mt76/mt76.h | 2 +-
drivers/net/wireless/mediatek/mt76/usb.c | 24 +++++++++++++++++------
2 files changed, 19 insertions(+), 7 deletions(-)
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index fb077760347a..1981912de1f9 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -382,7 +382,7 @@ enum mt76u_out_ep {
struct mt76_usb {
struct mutex usb_ctrl_mtx;
union {
- u8 data[32];
+ u8 data[128];
__le32 reg_val;
};
diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
index d6d47081e281..97b263ce3872 100644
--- a/drivers/net/wireless/mediatek/mt76/usb.c
+++ b/drivers/net/wireless/mediatek/mt76/usb.c
@@ -149,18 +149,30 @@ static void mt76u_copy(struct mt76_dev *dev, u32 offset,
const void *data, int len)
{
struct mt76_usb *usb = &dev->usb;
- const u32 *val = data;
- int i, ret;
+ const u8 *val = data;
+ int ret;
+ int current_batch_size;
+ int i = 0;
+
+ /* Assure that always a multiple of 4 bytes are copied,
+ * otherwise beacons can be corrupted.
+ * See: "mt76: round up length on mt76_wr_copy"
+ * Commit 850e8f6fbd5d0003b0
+ */
+ len = round_up(len, 4);
mutex_lock(&usb->usb_ctrl_mtx);
- for (i = 0; i < DIV_ROUND_UP(len, 4); i++) {
- put_unaligned(val[i], (u32 *)usb->data);
+ while (i < len) {
+ current_batch_size = min_t(int, sizeof(usb->data), 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,
- 0, offset + i * 4, usb->data,
- sizeof(u32));
+ 0, offset + i, usb->data,
+ current_batch_size);
if (ret < 0)
break;
+
+ i += current_batch_size;
}
mutex_unlock(&usb->usb_ctrl_mtx);
}
--
2.24.0
next prev parent reply other threads:[~2019-11-26 21:47 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-26 21:46 [PATCH v9 0/6] mt76: channel switch support for USB devices Markus Theil
2019-11-26 21:46 ` [PATCH v9 1/6] mt76: mt76x02: ommit beacon slot clearing Markus Theil
2019-11-26 21:47 ` [PATCH v9 2/6] mt76: mt76x02: split beaconing Markus Theil
2019-12-17 9:50 ` Lorenzo Bianconi
2019-12-18 9:37 ` Lorenzo Bianconi
2019-12-18 12:12 ` Markus Theil
2019-11-26 21:47 ` [PATCH v9 3/6] mt76: mt76x02: add check for invalid vif idx Markus Theil
2019-11-26 21:47 ` [PATCH v9 4/6] mt76: mt76x02: remove a copy call for usb speedup Markus Theil
2019-12-17 9:40 ` Lorenzo Bianconi
2019-12-18 12:11 ` Markus Theil
2019-12-18 13:17 ` Lorenzo Bianconi
2019-12-18 14:57 ` Markus Theil
2019-11-26 21:47 ` Markus Theil [this message]
2019-11-26 21:47 ` [PATCH v9 6/6] mt76: mt76x02: add channel switch support for usb interfaces Markus Theil
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191126214704.27297-6-markus.theil@tu-ilmenau.de \
--to=markus.theil@tu-ilmenau.de \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=nbd@nbd.name \
--cc=sgruszka@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).