From: Lorenzo Bianconi <lorenzo.bianconi@redhat.com>
To: Stanislaw Gruszka <sgruszka@redhat.com>
Cc: linux-wireless@vger.kernel.org, Felix Fietkau <nbd@nbd.name>
Subject: Re: [RFC 05/12] mt76usb: remove mt76u_buf redundant fileds
Date: Tue, 12 Mar 2019 17:25:50 +0100 [thread overview]
Message-ID: <20190312162549.GD2611@localhost.localdomain> (raw)
In-Reply-To: <1552403166-3821-6-git-send-email-sgruszka@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 3038 bytes --]
> Remove mt76u_buf->{len, buf} fields and operate on corresponding
> urb fields directly.
>
> Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
> ---
> drivers/net/wireless/mediatek/mt76/mt76.h | 2 --
> drivers/net/wireless/mediatek/mt76/usb.c | 40 +++++++++++++++++--------------
> 2 files changed, 22 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
> index 89cdfe4abf33..476cb39c99b7 100644
> --- a/drivers/net/wireless/mediatek/mt76/mt76.h
> +++ b/drivers/net/wireless/mediatek/mt76/mt76.h
> @@ -85,8 +85,6 @@ struct mt76_queue_buf {
>
[...]
> @@ -377,7 +378,6 @@ static void mt76u_buf_free(struct mt76u_buf *buf)
> void *context)
> {
> struct usb_device *udev = to_usb_device(dev->dev);
> - u8 *data = buf->urb->num_sgs ? NULL : buf->buf;
> unsigned int pipe;
>
> if (dir == USB_DIR_IN)
> @@ -385,8 +385,10 @@ static void mt76u_buf_free(struct mt76u_buf *buf)
> else
> pipe = usb_sndbulkpipe(udev, dev->usb.out_ep[index]);
>
> - usb_fill_bulk_urb(buf->urb, udev, pipe, data, buf->len,
> - complete_fn, context);
> + buf->urb->dev = udev;
> + buf->urb->pipe = pipe;
> + buf->urb->complete = complete_fn;
> + buf->urb->context = context;
> }
>
> static inline struct mt76u_buf
> @@ -426,7 +428,7 @@ static int mt76u_get_rx_entry_len(u8 *data, u32 data_len)
> {
> struct mt76_queue *q = &dev->q_rx[MT_RXQ_MAIN];
> struct urb *urb = buf->urb;
> - u8 *data = urb->num_sgs ? sg_virt(&urb->sg[0]) : buf->buf;
> + u8 *data = urb->num_sgs ? sg_virt(&urb->sg[0]) : urb->transfer_buffer;
> int data_len, len, nsgs = 1;
> struct sk_buff *skb;
>
> @@ -437,7 +439,7 @@ static int mt76u_get_rx_entry_len(u8 *data, u32 data_len)
> if (len < 0)
> return 0;
>
> - data_len = urb->num_sgs ? urb->sg[0].length : buf->len;
> + data_len = urb->num_sgs ? urb->sg[0].length : INT_MAX;
In this way we only use len, maybe better to do:
data_len = urb->num_sgs ? urb->sg[0].length :
SKB_WITH_OVERHEAD(q->buf_size)
> data_len = min_t(int, len, data_len - MT_DMA_HDR_LEN);
> if (MT_DMA_HDR_LEN + data_len > SKB_WITH_OVERHEAD(q->buf_size))
> return 0;
> @@ -731,14 +733,16 @@ static void mt76u_complete_tx(struct urb *urb)
> return err;
>
> buf = &q->entry[idx].ubuf;
> - buf->buf = skb->data;
> - buf->len = skb->len;
> + if (!dev->usb.sg_en) {
> + buf->urb->transfer_buffer = skb->data;
I think you can move this in mt76u_tx_build_sg or remove the if condition in
mt76u_tx_build_sg()
Regards,
Lorenzo
> + } else {
> + err = mt76u_tx_build_sg(dev, skb, buf->urb);
> + if (err < 0)
> + return err;
> + }
> + buf->urb->transfer_buffer_length = skb->len;
> buf->done = false;
>
> - err = mt76u_tx_build_sg(dev, skb, buf->urb);
> - if (err < 0)
> - return err;
> -
> mt76u_fill_bulk_urb(dev, USB_DIR_OUT, q2ep(q->hw_idx),
> buf, mt76u_complete_tx, buf);
>
> --
> 1.9.3
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2019-03-12 16:25 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-12 15:05 [RFC 00/12] mt76usb: some cleanups and optimizations Stanislaw Gruszka
2019-03-12 15:05 ` [RFC 01/12] mt76usb: change mt76u_submit_buf Stanislaw Gruszka
2019-03-12 15:05 ` [RFC 02/12] mt76: remove rx_page_lock Stanislaw Gruszka
2019-03-12 15:05 ` [RFC 03/12] mt76usb: change mt76u_fill_rx_sg arguments Stanislaw Gruszka
2019-03-12 15:05 ` [RFC 04/12] mt76usb: use usb_dev private data Stanislaw Gruszka
2019-03-12 15:05 ` [RFC 05/12] mt76usb: remove mt76u_buf redundant fileds Stanislaw Gruszka
2019-03-12 16:25 ` Lorenzo Bianconi [this message]
2019-03-13 12:53 ` Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 06/12] mt76usb: move mt76u_buf->done to queue entry Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 07/12] mt76usb: remove mt76u_buf and use urb directly Stanislaw Gruszka
2019-03-12 16:27 ` Lorenzo Bianconi
2019-03-13 12:53 ` Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 08/12] mt76usb: remove MT_RXQ_MAIN queue from mt76u_urb_alloc Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 09/12] mt76usb: resue mt76u_urb_alloc for tx Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 10/12] mt76usb: remove unneded sg_init_table Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 11/12] mt76usb: allocate urb and sg as linear data Stanislaw Gruszka
2019-03-12 16:34 ` Lorenzo Bianconi
2019-03-13 12:59 ` Stanislaw Gruszka
2019-03-12 15:06 ` [RFC 12/12] mt76usb: remove queue variable from rx_tasklet Stanislaw Gruszka
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=20190312162549.GD2611@localhost.localdomain \
--to=lorenzo.bianconi@redhat.com \
--cc=linux-wireless@vger.kernel.org \
--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).