From patchwork Fri Nov 29 12:32:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 11267055 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 271DC14B7 for ; Fri, 29 Nov 2019 12:32:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 068DD217BC for ; Fri, 29 Nov 2019 12:32:44 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="GwKbmN2N" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726780AbfK2Mcn (ORCPT ); Fri, 29 Nov 2019 07:32:43 -0500 Received: from us-smtp-2.mimecast.com ([207.211.31.81]:41346 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726360AbfK2Mcn (ORCPT ); Fri, 29 Nov 2019 07:32:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575030761; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x2fAuEBBSRpY/CSNwJra01Bn9YnaOkh9MtKcG5tFe0E=; b=GwKbmN2Nwwcw8CXZ1hTIcm1cj/h68n4Cca6jKjcHPndY/8skIEqXIEVyfD0Ah7U2BcEU43 earDUd9OG307gO14ZumJPmHxCrms1UlYJIe5CuqBtgSm6yaRWQ7Gue2a8erc9cgXIAlB0X rpJcg9KiSMowujXYbZiMmEbWW4DQ7jA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-369-Z0aioIREN7OjDpgUYbMl6A-1; Fri, 29 Nov 2019 07:32:38 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 38275184CAAA; Fri, 29 Nov 2019 12:32:37 +0000 (UTC) Received: from localhost (unknown [10.43.2.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id A4E2D60BE2; Fri, 29 Nov 2019 12:32:36 +0000 (UTC) From: Stanislaw Gruszka To: linux-wireless@vger.kernel.org Cc: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Roy Luo , Markus Theil Subject: [PATCH 1/3] mt76: usb: use max packet length for m76u_copy Date: Fri, 29 Nov 2019 13:32:26 +0100 Message-Id: <1575030748-2218-2-git-send-email-sgruszka@redhat.com> In-Reply-To: <1575030748-2218-1-git-send-email-sgruszka@redhat.com> References: <1575030748-2218-1-git-send-email-sgruszka@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: Z0aioIREN7OjDpgUYbMl6A-1 X-Mimecast-Spam-Score: 0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org For transferring data over USB the optimal size is endpoint maxpacket. For my hardware maxpaket for control endpoint is 64 bytes and changing to this value from 128 bytes further shorten TBTT work time from 3ms to 1ms. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/mediatek/mt76/mt76.h | 7 +++---- drivers/net/wireless/mediatek/mt76/usb.c | 29 +++++++++++++++++++---------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h index 1981912de1f9..c268c3d76b3d 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76.h +++ b/drivers/net/wireless/mediatek/mt76/mt76.h @@ -381,10 +381,9 @@ enum mt76u_out_ep { #define MCU_RESP_URB_SIZE 1024 struct mt76_usb { struct mutex usb_ctrl_mtx; - union { - u8 data[128]; - __le32 reg_val; - }; + __le32 reg_val; + u8 *data; + u16 data_len; struct tasklet_struct rx_tasklet; struct workqueue_struct *stat_wq; diff --git a/drivers/net/wireless/mediatek/mt76/usb.c b/drivers/net/wireless/mediatek/mt76/usb.c index 97b263ce3872..a9ff2bd62fc9 100644 --- a/drivers/net/wireless/mediatek/mt76/usb.c +++ b/drivers/net/wireless/mediatek/mt76/usb.c @@ -163,7 +163,7 @@ static void mt76u_copy(struct mt76_dev *dev, u32 offset, mutex_lock(&usb->usb_ctrl_mtx); while (i < len) { - current_batch_size = min_t(int, sizeof(usb->data), len - i); + current_batch_size = min_t(int, usb->data_len, 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, @@ -950,6 +950,15 @@ int mt76u_alloc_queues(struct mt76_dev *dev) .kick = mt76u_tx_kick, }; +void mt76u_deinit(struct mt76_dev *dev) +{ + if (dev->usb.stat_wq) { + destroy_workqueue(dev->usb.stat_wq); + dev->usb.stat_wq = NULL; + } +} +EXPORT_SYMBOL_GPL(mt76u_deinit); + int mt76u_init(struct mt76_dev *dev, struct usb_interface *intf) { @@ -974,6 +983,15 @@ int mt76u_init(struct mt76_dev *dev, if (!usb->stat_wq) return -ENOMEM; + usb->data_len = usb_maxpacket(udev, usb_sndctrlpipe(udev, 0), 1); + if (usb->data_len < 32) + usb->data_len = 32; + usb->data = devm_kmalloc(dev->dev, usb->data_len, GFP_KERNEL); + if (!usb->data) { + mt76u_deinit(dev); + return -ENOMEM; + } + mutex_init(&usb->mcu.mutex); mutex_init(&usb->usb_ctrl_mtx); @@ -988,14 +1006,5 @@ int mt76u_init(struct mt76_dev *dev, } EXPORT_SYMBOL_GPL(mt76u_init); -void mt76u_deinit(struct mt76_dev *dev) -{ - if (dev->usb.stat_wq) { - destroy_workqueue(dev->usb.stat_wq); - dev->usb.stat_wq = NULL; - } -} -EXPORT_SYMBOL_GPL(mt76u_deinit); - MODULE_AUTHOR("Lorenzo Bianconi "); MODULE_LICENSE("Dual BSD/GPL"); From patchwork Fri Nov 29 12:32:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 11267057 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A3CD109A for ; Fri, 29 Nov 2019 12:32:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5952C217BC for ; Fri, 29 Nov 2019 12:32:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="U/fTjMCx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726789AbfK2Mco (ORCPT ); Fri, 29 Nov 2019 07:32:44 -0500 Received: from us-smtp-2.mimecast.com ([205.139.110.61]:52899 "EHLO us-smtp-delivery-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726360AbfK2Mco (ORCPT ); Fri, 29 Nov 2019 07:32:44 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575030763; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nmmG7cTDF8j3dDlK5mWBV5RioNEA0v62kDAoZGSQA9M=; b=U/fTjMCxuOu9kNdkIlrKF6E4XK3sbHVtPZtLhUhoykDEXMQE1RkZBk1bufZ3N6mD8j0oFX wiWh781HX6jzSkPnpAnHODlib3AvEZjwDp+PcGlWnOOH2MfZv/z9CeDzMC1PSgVsuRepEP Y2pyPfbGAGt7UM+CmDOfTG5WuO52ans= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-224-qygBvUreN4q_OnwxnU5glQ-1; Fri, 29 Nov 2019 07:32:40 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A23BF800EC0; Fri, 29 Nov 2019 12:32:38 +0000 (UTC) Received: from localhost (unknown [10.43.2.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2485060BE2; Fri, 29 Nov 2019 12:32:37 +0000 (UTC) From: Stanislaw Gruszka To: linux-wireless@vger.kernel.org Cc: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Roy Luo , Markus Theil Subject: [PATCH 2/3] mt76: mt76x02u: do not set NULL beacons Date: Fri, 29 Nov 2019 13:32:27 +0100 Message-Id: <1575030748-2218-3-git-send-email-sgruszka@redhat.com> In-Reply-To: <1575030748-2218-1-git-send-email-sgruszka@redhat.com> References: <1575030748-2218-1-git-send-email-sgruszka@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-MC-Unique: qygBvUreN4q_OnwxnU5glQ-1 X-Mimecast-Spam-Score: 0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org With current implementation we do not cleanup beacon memory, so is not needed to call mt76x02_mac_set_beacon() with NULL skb. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c index 3dc3682d585a..c06d8b5f7995 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_usb_core.c @@ -198,7 +198,7 @@ static void mt76x02u_pre_tbtt_work(struct work_struct *work) container_of(work, struct mt76x02_dev, pre_tbtt_work); struct beacon_bc_data data = {}; struct sk_buff *skb; - int i, nbeacons; + int nbeacons; if (!dev->mt76.beacon_mask) return; @@ -224,10 +224,8 @@ static void mt76x02u_pre_tbtt_work(struct work_struct *work) nbeacons = hweight8(dev->mt76.beacon_mask); mt76x02_enqueue_buffered_bc(dev, &data, N_BCN_SLOTS - nbeacons); - for (i = nbeacons; i < N_BCN_SLOTS; i++) { - skb = __skb_dequeue(&data.q); + while ((skb = __skb_dequeue(&data.q)) != NULL) mt76x02_mac_set_beacon(dev, skb); - } out: mt76x02_mac_set_beacon_finish(dev); From patchwork Fri Nov 29 12:32:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stanislaw Gruszka X-Patchwork-Id: 11267059 X-Patchwork-Delegate: nbd@nbd.name Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C0ECC14B7 for ; Fri, 29 Nov 2019 12:32:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A0962217BC for ; Fri, 29 Nov 2019 12:32:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="WH2wU37I" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726805AbfK2Mcq (ORCPT ); Fri, 29 Nov 2019 07:32:46 -0500 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:50283 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726791AbfK2Mcp (ORCPT ); Fri, 29 Nov 2019 07:32:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1575030764; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DGVrxcKeZmdVG6IhI5+njp7E8j7/1R+N6N+9xWzbHzk=; b=WH2wU37IhGpx2yWdNNIdYLnVSpNtvMvki0mp5VEc6U7qhEJ6v8T1vBaGt1arVbI3wyZAgq VUPNjfkfiycKxle0R8iQ8f8g7AOhXBG15lQTx7UoLpLmnJHNe0BRqT4g0DkgacBuvI8DsW EWipkkwlEPYnxsIdwTxZTq0gm2mWZnQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-250-Tdnfg5KaPVygrTRYlJAapw-1; Fri, 29 Nov 2019 07:32:41 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF3F1100551B; Fri, 29 Nov 2019 12:32:39 +0000 (UTC) Received: from localhost (unknown [10.43.2.71]) by smtp.corp.redhat.com (Postfix) with ESMTP id 99549600C8; Fri, 29 Nov 2019 12:32:39 +0000 (UTC) From: Stanislaw Gruszka To: linux-wireless@vger.kernel.org Cc: Felix Fietkau , Lorenzo Bianconi , Ryder Lee , Roy Luo , Markus Theil Subject: [PATCH 3/3] mt76: mt76x02: minor mt76x02_mac_set_beacon optimization Date: Fri, 29 Nov 2019 13:32:28 +0100 Message-Id: <1575030748-2218-4-git-send-email-sgruszka@redhat.com> In-Reply-To: <1575030748-2218-1-git-send-email-sgruszka@redhat.com> References: <1575030748-2218-1-git-send-email-sgruszka@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: Tdnfg5KaPVygrTRYlJAapw-1 X-Mimecast-Spam-Score: 0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org We do not call mt76x02_mac_set_beacon() with NULL skb any longer and we do not need to return error value. Signed-off-by: Stanislaw Gruszka --- drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c | 14 ++++---------- drivers/net/wireless/mediatek/mt76/mt76x02_mac.h | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c b/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c index 68a4f512319e..3cc5226b05c1 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_beacon.c @@ -67,21 +67,15 @@ void mt76x02_mac_set_beacon_finish(struct mt76x02_dev *dev) } EXPORT_SYMBOL_GPL(mt76x02_mac_set_beacon_finish); -int mt76x02_mac_set_beacon(struct mt76x02_dev *dev, - struct sk_buff *skb) +void mt76x02_mac_set_beacon(struct mt76x02_dev *dev, + struct sk_buff *skb) { int bcn_len = dev->beacon_ops->slot_size; int bcn_addr = MT_BEACON_BASE + (bcn_len * dev->beacon_data_count); - int ret = 0; - - if (skb) { - ret = mt76x02_write_beacon(dev, bcn_addr, skb); - if (!ret) - dev->beacon_data_count++; - } + if (!mt76x02_write_beacon(dev, bcn_addr, skb)) + dev->beacon_data_count++; dev_kfree_skb(skb); - return ret; } EXPORT_SYMBOL_GPL(mt76x02_mac_set_beacon); diff --git a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h index f67f66f65ee0..5d6411ee44ce 100644 --- a/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h +++ b/drivers/net/wireless/mediatek/mt76/mt76x02_mac.h @@ -201,7 +201,7 @@ void mt76x02_tx_complete_skb(struct mt76_dev *mdev, enum mt76_txq_id qid, void mt76x02_mac_cc_reset(struct mt76x02_dev *dev); void mt76x02_mac_set_bssid(struct mt76x02_dev *dev, u8 idx, const u8 *addr); -int mt76x02_mac_set_beacon(struct mt76x02_dev *dev, struct sk_buff *skb); +void mt76x02_mac_set_beacon(struct mt76x02_dev *dev, struct sk_buff *skb); void mt76x02_mac_set_beacon_enable(struct mt76x02_dev *dev, struct ieee80211_vif *vif, bool enable); void mt76x02_mac_set_beacon_prepare(struct mt76x02_dev *dev);