Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp221642ybi; Thu, 13 Jun 2019 14:45:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqyW2j8NwmmWzUbgetFTPI3JciA2XW/bu6xgbnFKU5apDFv/sr6NbZDVJQrq9tgO3fZ2YCir X-Received: by 2002:a17:90a:cb09:: with SMTP id z9mr7664356pjt.87.1560462308411; Thu, 13 Jun 2019 14:45:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560462308; cv=none; d=google.com; s=arc-20160816; b=sAURnGQfj0BqfCfAeSLN3hCAKvz+TUl2EUX271RamPvVdMFn69zBrlak5HXiSBiARE X7uQ4c2rmiP3jErsi0gnyVju81MAq4keH0kaC865xJEdysSusGHkaNcxik1r2ha0nVgF hTEkG6EyjtCYEFHJl+/zJOTryD+Ls18Ah3lAJxNKauWrKKnyXzTbez6J7j+Mj0NLKGHc IUS2a4GxGValqDqSd9bcME3ncts5EkB86YDmG813ZO/IXaDndbvm89yYds6gAiMvL68C 8zZFYMjN3F7rQtKuWCnBiywnx2IjYFJfDa9WDs9X/Vk4Lk5ha/NPy1ik4Z2RP4TweQO+ pkHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5Zi8Y42IZNAkChT+7Jb7iN0ecuuwKqeahg/po5U5bWo=; b=SwBjQ+8g9hLvad1SBI4S67T4aw7kLzRZLpv36PGTnwKz1zL3+FqboGMX2oZvZWlVA6 elNa5ugMRlIMLIktYNnGMxzAhZfT4Q89KHK2yu7A+S6rURxFD7qHjgF6zP1FlwcMT+/D hn5LQwBGJtcY2PEbgpsdPuR1mG1ygGSiHliEqcNgAjNwQM22lzchGEZrOpctpXcpH0mu b5ydzXCvVQMh+F8iYq4eYNsNpTmntAN2TCcgkBgLq2fBlrYfoQhJTtJrZK9/gO5S+qzM I+oLhcEBG7PTzS0j03JsITS9xyq6ldmuw6MObNEkrfgqISyPE1isSFV4p3aX3E5bM32G xeLQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QpuhdgEu; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i41si568101pje.45.2019.06.13.14.44.54; Thu, 13 Jun 2019 14:45:08 -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; dkim=pass header.i=@kernel.org header.s=default header.b=QpuhdgEu; 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=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727122AbfFMVnc (ORCPT + 99 others); Thu, 13 Jun 2019 17:43:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:51362 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725747AbfFMVnb (ORCPT ); Thu, 13 Jun 2019 17:43:31 -0400 Received: from localhost.localdomain (unknown [151.66.40.206]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 20D7721721; Thu, 13 Jun 2019 21:43:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1560462211; bh=ptcpDMugFcdloUA9Yi3MZDY0TbSw8V3JklI4gCChYXA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QpuhdgEuppez/INRCQMFEZpAzeZ+3NJoNafH6tCn543uuYV/aPVYxe9wrK6bRoF2L 2jolsnDfVV8Fvv9kcSAzf5jXKMqEcdtiuzZRJSTtSzBBMN0aLzU7T1uUzo6/czo8qW Y3Wb8at10nOBd5jNCQ/hFyYdBh8q1dNvOO+fRfqI= From: Lorenzo Bianconi To: kvalo@codeaurora.org Cc: linux-wireless@vger.kernel.org, nbd@nbd.name, lorenzo.bianconi@redhat.com, sgruszka@redhat.com Subject: [PATCH v3 wireless-drivers 3/3] mt76: usb: do not always copy the first part of received frames Date: Thu, 13 Jun 2019 23:43:13 +0200 Message-Id: <1a9566c0a41ad0d940487a9d3f0008993c075ef2.1560461404.git.lorenzo@kernel.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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. Moreover align usb buffer size to max_ep boundaries and set buf_size to PAGE_SIZE even for sg case Signed-off-by: Lorenzo Bianconi --- drivers/net/wireless/mediatek/mt76/usb.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c index 1ee54a9b302e..2ee3f8fa1483 100644 --- a/drivers/net/wireless/mediatek/mt76/usb.c +++ b/drivers/net/wireless/mediatek/mt76/usb.c @@ -289,8 +289,10 @@ 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; + data_size = rounddown(SKB_WITH_OVERHEAD(q->buf_size), + dev->usb.in_ep[MT_EP_IN_PKT_RX].max_packet); for (i = 0; i < nsgs; i++) { struct page *page; void *data; @@ -302,7 +304,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) { @@ -314,7 +316,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 +613,9 @@ 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; q->ndesc = MT_NUM_RX_ENTRIES; + q->buf_size = PAGE_SIZE; + for (i = 0; i < q->ndesc; i++) { err = mt76u_rx_urb_alloc(dev, &q->entry[i]); if (err < 0) -- 2.21.0