Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp3458329ybi; Tue, 2 Jul 2019 08:08:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMqG9MR5IMjyjnRJN3Tcy99hcJYEoBODsjSvvbP3UNhcadbIWZ8WKtoNzsNqwu9QiPztFB X-Received: by 2002:a63:6ecf:: with SMTP id j198mr31104809pgc.437.1562080103769; Tue, 02 Jul 2019 08:08:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562080103; cv=none; d=google.com; s=arc-20160816; b=zFwavcSGtslAQokSFBz7LgJZ9Ye5Fb04FWhzpqyy7PHKmTYd+9Q6KQt4ne7WgNHe0n L4dE5K6Ogw/CBYG+7upBddIYfXpcvt2oamQainQJrDw0LqsSVgP23I0OMDeksZJIlu/k zBqvWw32OK0HZHyh3Vm3ZcFe8T3FZ9c5tpcN7w5Ygamu48HGrmRCDs9BqQ5ujCYia/O7 niH9XuXBayXa797KKUm3s7xSkMfyacmE4i+B3xl4yN8KTIkzz0oaVvz7nihVrZLoclpp CMz4EpyofCKD1FJddX0sR++8J0tRx3l1jZAalUy7qXlDINpIbAtIcf6npnF9JPJiuiB4 ta3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=8TOpdz0CgXUlnS9DnGoo01wA1MDjdmXLldxJwZtDiKE=; b=MzC09NnfcyUtg9J9zKTueNL1amXt3yhW77FT8h+70nZ3KP5WU7WiUnuwAi2wq2K9UE weKzHbFAkWqFj2nwr5h659YHFKDb7AQ3ttoC20VUZRB9lBSspknl5qR0oXDZlNfr2Ke0 /gYwTP0xtXygwc6m1Ou9fNgYlYCDi2tZS/y9nLNIBMm5uAdD8kksDtCG/cHbMsss5fiH gnADQZ1Ev4q067PIjELKE7TqB4dG/sqp8o76+hEySBFw0+WBwOTO3hbQ0zyr0LfipJzZ Uo4m3VlFkhN/o/aJ+6zPCJ21uv8X8BgC3xJrg4qf+Slya1n6jb8wksjjnsAp9zAUVwJU N5Cw== 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 i74si12723127pgd.413.2019.07.02.08.08.08; Tue, 02 Jul 2019 08:08:23 -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 S1726103AbfGBPGP (ORCPT + 99 others); Tue, 2 Jul 2019 11:06:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38674 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725996AbfGBPGO (ORCPT ); Tue, 2 Jul 2019 11:06:14 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AED982F8BCC; Tue, 2 Jul 2019 15:06:14 +0000 (UTC) Received: from localhost (unknown [10.43.2.9]) by smtp.corp.redhat.com (Postfix) with ESMTP id 54F77608BA; Tue, 2 Jul 2019 15:06:14 +0000 (UTC) From: Stanislaw Gruszka To: linux-wireless@vger.kernel.org Cc: Felix Fietkau , Lorenzo Bianconi , Stanislaw Gruszka Subject: [PATCH 3/3] mt76: usb: use full intermediate buffer in mt76u_copy Date: Tue, 2 Jul 2019 17:06:01 +0200 Message-Id: <1562079961-15527-4-git-send-email-sgruszka@redhat.com> In-Reply-To: <1562079961-15527-1-git-send-email-sgruszka@redhat.com> References: <1562079961-15527-1-git-send-email-sgruszka@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Tue, 02 Jul 2019 15:06:14 +0000 (UTC) Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org Instead of use several 4 bytes usb requests, use full 32 bytes buffer to copy data to device. With the change we use less requests and copy exact data size to the device regardless size is multiple of 4 or not. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/mediatek/mt76/usb.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c index a61bb8171557..7c564cc68c7c 100644 --- a/drivers/net/wireless/mediatek/mt76/usb.c +++ b/drivers/net/wireless/mediatek/mt76/usb.c @@ -160,19 +160,24 @@ 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; + int ret, req_len; mutex_lock(&usb->usb_ctrl_mtx); - for (i = 0; i < DIV_ROUND_UP(len, 4); i++) { - put_unaligned(val[i], usb->data); + do { + req_len = min_t(int, len, sizeof(usb->data)); + + memcpy(usb->data, data, req_len); + 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, usb->data, req_len); if (ret < 0) break; - } + + data += req_len; + offset += req_len; + len -= req_len; + } while (len > 0); mutex_unlock(&usb->usb_ctrl_mtx); } -- 1.9.3