Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5433830ybi; Wed, 12 Jun 2019 02:24:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqwS5cUxZZjBYRqMETTkQJyUovMLTO3Ms7C0Oa/cB/m/YBTKQOfduue29whvYfWC+1GOmV5Q X-Received: by 2002:a17:90a:25af:: with SMTP id k44mr30999033pje.122.1560331459569; Wed, 12 Jun 2019 02:24:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560331459; cv=none; d=google.com; s=arc-20160816; b=LMFVHLL8QOZMmR9WTQyd1vBLgKWD/qNTpj2EYuxH4TrsvCIITPKXvSonuY0n9cjnsV +B8suEKiNcAvbafUrkUhDytdJTTauTEI+/QjxMQBryBEIvAD19ac1Ob2wsMCDdFkOZci p3PzGomLryW6WiqECeHwcNkBjUCjO+tJdC9kIaJTEFdX+L8jwyndkjX5vewCl3+iz8Cw 3ZhPVZp9WJwczQK++5wKjZYhuF1fmDNUGpjCPlFSGJ4i+A031yTa8QZg7ohPN103D2Pc QZ8Q3iUaXWMtzGxMVY7bUN+eti//rE2grKZTfI14m7DBahAF6XCPnPUF/H4yhe7cwGi7 dsnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=HE+4BvB+qSZaOBgperzqF4lQ/Kp8/P3FKXNt8sty7pA=; b=nKuFDR3rNTfAB2/a1DUr0cYEbvByud3nMhQ6ZLw/y2wwRVsPZKm74Fy+YRW5MkuAFy UH3hteJMMR3XPkcUuZbJsLEIpTk7+gMrtdf3011He1s599t3YCE4jqQrK7SzM3RwjJkj U/UpAuu2zn7BXyLKFQOMNIBD0CxI0jw3m69V+Go9iy2vSpMvSVEqfvX+1nFL/zxs+j3K CBuNCqaHCL56umwDuVY14lYXYrwSQNnmE+EeZZcd8EnsQeSglvnJCTfWSkOUgvSE+/My edPdYg2GyDUrwGclqs0IGyoi/YNAlSSxLVaeZ0bKXadhoUxAq5MgBmTskH9+SAJTEA15 hxzg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si977612pgh.385.2019.06.12.02.24.02; Wed, 12 Jun 2019 02:24:19 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-wireless-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406494AbfFLJKm (ORCPT + 99 others); Wed, 12 Jun 2019 05:10:42 -0400 Received: from mx1.redhat.com ([209.132.183.28]:52128 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2405024AbfFLJKl (ORCPT ); Wed, 12 Jun 2019 05:10:41 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 98A3E3092675; Wed, 12 Jun 2019 09:10:41 +0000 (UTC) Received: from localhost (unknown [10.43.2.57]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1B5161001B0D; Wed, 12 Jun 2019 09:10:38 +0000 (UTC) Date: Wed, 12 Jun 2019 11:10:37 +0200 From: Stanislaw Gruszka To: Lorenzo Bianconi Cc: nbd@nbd.name, kvalo@codeaurora.org, linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com Subject: Re: [PATCH v2 2/2] mt76: usb: do not always copy the first part of received frames Message-ID: <20190612091036.GB2965@redhat.com> References: <2ed0b595a12944a8cfea14e066bcc4fa24f0ba44.1559293385.git.lorenzo@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <2ed0b595a12944a8cfea14e066bcc4fa24f0ba44.1559293385.git.lorenzo@kernel.org> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Wed, 12 Jun 2019 09:10:41 +0000 (UTC) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, May 31, 2019 at 11:38:23AM +0200, Lorenzo Bianconi wrote: > Set usb buffer size taking into account skb_shared_info in order to > not always copy the first part of received frames if A-MSDU is enabled > for SG capable devices > > Signed-off-by: Lorenzo Bianconi > --- > drivers/net/wireless/mediatek/mt76/mt76.h | 3 +++ > drivers/net/wireless/mediatek/mt76/usb.c | 12 ++++++++---- > 2 files changed, 11 insertions(+), 4 deletions(-) > > diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h > index 74d4edf941d6..7899e9b88b54 100644 > --- a/drivers/net/wireless/mediatek/mt76/mt76.h > +++ b/drivers/net/wireless/mediatek/mt76/mt76.h > @@ -32,6 +32,9 @@ > #define MT_RX_BUF_SIZE 2048 > #define MT_SKB_HEAD_LEN 128 > > +#define MT_BUF_WITH_OVERHEAD(x) \ > + ((x) + SKB_DATA_ALIGN(sizeof(struct skb_shared_info))) > + > struct mt76_dev; > struct mt76_wcid; > > diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c > index 2bfc8214c0d8..5081643ce701 100644 > --- a/drivers/net/wireless/mediatek/mt76/usb.c > +++ b/drivers/net/wireless/mediatek/mt76/usb.c > @@ -286,7 +286,7 @@ static int > mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76_queue *q, struct urb *urb, > int nsgs, gfp_t gfp) > { > - int i; > + int i, data_size = SKB_WITH_OVERHEAD(q->buf_size); > > for (i = 0; i < nsgs; i++) { > struct page *page; > @@ -299,7 +299,7 @@ mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76_queue *q, struct urb *urb, > > page = virt_to_head_page(data); > offset = data - page_address(page); > - sg_set_page(&urb->sg[i], page, q->buf_size, offset); > + sg_set_page(&urb->sg[i], page, data_size, offset); > } > > if (i < nsgs) { > @@ -311,7 +311,7 @@ mt76u_fill_rx_sg(struct mt76_dev *dev, struct mt76_queue *q, struct urb *urb, > } > > urb->num_sgs = max_t(int, i, urb->num_sgs); > - urb->transfer_buffer_length = urb->num_sgs * q->buf_size, > + urb->transfer_buffer_length = urb->num_sgs * data_size; > sg_init_marker(urb->sg, urb->num_sgs); > > return i ? : -ENOMEM; > @@ -611,8 +611,12 @@ static int mt76u_alloc_rx(struct mt76_dev *dev) > if (!q->entry) > return -ENOMEM; > > - q->buf_size = dev->usb.sg_en ? MT_RX_BUF_SIZE : PAGE_SIZE; > + if (dev->usb.sg_en) > + q->buf_size = MT_BUF_WITH_OVERHEAD(MT_RX_BUF_SIZE); I strongly recommend to not doing this. While this should work in theory creating buffer with size of 2k + some bytes might trigger various bugs in dma mapping or other low level code. And skb_shered_info is needed only in first buffer IIUC. Also this patch seems to make first patch unnecessary except for non sg_en case (in which I think rx AMSDU is broken anyway), so I would prefer just to apply first patch. Stanislaw