Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp3376203ybc; Mon, 18 Nov 2019 14:20:20 -0800 (PST) X-Google-Smtp-Source: APXvYqwWu2948ve5vL8O6xn2LqjX1UGHMtS+PsX6oaKCmHH1duXEpynXF3XEryn4XCnI1OJi+uVj X-Received: by 2002:a1c:e90b:: with SMTP id q11mr1674883wmc.125.1574115620192; Mon, 18 Nov 2019 14:20:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574115620; cv=none; d=google.com; s=arc-20160816; b=W4lR0D9A9ygsImLGKPfd+M+ZSiBfmLcK/Fpc+k9im9fQ2TFiFIdPMV1meetfeqp6TQ dfYPruJmYJWnw1O57rplYIJd/1cP5VQqFgSNUoylEp6QWrMyv0fOBDa7QrWmJO8AZBeu PEKcrjdO1dTv0o9vpmMHEP0q5NJoCWS6un7z4tPC8pQCUDtSFHCy6kYSAGPeF36Fy+DF WpepnF9j7C+hoEhzlzYDlAl/BC+0rXVcrNNQLHzSqVje53U5FuMJwgQJhODww898u4lE sNeL0xKgsXHcNiDxGU+1lA7FqWnqzXy2FPylmog5WYNPJOp+WHGT8Ywv6lI94FAYJDjB 3j4w== 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; bh=a3wo2VwdPNmdb+yDv0mCOaIHPsUm51SPrUU06iPaQDw=; b=OSRKkGnpmvIxPEkcggn1vobmbnSgjFpnc1++YHd0vJdkM9BNPoe1GLTF8FtAd1YU4T YJgF5Sf6uH7JQMqoZryFLrpiW7youA76gIxmYtlwV2dYvl/SCN+ME1yzDUsAbtBOFvRL Wty3P3g0A+1F6nVBFI/BT6hd/vsTUQXBrEIv+UOZpzttN4JeSNt/l8anUejAeSPnCH7l sBNEIkT2bNraxKpRU0WBLuvLlwp/t/oNWRRApDHifLwn02I+BHiQB9XpLVId4ur3qVfL XHXerDP/zNLDYVJnIZx9b32Zd1aIUecoHA+/dne0GWOlssNci8TquxkyfR2SIJBh6Mvg 2PBQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6si13926834eda.258.2019.11.18.14.19.54; Mon, 18 Nov 2019 14:20:20 -0800 (PST) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726976AbfKRWRG (ORCPT + 99 others); Mon, 18 Nov 2019 17:17:06 -0500 Received: from smail.rz.tu-ilmenau.de ([141.24.186.67]:40018 "EHLO smail.rz.tu-ilmenau.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726787AbfKRWRB (ORCPT ); Mon, 18 Nov 2019 17:17:01 -0500 Received: from localhost.localdomain (unknown [141.24.207.101]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smail.rz.tu-ilmenau.de (Postfix) with ESMTPSA id 27A9458007C; Mon, 18 Nov 2019 23:16:59 +0100 (CET) From: Markus Theil To: nbd@nbd.name Cc: linux-wireless@vger.kernel.org, lorenzo.bianconi@redhat.com, Stanislaw Gruszka , Markus Theil Subject: [PATCH v4 3/4] mt76: speed up usb bulk copy Date: Mon, 18 Nov 2019 23:15:39 +0100 Message-Id: <20191118221540.14886-4-markus.theil@tu-ilmenau.de> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191118221540.14886-1-markus.theil@tu-ilmenau.de> References: <20191118221540.14886-1-markus.theil@tu-ilmenau.de> 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 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 --- 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 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/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c index 20c6fe510e9d..f1f67b0f8265 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 = DIV_ROUND_UP(len, 4) * 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((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