From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Markus Theil <markus.theil@tu-ilmenau.de>
Cc: nbd@nbd.name, linux-wireless@vger.kernel.org,
lorenzo.bianconi@redhat.com,
Stanislaw Gruszka <sgruszka@redhat.com>
Subject: Re: [PATCH 3/4] mt76: speed up usb bulk copy
Date: Sat, 16 Nov 2019 13:43:12 +0200 [thread overview]
Message-ID: <20191116114312.GC20820@localhost.localdomain> (raw)
In-Reply-To: <20191116111709.4686-4-markus.theil@tu-ilmenau.de>
[-- Attachment #1: Type: text/plain, Size: 2977 bytes --]
> 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.
>
> Signed-off-by: Markus Theil <markus.theil@tu-ilmenau.de>
> ---
Hi Markus,
> drivers/net/wireless/mediatek/mt76/mt76.h | 2 +-
> .../wireless/mediatek/mt76/mt76x02_beacon.c | 1 -
> drivers/net/wireless/mediatek/mt76/usb.c | 22 ++++++++++++++-----
> 3 files changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
> index 8aec7ccf2d79..7a6f5d097a3d 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76.h
> @@ -383,7 +383,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/mt76x02_beacon.c b/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c
> index 47207b790bf9..8b2f7a0d58b5 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c
> +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c
> @@ -86,7 +86,6 @@ int mt76x02_mac_set_beacon(struct mt76x02_dev *dev, u8 vif_idx,
> dev->beacons[vif_idx] = skb;
> __mt76x02_mac_set_beacon(dev, vif_idx, skb);
>
> -
> return 0;
> }
> EXPORT_SYMBOL_GPL(mt76x02_mac_set_beacon);
> diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c
> index 20c6fe510e9d..6183105166ec 100644
> --- a/drivers/net/wireless/mediatek/mt76/usb.c
> +++ b/drivers/net/wireless/mediatek/mt76/usb.c
> @@ -149,18 +149,28 @@ 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;
> + const int batch_size_max = sizeof(usb->data);
> + int current_batch_size;
> + int i = 0;
>
> 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) {
> + if(len - i > batch_size_max) {
> + current_batch_size = batch_size_max;
> + } else {
> + current_batch_size = len - i;
> + }
current_batch_size = min(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);
@Stanislaw: I vaguely remember you reported some issues if the burst size
is greater than 4B (but I can be wrong)
> if (ret < 0)
> break;
> +
> + i += current_batch_size;
> }
> mutex_unlock(&usb->usb_ctrl_mtx);
> }
> --
> 2.24.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2019-11-16 11:43 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-16 11:17 [PATCH 0/4] mt76: channel switch support for USB devices Markus Theil
2019-11-16 11:17 ` [PATCH 1/4] mt76: mt76x02: ommit beacon slot clearing Markus Theil
2019-11-16 11:44 ` Markus Theil
2019-11-16 11:17 ` [PATCH 2/4] mt76: mt76x02: split beaconing Markus Theil
2019-11-16 12:51 ` Lorenzo Bianconi
2019-11-16 11:17 ` [PATCH 3/4] mt76: speed up usb bulk copy Markus Theil
2019-11-16 11:43 ` Lorenzo Bianconi [this message]
2019-11-19 10:58 ` Stanislaw Gruszka
2019-11-16 11:17 ` [PATCH 4/4] mt76: mt76x02: add channel switch support for usb interfaces Markus Theil
2019-11-16 11:45 ` Lorenzo Bianconi
2019-11-16 12:13 ` Markus Theil
2019-11-16 12:43 ` Lorenzo Bianconi
2019-11-17 3:44 ` kbuild test robot
2019-11-17 3:44 ` kbuild test robot
2019-11-17 3:44 ` [RFC PATCH] mt76: mt76x02: mt76x2u_channel_switch_beacon() can be static kbuild test robot
2019-11-17 3:44 ` kbuild test robot
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=20191116114312.GC20820@localhost.localdomain \
--to=lorenzo@kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lorenzo.bianconi@redhat.com \
--cc=markus.theil@tu-ilmenau.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.